sckim

package.json is updated

Showing 60 changed files with 3454 additions and 1706 deletions
1 +## 6.8.3 (05 Nov 2019)
2 +
3 +### Bug fix
4 +
5 +* Add exception handler in middleware (#153)
6 +
7 +### Feature
8 +
9 +* Flex Message Update 1 (#173)
10 +* Support friend statistics API (#161)
11 +
12 +### Misc
13 +
14 +* Update dependencies (#174)
15 +
16 +## 6.8.2 (08 Aug 2019)
17 +
18 +### Bug fix
19 +
20 +* Fix LINEThings Scenario Execution Event Types (#158)
21 +
22 +## 6.8.1 (29 Jul 2019)
23 +
24 +### Bug fix
25 +
26 +* Fix a type wrong in Template Message (#163)
27 +
28 +### Feature
29 +* Get `X-LINE-Request-Id` by using `responseData['x-line-request-id']` (#151 #157)
30 +
31 +## 6.8.0 (25 Jun 2019)
32 +
33 +### Feature
34 +
35 +* Add new parameter in push/reply/multicast/broadcast API to catch up the newest bot API (#147)
36 +* Add new APIs in bot API (#147)
37 + - Get the target limit for additional messages
38 + - Get number of messages sent this month
39 + - Get number of sent broadcast messages
40 + - Send broadcast message
41 +
42 +### Breaking changes
43 +* Deprecate Node 6 and start to support Node 12 (#139)
44 +* Remove polyfills for Node 6 (#149)
45 +
46 +### Type
47 +
48 +* Add LINE Things Event (#150)
49 +
50 +### Misc
51 +* Update axios and other dependencies by running `npm audit fix` to fix vulnerabilities. (#148 #154)
52 +
53 +## 6.7.0 (18 Apr 2019)
54 +
55 +### Feature
56 +
57 +* Add alt URL field to URI action (#135)
58 +* Implement (un)linkRichMenuToMultipleUsers (#135)
59 +
60 +### Type
61 +
62 +* Fix typo in a type (#124)
63 +
64 +
65 +## 6.6.0 (4 Mar 2019)
66 +
67 +### Feature
68 +
69 +* Add DeviceLinkEvent / DeviceUnlinkEvent (#123)
70 +
71 +### Type
72 +
73 +* Fix FlexSpacer to have optional 'size' property (#122)
74 +
75 +### Misc
76 +
77 +* Run `npm audit fix` to fix minor dependency vulnerability.
78 +
79 +
80 +## 6.5.0 (16 Feb 2019)
81 +
82 +### Feature
83 +
84 +* Add APIs to get number of sent messages (#116)
85 +* Add account link event (#117)
86 +
87 +### Misc
88 +
89 +* Fix a typo in doc (#119)
90 +
91 +
1 ## 6.4.0 (19 Nov 2018) 92 ## 6.4.0 (19 Nov 2018)
2 93
3 ### Feature 94 ### Feature
......
1 -# line-bot-sdk-nodejs 1 +# LINE Messaging API SDK for nodejs
2 2
3 [![Travis CI](https://travis-ci.org/line/line-bot-sdk-nodejs.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-nodejs) 3 [![Travis CI](https://travis-ci.org/line/line-bot-sdk-nodejs.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-nodejs)
4 [![npmjs](https://badge.fury.io/js/%40line%2Fbot-sdk.svg)](https://www.npmjs.com/package/@line/bot-sdk) 4 [![npmjs](https://badge.fury.io/js/%40line%2Fbot-sdk.svg)](https://www.npmjs.com/package/@line/bot-sdk)
5 5
6 -Node.js SDK for LINE Messaging API
7 6
8 -## Getting Started 7 +## Introduction
8 +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.
9 9
10 -### Install 10 +## Documentation
11 +
12 +See the official API documentation for more information
13 +
14 +- English: https://developers.line.biz/en/docs/messaging-api/overview/
15 +- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/
16 +
17 +line-bot-sdk-nodejs documentation: https://line.github.io/line-bot-sdk-nodejs/#getting-started
18 +
19 +## Requirements
20 +
21 +* **Node.js** 8 or higher
22 +
23 +## Installation
11 24
12 Using [npm](https://www.npmjs.com/): 25 Using [npm](https://www.npmjs.com/):
13 26
...@@ -15,30 +28,37 @@ Using [npm](https://www.npmjs.com/): ...@@ -15,30 +28,37 @@ Using [npm](https://www.npmjs.com/):
15 $ npm install @line/bot-sdk --save 28 $ npm install @line/bot-sdk --save
16 ``` 29 ```
17 30
18 -### Documentation 31 +## Help and media
19 - 32 +FAQ: https://developers.line.biz/en/faq/
20 -For guide, API reference, and other information, please refer to
21 -the [documentation](https://line.github.io/line-bot-sdk-nodejs/).
22 33
23 -### LINE Messaging API References 34 +Community Q&A: https://www.line-community.me/questions
24 35
25 -Here are links to official references for LINE Messaging API. It is recommended 36 +News: https://developers.line.biz/en/news/
26 -reading them beforehand.
27 37
28 -* LINE API Reference [EN](https://developers.line.me/en/docs/messaging-api/reference/) [JA](https://developers.line.me/ja/docs/messaging-api/reference/) 38 +Twitter: @LINE_DEV
29 -* LINE Developers - Messaging API
30 - * [Overview](https://developers.line.me/messaging-api/overview)
31 - * [Getting started](https://developers.line.me/messaging-api/getting-started)
32 - * [Joining groups and rooms](https://developers.line.me/messaging-api/joining-groups-and-rooms)
33 39
34 -## Requirements 40 +## Versioning
41 +This project respects semantic versioning
35 42
36 -* **Node.js** 6 or higher 43 +See http://semver.org/
37 44
38 ## Contributing 45 ## Contributing
39 46
40 Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution. 47 Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.
41 48
42 ## License 49 ## License
43 - 50 +```
44 -[Apache License Version 2.0](LICENSE) 51 +Copyright (C) 2016 LINE Corp.
52 +
53 +Licensed under the Apache License, Version 2.0 (the "License");
54 +you may not use this file except in compliance with the License.
55 +You may obtain a copy of the License at
56 +
57 + http://www.apache.org/licenses/LICENSE-2.0
58 +
59 +Unless required by applicable law or agreed to in writing, software
60 +distributed under the License is distributed on an "AS IS" BASIS,
61 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62 +See the License for the specific language governing permissions and
63 +limitations under the License.
64 +```
......
...@@ -5,9 +5,11 @@ export default class Client { ...@@ -5,9 +5,11 @@ export default class Client {
5 config: Types.ClientConfig; 5 config: Types.ClientConfig;
6 private http; 6 private http;
7 constructor(config: Types.ClientConfig); 7 constructor(config: Types.ClientConfig);
8 - pushMessage(to: string, messages: Types.Message | Types.Message[]): Promise<any>; 8 + private parseHTTPResponse;
9 - replyMessage(replyToken: string, messages: Types.Message | Types.Message[]): Promise<any>; 9 + pushMessage(to: string, messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
10 - multicast(to: string[], messages: Types.Message | Types.Message[]): Promise<any>; 10 + replyMessage(replyToken: string, messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
11 + multicast(to: string[], messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
12 + broadcast(messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
11 getProfile(userId: string): Promise<Types.Profile>; 13 getProfile(userId: string): Promise<Types.Profile>;
12 private getChatMemberProfile; 14 private getChatMemberProfile;
13 getGroupMemberProfile(groupId: string, userId: string): Promise<Types.Profile>; 15 getGroupMemberProfile(groupId: string, userId: string): Promise<Types.Profile>;
...@@ -25,6 +27,8 @@ export default class Client { ...@@ -25,6 +27,8 @@ export default class Client {
25 getRichMenuIdOfUser(userId: string): Promise<string>; 27 getRichMenuIdOfUser(userId: string): Promise<string>;
26 linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>; 28 linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>;
27 unlinkRichMenuFromUser(userId: string): Promise<any>; 29 unlinkRichMenuFromUser(userId: string): Promise<any>;
30 + linkRichMenuToMultipleUsers(richMenuId: string, userIds: string[]): Promise<any>;
31 + unlinkRichMenusFromMultipleUsers(userIds: string[]): Promise<any>;
28 getRichMenuImage(richMenuId: string): Promise<Readable>; 32 getRichMenuImage(richMenuId: string): Promise<Readable>;
29 setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>; 33 setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>;
30 getRichMenuList(): Promise<Array<Types.RichMenuResponse>>; 34 getRichMenuList(): Promise<Array<Types.RichMenuResponse>>;
...@@ -32,4 +36,23 @@ export default class Client { ...@@ -32,4 +36,23 @@ export default class Client {
32 getDefaultRichMenuId(): Promise<string>; 36 getDefaultRichMenuId(): Promise<string>;
33 deleteDefaultRichMenu(): Promise<{}>; 37 deleteDefaultRichMenu(): Promise<{}>;
34 getLinkToken(userId: string): Promise<string>; 38 getLinkToken(userId: string): Promise<string>;
39 + getNumberOfSentReplyMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
40 + getNumberOfSentPushMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
41 + getNumberOfSentMulticastMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
42 + getTargetLimitForAdditionalMessages(): Promise<Types.TargetLimitForAdditionalMessages>;
43 + getNumberOfMessagesSentThisMonth(): Promise<Types.NumberOfMessagesSentThisMonth>;
44 + getNumberOfSentBroadcastMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
45 + getNumberOfMessageDeliveries(date: string): Promise<Types.NumberOfMessageDeliveriesResponse>;
46 + getNumberOfFollowers(date: string): Promise<Types.NumberOfFollowersResponse>;
47 + getFriendDemographics(): Promise<Types.FriendDemoGraphics>;
48 +}
49 +export declare class OAuth {
50 + private http;
51 + constructor();
52 + issueAccessToken(client_id: string, client_secret: string): Promise<{
53 + access_token: string;
54 + expires_in: number;
55 + token_type: "Bearer";
56 + }>;
57 + revokeAccessToken(access_token: string): Promise<{}>;
35 } 58 }
......
1 "use strict"; 1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true }); 2 Object.defineProperty(exports, "__esModule", { value: true });
3 const http_1 = require("./http"); 3 const http_1 = require("./http");
4 +const Types = require("./types");
4 const exceptions_1 = require("./exceptions"); 5 const exceptions_1 = require("./exceptions");
5 function toArray(maybeArr) { 6 function toArray(maybeArr) {
6 return Array.isArray(maybeArr) ? maybeArr : [maybeArr]; 7 return Array.isArray(maybeArr) ? maybeArr : [maybeArr];
7 } 8 }
8 -function checkJSON(raw) { 9 +function ensureJSON(raw) {
9 if (typeof raw === "object") { 10 if (typeof raw === "object") {
10 return raw; 11 return raw;
11 } 12 }
...@@ -13,133 +14,211 @@ function checkJSON(raw) { ...@@ -13,133 +14,211 @@ function checkJSON(raw) {
13 throw new exceptions_1.JSONParseError("Failed to parse response body as JSON", raw); 14 throw new exceptions_1.JSONParseError("Failed to parse response body as JSON", raw);
14 } 15 }
15 } 16 }
17 +const API_HOST = process.env.API_BASE_URL || "https://api.line.me/v2/";
18 +const BOT_BASE_URL = process.env.API_BASE_URL || `${API_HOST}bot/`;
19 +const OAUTH_BASE_URL = `${API_HOST}oauth/`;
16 class Client { 20 class Client {
17 constructor(config) { 21 constructor(config) {
18 if (!config.channelAccessToken) { 22 if (!config.channelAccessToken) {
19 throw new Error("no channel access token"); 23 throw new Error("no channel access token");
20 } 24 }
21 this.config = config; 25 this.config = config;
22 - this.http = new http_1.default(process.env.API_BASE_URL || "https://api.line.me/v2/bot/", { 26 + this.http = new http_1.default({
23 - Authorization: "Bearer " + this.config.channelAccessToken, 27 + baseURL: BOT_BASE_URL,
28 + defaultHeaders: {
29 + Authorization: "Bearer " + this.config.channelAccessToken,
30 + },
31 + responseParser: this.parseHTTPResponse.bind(this),
24 }); 32 });
25 } 33 }
26 - pushMessage(to, messages) { 34 + parseHTTPResponse(response) {
35 + const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
36 + let resBody = Object.assign({}, response.data);
37 + if (response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME]) {
38 + resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] =
39 + response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME];
40 + }
41 + return resBody;
42 + }
43 + pushMessage(to, messages, notificationDisabled = false) {
27 return this.http.post("/message/push", { 44 return this.http.post("/message/push", {
28 messages: toArray(messages), 45 messages: toArray(messages),
29 to, 46 to,
47 + notificationDisabled,
30 }); 48 });
31 } 49 }
32 - replyMessage(replyToken, messages) { 50 + replyMessage(replyToken, messages, notificationDisabled = false) {
33 return this.http.post("/message/reply", { 51 return this.http.post("/message/reply", {
34 messages: toArray(messages), 52 messages: toArray(messages),
35 replyToken, 53 replyToken,
54 + notificationDisabled,
36 }); 55 });
37 } 56 }
38 - multicast(to, messages) { 57 + async multicast(to, messages, notificationDisabled = false) {
39 return this.http.post("/message/multicast", { 58 return this.http.post("/message/multicast", {
40 messages: toArray(messages), 59 messages: toArray(messages),
41 to, 60 to,
61 + notificationDisabled,
42 }); 62 });
43 } 63 }
44 - getProfile(userId) { 64 + async broadcast(messages, notificationDisabled = false) {
45 - return this.http.get(`/profile/${userId}`).then(checkJSON); 65 + return this.http.post("/message/broadcast", {
66 + messages: toArray(messages),
67 + notificationDisabled,
68 + });
46 } 69 }
47 - getChatMemberProfile(chatType, chatId, userId) { 70 + async getProfile(userId) {
48 - return this.http 71 + const profile = await this.http.get(`/profile/${userId}`);
49 - .get(`/${chatType}/${chatId}/member/${userId}`) 72 + return ensureJSON(profile);
50 - .then(checkJSON);
51 } 73 }
52 - getGroupMemberProfile(groupId, userId) { 74 + async getChatMemberProfile(chatType, chatId, userId) {
75 + const profile = await this.http.get(`/${chatType}/${chatId}/member/${userId}`);
76 + return ensureJSON(profile);
77 + }
78 + async getGroupMemberProfile(groupId, userId) {
53 return this.getChatMemberProfile("group", groupId, userId); 79 return this.getChatMemberProfile("group", groupId, userId);
54 } 80 }
55 - getRoomMemberProfile(roomId, userId) { 81 + async getRoomMemberProfile(roomId, userId) {
56 return this.getChatMemberProfile("room", roomId, userId); 82 return this.getChatMemberProfile("room", roomId, userId);
57 } 83 }
58 - getChatMemberIds(chatType, chatId) { 84 + async getChatMemberIds(chatType, chatId) {
59 - const load = (start) => this.http 85 + let memberIds = [];
60 - .get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null) 86 + let start;
61 - .then(checkJSON) 87 + do {
62 - .then((res) => { 88 + const res = await this.http.get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null);
63 - if (!res.next) { 89 + ensureJSON(res);
64 - return res.memberIds; 90 + memberIds = memberIds.concat(res.memberIds);
65 - } 91 + start = res.next;
66 - return load(res.next).then(extraIds => res.memberIds.concat(extraIds)); 92 + } while (start);
67 - }); 93 + return memberIds;
68 - return load(); 94 + }
69 - } 95 + async getGroupMemberIds(groupId) {
70 - getGroupMemberIds(groupId) {
71 return this.getChatMemberIds("group", groupId); 96 return this.getChatMemberIds("group", groupId);
72 } 97 }
73 - getRoomMemberIds(roomId) { 98 + async getRoomMemberIds(roomId) {
74 return this.getChatMemberIds("room", roomId); 99 return this.getChatMemberIds("room", roomId);
75 } 100 }
76 - getMessageContent(messageId) { 101 + async getMessageContent(messageId) {
77 return this.http.getStream(`/message/${messageId}/content`); 102 return this.http.getStream(`/message/${messageId}/content`);
78 } 103 }
79 leaveChat(chatType, chatId) { 104 leaveChat(chatType, chatId) {
80 return this.http.post(`/${chatType}/${chatId}/leave`); 105 return this.http.post(`/${chatType}/${chatId}/leave`);
81 } 106 }
82 - leaveGroup(groupId) { 107 + async leaveGroup(groupId) {
83 return this.leaveChat("group", groupId); 108 return this.leaveChat("group", groupId);
84 } 109 }
85 - leaveRoom(roomId) { 110 + async leaveRoom(roomId) {
86 return this.leaveChat("room", roomId); 111 return this.leaveChat("room", roomId);
87 } 112 }
88 - getRichMenu(richMenuId) { 113 + async getRichMenu(richMenuId) {
89 - return this.http 114 + const res = await this.http.get(`/richmenu/${richMenuId}`);
90 - .get(`/richmenu/${richMenuId}`) 115 + return ensureJSON(res);
91 - .then(checkJSON);
92 } 116 }
93 - createRichMenu(richMenu) { 117 + async createRichMenu(richMenu) {
94 - return this.http 118 + const res = await this.http.post("/richmenu", richMenu);
95 - .post("/richmenu", richMenu) 119 + return ensureJSON(res).richMenuId;
96 - .then(checkJSON)
97 - .then(res => res.richMenuId);
98 } 120 }
99 - deleteRichMenu(richMenuId) { 121 + async deleteRichMenu(richMenuId) {
100 return this.http.delete(`/richmenu/${richMenuId}`); 122 return this.http.delete(`/richmenu/${richMenuId}`);
101 } 123 }
102 - getRichMenuIdOfUser(userId) { 124 + async getRichMenuIdOfUser(userId) {
103 - return this.http 125 + const res = await this.http.get(`/user/${userId}/richmenu`);
104 - .get(`/user/${userId}/richmenu`) 126 + return ensureJSON(res).richMenuId;
105 - .then(checkJSON)
106 - .then(res => res.richMenuId);
107 } 127 }
108 - linkRichMenuToUser(userId, richMenuId) { 128 + async linkRichMenuToUser(userId, richMenuId) {
109 return this.http.post(`/user/${userId}/richmenu/${richMenuId}`); 129 return this.http.post(`/user/${userId}/richmenu/${richMenuId}`);
110 } 130 }
111 - unlinkRichMenuFromUser(userId) { 131 + async unlinkRichMenuFromUser(userId) {
112 return this.http.delete(`/user/${userId}/richmenu`); 132 return this.http.delete(`/user/${userId}/richmenu`);
113 } 133 }
114 - getRichMenuImage(richMenuId) { 134 + async linkRichMenuToMultipleUsers(richMenuId, userIds) {
135 + return this.http.post("/richmenu/bulk/link", {
136 + richMenuId,
137 + userIds,
138 + });
139 + }
140 + async unlinkRichMenusFromMultipleUsers(userIds) {
141 + return this.http.post("/richmenu/bulk/unlink", {
142 + userIds,
143 + });
144 + }
145 + async getRichMenuImage(richMenuId) {
115 return this.http.getStream(`/richmenu/${richMenuId}/content`); 146 return this.http.getStream(`/richmenu/${richMenuId}/content`);
116 } 147 }
117 - setRichMenuImage(richMenuId, data, contentType) { 148 + async setRichMenuImage(richMenuId, data, contentType) {
118 return this.http.postBinary(`/richmenu/${richMenuId}/content`, data, contentType); 149 return this.http.postBinary(`/richmenu/${richMenuId}/content`, data, contentType);
119 } 150 }
120 - getRichMenuList() { 151 + async getRichMenuList() {
121 - return this.http 152 + const res = await this.http.get(`/richmenu/list`);
122 - .get(`/richmenu/list`) 153 + return ensureJSON(res).richmenus;
123 - .then(checkJSON)
124 - .then(res => res.richmenus);
125 } 154 }
126 - setDefaultRichMenu(richMenuId) { 155 + async setDefaultRichMenu(richMenuId) {
127 return this.http.post(`/user/all/richmenu/${richMenuId}`); 156 return this.http.post(`/user/all/richmenu/${richMenuId}`);
128 } 157 }
129 - getDefaultRichMenuId() { 158 + async getDefaultRichMenuId() {
130 - return this.http 159 + const res = await this.http.get("/user/all/richmenu");
131 - .get("/user/all/richmenu") 160 + return ensureJSON(res).richMenuId;
132 - .then(checkJSON)
133 - .then(res => res.richMenuId);
134 } 161 }
135 - deleteDefaultRichMenu() { 162 + async deleteDefaultRichMenu() {
136 return this.http.delete("/user/all/richmenu"); 163 return this.http.delete("/user/all/richmenu");
137 } 164 }
138 - getLinkToken(userId) { 165 + async getLinkToken(userId) {
139 - return this.http 166 + const res = await this.http.post(`/user/${userId}/linkToken`);
140 - .post(`/user/${userId}/linkToken`) 167 + return ensureJSON(res).linkToken;
141 - .then(checkJSON) 168 + }
142 - .then(res => res.linkToken); 169 + async getNumberOfSentReplyMessages(date) {
170 + const res = await this.http.get(`/message/delivery/reply?date=${date}`);
171 + return ensureJSON(res);
172 + }
173 + async getNumberOfSentPushMessages(date) {
174 + const res = await this.http.get(`/message/delivery/push?date=${date}`);
175 + return ensureJSON(res);
176 + }
177 + async getNumberOfSentMulticastMessages(date) {
178 + const res = await this.http.get(`/message/delivery/multicast?date=${date}`);
179 + return ensureJSON(res);
180 + }
181 + async getTargetLimitForAdditionalMessages() {
182 + const res = await this.http.get("/message/quota");
183 + return ensureJSON(res);
184 + }
185 + async getNumberOfMessagesSentThisMonth() {
186 + const res = await this.http.get("/message/quota/consumption");
187 + return ensureJSON(res);
188 + }
189 + async getNumberOfSentBroadcastMessages(date) {
190 + const res = await this.http.get(`/message/delivery/broadcast?date=${date}`);
191 + return ensureJSON(res);
192 + }
193 + async getNumberOfMessageDeliveries(date) {
194 + const res = await this.http.get(`/insight/message/delivery?date=${date}`);
195 + return ensureJSON(res);
196 + }
197 + async getNumberOfFollowers(date) {
198 + const res = await this.http.get(`/insight/followers?date=${date}`);
199 + return ensureJSON(res);
200 + }
201 + async getFriendDemographics() {
202 + const res = await this.http.get(`/insight/demographic`);
203 + return ensureJSON(res);
143 } 204 }
144 } 205 }
145 exports.default = Client; 206 exports.default = Client;
207 +class OAuth {
208 + constructor() {
209 + this.http = new http_1.default({
210 + baseURL: OAUTH_BASE_URL,
211 + });
212 + }
213 + issueAccessToken(client_id, client_secret) {
214 + return this.http.postForm("/accessToken", {
215 + grant_type: "client_credentials",
216 + client_id,
217 + client_secret,
218 + });
219 + }
220 + revokeAccessToken(access_token) {
221 + return this.http.postForm("/revoke", { access_token });
222 + }
223 +}
224 +exports.OAuth = OAuth;
......
1 /// <reference types="node" /> 1 /// <reference types="node" />
2 +import { AxiosResponse } from "axios";
2 import { Readable } from "stream"; 3 import { Readable } from "stream";
4 +declare type httpClientConfig = {
5 + baseURL?: string;
6 + defaultHeaders?: any;
7 + responseParser?: <T>(res: AxiosResponse) => T;
8 +};
3 export default class HTTPClient { 9 export default class HTTPClient {
4 private instance; 10 private instance;
5 - constructor(baseURL?: string, defaultHeaders?: any); 11 + private config;
12 + constructor(config?: httpClientConfig);
6 get<T>(url: string, params?: any): Promise<T>; 13 get<T>(url: string, params?: any): Promise<T>;
7 getStream(url: string, params?: any): Promise<Readable>; 14 getStream(url: string, params?: any): Promise<Readable>;
8 - post<T>(url: string, data?: any): Promise<T>; 15 + post<T>(url: string, body?: any): Promise<T>;
16 + postForm<T>(url: string, body?: any): Promise<T>;
9 postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>; 17 postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>;
10 delete<T>(url: string, params?: any): Promise<T>; 18 delete<T>(url: string, params?: any): Promise<T>;
11 private wrapError; 19 private wrapError;
12 } 20 }
21 +export {};
......
...@@ -4,9 +4,12 @@ const axios_1 = require("axios"); ...@@ -4,9 +4,12 @@ const axios_1 = require("axios");
4 const stream_1 = require("stream"); 4 const stream_1 = require("stream");
5 const exceptions_1 = require("./exceptions"); 5 const exceptions_1 = require("./exceptions");
6 const fileType = require("file-type"); 6 const fileType = require("file-type");
7 +const qs = require("querystring");
7 const pkg = require("../package.json"); 8 const pkg = require("../package.json");
8 class HTTPClient { 9 class HTTPClient {
9 - constructor(baseURL, defaultHeaders) { 10 + constructor(config = {}) {
11 + this.config = config;
12 + const { baseURL, defaultHeaders } = config;
10 this.instance = axios_1.default.create({ 13 this.instance = axios_1.default.create({
11 baseURL, 14 baseURL,
12 headers: Object.assign({}, defaultHeaders, { 15 headers: Object.assign({}, defaultHeaders, {
...@@ -15,27 +18,40 @@ class HTTPClient { ...@@ -15,27 +18,40 @@ class HTTPClient {
15 }); 18 });
16 this.instance.interceptors.response.use(res => res, err => Promise.reject(this.wrapError(err))); 19 this.instance.interceptors.response.use(res => res, err => Promise.reject(this.wrapError(err)));
17 } 20 }
18 - get(url, params) { 21 + async get(url, params) {
19 - return this.instance.get(url, { params }).then(res => res.data); 22 + const res = await this.instance.get(url, { params });
23 + return res.data;
20 } 24 }
21 - getStream(url, params) { 25 + async getStream(url, params) {
22 - return this.instance 26 + const res = await this.instance.get(url, {
23 - .get(url, { params, responseType: "stream" }) 27 + params,
24 - .then(res => res.data); 28 + responseType: "stream",
29 + });
30 + return res.data;
25 } 31 }
26 - post(url, data) { 32 + async post(url, body) {
27 - return this.instance 33 + const res = await this.instance.post(url, body, {
28 - .post(url, data, { headers: { "Content-Type": "application/json" } }) 34 + headers: { "Content-Type": "application/json" },
29 - .then(res => res.data); 35 + });
36 + const { responseParser } = this.config;
37 + if (responseParser)
38 + return responseParser(res);
39 + else
40 + return res.data;
30 } 41 }
31 - postBinary(url, data, contentType) { 42 + async postForm(url, body) {
32 - let getBuffer; 43 + const res = await this.instance.post(url, qs.stringify(body), {
33 - if (Buffer.isBuffer(data)) { 44 + headers: { "Content-Type": "application/x-www-form-urlencoded" },
34 - getBuffer = Promise.resolve(data); 45 + });
35 - } 46 + return res.data;
36 - else { 47 + }
37 - getBuffer = new Promise((resolve, reject) => { 48 + async postBinary(url, data, contentType) {
38 - if (data instanceof stream_1.Readable) { 49 + const buffer = await (async () => {
50 + if (Buffer.isBuffer(data)) {
51 + return data;
52 + }
53 + else if (data instanceof stream_1.Readable) {
54 + return new Promise((resolve, reject) => {
39 const buffers = []; 55 const buffers = [];
40 let size = 0; 56 let size = 0;
41 data.on("data", (chunk) => { 57 data.on("data", (chunk) => {
...@@ -44,25 +60,23 @@ class HTTPClient { ...@@ -44,25 +60,23 @@ class HTTPClient {
44 }); 60 });
45 data.on("end", () => resolve(Buffer.concat(buffers, size))); 61 data.on("end", () => resolve(Buffer.concat(buffers, size)));
46 data.on("error", reject); 62 data.on("error", reject);
47 - } 63 + });
48 - else { 64 + }
49 - reject(new Error("invalid data type for postBinary")); 65 + else {
50 - } 66 + throw new Error("invalid data type for postBinary");
51 - }); 67 + }
52 - } 68 + })();
53 - return getBuffer.then(data => { 69 + const res = await this.instance.post(url, buffer, {
54 - return this.instance 70 + headers: {
55 - .post(url, data, { 71 + "Content-Type": contentType || fileType(buffer).mime,
56 - headers: { 72 + "Content-Length": buffer.length,
57 - "Content-Type": contentType || fileType(data).mime, 73 + },
58 - "Content-Length": data.length,
59 - },
60 - })
61 - .then(res => res.data);
62 }); 74 });
75 + return res.data;
63 } 76 }
64 - delete(url, params) { 77 + async delete(url, params) {
65 - return this.instance.delete(url, { params }).then(res => res.data); 78 + const res = await this.instance.delete(url, { params });
79 + return res.data;
66 } 80 }
67 wrapError(err) { 81 wrapError(err) {
68 if (err.response) { 82 if (err.response) {
......
1 -import Client from "./client"; 1 +import Client, { OAuth } from "./client";
2 import middleware from "./middleware"; 2 import middleware from "./middleware";
3 import validateSignature from "./validate-signature"; 3 import validateSignature from "./validate-signature";
4 -export { Client, middleware, validateSignature }; 4 +export { Client, middleware, validateSignature, OAuth };
5 export * from "./exceptions"; 5 export * from "./exceptions";
6 export * from "./types"; 6 export * from "./types";
......
...@@ -5,9 +5,11 @@ function __export(m) { ...@@ -5,9 +5,11 @@ function __export(m) {
5 Object.defineProperty(exports, "__esModule", { value: true }); 5 Object.defineProperty(exports, "__esModule", { value: true });
6 const client_1 = require("./client"); 6 const client_1 = require("./client");
7 exports.Client = client_1.default; 7 exports.Client = client_1.default;
8 +exports.OAuth = client_1.OAuth;
8 const middleware_1 = require("./middleware"); 9 const middleware_1 = require("./middleware");
9 exports.middleware = middleware_1.default; 10 exports.middleware = middleware_1.default;
10 const validate_signature_1 = require("./validate-signature"); 11 const validate_signature_1 = require("./validate-signature");
11 exports.validateSignature = validate_signature_1.default; 12 exports.validateSignature = validate_signature_1.default;
12 // re-export exceptions and types 13 // re-export exceptions and types
13 __export(require("./exceptions")); 14 __export(require("./exceptions"));
15 +__export(require("./types"));
......
...@@ -6,5 +6,5 @@ export declare type Request = http.IncomingMessage & { ...@@ -6,5 +6,5 @@ export declare type Request = http.IncomingMessage & {
6 }; 6 };
7 export declare type Response = http.ServerResponse; 7 export declare type Response = http.ServerResponse;
8 export declare type NextCallback = (err?: Error) => void; 8 export declare type NextCallback = (err?: Error) => void;
9 -export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void; 9 +export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void | Promise<void>;
10 export default function middleware(config: Types.MiddlewareConfig): Middleware; 10 export default function middleware(config: Types.MiddlewareConfig): Middleware;
......
...@@ -11,7 +11,7 @@ function middleware(config) { ...@@ -11,7 +11,7 @@ function middleware(config) {
11 throw new Error("no channel secret"); 11 throw new Error("no channel secret");
12 } 12 }
13 const secret = config.channelSecret; 13 const secret = config.channelSecret;
14 - return (req, res, next) => { 14 + const _middleware = async (req, res, next) => {
15 // header names are lower-cased 15 // header names are lower-cased
16 // https://nodejs.org/api/http.html#http_message_headers 16 // https://nodejs.org/api/http.html#http_message_headers
17 const signature = req.headers["x-line-signature"]; 17 const signature = req.headers["x-line-signature"];
...@@ -19,34 +19,34 @@ function middleware(config) { ...@@ -19,34 +19,34 @@ function middleware(config) {
19 next(new exceptions_1.SignatureValidationFailed("no signature")); 19 next(new exceptions_1.SignatureValidationFailed("no signature"));
20 return; 20 return;
21 } 21 }
22 - let getBody; 22 + const body = await (async () => {
23 - if (isValidBody(req.rawBody)) { 23 + if (isValidBody(req.rawBody)) {
24 - // rawBody is provided in Google Cloud Functions and others 24 + // rawBody is provided in Google Cloud Functions and others
25 - getBody = Promise.resolve(req.rawBody); 25 + return req.rawBody;
26 - }
27 - else if (isValidBody(req.body)) {
28 - getBody = Promise.resolve(req.body);
29 - }
30 - else {
31 - // body may not be parsed yet, parse it to a buffer
32 - getBody = new Promise(resolve => {
33 - body_parser_1.raw({ type: "*/*" })(req, res, () => resolve(req.body));
34 - });
35 - }
36 - getBody.then(body => {
37 - if (!validate_signature_1.default(body, secret, signature)) {
38 - next(new exceptions_1.SignatureValidationFailed("signature validation failed", signature));
39 - return;
40 } 26 }
41 - const strBody = Buffer.isBuffer(body) ? body.toString() : body; 27 + else if (isValidBody(req.body)) {
42 - try { 28 + return req.body;
43 - req.body = JSON.parse(strBody);
44 - next();
45 } 29 }
46 - catch (err) { 30 + else {
47 - next(new exceptions_1.JSONParseError(err.message, strBody)); 31 + // body may not be parsed yet, parse it to a buffer
32 + return new Promise((resolve, reject) => body_parser_1.raw({ type: "*/*" })(req, res, (error) => error ? reject(error) : resolve(req.body)));
48 } 33 }
49 - }); 34 + })();
35 + if (!validate_signature_1.default(body, secret, signature)) {
36 + next(new exceptions_1.SignatureValidationFailed("signature validation failed", signature));
37 + return;
38 + }
39 + const strBody = Buffer.isBuffer(body) ? body.toString() : body;
40 + try {
41 + req.body = JSON.parse(strBody);
42 + next();
43 + }
44 + catch (err) {
45 + next(new exceptions_1.JSONParseError(err.message, strBody));
46 + }
47 + };
48 + return (req, res, next) => {
49 + _middleware(req, res, next).catch(next);
50 }; 50 };
51 } 51 }
52 exports.default = middleware; 52 exports.default = middleware;
......
...@@ -17,7 +17,7 @@ export declare type Profile = { ...@@ -17,7 +17,7 @@ export declare type Profile = {
17 /** 17 /**
18 * Request body which is sent by webhook. 18 * Request body which is sent by webhook.
19 * 19 *
20 - * @see [Request body](https://developers.line.me/en/reference/messaging-api/#request-body) 20 + * @see [Request body](https://developers.line.biz/en/reference/messaging-api/#request-body)
21 */ 21 */
22 export declare type WebhookRequestBody = { 22 export declare type WebhookRequestBody = {
23 /** 23 /**
...@@ -32,9 +32,9 @@ export declare type WebhookRequestBody = { ...@@ -32,9 +32,9 @@ export declare type WebhookRequestBody = {
32 /** 32 /**
33 * JSON objects which contain events generated on the LINE Platform. 33 * JSON objects which contain events generated on the LINE Platform.
34 * 34 *
35 - * @see [Webhook event objects](https://developers.line.me/en/reference/messaging-api/#webhook-event-objects) 35 + * @see [Webhook event objects](https://developers.line.biz/en/reference/messaging-api/#webhook-event-objects)
36 */ 36 */
37 -export declare type WebhookEvent = MessageEvent | FollowEvent | UnfollowEvent | JoinEvent | LeaveEvent | MemberJoinEvent | MemberLeaveEvent | PostbackEvent | BeaconEvent; 37 +export declare type WebhookEvent = MessageEvent | FollowEvent | UnfollowEvent | JoinEvent | LeaveEvent | MemberJoinEvent | MemberLeaveEvent | PostbackEvent | BeaconEvent | AccountLinkEvent | DeviceLinkEvent | DeviceUnlinkEvent | LINEThingsScenarioExecutionEvent;
38 export declare type EventBase = { 38 export declare type EventBase = {
39 /** 39 /**
40 * Time of the event in milliseconds 40 * Time of the event in milliseconds
...@@ -56,9 +56,9 @@ export declare type Group = { ...@@ -56,9 +56,9 @@ export declare type Group = {
56 /** 56 /**
57 * ID of the source user. 57 * ID of the source user.
58 * 58 *
59 - * Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event). 59 + * Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
60 * Not included if the user has not agreed to the 60 * Not included if the user has not agreed to the
61 - * [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/). 61 + * [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
62 */ 62 */
63 userId?: string; 63 userId?: string;
64 }; 64 };
...@@ -68,9 +68,9 @@ export declare type Room = { ...@@ -68,9 +68,9 @@ export declare type Room = {
68 /** 68 /**
69 * ID of the source user. 69 * ID of the source user.
70 * 70 *
71 - * Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event). 71 + * Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
72 * Not included if the user has not agreed to the 72 * Not included if the user has not agreed to the
73 - * [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/). 73 + * [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
74 */ 74 */
75 userId?: string; 75 userId?: string;
76 }; 76 };
...@@ -83,7 +83,7 @@ export declare type ReplyableEvent = EventBase & { ...@@ -83,7 +83,7 @@ export declare type ReplyableEvent = EventBase & {
83 * The `message` property contains a message object which corresponds with the 83 * The `message` property contains a message object which corresponds with the
84 * message type. You can reply to message events. 84 * message type. You can reply to message events.
85 * 85 *
86 - * @see [Message event](https://developers.line.me/en/reference/messaging-api/#message-event) 86 + * @see [Message event](https://developers.line.biz/en/reference/messaging-api/#message-event)
87 */ 87 */
88 export declare type MessageEvent = { 88 export declare type MessageEvent = {
89 type: "message"; 89 type: "message";
...@@ -150,7 +150,7 @@ export declare type MemberLeaveEvent = { ...@@ -150,7 +150,7 @@ export declare type MemberLeaveEvent = {
150 } & EventBase; 150 } & EventBase;
151 /** 151 /**
152 * Event object for when a user performs an action on a 152 * Event object for when a user performs an action on a
153 - * [template message](https://developers.line.me/en/reference/messaging-api/#template-messages). 153 + * [template message](https://developers.line.biz/en/reference/messaging-api/#template-messages).
154 */ 154 */
155 export declare type PostbackEvent = { 155 export declare type PostbackEvent = {
156 type: "postback"; 156 type: "postback";
...@@ -158,7 +158,7 @@ export declare type PostbackEvent = { ...@@ -158,7 +158,7 @@ export declare type PostbackEvent = {
158 } & ReplyableEvent; 158 } & ReplyableEvent;
159 /** 159 /**
160 * Event object for when a user enters or leaves the range of a 160 * Event object for when a user enters or leaves the range of a
161 - * [LINE Beacon](https://developers.line.me/en/docs/messaging-api/using-beacons/). 161 + * [LINE Beacon](https://developers.line.biz/en/docs/messaging-api/using-beacons/).
162 */ 162 */
163 export declare type BeaconEvent = ReplyableEvent & { 163 export declare type BeaconEvent = ReplyableEvent & {
164 type: "beacon"; 164 type: "beacon";
...@@ -179,6 +179,119 @@ export declare type BeaconEvent = ReplyableEvent & { ...@@ -179,6 +179,119 @@ export declare type BeaconEvent = ReplyableEvent & {
179 dm?: string; 179 dm?: string;
180 }; 180 };
181 }; 181 };
182 +/**
183 + * Event object for when a user has linked his/her LINE account with a provider's service account.
184 + */
185 +export declare type AccountLinkEvent = ReplyableEvent & {
186 + type: "accountLink";
187 + link: {
188 + result: "ok" | "failed";
189 + /**
190 + * Specified nonce when verifying the user ID
191 + */
192 + nonce: string;
193 + };
194 +};
195 +/**
196 + * Indicates that a LINE Things-compatible device has been linked with LINE by a user operation.
197 + * For more information, see [Receiving device link events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#link-event).
198 + */
199 +export declare type DeviceLinkEvent = ReplyableEvent & {
200 + type: "things";
201 + things: {
202 + /**
203 + * Device ID of the LINE Things-compatible device that was linked with LINE
204 + */
205 + deviceId: string;
206 + type: "link";
207 + };
208 +};
209 +/**
210 + * Indicates that a LINE Things-compatible device has been unlinked from LINE by a user operation.
211 + * For more information, see [Receiving device unlink events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#unlink-event).
212 + */
213 +export declare type DeviceUnlinkEvent = ReplyableEvent & {
214 + type: "things";
215 + things: {
216 + /**
217 + * Device ID of the LINE Things-compatible device that was unlinked with LINE
218 + */
219 + deviceId: string;
220 + type: "unlink";
221 + };
222 +};
223 +export declare type LINEThingsScenarioExecutionEvent = ReplyableEvent & {
224 + type: "things";
225 + things: {
226 + type: "scenarioResult";
227 + /**
228 + * Device ID of the device that executed the scenario
229 + */
230 + deviceId: string;
231 + result: {
232 + /**
233 + * Scenario ID executed
234 + */
235 + scenarioId: string;
236 + /**
237 + * Revision number of the scenario set containing the executed scenario
238 + */
239 + revision: number;
240 + /**
241 + * Timestamp for when execution of scenario action started (milliseconds, LINE app time)
242 + */
243 + startTime: number;
244 + /**
245 + * Timestamp for when execution of scenario was completed (milliseconds, LINE app time)
246 + */
247 + endtime: number;
248 + /**
249 + * Scenario execution completion status
250 + * See also [things.resultCode definitions](https://developers.line.biz/en/reference/messaging-api/#things-resultcode).
251 + */
252 + resultCode: "success" | "gatt_error" | "runtime_error";
253 + /**
254 + * Execution result of individual operations specified in action
255 + * Note that an array of actions specified in a scenario has the following characteristics
256 + * - The actions defined in a scenario are performed sequentially, from top to bottom.
257 + * - Each action produces some result when executed.
258 + * Even actions that do not generate data, such as `SLEEP`, return an execution result of type `void`.
259 + * The number of items in an action array may be 0.
260 + *
261 + * Therefore, things.actionResults has the following properties:
262 + * - The number of items in the array matches the number of actions defined in the scenario.
263 + * - The order of execution results matches the order in which actions are performed.
264 + * That is, in a scenario set with multiple `GATT_READ` actions,
265 + * the results are returned in the order in which each individual `GATT_READ` action was performed.
266 + * - If 0 actions are defined in the scenario, the number of items in things.actionResults will be 0.
267 + */
268 + actionResults: Array<LINEThingsActionResult>;
269 + /**
270 + * Data contained in notification
271 + * The value is Base64-encoded binary data.
272 + * Only included for scenarios where `trigger.type = BLE_NOTIFICATION`.
273 + */
274 + bleNotificationPayload?: string;
275 + /**
276 + * Error reason
277 + */
278 + errorReason?: string;
279 + };
280 + };
281 +};
282 +export declare type LINEThingsActionResult = {
283 + /**
284 + * `void`, `binary`
285 + * Depends on `type` of the executed action.
286 + * This property is always included if `things.actionResults` is not empty.
287 + */
288 + type: "void" | "binary";
289 + /**
290 + * Base64-encoded binary data
291 + * This property is always included when `things.actionResults[].type` is `binary`.
292 + */
293 + data?: string;
294 +};
182 export declare type EventMessage = TextEventMessage | ImageEventMessage | VideoEventMessage | AudioEventMessage | LocationEventMessage | FileEventMessage | StickerEventMessage; 295 export declare type EventMessage = TextEventMessage | ImageEventMessage | VideoEventMessage | AudioEventMessage | LocationEventMessage | FileEventMessage | StickerEventMessage;
183 export declare type EventMessageBase = { 296 export declare type EventMessageBase = {
184 id: string; 297 id: string;
...@@ -260,7 +373,7 @@ export declare type LocationEventMessage = { ...@@ -260,7 +373,7 @@ export declare type LocationEventMessage = {
260 /** 373 /**
261 * Message object which contains the sticker data sent from the source. 374 * Message object which contains the sticker data sent from the source.
262 * For a list of basic LINE stickers and sticker IDs, see 375 * For a list of basic LINE stickers and sticker IDs, see
263 - * [sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf). 376 + * [sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
264 */ 377 */
265 export declare type StickerEventMessage = { 378 export declare type StickerEventMessage = {
266 type: "sticker"; 379 type: "sticker";
...@@ -271,9 +384,9 @@ export declare type Postback = { ...@@ -271,9 +384,9 @@ export declare type Postback = {
271 data: string; 384 data: string;
272 /** 385 /**
273 * Object with the date and time selected by a user through a 386 * Object with the date and time selected by a user through a
274 - * [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action). 387 + * [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
275 * Only returned for postback actions via a 388 * Only returned for postback actions via a
276 - * [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action). 389 + * [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
277 * The `full-date`, `time-hour`, and `time-minute` formats follow the 390 * The `full-date`, `time-hour`, and `time-minute` formats follow the
278 * [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt). 391 * [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt).
279 */ 392 */
...@@ -295,25 +408,25 @@ export declare type Postback = { ...@@ -295,25 +408,25 @@ export declare type Postback = {
295 /** 408 /**
296 * JSON object which contains the contents of the message you send. 409 * JSON object which contains the contents of the message you send.
297 * 410 *
298 - * @see [Message objects](https://developers.line.me/en/reference/messaging-api/#message-objects) 411 + * @see [Message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects)
299 */ 412 */
300 export declare type Message = TextMessage | ImageMessage | VideoMessage | AudioMessage | LocationMessage | StickerMessage | ImageMapMessage | TemplateMessage | FlexMessage; 413 export declare type Message = TextMessage | ImageMessage | VideoMessage | AudioMessage | LocationMessage | StickerMessage | ImageMapMessage | TemplateMessage | FlexMessage;
301 /** 414 /**
302 - * @see [Common properties for messages](https://developers.line.me/en/reference/messaging-api/#common-properties-for-messages) 415 + * @see [Common properties for messages](https://developers.line.biz/en/reference/messaging-api/#common-properties-for-messages)
303 */ 416 */
304 export declare type MessageCommon = { 417 export declare type MessageCommon = {
305 /** 418 /**
306 * For the quick reply feature. 419 * For the quick reply feature.
307 - * For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/). 420 + * For more information, see [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
308 * 421 *
309 * If the user receives multiple 422 * If the user receives multiple
310 - * [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), 423 + * [message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects),
311 * the quickReply property of the last message object is displayed. 424 * the quickReply property of the last message object is displayed.
312 */ 425 */
313 quickReply?: QuickReply; 426 quickReply?: QuickReply;
314 }; 427 };
315 /** 428 /**
316 - * @see [Text message](https://developers.line.me/en/reference/messaging-api/#text-message) 429 + * @see [Text message](https://developers.line.biz/en/reference/messaging-api/#text-message)
317 */ 430 */
318 export declare type TextMessage = MessageCommon & { 431 export declare type TextMessage = MessageCommon & {
319 type: "text"; 432 type: "text";
...@@ -322,14 +435,14 @@ export declare type TextMessage = MessageCommon & { ...@@ -322,14 +435,14 @@ export declare type TextMessage = MessageCommon & {
322 * 435 *
323 * - Unicode emoji 436 * - Unicode emoji
324 * - LINE original emoji 437 * - LINE original emoji
325 - * ([Unicode codepoint table for LINE original emoji](https://developers.line.me/media/messaging-api/emoji-list.pdf)) 438 + * ([Unicode codepoint table for LINE original emoji](https://developers.line.biz/media/messaging-api/emoji-list.pdf))
326 * 439 *
327 * Max: 2000 characters 440 * Max: 2000 characters
328 */ 441 */
329 text: string; 442 text: string;
330 }; 443 };
331 /** 444 /**
332 - * @see [Image message](https://developers.line.me/en/reference/messaging-api/#image-message) 445 + * @see [Image message](https://developers.line.biz/en/reference/messaging-api/#image-message)
333 */ 446 */
334 export declare type ImageMessage = MessageCommon & { 447 export declare type ImageMessage = MessageCommon & {
335 type: "image"; 448 type: "image";
...@@ -353,7 +466,7 @@ export declare type ImageMessage = MessageCommon & { ...@@ -353,7 +466,7 @@ export declare type ImageMessage = MessageCommon & {
353 previewImageUrl: string; 466 previewImageUrl: string;
354 }; 467 };
355 /** 468 /**
356 - * @see [Video message](https://developers.line.me/en/reference/messaging-api/#video-message) 469 + * @see [Video message](https://developers.line.biz/en/reference/messaging-api/#video-message)
357 */ 470 */
358 export declare type VideoMessage = MessageCommon & { 471 export declare type VideoMessage = MessageCommon & {
359 type: "video"; 472 type: "video";
...@@ -379,7 +492,7 @@ export declare type VideoMessage = MessageCommon & { ...@@ -379,7 +492,7 @@ export declare type VideoMessage = MessageCommon & {
379 previewImageUrl: string; 492 previewImageUrl: string;
380 }; 493 };
381 /** 494 /**
382 - * @see [Audio message](https://developers.line.me/en/reference/messaging-api/#audio-message) 495 + * @see [Audio message](https://developers.line.biz/en/reference/messaging-api/#audio-message)
383 */ 496 */
384 export declare type AudioMessage = MessageCommon & { 497 export declare type AudioMessage = MessageCommon & {
385 type: "audio"; 498 type: "audio";
...@@ -398,7 +511,7 @@ export declare type AudioMessage = MessageCommon & { ...@@ -398,7 +511,7 @@ export declare type AudioMessage = MessageCommon & {
398 duration: number; 511 duration: number;
399 }; 512 };
400 /** 513 /**
401 - * @see [Location message](https://developers.line.me/en/reference/messaging-api/#location-message) 514 + * @see [Location message](https://developers.line.biz/en/reference/messaging-api/#location-message)
402 */ 515 */
403 export declare type LocationMessage = MessageCommon & { 516 export declare type LocationMessage = MessageCommon & {
404 type: "location"; 517 type: "location";
...@@ -414,31 +527,31 @@ export declare type LocationMessage = MessageCommon & { ...@@ -414,31 +527,31 @@ export declare type LocationMessage = MessageCommon & {
414 longitude: number; 527 longitude: number;
415 }; 528 };
416 /** 529 /**
417 - * @see [Sticker message](https://developers.line.me/en/reference/messaging-api/#sticker-message) 530 + * @see [Sticker message](https://developers.line.biz/en/reference/messaging-api/#sticker-message)
418 */ 531 */
419 export declare type StickerMessage = MessageCommon & { 532 export declare type StickerMessage = MessageCommon & {
420 type: "sticker"; 533 type: "sticker";
421 /** 534 /**
422 * Package ID for a set of stickers. 535 * Package ID for a set of stickers.
423 * For information on package IDs, see the 536 * For information on package IDs, see the
424 - * [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf). 537 + * [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
425 */ 538 */
426 packageId: string; 539 packageId: string;
427 /** 540 /**
428 * Sticker ID. 541 * Sticker ID.
429 * For a list of sticker IDs for stickers that can be sent with the Messaging 542 * For a list of sticker IDs for stickers that can be sent with the Messaging
430 * API, see the 543 * API, see the
431 - * [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf). 544 + * [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
432 */ 545 */
433 stickerId: string; 546 stickerId: string;
434 }; 547 };
435 /** 548 /**
436 - * @see [Imagemap message](https://developers.line.me/en/reference/messaging-api/#imagemap-message) 549 + * @see [Imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)
437 */ 550 */
438 export declare type ImageMapMessage = MessageCommon & { 551 export declare type ImageMapMessage = MessageCommon & {
439 type: "imagemap"; 552 type: "imagemap";
440 /** 553 /**
441 - * [Base URL](https://developers.line.me/en/reference/messaging-api/#base-url) of image 554 + * [Base URL](https://developers.line.biz/en/reference/messaging-api/#base-url) of image
442 * (Max: 1000 characters, **HTTPS**) 555 * (Max: 1000 characters, **HTTPS**)
443 */ 556 */
444 baseUrl: string; 557 baseUrl: string;
...@@ -448,7 +561,7 @@ export declare type ImageMapMessage = MessageCommon & { ...@@ -448,7 +561,7 @@ export declare type ImageMapMessage = MessageCommon & {
448 altText: string; 561 altText: string;
449 baseSize: Size; 562 baseSize: Size;
450 /** 563 /**
451 - * Video to play inside a image map messagea 564 + * Video to play inside a image map messages
452 */ 565 */
453 video?: { 566 video?: {
454 /** 567 /**
...@@ -489,16 +602,16 @@ export declare type ImageMapMessage = MessageCommon & { ...@@ -489,16 +602,16 @@ export declare type ImageMapMessage = MessageCommon & {
489 /** 602 /**
490 * Template messages are messages with predefined layouts which you can 603 * Template messages are messages with predefined layouts which you can
491 * customize. For more information, see 604 * customize. For more information, see
492 - * [template messages](https://developers.line.me/en/docs/messaging-api/message-types/#template-messages). 605 + * [template messages](https://developers.line.biz/en/docs/messaging-api/message-types/#template-messages).
493 * 606 *
494 * The following template types are available: 607 * The following template types are available:
495 * 608 *
496 - * - [Buttons](https://developers.line.me/en/reference/messaging-api/#buttons) 609 + * - [Buttons](https://developers.line.biz/en/reference/messaging-api/#buttons)
497 - * - [Confirm](https://developers.line.me/en/reference/messaging-api/#confirm) 610 + * - [Confirm](https://developers.line.biz/en/reference/messaging-api/#confirm)
498 - * - [Carousel](https://developers.line.me/en/reference/messaging-api/#carousel) 611 + * - [Carousel](https://developers.line.biz/en/reference/messaging-api/#carousel)
499 - * - [Image carousel](https://developers.line.me/en/reference/messaging-api/#image-carousel) 612 + * - [Image carousel](https://developers.line.biz/en/reference/messaging-api/#image-carousel)
500 * 613 *
501 - * @see [Template messages](https://developers.line.me/en/reference/messaging-api/#template-messages) 614 + * @see [Template messages](https://developers.line.biz/en/reference/messaging-api/#template-messages)
502 */ 615 */
503 export declare type TemplateMessage = MessageCommon & { 616 export declare type TemplateMessage = MessageCommon & {
504 type: "template"; 617 type: "template";
...@@ -515,9 +628,9 @@ export declare type TemplateMessage = MessageCommon & { ...@@ -515,9 +628,9 @@ export declare type TemplateMessage = MessageCommon & {
515 * Flex Messages are messages with a customizable layout. 628 * Flex Messages are messages with a customizable layout.
516 * You can customize the layout freely by combining multiple elements. 629 * You can customize the layout freely by combining multiple elements.
517 * For more information, see 630 * For more information, see
518 - * [Using Flex Messages](https://developers.line.me/en/docs/messaging-api/using-flex-messages/). 631 + * [Using Flex Messages](https://developers.line.biz/en/docs/messaging-api/using-flex-messages/).
519 * 632 *
520 - * @see [Flex messages](https://developers.line.me/en/reference/messaging-api/#flex-message) 633 + * @see [Flex messages](https://developers.line.biz/en/reference/messaging-api/#flex-message)
521 */ 634 */
522 export declare type FlexMessage = MessageCommon & { 635 export declare type FlexMessage = MessageCommon & {
523 type: "flex"; 636 type: "flex";
...@@ -530,7 +643,7 @@ export declare type FlexMessage = MessageCommon & { ...@@ -530,7 +643,7 @@ export declare type FlexMessage = MessageCommon & {
530 * When a region is tapped, the user is redirected to the URI specified in 643 * When a region is tapped, the user is redirected to the URI specified in
531 * `uri` and the message specified in `message` is sent. 644 * `uri` and the message specified in `message` is sent.
532 * 645 *
533 - * @see [Imagemap action objects](https://developers.line.me/en/reference/messaging-api/#imagemap-action-objects) 646 + * @see [Imagemap action objects](https://developers.line.biz/en/reference/messaging-api/#imagemap-action-objects)
534 */ 647 */
535 export declare type ImageMapAction = ImageMapURIAction | ImageMapMessageAction; 648 export declare type ImageMapAction = ImageMapURIAction | ImageMapMessageAction;
536 export declare type ImageMapActionBase = { 649 export declare type ImageMapActionBase = {
...@@ -572,10 +685,10 @@ export declare type Area = { ...@@ -572,10 +685,10 @@ export declare type Area = {
572 /** 685 /**
573 * A container is the top-level structure of a Flex Message. Here are the types of containers available. 686 * A container is the top-level structure of a Flex Message. Here are the types of containers available.
574 * 687 *
575 - * - [Bubble](https://developers.line.me/en/reference/messaging-api/#bubble) 688 + * - [Bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
576 - * - [Carousel](https://developers.line.me/en/reference/messaging-api/#f-carousel) 689 + * - [Carousel](https://developers.line.biz/en/reference/messaging-api/#f-carousel)
577 * 690 *
578 - * See [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/) 691 + * See [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
579 * for the containers' JSON data samples and usage. 692 * for the containers' JSON data samples and usage.
580 */ 693 */
581 export declare type FlexContainer = FlexBubble | FlexCarousel; 694 export declare type FlexContainer = FlexBubble | FlexCarousel;
...@@ -584,10 +697,11 @@ export declare type FlexContainer = FlexBubble | FlexCarousel; ...@@ -584,10 +697,11 @@ export declare type FlexContainer = FlexBubble | FlexCarousel;
584 * blocks: header, hero, body, and footer. 697 * blocks: header, hero, body, and footer.
585 * 698 *
586 * For more information about using each block, see 699 * For more information about using each block, see
587 - * [Block](https://developers.line.me/en/docs/messaging-api/flex-message-elements/#block). 700 + * [Block](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/#block).
588 */ 701 */
589 export declare type FlexBubble = { 702 export declare type FlexBubble = {
590 type: "bubble"; 703 type: "bubble";
704 + size?: "nano" | "micro" | "kilo" | "mega" | "giga";
591 /** 705 /**
592 * Text directionality and the order of components in horizontal boxes in the 706 * Text directionality and the order of components in horizontal boxes in the
593 * container. Specify one of the following values: 707 * container. Specify one of the following values:
...@@ -599,10 +713,11 @@ export declare type FlexBubble = { ...@@ -599,10 +713,11 @@ export declare type FlexBubble = {
599 */ 713 */
600 direction?: "ltr" | "rtl"; 714 direction?: "ltr" | "rtl";
601 header?: FlexBox; 715 header?: FlexBox;
602 - hero?: FlexImage; 716 + hero?: FlexBox | FlexImage;
603 body?: FlexBox; 717 body?: FlexBox;
604 footer?: FlexBox; 718 footer?: FlexBox;
605 styles?: FlexBubbleStyle; 719 styles?: FlexBubbleStyle;
720 + action?: Action;
606 }; 721 };
607 export declare type FlexBubbleStyle = { 722 export declare type FlexBubbleStyle = {
608 header?: FlexBlockStyle; 723 header?: FlexBlockStyle;
...@@ -638,21 +753,22 @@ export declare type FlexCarousel = { ...@@ -638,21 +753,22 @@ export declare type FlexCarousel = {
638 * Components are objects that compose a Flex Message container. Here are the 753 * Components are objects that compose a Flex Message container. Here are the
639 * types of components available: 754 * types of components available:
640 * 755 *
641 - * - [Box](https://developers.line.me/en/reference/messaging-api/#box) 756 + * - [Box](https://developers.line.biz/en/reference/messaging-api/#box)
642 - * - [Button](https://developers.line.me/en/reference/messaging-api/#button) 757 + * - [Button](https://developers.line.biz/en/reference/messaging-api/#button)
643 - * - [Filler](https://developers.line.me/en/reference/messaging-api/#filler) 758 + * - [Image](https://developers.line.biz/en/reference/messaging-api/#f-image)
644 - * - [Icon](https://developers.line.me/en/reference/messaging-api/#icon) 759 + * - [Icon](https://developers.line.biz/en/reference/messaging-api/#icon)
645 - * - [Image](https://developers.line.me/en/reference/messaging-api/#f-image) 760 + * - [Text](https://developers.line.biz/en/reference/messaging-api/#f-text)
646 - * - [Separator](https://developers.line.me/en/reference/messaging-api/#separator) 761 + * - [Span](https://developers.line.biz/en/reference/messaging-api/#span)
647 - * - [Spacer](https://developers.line.me/en/reference/messaging-api/#spacer) 762 + * - [Separator](https://developers.line.biz/en/reference/messaging-api/#separator)
648 - * - [Text](https://developers.line.me/en/reference/messaging-api/#f-text) 763 + * - [Filler](https://developers.line.biz/en/reference/messaging-api/#filler)
764 + * - [Spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
649 * 765 *
650 * See the followings for the components' JSON data samples and usage. 766 * See the followings for the components' JSON data samples and usage.
651 * 767 *
652 - * - [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/) 768 + * - [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
653 - * - [Flex Message layout](https://developers.line.me/en/docs/messaging-api/flex-message-layout/) 769 + * - [Flex Message layout](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/)
654 */ 770 */
655 -export declare type FlexComponent = FlexBox | FlexButton | FlexFiller | FlexIcon | FlexImage | FlexSeparator | FlexSpacer | FlexText; 771 +export declare type FlexComponent = FlexBox | FlexButton | FlexImage | FlexIcon | FlexText | FlexSpan | FlexSeparator | FlexFiller | FlexSpacer;
656 /** 772 /**
657 * This is a component that defines the layout of child components. 773 * This is a component that defines the layout of child components.
658 * You can also include a box in a box. 774 * You can also include a box in a box.
...@@ -663,39 +779,71 @@ export declare type FlexBox = { ...@@ -663,39 +779,71 @@ export declare type FlexBox = {
663 * The placement style of components in this box. Specify one of the following values: 779 * The placement style of components in this box. Specify one of the following values:
664 * 780 *
665 * - `horizontal`: Components are placed horizontally. The `direction` 781 * - `horizontal`: Components are placed horizontally. The `direction`
666 - * property of the [bubble](https://developers.line.me/en/reference/messaging-api/#bubble) 782 + * property of the [bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
667 * container specifies the order. 783 * container specifies the order.
668 * - `vertical`: Components are placed vertically from top to bottom. 784 * - `vertical`: Components are placed vertically from top to bottom.
669 * - `baseline`: Components are placed in the same way as `horizontal` is 785 * - `baseline`: Components are placed in the same way as `horizontal` is
670 * specified except the baselines of the components are aligned. 786 * specified except the baselines of the components are aligned.
671 * 787 *
672 * For more information, see 788 * For more information, see
673 - * [Types of box layouts](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#box-layout-types). 789 + * [Types of box layouts](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-layout-types).
674 */ 790 */
675 layout: "horizontal" | "vertical" | "baseline"; 791 layout: "horizontal" | "vertical" | "baseline";
676 /** 792 /**
677 * Components in this box. Here are the types of components available: 793 * Components in this box. Here are the types of components available:
678 * 794 *
679 * - When the `layout` property is `horizontal` or `vertical`: 795 * - When the `layout` property is `horizontal` or `vertical`:
680 - * + [Box](https://developers.line.me/en/reference/messaging-api/#box) 796 + * + [Box](https://developers.line.biz/en/reference/messaging-api/#box)
681 - * + [button](https://developers.line.me/en/reference/messaging-api/#button) 797 + * + [button](https://developers.line.biz/en/reference/messaging-api/#button)
682 - * + [filler](https://developers.line.me/en/reference/messaging-api/#filler) 798 + * + [image](https://developers.line.biz/en/reference/messaging-api/#f-image)
683 - * + [image](https://developers.line.me/en/reference/messaging-api/#f-image) 799 + * + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
684 - * + [separator](https://developers.line.me/en/reference/messaging-api/#separator) 800 + * + [separator](https://developers.line.biz/en/reference/messaging-api/#separator)
685 - * + [text](https://developers.line.me/en/reference/messaging-api/#f-text) 801 + * + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
802 + * + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
686 * - When the `layout` property is `baseline`: 803 * - When the `layout` property is `baseline`:
687 - * + [filler](https://developers.line.me/en/reference/messaging-api/#filler) 804 + * + [icon](https://developers.line.biz/en/reference/messaging-api/#icon)
688 - * + [icon](https://developers.line.me/en/reference/messaging-api/#icon) 805 + * + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
689 - * + [text](https://developers.line.me/en/reference/messaging-api/#f-text) 806 + * + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
807 + * + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
690 */ 808 */
691 contents: FlexComponent[]; 809 contents: FlexComponent[];
692 /** 810 /**
811 + * Background color of the block. In addition to the RGB color, an alpha
812 + * channel (transparency) can also be set. Use a hexadecimal color code.
813 + * (Example:#RRGGBBAA) The default value is `#00000000`.
814 + */
815 + backgroundColor?: string;
816 + /**
817 + * Color of box border. Use a hexadecimal color code.
818 + */
819 + borderColor?: string;
820 + /**
821 + * Width of box border. You can specify a value in pixels or any one of none,
822 + * light, normal, medium, semi-bold, or bold. none does not render a border
823 + * while the others become wider in the order of listing.
824 + */
825 + borderWidth?: string | "none" | "light" | "normal" | "medium" | "semi-bold" | "bold";
826 + /**
827 + * Radius at the time of rounding the corners of the border. You can specify a
828 + * value in pixels or any one of `none`, `xs`, `sm`, `md`, `lg`, `xl`, or `xxl`. none does not
829 + * round the corner while the others increase in radius in the order of listing. The default value is none.
830 + */
831 + cornerRadius?: string | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
832 + /**
833 + * 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.
834 + */
835 + width?: string;
836 + /**
837 + * 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.
838 + */
839 + height?: string;
840 + /**
693 * The ratio of the width or height of this box within the parent box. The 841 * The ratio of the width or height of this box within the parent box. The
694 * default value for the horizontal parent box is `1`, and the default value 842 * default value for the horizontal parent box is `1`, and the default value
695 * for the vertical parent box is `0`. 843 * for the vertical parent box is `0`.
696 * 844 *
697 * For more information, see 845 * For more information, see
698 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 846 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
699 */ 847 */
700 flex?: number; 848 flex?: number;
701 /** 849 /**
...@@ -720,11 +868,67 @@ export declare type FlexBox = { ...@@ -720,11 +868,67 @@ export declare type FlexBox = {
720 */ 868 */
721 margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl"; 869 margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
722 /** 870 /**
871 + * Free space between the borders of this box and the child element.
872 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
873 + */
874 + paddingAll?: string;
875 + /**
876 + * Free space between the border at the upper end of this box and the upper end of the child element.
877 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
878 + */
879 + paddingTop?: string;
880 + /**
881 + * Free space between the border at the lower end of this box and the lower end of the child element.
882 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
883 + */
884 + paddingBottom?: string;
885 + /**
886 + * Free space between the border at the left end of this box and the left end of the child element.
887 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
888 + */
889 + paddingStart?: string;
890 + /**
891 + * Free space between the border at the right end of this box and the right end of the child element.
892 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
893 + */
894 + paddingEnd?: string;
895 + /**
723 * Action performed when this button is tapped. 896 * Action performed when this button is tapped.
724 * 897 *
725 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 898 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
726 */ 899 */
727 action?: Action; 900 action?: Action;
901 +} & Offset;
902 +export declare type Offset = {
903 + /**
904 + * Reference position for placing this box. Specify one of the following values:
905 + * - `relative`: Use the previous box as reference.
906 + * - `absolute`: Use the top left of parent element as reference.
907 + *
908 + * The default value is relative.
909 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
910 + */
911 + position?: "relative" | "absolute";
912 + /**
913 + * The top offset.
914 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
915 + */
916 + offsetTop?: string;
917 + /**
918 + * The bottom offset.
919 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
920 + */
921 + offsetBottom?: string;
922 + /**
923 + * The left offset.
924 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
925 + */
926 + offsetStart?: string;
927 + /**
928 + * The right offset.
929 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
930 + */
931 + offsetEnd?: string;
728 }; 932 };
729 /** 933 /**
730 * This component draws a button. 934 * This component draws a button.
...@@ -736,7 +940,7 @@ export declare type FlexButton = { ...@@ -736,7 +940,7 @@ export declare type FlexButton = {
736 /** 940 /**
737 * Action performed when this button is tapped. 941 * Action performed when this button is tapped.
738 * 942 *
739 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 943 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
740 */ 944 */
741 action: Action; 945 action: Action;
742 /** 946 /**
...@@ -746,7 +950,7 @@ export declare type FlexButton = { ...@@ -746,7 +950,7 @@ export declare type FlexButton = {
746 * value for the vertical parent box is `0`. 950 * value for the vertical parent box is `0`.
747 * 951 *
748 * For more information, see 952 * For more information, see
749 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 953 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
750 */ 954 */
751 flex?: number; 955 flex?: number;
752 /** 956 /**
...@@ -794,7 +998,7 @@ export declare type FlexButton = { ...@@ -794,7 +998,7 @@ export declare type FlexButton = {
794 * property will be ignored. 998 * property will be ignored.
795 */ 999 */
796 gravity?: "top" | "bottom" | "center"; 1000 gravity?: "top" | "bottom" | "center";
797 -}; 1001 +} & Offset;
798 /** 1002 /**
799 * This is an invisible component to fill extra space between components. 1003 * This is an invisible component to fill extra space between components.
800 * 1004 *
...@@ -803,6 +1007,10 @@ export declare type FlexButton = { ...@@ -803,6 +1007,10 @@ export declare type FlexButton = {
803 */ 1007 */
804 export declare type FlexFiller = { 1008 export declare type FlexFiller = {
805 type: "filler"; 1009 type: "filler";
1010 + /**
1011 + * 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).
1012 + */
1013 + flex?: number;
806 }; 1014 };
807 /** 1015 /**
808 * This component draws an icon. 1016 * This component draws an icon.
...@@ -840,7 +1048,7 @@ export declare type FlexIcon = { ...@@ -840,7 +1048,7 @@ export declare type FlexIcon = {
840 * Aspect ratio of the icon. The default value is `1:1`. 1048 * Aspect ratio of the icon. The default value is `1:1`.
841 */ 1049 */
842 aspectRatio?: "1:1" | "2:1" | "3:1"; 1050 aspectRatio?: "1:1" | "2:1" | "3:1";
843 -}; 1051 +} & Offset;
844 /** 1052 /**
845 * This component draws an image. 1053 * This component draws an image.
846 */ 1054 */
...@@ -862,7 +1070,7 @@ export declare type FlexImage = { ...@@ -862,7 +1070,7 @@ export declare type FlexImage = {
862 * value for the vertical parent box is `0`. 1070 * value for the vertical parent box is `0`.
863 * 1071 *
864 * - For more information, see 1072 * - For more information, see
865 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 1073 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
866 */ 1074 */
867 flex?: number; 1075 flex?: number;
868 /** 1076 /**
...@@ -928,10 +1136,10 @@ export declare type FlexImage = { ...@@ -928,10 +1136,10 @@ export declare type FlexImage = {
928 backgroundColor?: string; 1136 backgroundColor?: string;
929 /** 1137 /**
930 * Action performed when this button is tapped. 1138 * Action performed when this button is tapped.
931 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 1139 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
932 */ 1140 */
933 action?: Action; 1141 action?: Action;
934 -}; 1142 +} & Offset;
935 /** 1143 /**
936 * This component draws a separator between components in the parent box. 1144 * This component draws a separator between components in the parent box.
937 */ 1145 */
...@@ -965,19 +1173,23 @@ export declare type FlexSpacer = { ...@@ -965,19 +1173,23 @@ export declare type FlexSpacer = {
965 * The size increases in the order of listing. 1173 * The size increases in the order of listing.
966 * The default value is `md`. 1174 * The default value is `md`.
967 */ 1175 */
968 - size: "xs" | "sm" | "md" | "lg" | "xl" | "xxl"; 1176 + size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
969 }; 1177 };
970 export declare type FlexText = { 1178 export declare type FlexText = {
971 type: "text"; 1179 type: "text";
972 text: string; 1180 text: string;
973 /** 1181 /**
1182 + * 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.
1183 + */
1184 + contents?: FlexSpan[];
1185 + /**
974 * The ratio of the width or height of this box within the parent box. 1186 * The ratio of the width or height of this box within the parent box.
975 * 1187 *
976 * The default value for the horizontal parent box is `1`, and the default 1188 * The default value for the horizontal parent box is `1`, and the default
977 * value for the vertical parent box is `0`. 1189 * value for the vertical parent box is `0`.
978 * 1190 *
979 * For more information, see 1191 * For more information, see
980 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 1192 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
981 */ 1193 */
982 flex?: number; 1194 flex?: number;
983 /** 1195 /**
...@@ -1048,9 +1260,67 @@ export declare type FlexText = { ...@@ -1048,9 +1260,67 @@ export declare type FlexText = {
1048 color?: string; 1260 color?: string;
1049 /** 1261 /**
1050 * Action performed when this text is tapped. 1262 * Action performed when this text is tapped.
1051 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 1263 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
1052 */ 1264 */
1053 action?: Action; 1265 action?: Action;
1266 + /**
1267 + * Style of the text. Specify one of the following values:
1268 + * - `normal`: Normal
1269 + * - `italic`: Italic
1270 + *
1271 + * The default value is `normal`.
1272 + */
1273 + style?: string;
1274 + /**
1275 + * Decoration of the text. Specify one of the following values:
1276 + * `none`: No decoration
1277 + * `underline`: Underline
1278 + * `line-through`: Strikethrough
1279 + *
1280 + * The default value is `none`.
1281 + */
1282 + decoration?: string;
1283 +} & Offset;
1284 +/**
1285 + * 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).
1286 + */
1287 +export declare type FlexSpan = {
1288 + type: "span";
1289 + /**
1290 + * 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.
1291 + */
1292 + text: string;
1293 + /**
1294 + * Font color. Use a hexadecimal color code.
1295 + */
1296 + color?: string;
1297 + /**
1298 + * 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`.
1299 + */
1300 + size?: string;
1301 + /**
1302 + * Font weight. You can specify one of the following values: `regular` or `bold`. Specifying `bold` makes the font bold. The default value is `regular`.
1303 + */
1304 + weight?: string;
1305 + /**
1306 + * Style of the text. Specify one of the following values:
1307 + * - `normal`: Normal
1308 + * - `italic`: Italic
1309 + *
1310 + * The default value is `normal`.
1311 + */
1312 + style?: string;
1313 + /**
1314 + * Decoration of the text. Specify one of the following values:
1315 + * `none`: No decoration
1316 + * `underline`: Underline
1317 + * `line-through`: Strikethrough
1318 + *
1319 + * The default value is `none`.
1320 + *
1321 + * 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.
1322 + */
1323 + decoration?: string;
1054 }; 1324 };
1055 export declare type TemplateContent = TemplateButtons | TemplateConfirm | TemplateCarousel | TemplateImageCarousel; 1325 export declare type TemplateContent = TemplateButtons | TemplateConfirm | TemplateCarousel | TemplateImageCarousel;
1056 /** 1326 /**
...@@ -1218,7 +1488,7 @@ export declare type TemplateImageCarousel = { ...@@ -1218,7 +1488,7 @@ export declare type TemplateImageCarousel = {
1218 /** 1488 /**
1219 * Array of columns (Max: 10) 1489 * Array of columns (Max: 10)
1220 */ 1490 */
1221 - columns: TemplateImageColumn; 1491 + columns: TemplateImageColumn[];
1222 }; 1492 };
1223 export declare type TemplateImageColumn = { 1493 export declare type TemplateImageColumn = {
1224 /** 1494 /**
...@@ -1242,12 +1512,12 @@ export declare type TemplateImageColumn = { ...@@ -1242,12 +1512,12 @@ export declare type TemplateImageColumn = {
1242 * These properties are used for the quick reply. 1512 * These properties are used for the quick reply.
1243 * 1513 *
1244 * For more information, see 1514 * For more information, see
1245 - * [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/). 1515 + * [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
1246 */ 1516 */
1247 export declare type QuickReply = { 1517 export declare type QuickReply = {
1248 /** 1518 /**
1249 * This is a container that contains 1519 * This is a container that contains
1250 - * [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object). 1520 + * [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
1251 * 1521 *
1252 * Array of objects (Max: 13) 1522 * Array of objects (Max: 13)
1253 */ 1523 */
...@@ -1257,7 +1527,7 @@ export declare type QuickReply = { ...@@ -1257,7 +1527,7 @@ export declare type QuickReply = {
1257 * This is a quick reply option that is displayed as a button. 1527 * This is a quick reply option that is displayed as a button.
1258 * 1528 *
1259 * For more information, see 1529 * For more information, see
1260 - * [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object). 1530 + * [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
1261 */ 1531 */
1262 export declare type QuickReplyItem = { 1532 export declare type QuickReplyItem = {
1263 type: "action"; 1533 type: "action";
...@@ -1272,9 +1542,9 @@ export declare type QuickReplyItem = { ...@@ -1272,9 +1542,9 @@ export declare type QuickReplyItem = {
1272 * There is no limit on the image size. If the `action` property has the 1542 * There is no limit on the image size. If the `action` property has the
1273 * following actions with empty `imageUrl`: 1543 * following actions with empty `imageUrl`:
1274 * 1544 *
1275 - * - [camera action](https://developers.line.me/en/reference/messaging-api/#camera-action) 1545 + * - [camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
1276 - * - [camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action) 1546 + * - [camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
1277 - * - [location action](https://developers.line.me/en/reference/messaging-api/#location-action) 1547 + * - [location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
1278 * 1548 *
1279 * the default icon is displayed. 1549 * the default icon is displayed.
1280 */ 1550 */
...@@ -1282,33 +1552,39 @@ export declare type QuickReplyItem = { ...@@ -1282,33 +1552,39 @@ export declare type QuickReplyItem = {
1282 /** 1552 /**
1283 * Action performed when this button is tapped. 1553 * Action performed when this button is tapped.
1284 * 1554 *
1285 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 1555 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
1286 * 1556 *
1287 * The following is a list of the available actions: 1557 * The following is a list of the available actions:
1288 * 1558 *
1289 - * - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action) 1559 + * - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
1290 - * - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action) 1560 + * - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
1291 - * - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action) 1561 + * - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
1292 - * - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action) 1562 + * - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
1293 - * - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action) 1563 + * - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
1294 - * - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action) 1564 + * - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
1295 */ 1565 */
1296 action: Action; 1566 action: Action;
1297 }; 1567 };
1298 /** 1568 /**
1299 * These are types of actions for your bot to take when a user taps a button or an image in a message. 1569 * These are types of actions for your bot to take when a user taps a button or an image in a message.
1300 * 1570 *
1301 - * - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action) 1571 + * - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
1302 - * - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action) 1572 + * - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
1303 - * - [URI action](https://developers.line.me/en/reference/messaging-api/#uri-action) 1573 + * - [URI action](https://developers.line.biz/en/reference/messaging-api/#uri-action)
1304 - * - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action) 1574 + * - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
1305 - * - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action) 1575 + * - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
1306 - * - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action) 1576 + * - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
1307 - * - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action) 1577 + * - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
1308 */ 1578 */
1309 export declare type Action<ExtraFields = { 1579 export declare type Action<ExtraFields = {
1310 label: string; 1580 label: string;
1311 -}> = (PostbackAction | MessageAction | URIAction | DatetimePickerAction) & ExtraFields; 1581 +}> = (PostbackAction | MessageAction | URIAction | DatetimePickerAction | {
1582 + type: "camera";
1583 +} | {
1584 + type: "cameraRoll";
1585 +} | {
1586 + type: "location";
1587 +}) & ExtraFields;
1312 /** 1588 /**
1313 * When a control associated with this action is tapped, a postback event is 1589 * When a control associated with this action is tapped, a postback event is
1314 * returned via webhook with the specified string in the data property. 1590 * returned via webhook with the specified string in the data property.
...@@ -1363,10 +1639,24 @@ export declare type URIAction = { ...@@ -1363,10 +1639,24 @@ export declare type URIAction = {
1363 * Must start with `http`, `https`, or `tel`. 1639 * Must start with `http`, `https`, or `tel`.
1364 */ 1640 */
1365 uri: string; 1641 uri: string;
1642 + altUri?: AltURI;
1643 +};
1644 +/**
1645 + * URI opened on LINE for macOS and Windows when the action is performed (Max: 1000 characters)
1646 + * If the altUri.desktop property is set, the uri property is ignored on LINE for macOS and Windows.
1647 + * The available schemes are http, https, line, and tel.
1648 + * For more information about the LINE URL scheme, see Using the LINE URL scheme.
1649 + * This property is supported on the following version of LINE.
1650 + *
1651 + * LINE 5.12.0 or later for macOS and Windows
1652 + * Note: The altUri.desktop property is supported only when you set URI actions in Flex Messages.
1653 + */
1654 +export declare type AltURI = {
1655 + desktop: string;
1366 }; 1656 };
1367 /** 1657 /**
1368 * When a control associated with this action is tapped, a 1658 * When a control associated with this action is tapped, a
1369 - * [postback event](https://developers.line.me/en/reference/messaging-api/#postback-event) 1659 + * [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event)
1370 * is returned via webhook with the date and time selected by the user from the 1660 * is returned via webhook with the date and time selected by the user from the
1371 * date and time selection dialog. 1661 * date and time selection dialog.
1372 * 1662 *
...@@ -1414,21 +1704,21 @@ export declare type Size = { ...@@ -1414,21 +1704,21 @@ export declare type Size = {
1414 /** 1704 /**
1415 * Rich menus consist of either of these objects. 1705 * Rich menus consist of either of these objects.
1416 * 1706 *
1417 - * - [Rich menu object](https://developers.line.me/en/reference/messaging-api/#rich-menu-object) 1707 + * - [Rich menu object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-object)
1418 * without the rich menu ID. Use this object when you 1708 * without the rich menu ID. Use this object when you
1419 - * [create a rich menu](https://developers.line.me/en/reference/messaging-api/#create-rich-menu). 1709 + * [create a rich menu](https://developers.line.biz/en/reference/messaging-api/#create-rich-menu).
1420 - * - [Rich menu response object](https://developers.line.me/en/reference/messaging-api/#rich-menu-response-object) 1710 + * - [Rich menu response object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-response-object)
1421 * with the rich menu ID. This object is returned when you 1711 * with the rich menu ID. This object is returned when you
1422 - * [get a rich menu](https://developers.line.me/en/reference/messaging-api/#get-rich-menu) 1712 + * [get a rich menu](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu)
1423 - * or [get a list of rich menus](https://developers.line.me/en/reference/messaging-api/#get-rich-menu-list). 1713 + * or [get a list of rich menus](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list).
1424 * 1714 *
1425 - * [Area objects](https://developers.line.me/en/reference/messaging-api/#area-object) and 1715 + * [Area objects](https://developers.line.biz/en/reference/messaging-api/#area-object) and
1426 - * [action objects](https://developers.line.me/en/reference/messaging-api/#action-objects) 1716 + * [action objects](https://developers.line.biz/en/reference/messaging-api/#action-objects)
1427 * are included in these objects. 1717 * are included in these objects.
1428 */ 1718 */
1429 export declare type RichMenu = { 1719 export declare type RichMenu = {
1430 /** 1720 /**
1431 - * [`size` object](https://developers.line.me/en/reference/messaging-api/#size-object) 1721 + * [`size` object](https://developers.line.biz/en/reference/messaging-api/#size-object)
1432 * which contains the width and height of the rich menu displayed in the chat. 1722 * which contains the width and height of the rich menu displayed in the chat.
1433 * Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px. 1723 * Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px.
1434 */ 1724 */
...@@ -1451,7 +1741,7 @@ export declare type RichMenu = { ...@@ -1451,7 +1741,7 @@ export declare type RichMenu = {
1451 */ 1741 */
1452 chatBarText: string; 1742 chatBarText: string;
1453 /** 1743 /**
1454 - * Array of [area objects](https://developers.line.me/en/reference/messaging-api/#area-object) 1744 + * Array of [area objects](https://developers.line.biz/en/reference/messaging-api/#area-object)
1455 * which define the coordinates and size of tappable areas 1745 * which define the coordinates and size of tappable areas
1456 * (Max: 20 area objects) 1746 * (Max: 20 area objects)
1457 */ 1747 */
...@@ -1463,3 +1753,145 @@ export declare type RichMenu = { ...@@ -1463,3 +1753,145 @@ export declare type RichMenu = {
1463 export declare type RichMenuResponse = { 1753 export declare type RichMenuResponse = {
1464 richMenuId: string; 1754 richMenuId: string;
1465 } & RichMenu; 1755 } & RichMenu;
1756 +export declare type NumberOfMessagesSentResponse = InsightStatisticsResponse & {
1757 + /**
1758 + * The number of messages sent with the Messaging API on the date specified in date.
1759 + * The response has this property only when the value of status is `ready`.
1760 + */
1761 + success?: number;
1762 +};
1763 +export declare type TargetLimitForAdditionalMessages = {
1764 + /**
1765 + * One of the following values to indicate whether a target limit is set or not.
1766 + * - `none`: This indicates that a target limit is not set.
1767 + * - `limited`: This indicates that a target limit is set.
1768 + */
1769 + type: "none" | "limited";
1770 + /**
1771 + * The target limit for additional messages in the current month.
1772 + * This property is returned when the `type` property has a value of `limited`.
1773 + */
1774 + value?: number;
1775 +};
1776 +export declare type NumberOfMessagesSentThisMonth = {
1777 + /**
1778 + * The number of sent messages in the current month
1779 + */
1780 + totalUsage: number;
1781 +};
1782 +export declare const LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
1783 +export declare type MessageAPIResponseBase = {
1784 + [LINE_REQUEST_ID_HTTP_HEADER_NAME]?: string;
1785 +};
1786 +export declare type InsightStatisticsResponse = {
1787 + /**
1788 + * Calculation status. One of:
1789 + * - `ready`: Calculation has finished; the numbers are up-to-date.
1790 + * - `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.
1791 + * - `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/).
1792 + */
1793 + status: "ready" | "unready" | "out_of_service";
1794 +};
1795 +export declare type NumberOfMessageDeliveries = InsightStatisticsResponse & {
1796 + /**
1797 + * Number of push messages sent to **all** of this LINE official account's friends (broadcast messages).
1798 + */
1799 + broadcast: number;
1800 + /**
1801 + * Number of push messages sent to **some** of this LINE official account's friends, based on specific attributes (targeted/segmented messages).
1802 + */
1803 + targeting: number;
1804 + /**
1805 + * Number of auto-response messages sent.
1806 + */
1807 + autoResponse: number;
1808 + /**
1809 + * Number of greeting messages sent.
1810 + */
1811 + welcomeResponse: number;
1812 + /**
1813 + * Number of messages sent from LINE Official Account Manager [Chat screen](https://www.linebiz.com/jp-en/manual/OfficialAccountManager/chats/screens/).
1814 + */
1815 + chat: number;
1816 + /**
1817 + * Number of broadcast messages sent with the [Send broadcast message](https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message) Messaging API operation.
1818 + */
1819 + apiBroadcast: number;
1820 + /**
1821 + * Number of push messages sent with the [Send push message](https://developers.line.biz/en/reference/messaging-api/#send-push-message) Messaging API operation.
1822 + */
1823 + apiPush: number;
1824 + /**
1825 + * Number of multicast messages sent with the [Send multicast message](https://developers.line.biz/en/reference/messaging-api/#send-multicast-message) Messaging API operation.
1826 + */
1827 + apiMulticast: number;
1828 + /**
1829 + * Number of replies sent with the [Send reply message](https://developers.line.biz/en/reference/messaging-api/#send-reply-message) Messaging API operation.
1830 + */
1831 + apiReply: number;
1832 +};
1833 +export declare type NumberOfFollowers = InsightStatisticsResponse & {
1834 + /**
1835 + * 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.
1836 + */
1837 + followers: Number;
1838 + /**
1839 + * 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.
1840 + */
1841 + targetedReaches: Number;
1842 + /**
1843 + * The number of users blocking the account as of the specified `date`. The number decreases when a user unblocks the account.
1844 + */
1845 + blocks: Number;
1846 +};
1847 +export declare type NumberOfMessageDeliveriesResponse = InsightStatisticsResponse | NumberOfMessageDeliveries;
1848 +export declare type NumberOfFollowersResponse = InsightStatisticsResponse | NumberOfFollowers;
1849 +declare type PercentageAble = {
1850 + percentage: number;
1851 +};
1852 +export declare type FriendDemoGraphics = {
1853 + /**
1854 + * `true` if friend demographic information is available.
1855 + */
1856 + available: boolean;
1857 + /**
1858 + * Percentage per gender
1859 + */
1860 + genders?: Array<{
1861 + /**
1862 + * Gender
1863 + */
1864 + gender: "unknown" | "male" | "female";
1865 + } & PercentageAble>;
1866 + /**
1867 + * Percentage per age group
1868 + */
1869 + ages?: Array<{
1870 + /**
1871 + * Age group
1872 + */
1873 + age: string;
1874 + } & PercentageAble>;
1875 + /**
1876 + * Percentage per area
1877 + */
1878 + areas?: Array<{
1879 + area: string;
1880 + } & PercentageAble>;
1881 + /**
1882 + * Percentage by OS
1883 + */
1884 + appTypes?: Array<{
1885 + appType: "ios" | "android" | "others";
1886 + } & PercentageAble>;
1887 + /**
1888 + * Percentage per friendship duration
1889 + */
1890 + subscriptionPeriods?: Array<{
1891 + /**
1892 + * Friendship duration
1893 + */
1894 + subscriptionPeriod: "over365days" | "within365days" | "within180days" | "within90days" | "within30days" | "within7days" | "unknown";
1895 + } & PercentageAble>;
1896 +};
1897 +export {};
......
1 "use strict"; 1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true }); 2 Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
......
...@@ -2,35 +2,13 @@ ...@@ -2,35 +2,13 @@
2 Object.defineProperty(exports, "__esModule", { value: true }); 2 Object.defineProperty(exports, "__esModule", { value: true });
3 const crypto_1 = require("crypto"); 3 const crypto_1 = require("crypto");
4 function s2b(str, encoding) { 4 function s2b(str, encoding) {
5 - if (Buffer.from) { 5 + return Buffer.from(str, encoding);
6 - try {
7 - return Buffer.from(str, encoding);
8 - }
9 - catch (err) {
10 - if (err.name === "TypeError") {
11 - return new Buffer(str, encoding);
12 - }
13 - throw err;
14 - }
15 - }
16 - else {
17 - return new Buffer(str, encoding);
18 - }
19 } 6 }
20 function safeCompare(a, b) { 7 function safeCompare(a, b) {
21 if (a.length !== b.length) { 8 if (a.length !== b.length) {
22 return false; 9 return false;
23 } 10 }
24 - if (crypto_1.timingSafeEqual) { 11 + return crypto_1.timingSafeEqual(a, b);
25 - return crypto_1.timingSafeEqual(a, b);
26 - }
27 - else {
28 - let result = 0;
29 - for (let i = 0; i < a.length; i++) {
30 - result |= a[i] ^ b[i];
31 - }
32 - return result === 0;
33 - }
34 } 12 }
35 function validateSignature(body, channelSecret, signature) { 13 function validateSignature(body, channelSecret, signature) {
36 return safeCompare(crypto_1.createHmac("SHA256", channelSecret) 14 return safeCompare(crypto_1.createHmac("SHA256", channelSecret)
......
...@@ -2,12 +2,13 @@ import { Readable } from "stream"; ...@@ -2,12 +2,13 @@ import { Readable } from "stream";
2 import HTTPClient from "./http"; 2 import HTTPClient from "./http";
3 import * as Types from "./types"; 3 import * as Types from "./types";
4 import { JSONParseError } from "./exceptions"; 4 import { JSONParseError } from "./exceptions";
5 +import { AxiosResponse } from "axios";
5 6
6 function toArray<T>(maybeArr: T | T[]): T[] { 7 function toArray<T>(maybeArr: T | T[]): T[] {
7 return Array.isArray(maybeArr) ? maybeArr : [maybeArr]; 8 return Array.isArray(maybeArr) ? maybeArr : [maybeArr];
8 } 9 }
9 10
10 -function checkJSON<T>(raw: T): T { 11 +function ensureJSON<T>(raw: T): T {
11 if (typeof raw === "object") { 12 if (typeof raw === "object") {
12 return raw; 13 return raw;
13 } else { 14 } else {
...@@ -16,6 +17,9 @@ function checkJSON<T>(raw: T): T { ...@@ -16,6 +17,9 @@ function checkJSON<T>(raw: T): T {
16 } 17 }
17 18
18 type ChatType = "group" | "room"; 19 type ChatType = "group" | "room";
20 +const API_HOST: string = process.env.API_BASE_URL || "https://api.line.me/v2/";
21 +const BOT_BASE_URL: string = process.env.API_BASE_URL || `${API_HOST}bot/`;
22 +const OAUTH_BASE_URL = `${API_HOST}oauth/`;
19 23
20 export default class Client { 24 export default class Client {
21 public config: Types.ClientConfig; 25 public config: Types.ClientConfig;
...@@ -27,101 +31,132 @@ export default class Client { ...@@ -27,101 +31,132 @@ export default class Client {
27 } 31 }
28 32
29 this.config = config; 33 this.config = config;
30 - this.http = new HTTPClient( 34 + this.http = new HTTPClient({
31 - process.env.API_BASE_URL || "https://api.line.me/v2/bot/", 35 + baseURL: BOT_BASE_URL,
32 - { 36 + defaultHeaders: {
33 Authorization: "Bearer " + this.config.channelAccessToken, 37 Authorization: "Bearer " + this.config.channelAccessToken,
34 }, 38 },
35 - ); 39 + responseParser: this.parseHTTPResponse.bind(this),
40 + });
41 + }
42 +
43 + private parseHTTPResponse(response: AxiosResponse) {
44 + const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
45 + let resBody = {
46 + ...response.data,
47 + };
48 + if (response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME]) {
49 + resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] =
50 + response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME];
51 + }
52 + return resBody;
36 } 53 }
37 54
38 public pushMessage( 55 public pushMessage(
39 to: string, 56 to: string,
40 messages: Types.Message | Types.Message[], 57 messages: Types.Message | Types.Message[],
41 - ): Promise<any> { 58 + notificationDisabled: boolean = false,
59 + ): Promise<Types.MessageAPIResponseBase> {
42 return this.http.post("/message/push", { 60 return this.http.post("/message/push", {
43 messages: toArray(messages), 61 messages: toArray(messages),
44 to, 62 to,
63 + notificationDisabled,
45 }); 64 });
46 } 65 }
47 66
48 public replyMessage( 67 public replyMessage(
49 replyToken: string, 68 replyToken: string,
50 messages: Types.Message | Types.Message[], 69 messages: Types.Message | Types.Message[],
51 - ): Promise<any> { 70 + notificationDisabled: boolean = false,
71 + ): Promise<Types.MessageAPIResponseBase> {
52 return this.http.post("/message/reply", { 72 return this.http.post("/message/reply", {
53 messages: toArray(messages), 73 messages: toArray(messages),
54 replyToken, 74 replyToken,
75 + notificationDisabled,
55 }); 76 });
56 } 77 }
57 78
58 - public multicast( 79 + public async multicast(
59 to: string[], 80 to: string[],
60 messages: Types.Message | Types.Message[], 81 messages: Types.Message | Types.Message[],
61 - ): Promise<any> { 82 + notificationDisabled: boolean = false,
83 + ): Promise<Types.MessageAPIResponseBase> {
62 return this.http.post("/message/multicast", { 84 return this.http.post("/message/multicast", {
63 messages: toArray(messages), 85 messages: toArray(messages),
64 to, 86 to,
87 + notificationDisabled,
65 }); 88 });
66 } 89 }
67 90
68 - public getProfile(userId: string): Promise<Types.Profile> { 91 + public async broadcast(
69 - return this.http.get<Types.Profile>(`/profile/${userId}`).then(checkJSON); 92 + messages: Types.Message | Types.Message[],
93 + notificationDisabled: boolean = false,
94 + ): Promise<Types.MessageAPIResponseBase> {
95 + return this.http.post("/message/broadcast", {
96 + messages: toArray(messages),
97 + notificationDisabled,
98 + });
99 + }
100 +
101 + public async getProfile(userId: string): Promise<Types.Profile> {
102 + const profile = await this.http.get<Types.Profile>(`/profile/${userId}`);
103 + return ensureJSON(profile);
70 } 104 }
71 105
72 - private getChatMemberProfile( 106 + private async getChatMemberProfile(
73 chatType: ChatType, 107 chatType: ChatType,
74 chatId: string, 108 chatId: string,
75 userId: string, 109 userId: string,
76 ): Promise<Types.Profile> { 110 ): Promise<Types.Profile> {
77 - return this.http 111 + const profile = await this.http.get<Types.Profile>(
78 - .get<Types.Profile>(`/${chatType}/${chatId}/member/${userId}`) 112 + `/${chatType}/${chatId}/member/${userId}`,
79 - .then(checkJSON); 113 + );
114 + return ensureJSON(profile);
80 } 115 }
81 116
82 - public getGroupMemberProfile( 117 + public async getGroupMemberProfile(
83 groupId: string, 118 groupId: string,
84 userId: string, 119 userId: string,
85 ): Promise<Types.Profile> { 120 ): Promise<Types.Profile> {
86 return this.getChatMemberProfile("group", groupId, userId); 121 return this.getChatMemberProfile("group", groupId, userId);
87 } 122 }
88 123
89 - public getRoomMemberProfile( 124 + public async getRoomMemberProfile(
90 roomId: string, 125 roomId: string,
91 userId: string, 126 userId: string,
92 ): Promise<Types.Profile> { 127 ): Promise<Types.Profile> {
93 return this.getChatMemberProfile("room", roomId, userId); 128 return this.getChatMemberProfile("room", roomId, userId);
94 } 129 }
95 130
96 - private getChatMemberIds( 131 + private async getChatMemberIds(
97 chatType: ChatType, 132 chatType: ChatType,
98 chatId: string, 133 chatId: string,
99 ): Promise<string[]> { 134 ): Promise<string[]> {
100 - const load = (start?: string): Promise<string[]> => 135 + let memberIds: string[] = [];
101 - this.http 136 +
102 - .get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null) 137 + let start: string;
103 - .then(checkJSON) 138 + do {
104 - .then((res: { memberIds: string[]; next?: string }) => { 139 + const res = await this.http.get<{ memberIds: string[]; next?: string }>(
105 - if (!res.next) { 140 + `/${chatType}/${chatId}/members/ids`,
106 - return res.memberIds; 141 + start ? { start } : null,
107 - } 142 + );
108 - 143 + ensureJSON(res);
109 - return load(res.next).then(extraIds => 144 + memberIds = memberIds.concat(res.memberIds);
110 - res.memberIds.concat(extraIds), 145 + start = res.next;
111 - ); 146 + } while (start);
112 - }); 147 +
113 - return load(); 148 + return memberIds;
114 - } 149 + }
115 - 150 +
116 - public getGroupMemberIds(groupId: string): Promise<string[]> { 151 + public async getGroupMemberIds(groupId: string): Promise<string[]> {
117 return this.getChatMemberIds("group", groupId); 152 return this.getChatMemberIds("group", groupId);
118 } 153 }
119 154
120 - public getRoomMemberIds(roomId: string): Promise<string[]> { 155 + public async getRoomMemberIds(roomId: string): Promise<string[]> {
121 return this.getChatMemberIds("room", roomId); 156 return this.getChatMemberIds("room", roomId);
122 } 157 }
123 158
124 - public getMessageContent(messageId: string): Promise<Readable> { 159 + public async getMessageContent(messageId: string): Promise<Readable> {
125 return this.http.getStream(`/message/${messageId}/content`); 160 return this.http.getStream(`/message/${messageId}/content`);
126 } 161 }
127 162
...@@ -129,51 +164,71 @@ export default class Client { ...@@ -129,51 +164,71 @@ export default class Client {
129 return this.http.post(`/${chatType}/${chatId}/leave`); 164 return this.http.post(`/${chatType}/${chatId}/leave`);
130 } 165 }
131 166
132 - public leaveGroup(groupId: string): Promise<any> { 167 + public async leaveGroup(groupId: string): Promise<any> {
133 return this.leaveChat("group", groupId); 168 return this.leaveChat("group", groupId);
134 } 169 }
135 170
136 - public leaveRoom(roomId: string): Promise<any> { 171 + public async leaveRoom(roomId: string): Promise<any> {
137 return this.leaveChat("room", roomId); 172 return this.leaveChat("room", roomId);
138 } 173 }
139 174
140 - public getRichMenu(richMenuId: string): Promise<Types.RichMenuResponse> { 175 + public async getRichMenu(
141 - return this.http 176 + richMenuId: string,
142 - .get<Types.RichMenuResponse>(`/richmenu/${richMenuId}`) 177 + ): Promise<Types.RichMenuResponse> {
143 - .then(checkJSON); 178 + const res = await this.http.get<Types.RichMenuResponse>(
179 + `/richmenu/${richMenuId}`,
180 + );
181 + return ensureJSON(res);
144 } 182 }
145 183
146 - public createRichMenu(richMenu: Types.RichMenu): Promise<string> { 184 + public async createRichMenu(richMenu: Types.RichMenu): Promise<string> {
147 - return this.http 185 + const res = await this.http.post<any>("/richmenu", richMenu);
148 - .post<any>("/richmenu", richMenu) 186 + return ensureJSON(res).richMenuId;
149 - .then(checkJSON)
150 - .then(res => res.richMenuId);
151 } 187 }
152 188
153 - public deleteRichMenu(richMenuId: string): Promise<any> { 189 + public async deleteRichMenu(richMenuId: string): Promise<any> {
154 return this.http.delete(`/richmenu/${richMenuId}`); 190 return this.http.delete(`/richmenu/${richMenuId}`);
155 } 191 }
156 192
157 - public getRichMenuIdOfUser(userId: string): Promise<string> { 193 + public async getRichMenuIdOfUser(userId: string): Promise<string> {
158 - return this.http 194 + const res = await this.http.get<any>(`/user/${userId}/richmenu`);
159 - .get<any>(`/user/${userId}/richmenu`) 195 + return ensureJSON(res).richMenuId;
160 - .then(checkJSON)
161 - .then(res => res.richMenuId);
162 } 196 }
163 197
164 - public linkRichMenuToUser(userId: string, richMenuId: string): Promise<any> { 198 + public async linkRichMenuToUser(
199 + userId: string,
200 + richMenuId: string,
201 + ): Promise<any> {
165 return this.http.post(`/user/${userId}/richmenu/${richMenuId}`); 202 return this.http.post(`/user/${userId}/richmenu/${richMenuId}`);
166 } 203 }
167 204
168 - public unlinkRichMenuFromUser(userId: string): Promise<any> { 205 + public async unlinkRichMenuFromUser(userId: string): Promise<any> {
169 return this.http.delete(`/user/${userId}/richmenu`); 206 return this.http.delete(`/user/${userId}/richmenu`);
170 } 207 }
171 208
172 - public getRichMenuImage(richMenuId: string): Promise<Readable> { 209 + public async linkRichMenuToMultipleUsers(
210 + richMenuId: string,
211 + userIds: string[],
212 + ): Promise<any> {
213 + return this.http.post("/richmenu/bulk/link", {
214 + richMenuId,
215 + userIds,
216 + });
217 + }
218 +
219 + public async unlinkRichMenusFromMultipleUsers(
220 + userIds: string[],
221 + ): Promise<any> {
222 + return this.http.post("/richmenu/bulk/unlink", {
223 + userIds,
224 + });
225 + }
226 +
227 + public async getRichMenuImage(richMenuId: string): Promise<Readable> {
173 return this.http.getStream(`/richmenu/${richMenuId}/content`); 228 return this.http.getStream(`/richmenu/${richMenuId}/content`);
174 } 229 }
175 230
176 - public setRichMenuImage( 231 + public async setRichMenuImage(
177 richMenuId: string, 232 richMenuId: string,
178 data: Buffer | Readable, 233 data: Buffer | Readable,
179 contentType?: string, 234 contentType?: string,
...@@ -185,32 +240,134 @@ export default class Client { ...@@ -185,32 +240,134 @@ export default class Client {
185 ); 240 );
186 } 241 }
187 242
188 - public getRichMenuList(): Promise<Array<Types.RichMenuResponse>> { 243 + public async getRichMenuList(): Promise<Array<Types.RichMenuResponse>> {
189 - return this.http 244 + const res = await this.http.get<any>(`/richmenu/list`);
190 - .get<any>(`/richmenu/list`) 245 + return ensureJSON(res).richmenus;
191 - .then(checkJSON)
192 - .then(res => res.richmenus);
193 } 246 }
194 247
195 - public setDefaultRichMenu(richMenuId: string): Promise<{}> { 248 + public async setDefaultRichMenu(richMenuId: string): Promise<{}> {
196 return this.http.post(`/user/all/richmenu/${richMenuId}`); 249 return this.http.post(`/user/all/richmenu/${richMenuId}`);
197 } 250 }
198 251
199 - public getDefaultRichMenuId(): Promise<string> { 252 + public async getDefaultRichMenuId(): Promise<string> {
200 - return this.http 253 + const res = await this.http.get<any>("/user/all/richmenu");
201 - .get<any>("/user/all/richmenu") 254 + return ensureJSON(res).richMenuId;
202 - .then(checkJSON)
203 - .then(res => res.richMenuId);
204 } 255 }
205 256
206 - public deleteDefaultRichMenu(): Promise<{}> { 257 + public async deleteDefaultRichMenu(): Promise<{}> {
207 return this.http.delete("/user/all/richmenu"); 258 return this.http.delete("/user/all/richmenu");
208 } 259 }
209 260
210 - public getLinkToken(userId: string): Promise<string> { 261 + public async getLinkToken(userId: string): Promise<string> {
211 - return this.http 262 + const res = await this.http.post<any>(`/user/${userId}/linkToken`);
212 - .post<any>(`/user/${userId}/linkToken`) 263 + return ensureJSON(res).linkToken;
213 - .then(checkJSON) 264 + }
214 - .then(res => res.linkToken); 265 +
266 + public async getNumberOfSentReplyMessages(
267 + date: string,
268 + ): Promise<Types.NumberOfMessagesSentResponse> {
269 + const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
270 + `/message/delivery/reply?date=${date}`,
271 + );
272 + return ensureJSON(res);
273 + }
274 +
275 + public async getNumberOfSentPushMessages(
276 + date: string,
277 + ): Promise<Types.NumberOfMessagesSentResponse> {
278 + const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
279 + `/message/delivery/push?date=${date}`,
280 + );
281 + return ensureJSON(res);
282 + }
283 +
284 + public async getNumberOfSentMulticastMessages(
285 + date: string,
286 + ): Promise<Types.NumberOfMessagesSentResponse> {
287 + const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
288 + `/message/delivery/multicast?date=${date}`,
289 + );
290 + return ensureJSON(res);
291 + }
292 +
293 + public async getTargetLimitForAdditionalMessages(): Promise<
294 + Types.TargetLimitForAdditionalMessages
295 + > {
296 + const res = await this.http.get<Types.TargetLimitForAdditionalMessages>(
297 + "/message/quota",
298 + );
299 + return ensureJSON(res);
300 + }
301 +
302 + public async getNumberOfMessagesSentThisMonth(): Promise<
303 + Types.NumberOfMessagesSentThisMonth
304 + > {
305 + const res = await this.http.get<Types.NumberOfMessagesSentThisMonth>(
306 + "/message/quota/consumption",
307 + );
308 + return ensureJSON(res);
309 + }
310 +
311 + public async getNumberOfSentBroadcastMessages(
312 + date: string,
313 + ): Promise<Types.NumberOfMessagesSentResponse> {
314 + const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
315 + `/message/delivery/broadcast?date=${date}`,
316 + );
317 + return ensureJSON(res);
318 + }
319 +
320 + public async getNumberOfMessageDeliveries(
321 + date: string,
322 + ): Promise<Types.NumberOfMessageDeliveriesResponse> {
323 + const res = await this.http.get<Types.NumberOfMessageDeliveriesResponse>(
324 + `/insight/message/delivery?date=${date}`,
325 + );
326 + return ensureJSON(res);
327 + }
328 +
329 + public async getNumberOfFollowers(
330 + date: string,
331 + ): Promise<Types.NumberOfFollowersResponse> {
332 + const res = await this.http.get<Types.NumberOfFollowersResponse>(
333 + `/insight/followers?date=${date}`,
334 + );
335 + return ensureJSON(res);
336 + }
337 +
338 + public async getFriendDemographics(): Promise<Types.FriendDemoGraphics> {
339 + const res = await this.http.get<Types.FriendDemoGraphics>(
340 + `/insight/demographic`,
341 + );
342 + return ensureJSON(res);
343 + }
344 +}
345 +
346 +export class OAuth {
347 + private http: HTTPClient;
348 +
349 + constructor() {
350 + this.http = new HTTPClient({
351 + baseURL: OAUTH_BASE_URL,
352 + });
353 + }
354 +
355 + public issueAccessToken(
356 + client_id: string,
357 + client_secret: string,
358 + ): Promise<{
359 + access_token: string;
360 + expires_in: number;
361 + token_type: "Bearer";
362 + }> {
363 + return this.http.postForm("/accessToken", {
364 + grant_type: "client_credentials",
365 + client_id,
366 + client_secret,
367 + });
368 + }
369 +
370 + public revokeAccessToken(access_token: string): Promise<{}> {
371 + return this.http.postForm("/revoke", { access_token });
215 } 372 }
216 } 373 }
......
1 -import axios, { AxiosInstance, AxiosError } from "axios"; 1 +import axios, { AxiosInstance, AxiosError, AxiosResponse } from "axios";
2 import { Readable } from "stream"; 2 import { Readable } from "stream";
3 import { HTTPError, ReadError, RequestError } from "./exceptions"; 3 import { HTTPError, ReadError, RequestError } from "./exceptions";
4 import * as fileType from "file-type"; 4 import * as fileType from "file-type";
5 +import * as qs from "querystring";
5 6
6 const pkg = require("../package.json"); 7 const pkg = require("../package.json");
7 8
9 +type httpClientConfig = {
10 + baseURL?: string;
11 + defaultHeaders?: any;
12 + responseParser?: <T>(res: AxiosResponse) => T;
13 +};
14 +
8 export default class HTTPClient { 15 export default class HTTPClient {
9 private instance: AxiosInstance; 16 private instance: AxiosInstance;
17 + private config: httpClientConfig;
10 18
11 - constructor(baseURL?: string, defaultHeaders?: any) { 19 + constructor(config: httpClientConfig = {}) {
20 + this.config = config;
21 + const { baseURL, defaultHeaders } = config;
12 this.instance = axios.create({ 22 this.instance = axios.create({
13 baseURL, 23 baseURL,
14 headers: Object.assign({}, defaultHeaders, { 24 headers: Object.assign({}, defaultHeaders, {
...@@ -22,34 +32,47 @@ export default class HTTPClient { ...@@ -22,34 +32,47 @@ export default class HTTPClient {
22 ); 32 );
23 } 33 }
24 34
25 - public get<T>(url: string, params?: any): Promise<T> { 35 + public async get<T>(url: string, params?: any): Promise<T> {
26 - return this.instance.get(url, { params }).then(res => res.data); 36 + const res = await this.instance.get(url, { params });
37 + return res.data;
27 } 38 }
28 39
29 - public getStream(url: string, params?: any): Promise<Readable> { 40 + public async getStream(url: string, params?: any): Promise<Readable> {
30 - return this.instance 41 + const res = await this.instance.get(url, {
31 - .get(url, { params, responseType: "stream" }) 42 + params,
32 - .then(res => res.data as Readable); 43 + responseType: "stream",
44 + });
45 + return res.data as Readable;
33 } 46 }
34 47
35 - public post<T>(url: string, data?: any): Promise<T> { 48 + public async post<T>(url: string, body?: any): Promise<T> {
36 - return this.instance 49 + const res = await this.instance.post(url, body, {
37 - .post(url, data, { headers: { "Content-Type": "application/json" } }) 50 + headers: { "Content-Type": "application/json" },
38 - .then(res => res.data); 51 + });
52 +
53 + const { responseParser } = this.config;
54 + if (responseParser) return responseParser<T>(res);
55 + else return res.data;
39 } 56 }
40 57
41 - public postBinary<T>( 58 + public async postForm<T>(url: string, body?: any): Promise<T> {
59 + const res = await this.instance.post(url, qs.stringify(body), {
60 + headers: { "Content-Type": "application/x-www-form-urlencoded" },
61 + });
62 +
63 + return res.data;
64 + }
65 +
66 + public async postBinary<T>(
42 url: string, 67 url: string,
43 data: Buffer | Readable, 68 data: Buffer | Readable,
44 contentType?: string, 69 contentType?: string,
45 ): Promise<T> { 70 ): Promise<T> {
46 - let getBuffer: Promise<Buffer>; 71 + const buffer = await (async (): Promise<Buffer> => {
47 - 72 + if (Buffer.isBuffer(data)) {
48 - if (Buffer.isBuffer(data)) { 73 + return data;
49 - getBuffer = Promise.resolve(data); 74 + } else if (data instanceof Readable) {
50 - } else { 75 + return new Promise<Buffer>((resolve, reject) => {
51 - getBuffer = new Promise((resolve, reject) => {
52 - if (data instanceof Readable) {
53 const buffers: Buffer[] = []; 76 const buffers: Buffer[] = [];
54 let size = 0; 77 let size = 0;
55 data.on("data", (chunk: Buffer) => { 78 data.on("data", (chunk: Buffer) => {
...@@ -58,26 +81,25 @@ export default class HTTPClient { ...@@ -58,26 +81,25 @@ export default class HTTPClient {
58 }); 81 });
59 data.on("end", () => resolve(Buffer.concat(buffers, size))); 82 data.on("end", () => resolve(Buffer.concat(buffers, size)));
60 data.on("error", reject); 83 data.on("error", reject);
61 - } else { 84 + });
62 - reject(new Error("invalid data type for postBinary")); 85 + } else {
63 - } 86 + throw new Error("invalid data type for postBinary");
64 - }); 87 + }
65 - } 88 + })();
66 89
67 - return getBuffer.then(data => { 90 + const res = await this.instance.post(url, buffer, {
68 - return this.instance 91 + headers: {
69 - .post(url, data, { 92 + "Content-Type": contentType || fileType(buffer).mime,
70 - headers: { 93 + "Content-Length": buffer.length,
71 - "Content-Type": contentType || fileType(data).mime, 94 + },
72 - "Content-Length": data.length,
73 - },
74 - })
75 - .then(res => res.data);
76 }); 95 });
96 +
97 + return res.data;
77 } 98 }
78 99
79 - public delete<T>(url: string, params?: any): Promise<T> { 100 + public async delete<T>(url: string, params?: any): Promise<T> {
80 - return this.instance.delete(url, { params }).then(res => res.data); 101 + const res = await this.instance.delete(url, { params });
102 + return res.data;
81 } 103 }
82 104
83 private wrapError(err: AxiosError): Error { 105 private wrapError(err: AxiosError): Error {
......
1 -import Client from "./client"; 1 +import Client, { OAuth } from "./client";
2 import middleware from "./middleware"; 2 import middleware from "./middleware";
3 import validateSignature from "./validate-signature"; 3 import validateSignature from "./validate-signature";
4 4
5 -export { Client, middleware, validateSignature }; 5 +export { Client, middleware, validateSignature, OAuth };
6 6
7 // re-export exceptions and types 7 // re-export exceptions and types
8 export * from "./exceptions"; 8 export * from "./exceptions";
......
...@@ -12,7 +12,7 @@ export type Middleware = ( ...@@ -12,7 +12,7 @@ export type Middleware = (
12 req: Request, 12 req: Request,
13 res: Response, 13 res: Response,
14 next: NextCallback, 14 next: NextCallback,
15 -) => void; 15 +) => void | Promise<void>;
16 16
17 function isValidBody(body?: any): body is string | Buffer { 17 function isValidBody(body?: any): body is string | Buffer {
18 return (body && typeof body === "string") || Buffer.isBuffer(body); 18 return (body && typeof body === "string") || Buffer.isBuffer(body);
...@@ -25,7 +25,7 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware { ...@@ -25,7 +25,7 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware {
25 25
26 const secret = config.channelSecret; 26 const secret = config.channelSecret;
27 27
28 - return (req, res, next) => { 28 + const _middleware: Middleware = async (req, res, next) => {
29 // header names are lower-cased 29 // header names are lower-cased
30 // https://nodejs.org/api/http.html#http_message_headers 30 // https://nodejs.org/api/http.html#http_message_headers
31 const signature = req.headers["x-line-signature"] as string; 31 const signature = req.headers["x-line-signature"] as string;
...@@ -35,38 +35,39 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware { ...@@ -35,38 +35,39 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware {
35 return; 35 return;
36 } 36 }
37 37
38 - let getBody: Promise<string | Buffer>; 38 + const body = await (async (): Promise<string | Buffer> => {
39 - if (isValidBody((req as any).rawBody)) { 39 + if (isValidBody((req as any).rawBody)) {
40 - // rawBody is provided in Google Cloud Functions and others 40 + // rawBody is provided in Google Cloud Functions and others
41 - getBody = Promise.resolve((req as any).rawBody); 41 + return (req as any).rawBody;
42 - } else if (isValidBody(req.body)) { 42 + } else if (isValidBody(req.body)) {
43 - getBody = Promise.resolve(req.body); 43 + return req.body;
44 - } else { 44 + } else {
45 - // body may not be parsed yet, parse it to a buffer 45 + // body may not be parsed yet, parse it to a buffer
46 - getBody = new Promise(resolve => { 46 + return new Promise<Buffer>((resolve, reject) =>
47 - raw({ type: "*/*" })(req as any, res as any, () => resolve(req.body)); 47 + raw({ type: "*/*" })(req as any, res as any, (error: Error) =>
48 - }); 48 + error ? reject(error) : resolve(req.body),
49 - }
50 -
51 - getBody.then(body => {
52 - if (!validateSignature(body, secret, signature)) {
53 - next(
54 - new SignatureValidationFailed(
55 - "signature validation failed",
56 - signature,
57 ), 49 ),
58 ); 50 );
59 - return;
60 } 51 }
52 + })();
53 +
54 + if (!validateSignature(body, secret, signature)) {
55 + next(
56 + new SignatureValidationFailed("signature validation failed", signature),
57 + );
58 + return;
59 + }
61 60
62 - const strBody = Buffer.isBuffer(body) ? body.toString() : body; 61 + const strBody = Buffer.isBuffer(body) ? body.toString() : body;
63 62
64 - try { 63 + try {
65 - req.body = JSON.parse(strBody); 64 + req.body = JSON.parse(strBody);
66 - next(); 65 + next();
67 - } catch (err) { 66 + } catch (err) {
68 - next(new JSONParseError(err.message, strBody)); 67 + next(new JSONParseError(err.message, strBody));
69 - } 68 + }
70 - }); 69 + };
70 + return (req, res, next): void => {
71 + (<Promise<void>>_middleware(req, res, next)).catch(next);
71 }; 72 };
72 } 73 }
......
...@@ -21,7 +21,7 @@ export type Profile = { ...@@ -21,7 +21,7 @@ export type Profile = {
21 /** 21 /**
22 * Request body which is sent by webhook. 22 * Request body which is sent by webhook.
23 * 23 *
24 - * @see [Request body](https://developers.line.me/en/reference/messaging-api/#request-body) 24 + * @see [Request body](https://developers.line.biz/en/reference/messaging-api/#request-body)
25 */ 25 */
26 export type WebhookRequestBody = { 26 export type WebhookRequestBody = {
27 /** 27 /**
...@@ -38,7 +38,7 @@ export type WebhookRequestBody = { ...@@ -38,7 +38,7 @@ export type WebhookRequestBody = {
38 /** 38 /**
39 * JSON objects which contain events generated on the LINE Platform. 39 * JSON objects which contain events generated on the LINE Platform.
40 * 40 *
41 - * @see [Webhook event objects](https://developers.line.me/en/reference/messaging-api/#webhook-event-objects) 41 + * @see [Webhook event objects](https://developers.line.biz/en/reference/messaging-api/#webhook-event-objects)
42 */ 42 */
43 export type WebhookEvent = 43 export type WebhookEvent =
44 | MessageEvent 44 | MessageEvent
...@@ -49,7 +49,11 @@ export type WebhookEvent = ...@@ -49,7 +49,11 @@ export type WebhookEvent =
49 | MemberJoinEvent 49 | MemberJoinEvent
50 | MemberLeaveEvent 50 | MemberLeaveEvent
51 | PostbackEvent 51 | PostbackEvent
52 - | BeaconEvent; 52 + | BeaconEvent
53 + | AccountLinkEvent
54 + | DeviceLinkEvent
55 + | DeviceUnlinkEvent
56 + | LINEThingsScenarioExecutionEvent;
53 57
54 export type EventBase = { 58 export type EventBase = {
55 /** 59 /**
...@@ -72,9 +76,9 @@ export type Group = { ...@@ -72,9 +76,9 @@ export type Group = {
72 /** 76 /**
73 * ID of the source user. 77 * ID of the source user.
74 * 78 *
75 - * Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event). 79 + * Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
76 * Not included if the user has not agreed to the 80 * Not included if the user has not agreed to the
77 - * [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/). 81 + * [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
78 */ 82 */
79 userId?: string; 83 userId?: string;
80 }; 84 };
...@@ -85,9 +89,9 @@ export type Room = { ...@@ -85,9 +89,9 @@ export type Room = {
85 /** 89 /**
86 * ID of the source user. 90 * ID of the source user.
87 * 91 *
88 - * Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event). 92 + * Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
89 * Not included if the user has not agreed to the 93 * Not included if the user has not agreed to the
90 - * [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/). 94 + * [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
91 */ 95 */
92 userId?: string; 96 userId?: string;
93 }; 97 };
...@@ -100,7 +104,7 @@ export type ReplyableEvent = EventBase & { replyToken: string }; ...@@ -100,7 +104,7 @@ export type ReplyableEvent = EventBase & { replyToken: string };
100 * The `message` property contains a message object which corresponds with the 104 * The `message` property contains a message object which corresponds with the
101 * message type. You can reply to message events. 105 * message type. You can reply to message events.
102 * 106 *
103 - * @see [Message event](https://developers.line.me/en/reference/messaging-api/#message-event) 107 + * @see [Message event](https://developers.line.biz/en/reference/messaging-api/#message-event)
104 */ 108 */
105 export type MessageEvent = { 109 export type MessageEvent = {
106 type: "message"; 110 type: "message";
...@@ -162,7 +166,7 @@ export type MemberLeaveEvent = { ...@@ -162,7 +166,7 @@ export type MemberLeaveEvent = {
162 166
163 /** 167 /**
164 * Event object for when a user performs an action on a 168 * Event object for when a user performs an action on a
165 - * [template message](https://developers.line.me/en/reference/messaging-api/#template-messages). 169 + * [template message](https://developers.line.biz/en/reference/messaging-api/#template-messages).
166 */ 170 */
167 export type PostbackEvent = { 171 export type PostbackEvent = {
168 type: "postback"; 172 type: "postback";
...@@ -171,7 +175,7 @@ export type PostbackEvent = { ...@@ -171,7 +175,7 @@ export type PostbackEvent = {
171 175
172 /** 176 /**
173 * Event object for when a user enters or leaves the range of a 177 * Event object for when a user enters or leaves the range of a
174 - * [LINE Beacon](https://developers.line.me/en/docs/messaging-api/using-beacons/). 178 + * [LINE Beacon](https://developers.line.biz/en/docs/messaging-api/using-beacons/).
175 */ 179 */
176 export type BeaconEvent = ReplyableEvent & { 180 export type BeaconEvent = ReplyableEvent & {
177 type: "beacon"; 181 type: "beacon";
...@@ -195,6 +199,125 @@ export type BeaconEvent = ReplyableEvent & { ...@@ -195,6 +199,125 @@ export type BeaconEvent = ReplyableEvent & {
195 }; 199 };
196 }; 200 };
197 201
202 +/**
203 + * Event object for when a user has linked his/her LINE account with a provider's service account.
204 + */
205 +export type AccountLinkEvent = ReplyableEvent & {
206 + type: "accountLink";
207 + link: {
208 + result: "ok" | "failed";
209 +
210 + /**
211 + * Specified nonce when verifying the user ID
212 + */
213 + nonce: string;
214 + };
215 +};
216 +
217 +/**
218 + * Indicates that a LINE Things-compatible device has been linked with LINE by a user operation.
219 + * For more information, see [Receiving device link events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#link-event).
220 + */
221 +export type DeviceLinkEvent = ReplyableEvent & {
222 + type: "things";
223 + things: {
224 + /**
225 + * Device ID of the LINE Things-compatible device that was linked with LINE
226 + */
227 + deviceId: string;
228 + type: "link";
229 + };
230 +};
231 +
232 +/**
233 + * Indicates that a LINE Things-compatible device has been unlinked from LINE by a user operation.
234 + * For more information, see [Receiving device unlink events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#unlink-event).
235 + */
236 +export type DeviceUnlinkEvent = ReplyableEvent & {
237 + type: "things";
238 + things: {
239 + /**
240 + * Device ID of the LINE Things-compatible device that was unlinked with LINE
241 + */
242 + deviceId: string;
243 + type: "unlink";
244 + };
245 +};
246 +
247 +export type LINEThingsScenarioExecutionEvent = ReplyableEvent & {
248 + type: "things";
249 + things: {
250 + type: "scenarioResult";
251 + /**
252 + * Device ID of the device that executed the scenario
253 + */
254 + deviceId: string;
255 + result: {
256 + /**
257 + * Scenario ID executed
258 + */
259 + scenarioId: string;
260 + /**
261 + * Revision number of the scenario set containing the executed scenario
262 + */
263 + revision: number;
264 + /**
265 + * Timestamp for when execution of scenario action started (milliseconds, LINE app time)
266 + */
267 + startTime: number;
268 + /**
269 + * Timestamp for when execution of scenario was completed (milliseconds, LINE app time)
270 + */
271 + endtime: number;
272 + /**
273 + * Scenario execution completion status
274 + * See also [things.resultCode definitions](https://developers.line.biz/en/reference/messaging-api/#things-resultcode).
275 + */
276 + resultCode: "success" | "gatt_error" | "runtime_error";
277 + /**
278 + * Execution result of individual operations specified in action
279 + * Note that an array of actions specified in a scenario has the following characteristics
280 + * - The actions defined in a scenario are performed sequentially, from top to bottom.
281 + * - Each action produces some result when executed.
282 + * Even actions that do not generate data, such as `SLEEP`, return an execution result of type `void`.
283 + * The number of items in an action array may be 0.
284 + *
285 + * Therefore, things.actionResults has the following properties:
286 + * - The number of items in the array matches the number of actions defined in the scenario.
287 + * - The order of execution results matches the order in which actions are performed.
288 + * That is, in a scenario set with multiple `GATT_READ` actions,
289 + * the results are returned in the order in which each individual `GATT_READ` action was performed.
290 + * - If 0 actions are defined in the scenario, the number of items in things.actionResults will be 0.
291 + */
292 + actionResults: Array<LINEThingsActionResult>;
293 + /**
294 + * Data contained in notification
295 + * The value is Base64-encoded binary data.
296 + * Only included for scenarios where `trigger.type = BLE_NOTIFICATION`.
297 + */
298 + bleNotificationPayload?: string;
299 + /**
300 + * Error reason
301 + */
302 + errorReason?: string;
303 + };
304 + };
305 +};
306 +
307 +export type LINEThingsActionResult = {
308 + /**
309 + * `void`, `binary`
310 + * Depends on `type` of the executed action.
311 + * This property is always included if `things.actionResults` is not empty.
312 + */
313 + type: "void" | "binary";
314 + /**
315 + * Base64-encoded binary data
316 + * This property is always included when `things.actionResults[].type` is `binary`.
317 + */
318 + data?: string;
319 +};
320 +
198 export type EventMessage = 321 export type EventMessage =
199 | TextEventMessage 322 | TextEventMessage
200 | ImageEventMessage 323 | ImageEventMessage
...@@ -292,7 +415,7 @@ export type LocationEventMessage = { ...@@ -292,7 +415,7 @@ export type LocationEventMessage = {
292 /** 415 /**
293 * Message object which contains the sticker data sent from the source. 416 * Message object which contains the sticker data sent from the source.
294 * For a list of basic LINE stickers and sticker IDs, see 417 * For a list of basic LINE stickers and sticker IDs, see
295 - * [sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf). 418 + * [sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
296 */ 419 */
297 export type StickerEventMessage = { 420 export type StickerEventMessage = {
298 type: "sticker"; 421 type: "sticker";
...@@ -304,9 +427,9 @@ export type Postback = { ...@@ -304,9 +427,9 @@ export type Postback = {
304 data: string; 427 data: string;
305 /** 428 /**
306 * Object with the date and time selected by a user through a 429 * Object with the date and time selected by a user through a
307 - * [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action). 430 + * [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
308 * Only returned for postback actions via a 431 * Only returned for postback actions via a
309 - * [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action). 432 + * [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
310 * The `full-date`, `time-hour`, and `time-minute` formats follow the 433 * The `full-date`, `time-hour`, and `time-minute` formats follow the
311 * [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt). 434 * [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt).
312 */ 435 */
...@@ -329,7 +452,7 @@ export type Postback = { ...@@ -329,7 +452,7 @@ export type Postback = {
329 /** 452 /**
330 * JSON object which contains the contents of the message you send. 453 * JSON object which contains the contents of the message you send.
331 * 454 *
332 - * @see [Message objects](https://developers.line.me/en/reference/messaging-api/#message-objects) 455 + * @see [Message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects)
333 */ 456 */
334 export type Message = 457 export type Message =
335 | TextMessage 458 | TextMessage
...@@ -343,22 +466,22 @@ export type Message = ...@@ -343,22 +466,22 @@ export type Message =
343 | FlexMessage; 466 | FlexMessage;
344 467
345 /** 468 /**
346 - * @see [Common properties for messages](https://developers.line.me/en/reference/messaging-api/#common-properties-for-messages) 469 + * @see [Common properties for messages](https://developers.line.biz/en/reference/messaging-api/#common-properties-for-messages)
347 */ 470 */
348 export type MessageCommon = { 471 export type MessageCommon = {
349 /** 472 /**
350 * For the quick reply feature. 473 * For the quick reply feature.
351 - * For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/). 474 + * For more information, see [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
352 * 475 *
353 * If the user receives multiple 476 * If the user receives multiple
354 - * [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects), 477 + * [message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects),
355 * the quickReply property of the last message object is displayed. 478 * the quickReply property of the last message object is displayed.
356 */ 479 */
357 quickReply?: QuickReply; 480 quickReply?: QuickReply;
358 }; 481 };
359 482
360 /** 483 /**
361 - * @see [Text message](https://developers.line.me/en/reference/messaging-api/#text-message) 484 + * @see [Text message](https://developers.line.biz/en/reference/messaging-api/#text-message)
362 */ 485 */
363 export type TextMessage = MessageCommon & { 486 export type TextMessage = MessageCommon & {
364 type: "text"; 487 type: "text";
...@@ -367,7 +490,7 @@ export type TextMessage = MessageCommon & { ...@@ -367,7 +490,7 @@ export type TextMessage = MessageCommon & {
367 * 490 *
368 * - Unicode emoji 491 * - Unicode emoji
369 * - LINE original emoji 492 * - LINE original emoji
370 - * ([Unicode codepoint table for LINE original emoji](https://developers.line.me/media/messaging-api/emoji-list.pdf)) 493 + * ([Unicode codepoint table for LINE original emoji](https://developers.line.biz/media/messaging-api/emoji-list.pdf))
371 * 494 *
372 * Max: 2000 characters 495 * Max: 2000 characters
373 */ 496 */
...@@ -375,7 +498,7 @@ export type TextMessage = MessageCommon & { ...@@ -375,7 +498,7 @@ export type TextMessage = MessageCommon & {
375 }; 498 };
376 499
377 /** 500 /**
378 - * @see [Image message](https://developers.line.me/en/reference/messaging-api/#image-message) 501 + * @see [Image message](https://developers.line.biz/en/reference/messaging-api/#image-message)
379 */ 502 */
380 export type ImageMessage = MessageCommon & { 503 export type ImageMessage = MessageCommon & {
381 type: "image"; 504 type: "image";
...@@ -400,7 +523,7 @@ export type ImageMessage = MessageCommon & { ...@@ -400,7 +523,7 @@ export type ImageMessage = MessageCommon & {
400 }; 523 };
401 524
402 /** 525 /**
403 - * @see [Video message](https://developers.line.me/en/reference/messaging-api/#video-message) 526 + * @see [Video message](https://developers.line.biz/en/reference/messaging-api/#video-message)
404 */ 527 */
405 export type VideoMessage = MessageCommon & { 528 export type VideoMessage = MessageCommon & {
406 type: "video"; 529 type: "video";
...@@ -427,7 +550,7 @@ export type VideoMessage = MessageCommon & { ...@@ -427,7 +550,7 @@ export type VideoMessage = MessageCommon & {
427 }; 550 };
428 551
429 /** 552 /**
430 - * @see [Audio message](https://developers.line.me/en/reference/messaging-api/#audio-message) 553 + * @see [Audio message](https://developers.line.biz/en/reference/messaging-api/#audio-message)
431 */ 554 */
432 export type AudioMessage = MessageCommon & { 555 export type AudioMessage = MessageCommon & {
433 type: "audio"; 556 type: "audio";
...@@ -447,7 +570,7 @@ export type AudioMessage = MessageCommon & { ...@@ -447,7 +570,7 @@ export type AudioMessage = MessageCommon & {
447 }; 570 };
448 571
449 /** 572 /**
450 - * @see [Location message](https://developers.line.me/en/reference/messaging-api/#location-message) 573 + * @see [Location message](https://developers.line.biz/en/reference/messaging-api/#location-message)
451 */ 574 */
452 export type LocationMessage = MessageCommon & { 575 export type LocationMessage = MessageCommon & {
453 type: "location"; 576 type: "location";
...@@ -464,32 +587,32 @@ export type LocationMessage = MessageCommon & { ...@@ -464,32 +587,32 @@ export type LocationMessage = MessageCommon & {
464 }; 587 };
465 588
466 /** 589 /**
467 - * @see [Sticker message](https://developers.line.me/en/reference/messaging-api/#sticker-message) 590 + * @see [Sticker message](https://developers.line.biz/en/reference/messaging-api/#sticker-message)
468 */ 591 */
469 export type StickerMessage = MessageCommon & { 592 export type StickerMessage = MessageCommon & {
470 type: "sticker"; 593 type: "sticker";
471 /** 594 /**
472 * Package ID for a set of stickers. 595 * Package ID for a set of stickers.
473 * For information on package IDs, see the 596 * For information on package IDs, see the
474 - * [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf). 597 + * [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
475 */ 598 */
476 packageId: string; 599 packageId: string;
477 /** 600 /**
478 * Sticker ID. 601 * Sticker ID.
479 * For a list of sticker IDs for stickers that can be sent with the Messaging 602 * For a list of sticker IDs for stickers that can be sent with the Messaging
480 * API, see the 603 * API, see the
481 - * [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf). 604 + * [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
482 */ 605 */
483 stickerId: string; 606 stickerId: string;
484 }; 607 };
485 608
486 /** 609 /**
487 - * @see [Imagemap message](https://developers.line.me/en/reference/messaging-api/#imagemap-message) 610 + * @see [Imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)
488 */ 611 */
489 export type ImageMapMessage = MessageCommon & { 612 export type ImageMapMessage = MessageCommon & {
490 type: "imagemap"; 613 type: "imagemap";
491 /** 614 /**
492 - * [Base URL](https://developers.line.me/en/reference/messaging-api/#base-url) of image 615 + * [Base URL](https://developers.line.biz/en/reference/messaging-api/#base-url) of image
493 * (Max: 1000 characters, **HTTPS**) 616 * (Max: 1000 characters, **HTTPS**)
494 */ 617 */
495 baseUrl: string; 618 baseUrl: string;
...@@ -499,7 +622,7 @@ export type ImageMapMessage = MessageCommon & { ...@@ -499,7 +622,7 @@ export type ImageMapMessage = MessageCommon & {
499 altText: string; 622 altText: string;
500 baseSize: Size; 623 baseSize: Size;
501 /** 624 /**
502 - * Video to play inside a image map messagea 625 + * Video to play inside a image map messages
503 */ 626 */
504 video?: { 627 video?: {
505 /** 628 /**
...@@ -541,16 +664,16 @@ export type ImageMapMessage = MessageCommon & { ...@@ -541,16 +664,16 @@ export type ImageMapMessage = MessageCommon & {
541 /** 664 /**
542 * Template messages are messages with predefined layouts which you can 665 * Template messages are messages with predefined layouts which you can
543 * customize. For more information, see 666 * customize. For more information, see
544 - * [template messages](https://developers.line.me/en/docs/messaging-api/message-types/#template-messages). 667 + * [template messages](https://developers.line.biz/en/docs/messaging-api/message-types/#template-messages).
545 * 668 *
546 * The following template types are available: 669 * The following template types are available:
547 * 670 *
548 - * - [Buttons](https://developers.line.me/en/reference/messaging-api/#buttons) 671 + * - [Buttons](https://developers.line.biz/en/reference/messaging-api/#buttons)
549 - * - [Confirm](https://developers.line.me/en/reference/messaging-api/#confirm) 672 + * - [Confirm](https://developers.line.biz/en/reference/messaging-api/#confirm)
550 - * - [Carousel](https://developers.line.me/en/reference/messaging-api/#carousel) 673 + * - [Carousel](https://developers.line.biz/en/reference/messaging-api/#carousel)
551 - * - [Image carousel](https://developers.line.me/en/reference/messaging-api/#image-carousel) 674 + * - [Image carousel](https://developers.line.biz/en/reference/messaging-api/#image-carousel)
552 * 675 *
553 - * @see [Template messages](https://developers.line.me/en/reference/messaging-api/#template-messages) 676 + * @see [Template messages](https://developers.line.biz/en/reference/messaging-api/#template-messages)
554 */ 677 */
555 export type TemplateMessage = MessageCommon & { 678 export type TemplateMessage = MessageCommon & {
556 type: "template"; 679 type: "template";
...@@ -568,9 +691,9 @@ export type TemplateMessage = MessageCommon & { ...@@ -568,9 +691,9 @@ export type TemplateMessage = MessageCommon & {
568 * Flex Messages are messages with a customizable layout. 691 * Flex Messages are messages with a customizable layout.
569 * You can customize the layout freely by combining multiple elements. 692 * You can customize the layout freely by combining multiple elements.
570 * For more information, see 693 * For more information, see
571 - * [Using Flex Messages](https://developers.line.me/en/docs/messaging-api/using-flex-messages/). 694 + * [Using Flex Messages](https://developers.line.biz/en/docs/messaging-api/using-flex-messages/).
572 * 695 *
573 - * @see [Flex messages](https://developers.line.me/en/reference/messaging-api/#flex-message) 696 + * @see [Flex messages](https://developers.line.biz/en/reference/messaging-api/#flex-message)
574 */ 697 */
575 export type FlexMessage = MessageCommon & { 698 export type FlexMessage = MessageCommon & {
576 type: "flex"; 699 type: "flex";
...@@ -584,7 +707,7 @@ export type FlexMessage = MessageCommon & { ...@@ -584,7 +707,7 @@ export type FlexMessage = MessageCommon & {
584 * When a region is tapped, the user is redirected to the URI specified in 707 * When a region is tapped, the user is redirected to the URI specified in
585 * `uri` and the message specified in `message` is sent. 708 * `uri` and the message specified in `message` is sent.
586 * 709 *
587 - * @see [Imagemap action objects](https://developers.line.me/en/reference/messaging-api/#imagemap-action-objects) 710 + * @see [Imagemap action objects](https://developers.line.biz/en/reference/messaging-api/#imagemap-action-objects)
588 */ 711 */
589 export type ImageMapAction = ImageMapURIAction | ImageMapMessageAction; 712 export type ImageMapAction = ImageMapURIAction | ImageMapMessageAction;
590 713
...@@ -631,10 +754,10 @@ export type Area = { ...@@ -631,10 +754,10 @@ export type Area = {
631 /** 754 /**
632 * A container is the top-level structure of a Flex Message. Here are the types of containers available. 755 * A container is the top-level structure of a Flex Message. Here are the types of containers available.
633 * 756 *
634 - * - [Bubble](https://developers.line.me/en/reference/messaging-api/#bubble) 757 + * - [Bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
635 - * - [Carousel](https://developers.line.me/en/reference/messaging-api/#f-carousel) 758 + * - [Carousel](https://developers.line.biz/en/reference/messaging-api/#f-carousel)
636 * 759 *
637 - * See [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/) 760 + * See [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
638 * for the containers' JSON data samples and usage. 761 * for the containers' JSON data samples and usage.
639 */ 762 */
640 export type FlexContainer = FlexBubble | FlexCarousel; 763 export type FlexContainer = FlexBubble | FlexCarousel;
...@@ -644,10 +767,11 @@ export type FlexContainer = FlexBubble | FlexCarousel; ...@@ -644,10 +767,11 @@ export type FlexContainer = FlexBubble | FlexCarousel;
644 * blocks: header, hero, body, and footer. 767 * blocks: header, hero, body, and footer.
645 * 768 *
646 * For more information about using each block, see 769 * For more information about using each block, see
647 - * [Block](https://developers.line.me/en/docs/messaging-api/flex-message-elements/#block). 770 + * [Block](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/#block).
648 */ 771 */
649 export type FlexBubble = { 772 export type FlexBubble = {
650 type: "bubble"; 773 type: "bubble";
774 + size?: "nano" | "micro" | "kilo" | "mega" | "giga";
651 /** 775 /**
652 * Text directionality and the order of components in horizontal boxes in the 776 * Text directionality and the order of components in horizontal boxes in the
653 * container. Specify one of the following values: 777 * container. Specify one of the following values:
...@@ -659,10 +783,11 @@ export type FlexBubble = { ...@@ -659,10 +783,11 @@ export type FlexBubble = {
659 */ 783 */
660 direction?: "ltr" | "rtl"; 784 direction?: "ltr" | "rtl";
661 header?: FlexBox; 785 header?: FlexBox;
662 - hero?: FlexImage; 786 + hero?: FlexBox | FlexImage;
663 body?: FlexBox; 787 body?: FlexBox;
664 footer?: FlexBox; 788 footer?: FlexBox;
665 styles?: FlexBubbleStyle; 789 styles?: FlexBubbleStyle;
790 + action?: Action;
666 }; 791 };
667 792
668 export type FlexBubbleStyle = { 793 export type FlexBubbleStyle = {
...@@ -702,29 +827,31 @@ export type FlexCarousel = { ...@@ -702,29 +827,31 @@ export type FlexCarousel = {
702 * Components are objects that compose a Flex Message container. Here are the 827 * Components are objects that compose a Flex Message container. Here are the
703 * types of components available: 828 * types of components available:
704 * 829 *
705 - * - [Box](https://developers.line.me/en/reference/messaging-api/#box) 830 + * - [Box](https://developers.line.biz/en/reference/messaging-api/#box)
706 - * - [Button](https://developers.line.me/en/reference/messaging-api/#button) 831 + * - [Button](https://developers.line.biz/en/reference/messaging-api/#button)
707 - * - [Filler](https://developers.line.me/en/reference/messaging-api/#filler) 832 + * - [Image](https://developers.line.biz/en/reference/messaging-api/#f-image)
708 - * - [Icon](https://developers.line.me/en/reference/messaging-api/#icon) 833 + * - [Icon](https://developers.line.biz/en/reference/messaging-api/#icon)
709 - * - [Image](https://developers.line.me/en/reference/messaging-api/#f-image) 834 + * - [Text](https://developers.line.biz/en/reference/messaging-api/#f-text)
710 - * - [Separator](https://developers.line.me/en/reference/messaging-api/#separator) 835 + * - [Span](https://developers.line.biz/en/reference/messaging-api/#span)
711 - * - [Spacer](https://developers.line.me/en/reference/messaging-api/#spacer) 836 + * - [Separator](https://developers.line.biz/en/reference/messaging-api/#separator)
712 - * - [Text](https://developers.line.me/en/reference/messaging-api/#f-text) 837 + * - [Filler](https://developers.line.biz/en/reference/messaging-api/#filler)
838 + * - [Spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
713 * 839 *
714 * See the followings for the components' JSON data samples and usage. 840 * See the followings for the components' JSON data samples and usage.
715 * 841 *
716 - * - [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/) 842 + * - [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
717 - * - [Flex Message layout](https://developers.line.me/en/docs/messaging-api/flex-message-layout/) 843 + * - [Flex Message layout](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/)
718 */ 844 */
719 export type FlexComponent = 845 export type FlexComponent =
720 | FlexBox 846 | FlexBox
721 | FlexButton 847 | FlexButton
722 - | FlexFiller
723 - | FlexIcon
724 | FlexImage 848 | FlexImage
849 + | FlexIcon
850 + | FlexText
851 + | FlexSpan
725 | FlexSeparator 852 | FlexSeparator
726 - | FlexSpacer 853 + | FlexFiller
727 - | FlexText; 854 + | FlexSpacer;
728 855
729 /** 856 /**
730 * This is a component that defines the layout of child components. 857 * This is a component that defines the layout of child components.
...@@ -736,39 +863,78 @@ export type FlexBox = { ...@@ -736,39 +863,78 @@ export type FlexBox = {
736 * The placement style of components in this box. Specify one of the following values: 863 * The placement style of components in this box. Specify one of the following values:
737 * 864 *
738 * - `horizontal`: Components are placed horizontally. The `direction` 865 * - `horizontal`: Components are placed horizontally. The `direction`
739 - * property of the [bubble](https://developers.line.me/en/reference/messaging-api/#bubble) 866 + * property of the [bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
740 * container specifies the order. 867 * container specifies the order.
741 * - `vertical`: Components are placed vertically from top to bottom. 868 * - `vertical`: Components are placed vertically from top to bottom.
742 * - `baseline`: Components are placed in the same way as `horizontal` is 869 * - `baseline`: Components are placed in the same way as `horizontal` is
743 * specified except the baselines of the components are aligned. 870 * specified except the baselines of the components are aligned.
744 * 871 *
745 * For more information, see 872 * For more information, see
746 - * [Types of box layouts](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#box-layout-types). 873 + * [Types of box layouts](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-layout-types).
747 */ 874 */
748 layout: "horizontal" | "vertical" | "baseline"; 875 layout: "horizontal" | "vertical" | "baseline";
749 /** 876 /**
750 * Components in this box. Here are the types of components available: 877 * Components in this box. Here are the types of components available:
751 * 878 *
752 * - When the `layout` property is `horizontal` or `vertical`: 879 * - When the `layout` property is `horizontal` or `vertical`:
753 - * + [Box](https://developers.line.me/en/reference/messaging-api/#box) 880 + * + [Box](https://developers.line.biz/en/reference/messaging-api/#box)
754 - * + [button](https://developers.line.me/en/reference/messaging-api/#button) 881 + * + [button](https://developers.line.biz/en/reference/messaging-api/#button)
755 - * + [filler](https://developers.line.me/en/reference/messaging-api/#filler) 882 + * + [image](https://developers.line.biz/en/reference/messaging-api/#f-image)
756 - * + [image](https://developers.line.me/en/reference/messaging-api/#f-image) 883 + * + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
757 - * + [separator](https://developers.line.me/en/reference/messaging-api/#separator) 884 + * + [separator](https://developers.line.biz/en/reference/messaging-api/#separator)
758 - * + [text](https://developers.line.me/en/reference/messaging-api/#f-text) 885 + * + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
886 + * + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
759 * - When the `layout` property is `baseline`: 887 * - When the `layout` property is `baseline`:
760 - * + [filler](https://developers.line.me/en/reference/messaging-api/#filler) 888 + * + [icon](https://developers.line.biz/en/reference/messaging-api/#icon)
761 - * + [icon](https://developers.line.me/en/reference/messaging-api/#icon) 889 + * + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
762 - * + [text](https://developers.line.me/en/reference/messaging-api/#f-text) 890 + * + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
891 + * + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
763 */ 892 */
764 contents: FlexComponent[]; 893 contents: FlexComponent[];
765 /** 894 /**
895 + * Background color of the block. In addition to the RGB color, an alpha
896 + * channel (transparency) can also be set. Use a hexadecimal color code.
897 + * (Example:#RRGGBBAA) The default value is `#00000000`.
898 + */
899 + backgroundColor?: string;
900 + /**
901 + * Color of box border. Use a hexadecimal color code.
902 + */
903 + borderColor?: string;
904 + /**
905 + * Width of box border. You can specify a value in pixels or any one of none,
906 + * light, normal, medium, semi-bold, or bold. none does not render a border
907 + * while the others become wider in the order of listing.
908 + */
909 + borderWidth?:
910 + | string
911 + | "none"
912 + | "light"
913 + | "normal"
914 + | "medium"
915 + | "semi-bold"
916 + | "bold";
917 + /**
918 + * Radius at the time of rounding the corners of the border. You can specify a
919 + * value in pixels or any one of `none`, `xs`, `sm`, `md`, `lg`, `xl`, or `xxl`. none does not
920 + * round the corner while the others increase in radius in the order of listing. The default value is none.
921 + */
922 + cornerRadius?: string | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
923 + /**
924 + * 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.
925 + */
926 + width?: string;
927 + /**
928 + * 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.
929 + */
930 + height?: string;
931 + /**
766 * The ratio of the width or height of this box within the parent box. The 932 * The ratio of the width or height of this box within the parent box. The
767 * default value for the horizontal parent box is `1`, and the default value 933 * default value for the horizontal parent box is `1`, and the default value
768 * for the vertical parent box is `0`. 934 * for the vertical parent box is `0`.
769 * 935 *
770 * For more information, see 936 * For more information, see
771 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 937 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
772 */ 938 */
773 flex?: number; 939 flex?: number;
774 /** 940 /**
...@@ -793,11 +959,68 @@ export type FlexBox = { ...@@ -793,11 +959,68 @@ export type FlexBox = {
793 */ 959 */
794 margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl"; 960 margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
795 /** 961 /**
962 + * Free space between the borders of this box and the child element.
963 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
964 + */
965 + paddingAll?: string;
966 + /**
967 + * Free space between the border at the upper end of this box and the upper end of the child element.
968 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
969 + */
970 + paddingTop?: string;
971 + /**
972 + * Free space between the border at the lower end of this box and the lower end of the child element.
973 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
974 + */
975 + paddingBottom?: string;
976 + /**
977 + * Free space between the border at the left end of this box and the left end of the child element.
978 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
979 + */
980 + paddingStart?: string;
981 + /**
982 + * Free space between the border at the right end of this box and the right end of the child element.
983 + * For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
984 + */
985 + paddingEnd?: string;
986 + /**
796 * Action performed when this button is tapped. 987 * Action performed when this button is tapped.
797 * 988 *
798 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 989 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
799 */ 990 */
800 action?: Action; 991 action?: Action;
992 +} & Offset;
993 +
994 +export type Offset = {
995 + /**
996 + * Reference position for placing this box. Specify one of the following values:
997 + * - `relative`: Use the previous box as reference.
998 + * - `absolute`: Use the top left of parent element as reference.
999 + *
1000 + * The default value is relative.
1001 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
1002 + */
1003 + position?: "relative" | "absolute";
1004 + /**
1005 + * The top offset.
1006 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
1007 + */
1008 + offsetTop?: string;
1009 + /**
1010 + * The bottom offset.
1011 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
1012 + */
1013 + offsetBottom?: string;
1014 + /**
1015 + * The left offset.
1016 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
1017 + */
1018 + offsetStart?: string;
1019 + /**
1020 + * The right offset.
1021 + * For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
1022 + */
1023 + offsetEnd?: string;
801 }; 1024 };
802 1025
803 /** 1026 /**
...@@ -810,7 +1033,7 @@ export type FlexButton = { ...@@ -810,7 +1033,7 @@ export type FlexButton = {
810 /** 1033 /**
811 * Action performed when this button is tapped. 1034 * Action performed when this button is tapped.
812 * 1035 *
813 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 1036 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
814 */ 1037 */
815 action: Action; 1038 action: Action;
816 /** 1039 /**
...@@ -820,7 +1043,7 @@ export type FlexButton = { ...@@ -820,7 +1043,7 @@ export type FlexButton = {
820 * value for the vertical parent box is `0`. 1043 * value for the vertical parent box is `0`.
821 * 1044 *
822 * For more information, see 1045 * For more information, see
823 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 1046 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
824 */ 1047 */
825 flex?: number; 1048 flex?: number;
826 /** 1049 /**
...@@ -868,7 +1091,7 @@ export type FlexButton = { ...@@ -868,7 +1091,7 @@ export type FlexButton = {
868 * property will be ignored. 1091 * property will be ignored.
869 */ 1092 */
870 gravity?: "top" | "bottom" | "center"; 1093 gravity?: "top" | "bottom" | "center";
871 -}; 1094 +} & Offset;
872 1095
873 /** 1096 /**
874 * This is an invisible component to fill extra space between components. 1097 * This is an invisible component to fill extra space between components.
...@@ -878,6 +1101,10 @@ export type FlexButton = { ...@@ -878,6 +1101,10 @@ export type FlexButton = {
878 */ 1101 */
879 export type FlexFiller = { 1102 export type FlexFiller = {
880 type: "filler"; 1103 type: "filler";
1104 + /**
1105 + * 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).
1106 + */
1107 + flex?: number;
881 }; 1108 };
882 1109
883 /** 1110 /**
...@@ -926,7 +1153,7 @@ export type FlexIcon = { ...@@ -926,7 +1153,7 @@ export type FlexIcon = {
926 * Aspect ratio of the icon. The default value is `1:1`. 1153 * Aspect ratio of the icon. The default value is `1:1`.
927 */ 1154 */
928 aspectRatio?: "1:1" | "2:1" | "3:1"; 1155 aspectRatio?: "1:1" | "2:1" | "3:1";
929 -}; 1156 +} & Offset;
930 1157
931 /** 1158 /**
932 * This component draws an image. 1159 * This component draws an image.
...@@ -949,7 +1176,7 @@ export type FlexImage = { ...@@ -949,7 +1176,7 @@ export type FlexImage = {
949 * value for the vertical parent box is `0`. 1176 * value for the vertical parent box is `0`.
950 * 1177 *
951 * - For more information, see 1178 * - For more information, see
952 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 1179 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
953 */ 1180 */
954 flex?: number; 1181 flex?: number;
955 /** 1182 /**
...@@ -1038,10 +1265,10 @@ export type FlexImage = { ...@@ -1038,10 +1265,10 @@ export type FlexImage = {
1038 backgroundColor?: string; 1265 backgroundColor?: string;
1039 /** 1266 /**
1040 * Action performed when this button is tapped. 1267 * Action performed when this button is tapped.
1041 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 1268 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
1042 */ 1269 */
1043 action?: Action; 1270 action?: Action;
1044 -}; 1271 +} & Offset;
1045 1272
1046 /** 1273 /**
1047 * This component draws a separator between components in the parent box. 1274 * This component draws a separator between components in the parent box.
...@@ -1077,20 +1304,24 @@ export type FlexSpacer = { ...@@ -1077,20 +1304,24 @@ export type FlexSpacer = {
1077 * The size increases in the order of listing. 1304 * The size increases in the order of listing.
1078 * The default value is `md`. 1305 * The default value is `md`.
1079 */ 1306 */
1080 - size: "xs" | "sm" | "md" | "lg" | "xl" | "xxl"; 1307 + size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
1081 }; 1308 };
1082 1309
1083 export type FlexText = { 1310 export type FlexText = {
1084 type: "text"; 1311 type: "text";
1085 text: string; 1312 text: string;
1086 /** 1313 /**
1314 + * 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.
1315 + */
1316 + contents?: FlexSpan[];
1317 + /**
1087 * The ratio of the width or height of this box within the parent box. 1318 * The ratio of the width or height of this box within the parent box.
1088 * 1319 *
1089 * The default value for the horizontal parent box is `1`, and the default 1320 * The default value for the horizontal parent box is `1`, and the default
1090 * value for the vertical parent box is `0`. 1321 * value for the vertical parent box is `0`.
1091 * 1322 *
1092 * For more information, see 1323 * For more information, see
1093 - * [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height). 1324 + * [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
1094 */ 1325 */
1095 flex?: number; 1326 flex?: number;
1096 /** 1327 /**
...@@ -1171,9 +1402,68 @@ export type FlexText = { ...@@ -1171,9 +1402,68 @@ export type FlexText = {
1171 color?: string; 1402 color?: string;
1172 /** 1403 /**
1173 * Action performed when this text is tapped. 1404 * Action performed when this text is tapped.
1174 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 1405 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
1175 */ 1406 */
1176 action?: Action; 1407 action?: Action;
1408 + /**
1409 + * Style of the text. Specify one of the following values:
1410 + * - `normal`: Normal
1411 + * - `italic`: Italic
1412 + *
1413 + * The default value is `normal`.
1414 + */
1415 + style?: string;
1416 + /**
1417 + * Decoration of the text. Specify one of the following values:
1418 + * `none`: No decoration
1419 + * `underline`: Underline
1420 + * `line-through`: Strikethrough
1421 + *
1422 + * The default value is `none`.
1423 + */
1424 + decoration?: string;
1425 +} & Offset;
1426 +
1427 +/**
1428 + * 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).
1429 + */
1430 +export type FlexSpan = {
1431 + type: "span";
1432 + /**
1433 + * 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.
1434 + */
1435 + text: string;
1436 + /**
1437 + * Font color. Use a hexadecimal color code.
1438 + */
1439 + color?: string;
1440 + /**
1441 + * 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`.
1442 + */
1443 + size?: string;
1444 + /**
1445 + * Font weight. You can specify one of the following values: `regular` or `bold`. Specifying `bold` makes the font bold. The default value is `regular`.
1446 + */
1447 + weight?: string;
1448 + /**
1449 + * Style of the text. Specify one of the following values:
1450 + * - `normal`: Normal
1451 + * - `italic`: Italic
1452 + *
1453 + * The default value is `normal`.
1454 + */
1455 + style?: string;
1456 + /**
1457 + * Decoration of the text. Specify one of the following values:
1458 + * `none`: No decoration
1459 + * `underline`: Underline
1460 + * `line-through`: Strikethrough
1461 + *
1462 + * The default value is `none`.
1463 + *
1464 + * 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.
1465 + */
1466 + decoration?: string;
1177 }; 1467 };
1178 1468
1179 export type TemplateContent = 1469 export type TemplateContent =
...@@ -1351,7 +1641,7 @@ export type TemplateImageCarousel = { ...@@ -1351,7 +1641,7 @@ export type TemplateImageCarousel = {
1351 /** 1641 /**
1352 * Array of columns (Max: 10) 1642 * Array of columns (Max: 10)
1353 */ 1643 */
1354 - columns: TemplateImageColumn; 1644 + columns: TemplateImageColumn[];
1355 }; 1645 };
1356 1646
1357 export type TemplateImageColumn = { 1647 export type TemplateImageColumn = {
...@@ -1375,12 +1665,12 @@ export type TemplateImageColumn = { ...@@ -1375,12 +1665,12 @@ export type TemplateImageColumn = {
1375 * These properties are used for the quick reply. 1665 * These properties are used for the quick reply.
1376 * 1666 *
1377 * For more information, see 1667 * For more information, see
1378 - * [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/). 1668 + * [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
1379 */ 1669 */
1380 export type QuickReply = { 1670 export type QuickReply = {
1381 /** 1671 /**
1382 * This is a container that contains 1672 * This is a container that contains
1383 - * [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object). 1673 + * [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
1384 * 1674 *
1385 * Array of objects (Max: 13) 1675 * Array of objects (Max: 13)
1386 */ 1676 */
...@@ -1391,7 +1681,7 @@ export type QuickReply = { ...@@ -1391,7 +1681,7 @@ export type QuickReply = {
1391 * This is a quick reply option that is displayed as a button. 1681 * This is a quick reply option that is displayed as a button.
1392 * 1682 *
1393 * For more information, see 1683 * For more information, see
1394 - * [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object). 1684 + * [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
1395 */ 1685 */
1396 export type QuickReplyItem = { 1686 export type QuickReplyItem = {
1397 type: "action"; 1687 type: "action";
...@@ -1406,9 +1696,9 @@ export type QuickReplyItem = { ...@@ -1406,9 +1696,9 @@ export type QuickReplyItem = {
1406 * There is no limit on the image size. If the `action` property has the 1696 * There is no limit on the image size. If the `action` property has the
1407 * following actions with empty `imageUrl`: 1697 * following actions with empty `imageUrl`:
1408 * 1698 *
1409 - * - [camera action](https://developers.line.me/en/reference/messaging-api/#camera-action) 1699 + * - [camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
1410 - * - [camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action) 1700 + * - [camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
1411 - * - [location action](https://developers.line.me/en/reference/messaging-api/#location-action) 1701 + * - [location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
1412 * 1702 *
1413 * the default icon is displayed. 1703 * the default icon is displayed.
1414 */ 1704 */
...@@ -1416,16 +1706,16 @@ export type QuickReplyItem = { ...@@ -1416,16 +1706,16 @@ export type QuickReplyItem = {
1416 /** 1706 /**
1417 * Action performed when this button is tapped. 1707 * Action performed when this button is tapped.
1418 * 1708 *
1419 - * Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects). 1709 + * Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
1420 * 1710 *
1421 * The following is a list of the available actions: 1711 * The following is a list of the available actions:
1422 * 1712 *
1423 - * - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action) 1713 + * - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
1424 - * - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action) 1714 + * - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
1425 - * - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action) 1715 + * - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
1426 - * - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action) 1716 + * - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
1427 - * - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action) 1717 + * - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
1428 - * - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action) 1718 + * - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
1429 */ 1719 */
1430 action: Action; 1720 action: Action;
1431 }; 1721 };
...@@ -1433,19 +1723,22 @@ export type QuickReplyItem = { ...@@ -1433,19 +1723,22 @@ export type QuickReplyItem = {
1433 /** 1723 /**
1434 * These are types of actions for your bot to take when a user taps a button or an image in a message. 1724 * These are types of actions for your bot to take when a user taps a button or an image in a message.
1435 * 1725 *
1436 - * - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action) 1726 + * - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
1437 - * - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action) 1727 + * - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
1438 - * - [URI action](https://developers.line.me/en/reference/messaging-api/#uri-action) 1728 + * - [URI action](https://developers.line.biz/en/reference/messaging-api/#uri-action)
1439 - * - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action) 1729 + * - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
1440 - * - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action) 1730 + * - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
1441 - * - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action) 1731 + * - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
1442 - * - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action) 1732 + * - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
1443 */ 1733 */
1444 export type Action<ExtraFields = { label: string }> = ( 1734 export type Action<ExtraFields = { label: string }> = (
1445 | PostbackAction 1735 | PostbackAction
1446 | MessageAction 1736 | MessageAction
1447 | URIAction 1737 | URIAction
1448 - | DatetimePickerAction) & 1738 + | DatetimePickerAction
1739 + | { type: "camera" }
1740 + | { type: "cameraRoll" }
1741 + | { type: "location" }) &
1449 ExtraFields; 1742 ExtraFields;
1450 1743
1451 /** 1744 /**
...@@ -1504,11 +1797,26 @@ export type URIAction = { ...@@ -1504,11 +1797,26 @@ export type URIAction = {
1504 * Must start with `http`, `https`, or `tel`. 1797 * Must start with `http`, `https`, or `tel`.
1505 */ 1798 */
1506 uri: string; 1799 uri: string;
1800 + altUri?: AltURI;
1801 +};
1802 +
1803 +/**
1804 + * URI opened on LINE for macOS and Windows when the action is performed (Max: 1000 characters)
1805 + * If the altUri.desktop property is set, the uri property is ignored on LINE for macOS and Windows.
1806 + * The available schemes are http, https, line, and tel.
1807 + * For more information about the LINE URL scheme, see Using the LINE URL scheme.
1808 + * This property is supported on the following version of LINE.
1809 + *
1810 + * LINE 5.12.0 or later for macOS and Windows
1811 + * Note: The altUri.desktop property is supported only when you set URI actions in Flex Messages.
1812 + */
1813 +export type AltURI = {
1814 + desktop: string;
1507 }; 1815 };
1508 1816
1509 /** 1817 /**
1510 * When a control associated with this action is tapped, a 1818 * When a control associated with this action is tapped, a
1511 - * [postback event](https://developers.line.me/en/reference/messaging-api/#postback-event) 1819 + * [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event)
1512 * is returned via webhook with the date and time selected by the user from the 1820 * is returned via webhook with the date and time selected by the user from the
1513 * date and time selection dialog. 1821 * date and time selection dialog.
1514 * 1822 *
...@@ -1558,21 +1866,21 @@ export type Size = { ...@@ -1558,21 +1866,21 @@ export type Size = {
1558 /** 1866 /**
1559 * Rich menus consist of either of these objects. 1867 * Rich menus consist of either of these objects.
1560 * 1868 *
1561 - * - [Rich menu object](https://developers.line.me/en/reference/messaging-api/#rich-menu-object) 1869 + * - [Rich menu object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-object)
1562 * without the rich menu ID. Use this object when you 1870 * without the rich menu ID. Use this object when you
1563 - * [create a rich menu](https://developers.line.me/en/reference/messaging-api/#create-rich-menu). 1871 + * [create a rich menu](https://developers.line.biz/en/reference/messaging-api/#create-rich-menu).
1564 - * - [Rich menu response object](https://developers.line.me/en/reference/messaging-api/#rich-menu-response-object) 1872 + * - [Rich menu response object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-response-object)
1565 * with the rich menu ID. This object is returned when you 1873 * with the rich menu ID. This object is returned when you
1566 - * [get a rich menu](https://developers.line.me/en/reference/messaging-api/#get-rich-menu) 1874 + * [get a rich menu](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu)
1567 - * or [get a list of rich menus](https://developers.line.me/en/reference/messaging-api/#get-rich-menu-list). 1875 + * or [get a list of rich menus](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list).
1568 * 1876 *
1569 - * [Area objects](https://developers.line.me/en/reference/messaging-api/#area-object) and 1877 + * [Area objects](https://developers.line.biz/en/reference/messaging-api/#area-object) and
1570 - * [action objects](https://developers.line.me/en/reference/messaging-api/#action-objects) 1878 + * [action objects](https://developers.line.biz/en/reference/messaging-api/#action-objects)
1571 * are included in these objects. 1879 * are included in these objects.
1572 */ 1880 */
1573 export type RichMenu = { 1881 export type RichMenu = {
1574 /** 1882 /**
1575 - * [`size` object](https://developers.line.me/en/reference/messaging-api/#size-object) 1883 + * [`size` object](https://developers.line.biz/en/reference/messaging-api/#size-object)
1576 * which contains the width and height of the rich menu displayed in the chat. 1884 * which contains the width and height of the rich menu displayed in the chat.
1577 * Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px. 1885 * Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px.
1578 */ 1886 */
...@@ -1595,7 +1903,7 @@ export type RichMenu = { ...@@ -1595,7 +1903,7 @@ export type RichMenu = {
1595 */ 1903 */
1596 chatBarText: string; 1904 chatBarText: string;
1597 /** 1905 /**
1598 - * Array of [area objects](https://developers.line.me/en/reference/messaging-api/#area-object) 1906 + * Array of [area objects](https://developers.line.biz/en/reference/messaging-api/#area-object)
1599 * which define the coordinates and size of tappable areas 1907 * which define the coordinates and size of tappable areas
1600 * (Max: 20 area objects) 1908 * (Max: 20 area objects)
1601 */ 1909 */
...@@ -1603,3 +1911,177 @@ export type RichMenu = { ...@@ -1603,3 +1911,177 @@ export type RichMenu = {
1603 }; 1911 };
1604 1912
1605 export type RichMenuResponse = { richMenuId: string } & RichMenu; 1913 export type RichMenuResponse = { richMenuId: string } & RichMenu;
1914 +
1915 +export type NumberOfMessagesSentResponse = InsightStatisticsResponse & {
1916 + /**
1917 + * The number of messages sent with the Messaging API on the date specified in date.
1918 + * The response has this property only when the value of status is `ready`.
1919 + */
1920 + success?: number;
1921 +};
1922 +
1923 +export type TargetLimitForAdditionalMessages = {
1924 + /**
1925 + * One of the following values to indicate whether a target limit is set or not.
1926 + * - `none`: This indicates that a target limit is not set.
1927 + * - `limited`: This indicates that a target limit is set.
1928 + */
1929 + type: "none" | "limited";
1930 + /**
1931 + * The target limit for additional messages in the current month.
1932 + * This property is returned when the `type` property has a value of `limited`.
1933 + */
1934 + value?: number;
1935 +};
1936 +
1937 +export type NumberOfMessagesSentThisMonth = {
1938 + /**
1939 + * The number of sent messages in the current month
1940 + */
1941 + totalUsage: number;
1942 +};
1943 +
1944 +export const LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
1945 +export type MessageAPIResponseBase = {
1946 + [LINE_REQUEST_ID_HTTP_HEADER_NAME]?: string;
1947 +};
1948 +
1949 +export type InsightStatisticsResponse = {
1950 + /**
1951 + * Calculation status. One of:
1952 + * - `ready`: Calculation has finished; the numbers are up-to-date.
1953 + * - `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.
1954 + * - `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/).
1955 + */
1956 + status: "ready" | "unready" | "out_of_service";
1957 +};
1958 +
1959 +export type NumberOfMessageDeliveries = InsightStatisticsResponse & {
1960 + /**
1961 + * Number of push messages sent to **all** of this LINE official account's friends (broadcast messages).
1962 + */
1963 + broadcast: number;
1964 + /**
1965 + * Number of push messages sent to **some** of this LINE official account's friends, based on specific attributes (targeted/segmented messages).
1966 + */
1967 + targeting: number;
1968 + /**
1969 + * Number of auto-response messages sent.
1970 + */
1971 + autoResponse: number;
1972 + /**
1973 + * Number of greeting messages sent.
1974 + */
1975 + welcomeResponse: number;
1976 + /**
1977 + * Number of messages sent from LINE Official Account Manager [Chat screen](https://www.linebiz.com/jp-en/manual/OfficialAccountManager/chats/screens/).
1978 + */
1979 + chat: number;
1980 + /**
1981 + * Number of broadcast messages sent with the [Send broadcast message](https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message) Messaging API operation.
1982 + */
1983 + apiBroadcast: number;
1984 + /**
1985 + * Number of push messages sent with the [Send push message](https://developers.line.biz/en/reference/messaging-api/#send-push-message) Messaging API operation.
1986 + */
1987 + apiPush: number;
1988 + /**
1989 + * Number of multicast messages sent with the [Send multicast message](https://developers.line.biz/en/reference/messaging-api/#send-multicast-message) Messaging API operation.
1990 + */
1991 + apiMulticast: number;
1992 + /**
1993 + * Number of replies sent with the [Send reply message](https://developers.line.biz/en/reference/messaging-api/#send-reply-message) Messaging API operation.
1994 + */
1995 + apiReply: number;
1996 +};
1997 +
1998 +export type NumberOfFollowers = InsightStatisticsResponse & {
1999 + /**
2000 + * 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.
2001 + */
2002 + followers: Number;
2003 + /**
2004 + * 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.
2005 + */
2006 + targetedReaches: Number;
2007 + /**
2008 + * The number of users blocking the account as of the specified `date`. The number decreases when a user unblocks the account.
2009 + */
2010 + blocks: Number;
2011 +};
2012 +
2013 +export type NumberOfMessageDeliveriesResponse =
2014 + | InsightStatisticsResponse
2015 + | NumberOfMessageDeliveries;
2016 +
2017 +export type NumberOfFollowersResponse =
2018 + | InsightStatisticsResponse
2019 + | NumberOfFollowers;
2020 +
2021 +type PercentageAble = {
2022 + percentage: number;
2023 +};
2024 +
2025 +export type FriendDemoGraphics = {
2026 + /**
2027 + * `true` if friend demographic information is available.
2028 + */
2029 + available: boolean;
2030 + /**
2031 + * Percentage per gender
2032 + */
2033 + genders?: Array<
2034 + {
2035 + /**
2036 + * Gender
2037 + */
2038 + gender: "unknown" | "male" | "female";
2039 + } & PercentageAble
2040 + >;
2041 + /**
2042 + * Percentage per age group
2043 + */
2044 + ages?: Array<
2045 + {
2046 + /**
2047 + * Age group
2048 + */
2049 + age: string;
2050 + } & PercentageAble
2051 + >;
2052 + /**
2053 + * Percentage per area
2054 + */
2055 + areas?: Array<
2056 + {
2057 + area: string;
2058 + } & PercentageAble
2059 + >;
2060 + /**
2061 + * Percentage by OS
2062 + */
2063 + appTypes?: Array<
2064 + {
2065 + appType: "ios" | "android" | "others";
2066 + } & PercentageAble
2067 + >;
2068 + /**
2069 + * Percentage per friendship duration
2070 + */
2071 + subscriptionPeriods?: Array<
2072 + {
2073 + /**
2074 + * Friendship duration
2075 + */
2076 + subscriptionPeriod:
2077 + | "over365days"
2078 + | "within365days"
2079 + | "within180days"
2080 + | "within90days"
2081 + | "within30days"
2082 + | "within7days"
2083 + // in case for some rare cases(almost no)
2084 + | "unknown";
2085 + } & PercentageAble
2086 + >;
2087 +};
......
1 import { createHmac, timingSafeEqual } from "crypto"; 1 import { createHmac, timingSafeEqual } from "crypto";
2 2
3 function s2b(str: string, encoding: string): Buffer { 3 function s2b(str: string, encoding: string): Buffer {
4 - if (Buffer.from) { 4 + return Buffer.from(str, encoding);
5 - try {
6 - return Buffer.from(str, encoding);
7 - } catch (err) {
8 - if (err.name === "TypeError") {
9 - return new Buffer(str, encoding);
10 - }
11 - throw err;
12 - }
13 - } else {
14 - return new Buffer(str, encoding);
15 - }
16 } 5 }
17 6
18 function safeCompare(a: Buffer, b: Buffer): boolean { 7 function safeCompare(a: Buffer, b: Buffer): boolean {
19 if (a.length !== b.length) { 8 if (a.length !== b.length) {
20 return false; 9 return false;
21 } 10 }
22 - 11 + return timingSafeEqual(a, b);
23 - if (timingSafeEqual) {
24 - return timingSafeEqual(a, b);
25 - } else {
26 - let result = 0;
27 - for (let i = 0; i < a.length; i++) {
28 - result |= a[i] ^ b[i];
29 - }
30 - return result === 0;
31 - }
32 } 12 }
33 13
34 export default function validateSignature( 14 export default function validateSignature(
......
1 { 1 {
2 - "_from": "@line/bot-sdk", 2 + "_from": "@line/bot-sdk@6.8.3",
3 - "_id": "@line/bot-sdk@6.4.0", 3 + "_id": "@line/bot-sdk@6.8.3",
4 "_inBundle": false, 4 "_inBundle": false,
5 - "_integrity": "sha512-N0FkrqFxTTleOpD6y7DTK8qbMYHr9Q8qZfrAmSYEFAGedM1HLJdbNNkStj5GT+svx+w+/ePF/n7nAEts0aJwkA==", 5 + "_integrity": "sha512-nj2T4CQxw0W/juAlpj0kMTDScOh5QUK6xMCR2dZp+pN8B0vj/c+5uX3TyGB4ijz/NIsehgfKujPgzw7LhtYtJw==",
6 "_location": "/@line/bot-sdk", 6 "_location": "/@line/bot-sdk",
7 "_phantomChildren": {}, 7 "_phantomChildren": {},
8 "_requested": { 8 "_requested": {
9 - "type": "tag", 9 + "type": "version",
10 "registry": true, 10 "registry": true,
11 - "raw": "@line/bot-sdk", 11 + "raw": "@line/bot-sdk@6.8.3",
12 "name": "@line/bot-sdk", 12 "name": "@line/bot-sdk",
13 "escapedName": "@line%2fbot-sdk", 13 "escapedName": "@line%2fbot-sdk",
14 "scope": "@line", 14 "scope": "@line",
15 - "rawSpec": "", 15 + "rawSpec": "6.8.3",
16 "saveSpec": null, 16 "saveSpec": null,
17 - "fetchSpec": "latest" 17 + "fetchSpec": "6.8.3"
18 }, 18 },
19 "_requiredBy": [ 19 "_requiredBy": [
20 "#USER", 20 "#USER",
21 "/" 21 "/"
22 ], 22 ],
23 - "_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.4.0.tgz", 23 + "_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.8.3.tgz",
24 - "_shasum": "18aa7659da26d3a8487614c74ad9ccb80ec4ca59", 24 + "_shasum": "0a886461e8c16a8c89091fd5338f6071335636a6",
25 - "_spec": "@line/bot-sdk", 25 + "_spec": "@line/bot-sdk@6.8.3",
26 - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot", 26 + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT",
27 "bugs": { 27 "bugs": {
28 "url": "https://github.com/line/line-bot-sdk-nodejs/issues" 28 "url": "https://github.com/line/line-bot-sdk-nodejs/issues"
29 }, 29 },
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
32 "@types/body-parser": "^1.16.8", 32 "@types/body-parser": "^1.16.8",
33 "@types/file-type": "^5.2.1", 33 "@types/file-type": "^5.2.1",
34 "@types/node": "^7.0.31", 34 "@types/node": "^7.0.31",
35 - "axios": "^0.16.2", 35 + "axios": "^0.19.0",
36 "body-parser": "^1.18.2", 36 "body-parser": "^1.18.2",
37 "file-type": "^7.2.0" 37 "file-type": "^7.2.0"
38 }, 38 },
...@@ -40,19 +40,21 @@ ...@@ -40,19 +40,21 @@
40 "description": "Node.js SDK for LINE Messaging API", 40 "description": "Node.js SDK for LINE Messaging API",
41 "devDependencies": { 41 "devDependencies": {
42 "@types/express": "^4.0.35", 42 "@types/express": "^4.0.35",
43 + "@types/finalhandler": "^1.1.0",
43 "@types/mocha": "^2.2.41", 44 "@types/mocha": "^2.2.41",
44 "del-cli": "^1.1.0", 45 "del-cli": "^1.1.0",
45 "express": "^4.16.3", 46 "express": "^4.16.3",
47 + "finalhandler": "^1.1.2",
46 "husky": "^0.14.3", 48 "husky": "^0.14.3",
47 "mocha": "^5.2.0", 49 "mocha": "^5.2.0",
48 - "nyc": "^12.0.2", 50 + "nyc": "^14.1.1",
49 "prettier": "^1.15.2", 51 "prettier": "^1.15.2",
50 - "ts-node": "^3.3.0", 52 + "ts-node": "^8.3.0",
51 "typescript": "^3.1.6", 53 "typescript": "^3.1.6",
52 - "vuepress": "^0.14.2" 54 + "vuepress": "^0.14.10"
53 }, 55 },
54 "engines": { 56 "engines": {
55 - "node": ">=6" 57 + "node": ">=8"
56 }, 58 },
57 "files": [ 59 "files": [
58 "dist", 60 "dist",
...@@ -102,5 +104,5 @@ ...@@ -102,5 +104,5 @@
102 "test": "API_BASE_URL=http://localhost:1234/ TEST_PORT=1234 TS_NODE_CACHE=0 nyc mocha" 104 "test": "API_BASE_URL=http://localhost:1234/ TEST_PORT=1234 TS_NODE_CACHE=0 nyc mocha"
103 }, 105 },
104 "types": "dist/index.d.ts", 106 "types": "dist/index.d.ts",
105 - "version": "6.4.0" 107 + "version": "6.8.3"
106 } 108 }
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
5 This package contains type definitions for body-parser (https://github.com/expressjs/body-parser). 5 This package contains type definitions for body-parser (https://github.com/expressjs/body-parser).
6 6
7 # Details 7 # Details
8 -Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser 8 +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser
9 9
10 Additional Details 10 Additional Details
11 - * Last updated: Wed, 25 Apr 2018 00:24:37 GMT 11 + * Last updated: Mon, 19 Aug 2019 00:51:08 GMT
12 - * Dependencies: connect, http, node 12 + * Dependencies: @types/connect, @types/node
13 * Global values: none 13 * Global values: none
14 14
15 # Credits 15 # Credits
16 -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>. 16 +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 @@ ...@@ -7,7 +7,7 @@
7 // Tomasz Łaziuk <https://github.com/tlaziuk> 7 // Tomasz Łaziuk <https://github.com/tlaziuk>
8 // Jason Walton <https://github.com/jwalton> 8 // Jason Walton <https://github.com/jwalton>
9 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 9 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10 -// TypeScript Version: 2.2 10 +// TypeScript Version: 2.3
11 11
12 /// <reference types="node" /> 12 /// <reference types="node" />
13 13
......
1 { 1 {
2 "_from": "@types/body-parser@^1.16.8", 2 "_from": "@types/body-parser@^1.16.8",
3 - "_id": "@types/body-parser@1.17.0", 3 + "_id": "@types/body-parser@1.17.1",
4 "_inBundle": false, 4 "_inBundle": false,
5 - "_integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==", 5 + "_integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==",
6 "_location": "/@types/body-parser", 6 "_location": "/@types/body-parser",
7 "_phantomChildren": {}, 7 "_phantomChildren": {},
8 "_requested": { 8 "_requested": {
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
19 "_requiredBy": [ 19 "_requiredBy": [
20 "/@line/bot-sdk" 20 "/@line/bot-sdk"
21 ], 21 ],
22 - "_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", 22 + "_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz",
23 - "_shasum": "9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c", 23 + "_shasum": "18fcf61768fb5c30ccc508c21d6fd2e8b3bf7897",
24 "_spec": "@types/body-parser@^1.16.8", 24 "_spec": "@types/body-parser@^1.16.8",
25 - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk", 25 + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk",
26 "bugs": { 26 "bugs": {
27 "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" 27 "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28 }, 28 },
...@@ -65,10 +65,12 @@ ...@@ -65,10 +65,12 @@
65 "name": "@types/body-parser", 65 "name": "@types/body-parser",
66 "repository": { 66 "repository": {
67 "type": "git", 67 "type": "git",
68 - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git" 68 + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
69 + "directory": "types/body-parser"
69 }, 70 },
70 "scripts": {}, 71 "scripts": {},
71 - "typeScriptVersion": "2.2", 72 + "typeScriptVersion": "2.3",
72 - "typesPublisherContentHash": "d50d69303022e9f76f6d905e480a7dc98120bbcedb696a9722a4a2e9f08473e6", 73 + "types": "index",
73 - "version": "1.17.0" 74 + "typesPublisherContentHash": "ada1b55777df6de5327f420d23285a5c476895faa88cacf6b80a1a791eef0f67",
75 + "version": "1.17.1"
74 } 76 }
......
...@@ -8,9 +8,9 @@ This package contains type definitions for Node.js (http://nodejs.org/). ...@@ -8,9 +8,9 @@ This package contains type definitions for Node.js (http://nodejs.org/).
8 Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v7 8 Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v7
9 9
10 Additional Details 10 Additional Details
11 - * Last updated: Thu, 15 Nov 2018 00:16:17 GMT 11 + * Last updated: Wed, 30 Oct 2019 15:44:46 GMT
12 * Dependencies: none 12 * Dependencies: none
13 * Global values: Buffer, NodeJS, SlowBuffer, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, require, setImmediate, setInterval, setTimeout 13 * Global values: Buffer, NodeJS, SlowBuffer, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, require, setImmediate, setInterval, setTimeout
14 14
15 # Credits 15 # Credits
16 -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>. 16 +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.
1 { 1 {
2 "_from": "@types/node@^7.0.31", 2 "_from": "@types/node@^7.0.31",
3 - "_id": "@types/node@7.10.2", 3 + "_id": "@types/node@7.10.9",
4 "_inBundle": false, 4 "_inBundle": false,
5 - "_integrity": "sha512-RO4ig5taKmcrU4Rex8ojG1gpwFkjddzug9iPQSDvbewHN9vDpcFewevkaOK+KT+w1LeZnxbgOyfXwV4pxsQ4GQ==", 5 + "_integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw==",
6 "_location": "/@types/node", 6 "_location": "/@types/node",
7 "_phantomChildren": {}, 7 "_phantomChildren": {},
8 "_requested": { 8 "_requested": {
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
22 "/@types/connect", 22 "/@types/connect",
23 "/@types/file-type" 23 "/@types/file-type"
24 ], 24 ],
25 - "_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.2.tgz", 25 + "_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz",
26 - "_shasum": "a98845168012d7a63a84d50e738829da43bdb0de", 26 + "_shasum": "4343e3b009f8cf5e1ed685e36097b74b4101e880",
27 "_spec": "@types/node@^7.0.31", 27 "_spec": "@types/node@^7.0.31",
28 - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk", 28 + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk",
29 "bugs": { 29 "bugs": {
30 "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" 30 "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
31 }, 31 },
...@@ -62,6 +62,10 @@ ...@@ -62,6 +62,10 @@
62 { 62 {
63 "name": "Sander Koenders", 63 "name": "Sander Koenders",
64 "url": "https://github.com/Archcry" 64 "url": "https://github.com/Archcry"
65 + },
66 + {
67 + "name": "Jordi Oliveras Rovira",
68 + "url": "https://github.com/j-oliveras"
65 } 69 }
66 ], 70 ],
67 "dependencies": {}, 71 "dependencies": {},
...@@ -73,11 +77,19 @@ ...@@ -73,11 +77,19 @@
73 "name": "@types/node", 77 "name": "@types/node",
74 "repository": { 78 "repository": {
75 "type": "git", 79 "type": "git",
76 - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git" 80 + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
81 + "directory": "types/node"
77 }, 82 },
78 "scripts": {}, 83 "scripts": {},
79 "typeScriptVersion": "2.0", 84 "typeScriptVersion": "2.0",
80 "types": "index", 85 "types": "index",
81 - "typesPublisherContentHash": "55896a12ed8765c021f335913ef256ce4eb8ac2fc4b0c93611d7ce514e2906ea", 86 + "typesPublisherContentHash": "0c534d9103600d73c97ec8a474420c4d9262b941ae93e66c175cb27e62683e84",
82 - "version": "7.10.2" 87 + "typesVersions": {
88 + ">=3.2.0-0": {
89 + "*": [
90 + "ts3.2/*"
91 + ]
92 + }
93 + },
94 + "version": "7.10.9"
83 } 95 }
......
1 +// NOTE: These definitions support NodeJS and TypeScript 3.2.
2 +
3 +// NOTE: TypeScript version-specific augmentations can be found in the following paths:
4 +// - ~/base.d.ts - Shared definitions common to all TypeScript versions
5 +// - ~/index.d.ts - Definitions specific to TypeScript 2.1
6 +// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2
7 +
8 +// Reference required types from the default lib:
9 +/// <reference lib="es2016" />
10 +
11 +// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
12 +// tslint:disable-next-line:no-bad-reference
13 +/// <reference path="../base.d.ts" />
14 +
15 +// TypeScript 3.2-specific augmentations:
1 # Changelog 1 # Changelog
2 2
3 +### 0.19.0 (May 30, 2019)
4 +
5 +Fixes and Functionality:
6 +
7 +- Unzip response body only for statuses != 204 ([#1129](https://github.com/axios/axios/pull/1129)) - drawski
8 +- Destroy stream on exceeding maxContentLength (fixes [#1098](https://github.com/axios/axios/issue/1098)) ([#1485](https://github.com/axios/axios/pull/1485)) - Gadzhi Gadzhiev
9 +- Makes Axios error generic to use AxiosResponse ([#1738](https://github.com/axios/axios/pull/1738)) - Suman Lama
10 +- Fixing Mocha tests by locking follow-redirects version to 1.5.10 ([#1993](https://github.com/axios/axios/pull/1993)) - grumblerchester
11 +- Allow uppercase methods in typings. ([#1781](https://github.com/axios/axios/pull/1781)) - Ken Powers
12 +- Fixing .eslintrc without extension ([#1789](https://github.com/axios/axios/pull/1789)) - Manoel
13 +- Consistent coding style ([#1787](https://github.com/axios/axios/pull/1787)) - Ali Servet Donmez
14 +- Fixing building url with hash mark ([#1771](https://github.com/axios/axios/pull/1771)) - Anatoly Ryabov
15 +- 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 `#`
16 +- Preserve HTTP method when following redirect ([#1758](https://github.com/axios/axios/pull/1758)) - Rikki Gibson
17 +- Add `getUri` signature to TypeScript definition. ([#1736](https://github.com/axios/axios/pull/1736)) - Alexander Trauzzi
18 +- Adding isAxiosError flag to errors thrown by axios ([#1419](https://github.com/axios/axios/pull/1419)) - Ayush Gupta
19 +- Fix failing SauceLabs tests by updating configuration - Emily Morehouse
20 +
21 +Documentation:
22 +
23 +- Add information about auth parameter to README ([#2166](https://github.com/axios/axios/pull/2166)) - xlaguna
24 +- 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
25 +- Update ECOSYSTEM.md - Add Axios Endpoints ([#2176](https://github.com/axios/axios/pull/2176)) - Renan
26 +- Add r2curl in ECOSYSTEM ([#2141](https://github.com/axios/axios/pull/2141)) - 유용우 / CX
27 +- Update README.md - Add instructions for installing with yarn ([#2036](https://github.com/axios/axios/pull/2036)) - Victor Hermes
28 +- Fixing spacing for README.md ([#2066](https://github.com/axios/axios/pull/2066)) - Josh McCarty
29 +- Update README.md. - Change `.then` to `.finally` in example code ([#2090](https://github.com/axios/axios/pull/2090)) - Omar Cai
30 +- Clarify what values responseType can have in Node ([#2121](https://github.com/axios/axios/pull/2121)) - Tyler Breisacher
31 +- docs(ECOSYSTEM): add axios-api-versioning ([#2020](https://github.com/axios/axios/pull/2020)) - Weffe
32 +- 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
33 +- Add issue templates - Emily Morehouse
34 +- Update README.md. - Add Querystring library note ([#1896](https://github.com/axios/axios/pull/1896)) - Dmitriy Eroshenko
35 +- Add react-hooks-axios to Libraries section of ECOSYSTEM.md ([#1925](https://github.com/axios/axios/pull/1925)) - Cody Chan
36 +- Clarify in README that default timeout is 0 (no timeout) ([#1750](https://github.com/axios/axios/pull/1750)) - Ben Standefer
37 +
38 +### 0.19.0-beta.1 (Aug 9, 2018)
39 +
40 +**NOTE:** This is a beta version of this release. There may be functionality that is broken in
41 +certain browsers, though we suspect that builds are hanging and not erroring. See
42 +https://saucelabs.com/u/axios for the most up-to-date information.
43 +
44 +New Functionality:
45 +
46 +- Add getUri method ([#1712](https://github.com/axios/axios/issues/1712))
47 +- Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693))
48 +- Add toJSON to decorated Axios errors to faciliate serialization ([#1625](https://github.com/axios/axios/issues/1625))
49 +- Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623))
50 +- Typings: allow custom return types
51 +- Add option to specify character set in responses (with http adapter)
52 +
53 +Fixes:
54 +
55 +- Fix Keep defaults local to instance ([#385](https://github.com/axios/axios/issues/385))
56 +- Correctly catch exception in http test ([#1475](https://github.com/axios/axios/issues/1475))
57 +- Fix accept header normalization ([#1698](https://github.com/axios/axios/issues/1698))
58 +- Fix http adapter to allow HTTPS connections via HTTP ([#959](https://github.com/axios/axios/issues/959))
59 +- Fix Removes usage of deprecated Buffer constructor. ([#1555](https://github.com/axios/axios/issues/1555), [#1622](https://github.com/axios/axios/issues/1622))
60 +- Fix defaults to use httpAdapter if available ([#1285](https://github.com/axios/axios/issues/1285))
61 + - Fixing defaults to use httpAdapter if available
62 + - Use a safer, cross-platform method to detect the Node environment
63 +- Fix Reject promise if request is cancelled by the browser ([#537](https://github.com/axios/axios/issues/537))
64 +- [Typescript] Fix missing type parameters on delete/head methods
65 +- [NS]: Send `false` flag isStandardBrowserEnv for Nativescript
66 +- Fix missing type parameters on delete/head
67 +- Fix Default method for an instance always overwritten by get
68 +- Fix type error when socketPath option in AxiosRequestConfig
69 +- Capture errors on request data streams
70 +- Decorate resolve and reject to clear timeout in all cases
71 +
72 +Huge thanks to everyone who contributed to this release via code (authors listed
73 +below) or via reviews and triaging on GitHub:
74 +
75 +- Andrew Scott <ascott18@gmail.com>
76 +- Anthony Gauthier <antho325@hotmail.com>
77 +- arpit <arpit2438735@gmail.com>
78 +- ascott18
79 +- Benedikt Rötsch <axe312ger@users.noreply.github.com>
80 +- Chance Dickson <me@chancedickson.com>
81 +- Dave Stewart <info@davestewart.co.uk>
82 +- Deric Cain <deric.cain@gmail.com>
83 +- Guillaume Briday <guillaumebriday@gmail.com>
84 +- Jacob Wejendorp <jacob@wejendorp.dk>
85 +- Jim Lynch <mrdotjim@gmail.com>
86 +- johntron
87 +- Justin Beckwith <beckwith@google.com>
88 +- Justin Beckwith <justin.beckwith@gmail.com>
89 +- Khaled Garbaya <khaledgarbaya@gmail.com>
90 +- Lim Jing Rong <jjingrong@users.noreply.github.com>
91 +- Mark van den Broek <mvdnbrk@gmail.com>
92 +- Martti Laine <martti@codeclown.net>
93 +- mattridley
94 +- mattridley <matt.r@joinblink.com>
95 +- Nicolas Del Valle <nicolas.delvalle@gmail.com>
96 +- Nilegfx
97 +- pbarbiero
98 +- Rikki Gibson <rikkigibson@gmail.com>
99 +- Sako Hartounian <sakohartounian@yahoo.com>
100 +- Shane Fitzpatrick <fitzpasd@gmail.com>
101 +- Stephan Schneider <stephanschndr@gmail.com>
102 +- Steven <steven@ceriously.com>
103 +- Tim Garthwaite <tim.garthwaite@jibo.com>
104 +- Tim Johns <timjohns@yahoo.com>
105 +- Yutaro Miyazaki <yutaro@studio-rubbish.com>
106 +
107 +### 0.18.0 (Feb 19, 2018)
108 +
109 +- Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070))
110 +- Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)):
111 + - AxiosRequestConfig.proxy: allows type false
112 + - AxiosProxyConfig: added auth field
113 +- 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))
114 +- Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287))
115 +- Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342))
116 +
117 +### 0.17.1 (Nov 11, 2017)
118 +
119 +- Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160))
120 +- Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080))
121 +- 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))
122 +
123 +### 0.17.0 (Oct 21, 2017)
124 +
125 +- **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950))
126 +- **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874))
127 +- Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691))
128 +- Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061))
129 +
3 ### 0.16.2 (Jun 3, 2017) 130 ### 0.16.2 (Jun 3, 2017)
4 131
5 -- Fixing issue with including `buffer` in bundle ([#887](https://github.com/mzabriskie/axios/pull/887)) 132 +- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887))
6 -- Including underlying request in errors ([#830](https://github.com/mzabriskie/axios/pull/830)) 133 +- Including underlying request in errors ([#830](https://github.com/axios/axios/pull/830))
7 -- Convert `method` to lowercase ([#930](https://github.com/mzabriskie/axios/pull/930)) 134 +- Convert `method` to lowercase ([#930](https://github.com/axios/axios/pull/930))
8 135
9 ### 0.16.1 (Apr 8, 2017) 136 ### 0.16.1 (Apr 8, 2017)
10 137
11 -- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/mzabriskie/axios/pull/828)) 138 +- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/axios/axios/pull/828))
12 -- Updating `follow-redirects` dependency ([#829](https://github.com/mzabriskie/axios/pull/829)) 139 +- Updating `follow-redirects` dependency ([#829](https://github.com/axios/axios/pull/829))
13 -- Adding support for passing `Buffer` in node ([#773](https://github.com/mzabriskie/axios/pull/773)) 140 +- Adding support for passing `Buffer` in node ([#773](https://github.com/axios/axios/pull/773))
14 141
15 ### 0.16.0 (Mar 31, 2017) 142 ### 0.16.0 (Mar 31, 2017)
16 143
17 -- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/mzabriskie/axios/issues/480)) 144 +- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/axios/axios/issues/480))
18 -- Adding `options` shortcut method ([#461](https://github.com/mzabriskie/axios/pull/461)) 145 +- Adding `options` shortcut method ([#461](https://github.com/axios/axios/pull/461))
19 -- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/mzabriskie/axios/pull/654)) 146 +- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/axios/axios/pull/654))
20 -- Improving React Native detection ([#731](https://github.com/mzabriskie/axios/pull/731)) 147 +- Improving React Native detection ([#731](https://github.com/axios/axios/pull/731))
21 -- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/mzabriskie/axios/pull/581)) 148 +- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/axios/axios/pull/581))
22 -- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/mzabriskie/axios/pull/561)) 149 +- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/axios/axios/pull/561))
23 150
24 ### 0.15.3 (Nov 27, 2016) 151 ### 0.15.3 (Nov 27, 2016)
25 152
26 -- Fixing issue with custom instances and global defaults ([#443](https://github.com/mzabriskie/axios/issues/443)) 153 +- Fixing issue with custom instances and global defaults ([#443](https://github.com/axios/axios/issues/443))
27 -- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/mzabriskie/axios/issues/519)) 154 +- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/axios/axios/issues/519))
28 -- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/mzabriskie/axios/issues/509)) 155 +- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/axios/axios/issues/509))
29 -- Fixing issue with `btoa` and IE ([#507](https://github.com/mzabriskie/axios/issues/507)) 156 +- Fixing issue with `btoa` and IE ([#507](https://github.com/axios/axios/issues/507))
30 -- Adding support for proxy authentication ([#483](https://github.com/mzabriskie/axios/pull/483)) 157 +- Adding support for proxy authentication ([#483](https://github.com/axios/axios/pull/483))
31 -- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/mzabriskie/axios/pull/493)) 158 +- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/axios/axios/pull/493))
32 -- Fixing proxy issues ([#491](https://github.com/mzabriskie/axios/pull/491)) 159 +- Fixing proxy issues ([#491](https://github.com/axios/axios/pull/491))
33 160
34 ### 0.15.2 (Oct 17, 2016) 161 ### 0.15.2 (Oct 17, 2016)
35 162
36 -- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/mzabriskie/axios/issues/482)) 163 +- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482))
37 164
38 ### 0.15.1 (Oct 14, 2016) 165 ### 0.15.1 (Oct 14, 2016)
39 166
40 -- Fixing issue with UMD ([#485](https://github.com/mzabriskie/axios/issues/485)) 167 +- Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485))
41 168
42 ### 0.15.0 (Oct 10, 2016) 169 ### 0.15.0 (Oct 10, 2016)
43 170
44 -- Adding cancellation support ([#452](https://github.com/mzabriskie/axios/pull/452)) 171 +- Adding cancellation support ([#452](https://github.com/axios/axios/pull/452))
45 -- Moving default adapter to global defaults ([#437](https://github.com/mzabriskie/axios/pull/437)) 172 +- Moving default adapter to global defaults ([#437](https://github.com/axios/axios/pull/437))
46 -- Fixing issue with `file` URI scheme ([#440](https://github.com/mzabriskie/axios/pull/440)) 173 +- Fixing issue with `file` URI scheme ([#440](https://github.com/axios/axios/pull/440))
47 -- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/mzabriskie/axios/pull/445)) 174 +- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/axios/axios/pull/445))
48 175
49 ### 0.14.0 (Aug 27, 2016) 176 ### 0.14.0 (Aug 27, 2016)
50 177
51 -- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/mzabriskie/axios/pull/419)) 178 +- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/axios/axios/pull/419))
52 -- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/mzabriskie/axios/pull/387)) 179 +- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/axios/axios/pull/387))
53 -- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/mzabriskie/axios/pull/423)) 180 +- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/axios/axios/pull/423))
54 -- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/mzabriskie/axios/pull/366)) 181 +- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/axios/axios/pull/366))
55 -- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/mzabriskie/axios/pull/397)) 182 +- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/axios/axios/pull/397))
56 -- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/mzabriskie/axios/pull/406)) 183 +- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/axios/axios/pull/406))
57 184
58 ### 0.13.1 (Jul 16, 2016) 185 ### 0.13.1 (Jul 16, 2016)
59 186
60 -- Fixing issue with response data not being transformed on error ([#378](https://github.com/mzabriskie/axios/issues/378)) 187 +- Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378))
61 188
62 ### 0.13.0 (Jul 13, 2016) 189 ### 0.13.0 (Jul 13, 2016)
63 190
64 -- **BREAKING** Improved error handling ([#345](https://github.com/mzabriskie/axios/pull/345)) 191 +- **BREAKING** Improved error handling ([#345](https://github.com/axios/axios/pull/345))
65 -- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/mzabriskie/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)) 192 +- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e))
66 -- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/mzabriskie/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)) 193 +- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a))
67 -- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/mzabriskie/axios/issues/343)) 194 +- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/axios/axios/issues/343))
68 -- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/mzabriskie/axios/issues/352)) 195 +- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/axios/axios/issues/352))
69 -- Fixing custom instance defaults ([#341](https://github.com/mzabriskie/axios/issues/341)) 196 +- Fixing custom instance defaults ([#341](https://github.com/axios/axios/issues/341))
70 -- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/mzabriskie/axios/issues/217)) 197 +- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/axios/axios/issues/217))
71 198
72 ### 0.12.0 (May 31, 2016) 199 ### 0.12.0 (May 31, 2016)
73 200
74 -- Adding support for `URLSearchParams` ([#317](https://github.com/mzabriskie/axios/pull/317)) 201 +- Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317))
75 -- Adding `maxRedirects` option ([#307](https://github.com/mzabriskie/axios/pull/307)) 202 +- Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307))
76 203
77 ### 0.11.1 (May 17, 2016) 204 ### 0.11.1 (May 17, 2016)
78 205
79 -- Fixing IE CORS support ([#313](https://github.com/mzabriskie/axios/pull/313)) 206 +- Fixing IE CORS support ([#313](https://github.com/axios/axios/pull/313))
80 -- Fixing detection of `FormData` ([#325](https://github.com/mzabriskie/axios/pull/325)) 207 +- Fixing detection of `FormData` ([#325](https://github.com/axios/axios/pull/325))
81 -- Adding `Axios` class to exports ([#321](https://github.com/mzabriskie/axios/pull/321)) 208 +- Adding `Axios` class to exports ([#321](https://github.com/axios/axios/pull/321))
82 209
83 ### 0.11.0 (Apr 26, 2016) 210 ### 0.11.0 (Apr 26, 2016)
84 211
85 -- Adding support for Stream with HTTP adapter ([#296](https://github.com/mzabriskie/axios/pull/296)) 212 +- Adding support for Stream with HTTP adapter ([#296](https://github.com/axios/axios/pull/296))
86 -- Adding support for custom HTTP status code error ranges ([#308](https://github.com/mzabriskie/axios/pull/308)) 213 +- Adding support for custom HTTP status code error ranges ([#308](https://github.com/axios/axios/pull/308))
87 -- Fixing issue with ArrayBuffer ([#299](https://github.com/mzabriskie/axios/pull/299)) 214 +- Fixing issue with ArrayBuffer ([#299](https://github.com/axios/axios/pull/299))
88 215
89 ### 0.10.0 (Apr 20, 2016) 216 ### 0.10.0 (Apr 20, 2016)
90 217
91 -- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/mzabriskie/axios/pull/250)) 218 +- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/axios/axios/pull/250))
92 -- Fixing basic auth for HTTP adapter ([#252](https://github.com/mzabriskie/axios/pull/252)) 219 +- Fixing basic auth for HTTP adapter ([#252](https://github.com/axios/axios/pull/252))
93 -- Fixing request timeout for XHR adapter ([#227](https://github.com/mzabriskie/axios/pull/227)) 220 +- Fixing request timeout for XHR adapter ([#227](https://github.com/axios/axios/pull/227))
94 -- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/mzabriskie/axios/pull/249)) 221 +- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/axios/axios/pull/249))
95 -- Fixing IE9 cross domain requests ([#251](https://github.com/mzabriskie/axios/pull/251)) 222 +- Fixing IE9 cross domain requests ([#251](https://github.com/axios/axios/pull/251))
96 -- Adding `maxContentLength` option ([#275](https://github.com/mzabriskie/axios/pull/275)) 223 +- Adding `maxContentLength` option ([#275](https://github.com/axios/axios/pull/275))
97 -- Fixing XHR support for WebWorker environment ([#279](https://github.com/mzabriskie/axios/pull/279)) 224 +- Fixing XHR support for WebWorker environment ([#279](https://github.com/axios/axios/pull/279))
98 -- Adding request instance to response ([#200](https://github.com/mzabriskie/axios/pull/200)) 225 +- Adding request instance to response ([#200](https://github.com/axios/axios/pull/200))
99 226
100 ### 0.9.1 (Jan 24, 2016) 227 ### 0.9.1 (Jan 24, 2016)
101 228
102 -- Improving handling of request timeout in node ([#124](https://github.com/mzabriskie/axios/issues/124)) 229 +- Improving handling of request timeout in node ([#124](https://github.com/axios/axios/issues/124))
103 -- Fixing network errors not rejecting ([#205](https://github.com/mzabriskie/axios/pull/205)) 230 +- Fixing network errors not rejecting ([#205](https://github.com/axios/axios/pull/205))
104 -- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/mzabriskie/axios/issues/201)) 231 +- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/axios/axios/issues/201))
105 -- Fixing host/port when following redirects ([#198](https://github.com/mzabriskie/axios/pull/198)) 232 +- Fixing host/port when following redirects ([#198](https://github.com/axios/axios/pull/198))
106 233
107 ### 0.9.0 (Jan 18, 2016) 234 ### 0.9.0 (Jan 18, 2016)
108 235
109 - Adding support for custom adapters 236 - Adding support for custom adapters
110 -- Fixing Content-Type header being removed when data is false ([#195](https://github.com/mzabriskie/axios/pull/195)) 237 +- Fixing Content-Type header being removed when data is false ([#195](https://github.com/axios/axios/pull/195))
111 -- Improving XDomainRequest implementation ([#185](https://github.com/mzabriskie/axios/pull/185)) 238 +- Improving XDomainRequest implementation ([#185](https://github.com/axios/axios/pull/185))
112 -- Improving config merging and order of precedence ([#183](https://github.com/mzabriskie/axios/pull/183)) 239 +- Improving config merging and order of precedence ([#183](https://github.com/axios/axios/pull/183))
113 -- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/mzabriskie/axios/pull/182)) 240 +- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/axios/axios/pull/182))
114 241
115 ### 0.8.1 (Dec 14, 2015) 242 ### 0.8.1 (Dec 14, 2015)
116 243
117 -- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/mzabriskie/axios/pull/168)) 244 +- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/axios/axios/pull/168))
118 -- Fixing error with format of basic auth header ([#178](https://github.com/mzabriskie/axios/pull/173)) 245 +- Fixing error with format of basic auth header ([#178](https://github.com/axios/axios/pull/173))
119 -- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/mzabriskie/axios/pull/174)) 246 +- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/axios/axios/pull/174))
120 247
121 ### 0.8.0 (Dec 11, 2015) 248 ### 0.8.0 (Dec 11, 2015)
122 249
123 -- Adding support for creating instances of axios ([#123](https://github.com/mzabriskie/axios/pull/123)) 250 +- Adding support for creating instances of axios ([#123](https://github.com/axios/axios/pull/123))
124 -- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/mzabriskie/axios/pull/128)) 251 +- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/axios/axios/pull/128))
125 -- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/mzabriskie/axios/pull/121)) 252 +- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/axios/axios/pull/121))
126 -- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/mzabriskie/axios/pull/127)) 253 +- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/axios/axios/pull/127))
127 -- Adding support for following redirects in node ([#146](https://github.com/mzabriskie/axios/pull/146)) 254 +- Adding support for following redirects in node ([#146](https://github.com/axios/axios/pull/146))
128 -- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/mzabriskie/axios/pull/149)) 255 +- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/axios/axios/pull/149))
129 -- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/mzabriskie/axios/pull/140)) 256 +- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/axios/axios/pull/140))
130 -- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/mzabriskie/axios/pull/167)) 257 +- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/axios/axios/pull/167))
131 -- Adding support for baseURL option ([#160](https://github.com/mzabriskie/axios/pull/160)) 258 +- Adding support for baseURL option ([#160](https://github.com/axios/axios/pull/160))
132 259
133 ### 0.7.0 (Sep 29, 2015) 260 ### 0.7.0 (Sep 29, 2015)
134 261
135 -- Fixing issue with minified bundle in IE8 ([#87](https://github.com/mzabriskie/axios/pull/87)) 262 +- Fixing issue with minified bundle in IE8 ([#87](https://github.com/axios/axios/pull/87))
136 -- Adding support for passing agent in node ([#102](https://github.com/mzabriskie/axios/pull/102)) 263 +- Adding support for passing agent in node ([#102](https://github.com/axios/axios/pull/102))
137 -- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/mzabriskie/axios/pull/106)) 264 +- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/axios/axios/pull/106))
138 -- Fixing typescript definition ([#105](https://github.com/mzabriskie/axios/pull/105)) 265 +- Fixing typescript definition ([#105](https://github.com/axios/axios/pull/105))
139 -- Fixing default timeout config for node ([#112](https://github.com/mzabriskie/axios/pull/112)) 266 +- Fixing default timeout config for node ([#112](https://github.com/axios/axios/pull/112))
140 -- 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)) 267 +- 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))
141 -- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/mzabriskie/axios/issues/116)) 268 +- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/axios/axios/issues/116))
142 269
143 ### 0.6.0 (Sep 21, 2015) 270 ### 0.6.0 (Sep 21, 2015)
144 271
145 - Removing deprecated success/error aliases 272 - Removing deprecated success/error aliases
146 -- Fixing issue with array params not being properly encoded ([#49](https://github.com/mzabriskie/axios/pull/49)) 273 +- Fixing issue with array params not being properly encoded ([#49](https://github.com/axios/axios/pull/49))
147 -- Fixing issue with User-Agent getting overridden ([#69](https://github.com/mzabriskie/axios/issues/69)) 274 +- Fixing issue with User-Agent getting overridden ([#69](https://github.com/axios/axios/issues/69))
148 -- Adding support for timeout config ([#56](https://github.com/mzabriskie/axios/issues/56)) 275 +- Adding support for timeout config ([#56](https://github.com/axios/axios/issues/56))
149 - Removing es6-promise dependency 276 - Removing es6-promise dependency
150 -- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/mzabriskie/axios/pull/91)) 277 +- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/axios/axios/pull/91))
151 -- Fixing issue with IE8 ([#85](https://github.com/mzabriskie/axios/pull/85)) 278 +- Fixing issue with IE8 ([#85](https://github.com/axios/axios/pull/85))
152 - Converting build to UMD 279 - Converting build to UMD
153 280
154 ### 0.5.4 (Apr 08, 2015) 281 ### 0.5.4 (Apr 08, 2015)
155 282
156 -- Fixing issue with FormData not being sent ([#53](https://github.com/mzabriskie/axios/issues/53)) 283 +- Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53))
157 284
158 ### 0.5.3 (Apr 07, 2015) 285 ### 0.5.3 (Apr 07, 2015)
159 286
160 -- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/mzabriskie/axios/issues/55)) 287 +- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55))
161 288
162 ### 0.5.2 (Mar 13, 2015) 289 ### 0.5.2 (Mar 13, 2015)
163 290
164 -- Adding support for `statusText` in response ([#46](https://github.com/mzabriskie/axios/issues/46)) 291 +- Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46))
165 292
166 ### 0.5.1 (Mar 10, 2015) 293 ### 0.5.1 (Mar 10, 2015)
167 294
168 -- Fixing issue using strict mode ([#45](https://github.com/mzabriskie/axios/issues/45)) 295 +- Fixing issue using strict mode ([#45](https://github.com/axios/axios/issues/45))
169 -- Fixing issue with standalone build ([#47](https://github.com/mzabriskie/axios/issues/47)) 296 +- Fixing issue with standalone build ([#47](https://github.com/axios/axios/issues/47))
170 297
171 ### 0.5.0 (Jan 23, 2015) 298 ### 0.5.0 (Jan 23, 2015)
172 299
173 -- Adding support for intercepetors ([#14](https://github.com/mzabriskie/axios/issues/14)) 300 +- Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14))
174 - Updating es6-promise dependency 301 - Updating es6-promise dependency
175 302
176 ### 0.4.2 (Dec 10, 2014) 303 ### 0.4.2 (Dec 10, 2014)
177 304
178 -- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/mzabriskie/axios/issues/22)) 305 +- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/axios/axios/issues/22))
179 -- Adding support for TypeScript ([#25](https://github.com/mzabriskie/axios/issues/25)) 306 +- Adding support for TypeScript ([#25](https://github.com/axios/axios/issues/25))
180 -- Fixing issue with standalone build ([#29](https://github.com/mzabriskie/axios/issues/29)) 307 +- Fixing issue with standalone build ([#29](https://github.com/axios/axios/issues/29))
181 -- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/mzabriskie/axios/issues/30)) 308 +- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/axios/axios/issues/30))
182 309
183 ### 0.4.1 (Oct 15, 2014) 310 ### 0.4.1 (Oct 15, 2014)
184 311
185 -- Adding error handling to request for node.js ([#18](https://github.com/mzabriskie/axios/issues/18)) 312 +- Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18))
186 313
187 ### 0.4.0 (Oct 03, 2014) 314 ### 0.4.0 (Oct 03, 2014)
188 315
189 -- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/mzabriskie/axios/issues/10)) 316 +- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/axios/axios/issues/10))
190 -- Adding support for utf-8 for node.js ([#13](https://github.com/mzabriskie/axios/issues/13)) 317 +- Adding support for utf-8 for node.js ([#13](https://github.com/axios/axios/issues/13))
191 -- Adding support for SSL for node.js ([#12](https://github.com/mzabriskie/axios/issues/12)) 318 +- Adding support for SSL for node.js ([#12](https://github.com/axios/axios/issues/12))
192 -- Fixing incorrect `Content-Type` header ([#9](https://github.com/mzabriskie/axios/issues/9)) 319 +- Fixing incorrect `Content-Type` header ([#9](https://github.com/axios/axios/issues/9))
193 -- Adding standalone build without bundled es6-promise ([#11](https://github.com/mzabriskie/axios/issues/11)) 320 +- Adding standalone build without bundled es6-promise ([#11](https://github.com/axios/axios/issues/11))
194 - Deprecating `success`/`error` in favor of `then`/`catch` 321 - Deprecating `success`/`error` in favor of `then`/`catch`
195 322
196 ### 0.3.1 (Sep 16, 2014) 323 ### 0.3.1 (Sep 16, 2014)
197 324
198 -- Fixing missing post body when using node.js ([#3](https://github.com/mzabriskie/axios/issues/3)) 325 +- Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3))
199 326
200 ### 0.3.0 (Sep 16, 2014) 327 ### 0.3.0 (Sep 16, 2014)
201 328
202 -- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/mzabriskie/axios/issues/8)) 329 +- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/axios/axios/issues/8))
203 -- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/mzabriskie/axios/issues/6)) 330 +- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/axios/axios/issues/6))
204 -- Fixing issue with `all` not working ([#7](https://github.com/mzabriskie/axios/issues/7)) 331 +- Fixing issue with `all` not working ([#7](https://github.com/axios/axios/issues/7))
205 332
206 ### 0.2.2 (Sep 14, 2014) 333 ### 0.2.2 (Sep 14, 2014)
207 334
208 -- Fixing bundling with browserify ([#4](https://github.com/mzabriskie/axios/issues/4)) 335 +- Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4))
209 336
210 ### 0.2.1 (Sep 12, 2014) 337 ### 0.2.1 (Sep 12, 2014)
211 338
...@@ -214,7 +341,7 @@ ...@@ -214,7 +341,7 @@
214 ### 0.2.0 (Sep 12, 2014) 341 ### 0.2.0 (Sep 12, 2014)
215 342
216 - Adding support for `all` and `spread` 343 - Adding support for `all` and `spread`
217 -- Adding support for node.js ([#1](https://github.com/mzabriskie/axios/issues/1)) 344 +- Adding support for node.js ([#1](https://github.com/axios/axios/issues/1))
218 345
219 ### 0.1.0 (Aug 29, 2014) 346 ### 0.1.0 (Aug 29, 2014)
220 347
......
1 -Copyright (c) 2014 Matt Zabriskie 1 +Copyright (c) 2014-present Matt Zabriskie
2 2
3 Permission is hereby granted, free of charge, to any person obtaining a copy 3 Permission is hereby granted, free of charge, to any person obtaining a copy
4 of this software and associated documentation files (the "Software"), to deal 4 of this software and associated documentation files (the "Software"), to deal
......
1 # axios 1 # axios
2 2
3 [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios) 3 [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
4 -[![build status](https://img.shields.io/travis/mzabriskie/axios.svg?style=flat-square)](https://travis-ci.org/mzabriskie/axios) 4 +[![build status](https://img.shields.io/travis/axios/axios.svg?style=flat-square)](https://travis-ci.org/axios/axios)
5 [![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios) 5 [![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
6 +[![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
6 [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios) 7 [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
7 [![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios) 8 [![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
9 +[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
8 10
9 Promise based HTTP client for the browser and node.js 11 Promise based HTTP client for the browser and node.js
10 12
...@@ -23,7 +25,7 @@ Promise based HTTP client for the browser and node.js ...@@ -23,7 +25,7 @@ Promise based HTTP client for the browser and node.js
23 25
24 ![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) | 26 ![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) |
25 --- | --- | --- | --- | --- | --- | 27 --- | --- | --- | --- | --- | --- |
26 -Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ | 28 +Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
27 29
28 [![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios) 30 [![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios)
29 31
...@@ -41,6 +43,12 @@ Using bower: ...@@ -41,6 +43,12 @@ Using bower:
41 $ bower install axios 43 $ bower install axios
42 ``` 44 ```
43 45
46 +Using yarn:
47 +
48 +```bash
49 +$ yarn add axios
50 +```
51 +
44 Using cdn: 52 Using cdn:
45 53
46 ```html 54 ```html
...@@ -52,13 +60,20 @@ Using cdn: ...@@ -52,13 +60,20 @@ Using cdn:
52 Performing a `GET` request 60 Performing a `GET` request
53 61
54 ```js 62 ```js
63 +const axios = require('axios');
64 +
55 // Make a request for a user with a given ID 65 // Make a request for a user with a given ID
56 axios.get('/user?ID=12345') 66 axios.get('/user?ID=12345')
57 .then(function (response) { 67 .then(function (response) {
68 + // handle success
58 console.log(response); 69 console.log(response);
59 }) 70 })
60 .catch(function (error) { 71 .catch(function (error) {
72 + // handle error
61 console.log(error); 73 console.log(error);
74 + })
75 + .finally(function () {
76 + // always executed
62 }); 77 });
63 78
64 // Optionally the request above could also be done as 79 // Optionally the request above could also be done as
...@@ -72,9 +87,25 @@ axios.get('/user', { ...@@ -72,9 +87,25 @@ axios.get('/user', {
72 }) 87 })
73 .catch(function (error) { 88 .catch(function (error) {
74 console.log(error); 89 console.log(error);
75 - }); 90 + })
91 + .then(function () {
92 + // always executed
93 + });
94 +
95 +// Want to use async/await? Add the `async` keyword to your outer function/method.
96 +async function getUser() {
97 + try {
98 + const response = await axios.get('/user?ID=12345');
99 + console.log(response);
100 + } catch (error) {
101 + console.error(error);
102 + }
103 +}
76 ``` 104 ```
77 105
106 +> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet
107 +> Explorer and older browsers, so use with caution.
108 +
78 Performing a `POST` request 109 Performing a `POST` request
79 110
80 ```js 111 ```js
...@@ -128,13 +159,13 @@ axios({ ...@@ -128,13 +159,13 @@ axios({
128 ```js 159 ```js
129 // GET request for remote image 160 // GET request for remote image
130 axios({ 161 axios({
131 - method:'get', 162 + method: 'get',
132 - url:'http://bit.ly/2mTM3nY', 163 + url: 'http://bit.ly/2mTM3nY',
133 - responseType:'stream' 164 + responseType: 'stream'
134 }) 165 })
135 - .then(function(response) { 166 + .then(function (response) {
136 - response.data.pipe(fs.createWriteStream('ada_lovelace.jpg')) 167 + response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
137 -}); 168 + });
138 ``` 169 ```
139 170
140 ##### axios(url[, config]) 171 ##### axios(url[, config])
...@@ -174,7 +205,7 @@ You can create a new instance of axios with a custom config. ...@@ -174,7 +205,7 @@ You can create a new instance of axios with a custom config.
174 ##### axios.create([config]) 205 ##### axios.create([config])
175 206
176 ```js 207 ```js
177 -var instance = axios.create({ 208 +const instance = axios.create({
178 baseURL: 'https://some-domain.com/api/', 209 baseURL: 'https://some-domain.com/api/',
179 timeout: 1000, 210 timeout: 1000,
180 headers: {'X-Custom-Header': 'foobar'} 211 headers: {'X-Custom-Header': 'foobar'}
...@@ -193,6 +224,7 @@ The available instance methods are listed below. The specified config will be me ...@@ -193,6 +224,7 @@ The available instance methods are listed below. The specified config will be me
193 ##### axios#post(url[, data[, config]]) 224 ##### axios#post(url[, data[, config]])
194 ##### axios#put(url[, data[, config]]) 225 ##### axios#put(url[, data[, config]])
195 ##### axios#patch(url[, data[, config]]) 226 ##### axios#patch(url[, data[, config]])
227 +##### axios#getUri([config])
196 228
197 ## Request Config 229 ## Request Config
198 230
...@@ -212,10 +244,11 @@ These are the available config options for making requests. Only the `url` is re ...@@ -212,10 +244,11 @@ These are the available config options for making requests. Only the `url` is re
212 baseURL: 'https://some-domain.com/api/', 244 baseURL: 'https://some-domain.com/api/',
213 245
214 // `transformRequest` allows changes to the request data before it is sent to the server 246 // `transformRequest` allows changes to the request data before it is sent to the server
215 - // This is only applicable for request methods 'PUT', 'POST', and 'PATCH' 247 + // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE'
216 // The last function in the array must return a string or an instance of Buffer, ArrayBuffer, 248 // The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
217 // FormData or Stream 249 // FormData or Stream
218 - transformRequest: [function (data) { 250 + // You may modify the headers object.
251 + transformRequest: [function (data, headers) {
219 // Do whatever you want to transform the data 252 // Do whatever you want to transform the data
220 253
221 return data; 254 return data;
...@@ -240,7 +273,7 @@ These are the available config options for making requests. Only the `url` is re ...@@ -240,7 +273,7 @@ These are the available config options for making requests. Only the `url` is re
240 273
241 // `paramsSerializer` is an optional function in charge of serializing `params` 274 // `paramsSerializer` is an optional function in charge of serializing `params`
242 // (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) 275 // (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
243 - paramsSerializer: function(params) { 276 + paramsSerializer: function (params) {
244 return Qs.stringify(params, {arrayFormat: 'brackets'}) 277 return Qs.stringify(params, {arrayFormat: 'brackets'})
245 }, 278 },
246 279
...@@ -256,7 +289,7 @@ These are the available config options for making requests. Only the `url` is re ...@@ -256,7 +289,7 @@ These are the available config options for making requests. Only the `url` is re
256 289
257 // `timeout` specifies the number of milliseconds before the request times out. 290 // `timeout` specifies the number of milliseconds before the request times out.
258 // If the request takes longer than `timeout`, the request will be aborted. 291 // If the request takes longer than `timeout`, the request will be aborted.
259 - timeout: 1000, 292 + timeout: 1000, // default is `0` (no timeout)
260 293
261 // `withCredentials` indicates whether or not cross-site Access-Control requests 294 // `withCredentials` indicates whether or not cross-site Access-Control requests
262 // should be made using credentials 295 // should be made using credentials
...@@ -271,15 +304,22 @@ These are the available config options for making requests. Only the `url` is re ...@@ -271,15 +304,22 @@ These are the available config options for making requests. Only the `url` is re
271 // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. 304 // `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
272 // This will set an `Authorization` header, overwriting any existing 305 // This will set an `Authorization` header, overwriting any existing
273 // `Authorization` custom headers you have set using `headers`. 306 // `Authorization` custom headers you have set using `headers`.
307 + // Please note that only HTTP Basic auth is configurable through this parameter.
308 + // For Bearer tokens and such, use `Authorization` custom headers instead.
274 auth: { 309 auth: {
275 username: 'janedoe', 310 username: 'janedoe',
276 password: 's00pers3cret' 311 password: 's00pers3cret'
277 }, 312 },
278 313
279 // `responseType` indicates the type of data that the server will respond with 314 // `responseType` indicates the type of data that the server will respond with
280 - // options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream' 315 + // options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
316 + // browser only: 'blob'
281 responseType: 'json', // default 317 responseType: 'json', // default
282 318
319 + // `responseEncoding` indicates encoding to use for decoding responses
320 + // Note: Ignored for `responseType` of 'stream' or client-side requests
321 + responseEncoding: 'utf8', // default
322 +
283 // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token 323 // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
284 xsrfCookieName: 'XSRF-TOKEN', // default 324 xsrfCookieName: 'XSRF-TOKEN', // default
285 325
...@@ -296,7 +336,7 @@ These are the available config options for making requests. Only the `url` is re ...@@ -296,7 +336,7 @@ These are the available config options for making requests. Only the `url` is re
296 // Do whatever you want with the native progress event 336 // Do whatever you want with the native progress event
297 }, 337 },
298 338
299 - // `maxContentLength` defines the max size of the http response content allowed 339 + // `maxContentLength` defines the max size of the http response content in bytes allowed
300 maxContentLength: 2000, 340 maxContentLength: 2000,
301 341
302 // `validateStatus` defines whether to resolve or reject the promise for a given 342 // `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 ...@@ -311,13 +351,24 @@ These are the available config options for making requests. Only the `url` is re
311 // If set to 0, no redirects will be followed. 351 // If set to 0, no redirects will be followed.
312 maxRedirects: 5, // default 352 maxRedirects: 5, // default
313 353
354 + // `socketPath` defines a UNIX Socket to be used in node.js.
355 + // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
356 + // Only either `socketPath` or `proxy` can be specified.
357 + // If both are specified, `socketPath` is used.
358 + socketPath: null, // default
359 +
314 // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http 360 // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
315 // and https requests, respectively, in node.js. This allows options to be added like 361 // and https requests, respectively, in node.js. This allows options to be added like
316 // `keepAlive` that are not enabled by default. 362 // `keepAlive` that are not enabled by default.
317 httpAgent: new http.Agent({ keepAlive: true }), 363 httpAgent: new http.Agent({ keepAlive: true }),
318 httpsAgent: new https.Agent({ keepAlive: true }), 364 httpsAgent: new https.Agent({ keepAlive: true }),
319 365
320 - // 'proxy' defines the hostname and port of the proxy server 366 + // 'proxy' defines the hostname and port of the proxy server.
367 + // You can also define your proxy using the conventional `http_proxy` and
368 + // `https_proxy` environment variables. If you are using environment variables
369 + // for your proxy configuration, you can also define a `no_proxy` environment
370 + // variable as a comma-separated list of domains that should not be proxied.
371 + // Use `false` to disable proxies, ignoring environment variables.
321 // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and 372 // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
322 // supplies credentials. 373 // supplies credentials.
323 // This will set an `Proxy-Authorization` header, overwriting any existing 374 // This will set an `Proxy-Authorization` header, overwriting any existing
...@@ -371,7 +422,7 @@ When using `then`, you will receive the response as follows: ...@@ -371,7 +422,7 @@ When using `then`, you will receive the response as follows:
371 422
372 ```js 423 ```js
373 axios.get('/user/12345') 424 axios.get('/user/12345')
374 - .then(function(response) { 425 + .then(function (response) {
375 console.log(response.data); 426 console.log(response.data);
376 console.log(response.status); 427 console.log(response.status);
377 console.log(response.statusText); 428 console.log(response.statusText);
...@@ -398,7 +449,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded ...@@ -398,7 +449,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded
398 449
399 ```js 450 ```js
400 // Set config defaults when creating the instance 451 // Set config defaults when creating the instance
401 -var instance = axios.create({ 452 +const instance = axios.create({
402 baseURL: 'https://api.example.com' 453 baseURL: 'https://api.example.com'
403 }); 454 });
404 455
...@@ -408,15 +459,15 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; ...@@ -408,15 +459,15 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
408 459
409 ### Config order of precedence 460 ### Config order of precedence
410 461
411 -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. 462 +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.
412 463
413 ```js 464 ```js
414 // Create an instance using the config defaults provided by the library 465 // Create an instance using the config defaults provided by the library
415 // At this point the timeout config value is `0` as is the default for the library 466 // At this point the timeout config value is `0` as is the default for the library
416 -var instance = axios.create(); 467 +const instance = axios.create();
417 468
418 // Override timeout default for the library 469 // Override timeout default for the library
419 -// Now all requests will wait 2.5 seconds before timing out 470 +// Now all requests using this instance will wait 2.5 seconds before timing out
420 instance.defaults.timeout = 2500; 471 instance.defaults.timeout = 2500;
421 472
422 // Override timeout for this request as it's known to take a long time 473 // Override timeout for this request as it's known to take a long time
...@@ -452,14 +503,14 @@ axios.interceptors.response.use(function (response) { ...@@ -452,14 +503,14 @@ axios.interceptors.response.use(function (response) {
452 If you may need to remove an interceptor later you can. 503 If you may need to remove an interceptor later you can.
453 504
454 ```js 505 ```js
455 -var myInterceptor = axios.interceptors.request.use(function () {/*...*/}); 506 +const myInterceptor = axios.interceptors.request.use(function () {/*...*/});
456 axios.interceptors.request.eject(myInterceptor); 507 axios.interceptors.request.eject(myInterceptor);
457 ``` 508 ```
458 509
459 You can add interceptors to a custom instance of axios. 510 You can add interceptors to a custom instance of axios.
460 511
461 ```js 512 ```js
462 -var instance = axios.create(); 513 +const instance = axios.create();
463 instance.interceptors.request.use(function () {/*...*/}); 514 instance.interceptors.request.use(function () {/*...*/});
464 ``` 515 ```
465 516
...@@ -506,12 +557,12 @@ You can cancel a request using a *cancel token*. ...@@ -506,12 +557,12 @@ You can cancel a request using a *cancel token*.
506 You can create a cancel token using the `CancelToken.source` factory as shown below: 557 You can create a cancel token using the `CancelToken.source` factory as shown below:
507 558
508 ```js 559 ```js
509 -var CancelToken = axios.CancelToken; 560 +const CancelToken = axios.CancelToken;
510 -var source = CancelToken.source(); 561 +const source = CancelToken.source();
511 562
512 axios.get('/user/12345', { 563 axios.get('/user/12345', {
513 cancelToken: source.token 564 cancelToken: source.token
514 -}).catch(function(thrown) { 565 +}).catch(function (thrown) {
515 if (axios.isCancel(thrown)) { 566 if (axios.isCancel(thrown)) {
516 console.log('Request canceled', thrown.message); 567 console.log('Request canceled', thrown.message);
517 } else { 568 } else {
...@@ -519,6 +570,12 @@ axios.get('/user/12345', { ...@@ -519,6 +570,12 @@ axios.get('/user/12345', {
519 } 570 }
520 }); 571 });
521 572
573 +axios.post('/user/12345', {
574 + name: 'new name'
575 +}, {
576 + cancelToken: source.token
577 +})
578 +
522 // cancel the request (the message parameter is optional) 579 // cancel the request (the message parameter is optional)
523 source.cancel('Operation canceled by the user.'); 580 source.cancel('Operation canceled by the user.');
524 ``` 581 ```
...@@ -526,8 +583,8 @@ source.cancel('Operation canceled by the user.'); ...@@ -526,8 +583,8 @@ source.cancel('Operation canceled by the user.');
526 You can also create a cancel token by passing an executor function to the `CancelToken` constructor: 583 You can also create a cancel token by passing an executor function to the `CancelToken` constructor:
527 584
528 ```js 585 ```js
529 -var CancelToken = axios.CancelToken; 586 +const CancelToken = axios.CancelToken;
530 -var cancel; 587 +let cancel;
531 588
532 axios.get('/user/12345', { 589 axios.get('/user/12345', {
533 cancelToken: new CancelToken(function executor(c) { 590 cancelToken: new CancelToken(function executor(c) {
...@@ -551,31 +608,48 @@ By default, axios serializes JavaScript objects to `JSON`. To send data in the ` ...@@ -551,31 +608,48 @@ By default, axios serializes JavaScript objects to `JSON`. To send data in the `
551 In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: 608 In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows:
552 609
553 ```js 610 ```js
554 -var params = new URLSearchParams(); 611 +const params = new URLSearchParams();
555 params.append('param1', 'value1'); 612 params.append('param1', 'value1');
556 params.append('param2', 'value2'); 613 params.append('param2', 'value2');
557 axios.post('/foo', params); 614 axios.post('/foo', params);
558 ``` 615 ```
559 616
560 -> 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). 617 +> 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).
561 618
562 Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: 619 Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library:
563 620
564 ```js 621 ```js
565 -var qs = require('qs'); 622 +const qs = require('qs');
566 axios.post('/foo', qs.stringify({ 'bar': 123 })); 623 axios.post('/foo', qs.stringify({ 'bar': 123 }));
567 ``` 624 ```
568 625
626 +Or in another way (ES6),
627 +
628 +```js
629 +import qs from 'qs';
630 +const data = { 'bar': 123 };
631 +const options = {
632 + method: 'POST',
633 + headers: { 'content-type': 'application/x-www-form-urlencoded' },
634 + data: qs.stringify(data),
635 + url,
636 +};
637 +axios(options);
638 +```
639 +
569 ### Node.js 640 ### Node.js
570 641
571 In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: 642 In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
572 643
573 ```js 644 ```js
574 -var querystring = require('querystring'); 645 +const querystring = require('querystring');
575 axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); 646 axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
576 ``` 647 ```
577 648
578 -You can also use the `qs` library. 649 +You can also use the [`qs`](https://github.com/ljharb/qs) library.
650 +
651 +###### NOTE
652 +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).
579 653
580 ## Semver 654 ## Semver
581 655
...@@ -595,11 +669,11 @@ axios.get('/user?ID=12345'); ...@@ -595,11 +669,11 @@ axios.get('/user?ID=12345');
595 669
596 ## Resources 670 ## Resources
597 671
598 -* [Changelog](https://github.com/mzabriskie/axios/blob/master/CHANGELOG.md) 672 +* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
599 -* [Upgrade Guide](https://github.com/mzabriskie/axios/blob/master/UPGRADE_GUIDE.md) 673 +* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md)
600 -* [Ecosystem](https://github.com/mzabriskie/axios/blob/master/ECOSYSTEM.md) 674 +* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md)
601 -* [Contributing Guide](https://github.com/mzabriskie/axios/blob/master/CONTRIBUTING.md) 675 +* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md)
602 -* [Code of Conduct](https://github.com/mzabriskie/axios/blob/master/CODE_OF_CONDUCT.md) 676 +* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md)
603 677
604 ## Credits 678 ## Credits
605 679
......
...@@ -115,8 +115,8 @@ function myAdapter(config) { ...@@ -115,8 +115,8 @@ function myAdapter(config) {
115 ``` 115 ```
116 116
117 See the related commits for more details: 117 See the related commits for more details:
118 -- [Response transformers](https://github.com/mzabriskie/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) 118 +- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
119 -- [Request adapter Promise](https://github.com/mzabriskie/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) 119 +- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
120 120
121 ### 0.5.x -> 0.6.0 121 ### 0.5.x -> 0.6.0
122 122
...@@ -135,7 +135,7 @@ This will polyfill the global environment, and only needs to be done once. ...@@ -135,7 +135,7 @@ This will polyfill the global environment, and only needs to be done once.
135 135
136 #### `axios.success`/`axios.error` 136 #### `axios.success`/`axios.error`
137 137
138 -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. 138 +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.
139 139
140 ```js 140 ```js
141 axios.get('some/url') 141 axios.get('some/url')
......
1 -/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */ 1 +/* axios v0.19.0 | (c) 2019 by Matt Zabriskie */
2 (function webpackUniversalModuleDefinition(root, factory) { 2 (function webpackUniversalModuleDefinition(root, factory) {
3 if(typeof exports === 'object' && typeof module === 'object') 3 if(typeof exports === 'object' && typeof module === 'object')
4 module.exports = factory(); 4 module.exports = factory();
...@@ -53,20 +53,21 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -53,20 +53,21 @@ return /******/ (function(modules) { // webpackBootstrap
53 /************************************************************************/ 53 /************************************************************************/
54 /******/ ([ 54 /******/ ([
55 /* 0 */ 55 /* 0 */
56 -/***/ function(module, exports, __webpack_require__) { 56 +/***/ (function(module, exports, __webpack_require__) {
57 57
58 module.exports = __webpack_require__(1); 58 module.exports = __webpack_require__(1);
59 59
60 -/***/ }, 60 +/***/ }),
61 /* 1 */ 61 /* 1 */
62 -/***/ function(module, exports, __webpack_require__) { 62 +/***/ (function(module, exports, __webpack_require__) {
63 63
64 'use strict'; 64 'use strict';
65 65
66 var utils = __webpack_require__(2); 66 var utils = __webpack_require__(2);
67 var bind = __webpack_require__(3); 67 var bind = __webpack_require__(3);
68 var Axios = __webpack_require__(5); 68 var Axios = __webpack_require__(5);
69 - var defaults = __webpack_require__(6); 69 + var mergeConfig = __webpack_require__(22);
70 + var defaults = __webpack_require__(11);
70 71
71 /** 72 /**
72 * Create an instance of Axios 73 * Create an instance of Axios
...@@ -95,13 +96,13 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -95,13 +96,13 @@ return /******/ (function(modules) { // webpackBootstrap
95 96
96 // Factory for creating new instances 97 // Factory for creating new instances
97 axios.create = function create(instanceConfig) { 98 axios.create = function create(instanceConfig) {
98 - return createInstance(utils.merge(defaults, instanceConfig)); 99 + return createInstance(mergeConfig(axios.defaults, instanceConfig));
99 }; 100 };
100 101
101 // Expose Cancel & CancelToken 102 // Expose Cancel & CancelToken
102 axios.Cancel = __webpack_require__(23); 103 axios.Cancel = __webpack_require__(23);
103 axios.CancelToken = __webpack_require__(24); 104 axios.CancelToken = __webpack_require__(24);
104 - axios.isCancel = __webpack_require__(20); 105 + axios.isCancel = __webpack_require__(10);
105 106
106 // Expose all/spread 107 // Expose all/spread
107 axios.all = function all(promises) { 108 axios.all = function all(promises) {
...@@ -115,9 +116,9 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -115,9 +116,9 @@ return /******/ (function(modules) { // webpackBootstrap
115 module.exports.default = axios; 116 module.exports.default = axios;
116 117
117 118
118 -/***/ }, 119 +/***/ }),
119 /* 2 */ 120 /* 2 */
120 -/***/ function(module, exports, __webpack_require__) { 121 +/***/ (function(module, exports, __webpack_require__) {
121 122
122 'use strict'; 123 'use strict';
123 124
...@@ -298,9 +299,13 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -298,9 +299,13 @@ return /******/ (function(modules) { // webpackBootstrap
298 * 299 *
299 * react-native: 300 * react-native:
300 * navigator.product -> 'ReactNative' 301 * navigator.product -> 'ReactNative'
302 + * nativescript
303 + * navigator.product -> 'NativeScript' or 'NS'
301 */ 304 */
302 function isStandardBrowserEnv() { 305 function isStandardBrowserEnv() {
303 - if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { 306 + if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
307 + navigator.product === 'NativeScript' ||
308 + navigator.product === 'NS')) {
304 return false; 309 return false;
305 } 310 }
306 return ( 311 return (
...@@ -328,7 +333,7 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -328,7 +333,7 @@ return /******/ (function(modules) { // webpackBootstrap
328 } 333 }
329 334
330 // Force an array if not already something iterable 335 // Force an array if not already something iterable
331 - if (typeof obj !== 'object' && !isArray(obj)) { 336 + if (typeof obj !== 'object') {
332 /*eslint no-param-reassign:0*/ 337 /*eslint no-param-reassign:0*/
333 obj = [obj]; 338 obj = [obj];
334 } 339 }
...@@ -382,6 +387,32 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -382,6 +387,32 @@ return /******/ (function(modules) { // webpackBootstrap
382 } 387 }
383 388
384 /** 389 /**
390 + * Function equal to merge with the difference being that no reference
391 + * to original objects is kept.
392 + *
393 + * @see merge
394 + * @param {Object} obj1 Object to merge
395 + * @returns {Object} Result of all merge properties
396 + */
397 + function deepMerge(/* obj1, obj2, obj3, ... */) {
398 + var result = {};
399 + function assignValue(val, key) {
400 + if (typeof result[key] === 'object' && typeof val === 'object') {
401 + result[key] = deepMerge(result[key], val);
402 + } else if (typeof val === 'object') {
403 + result[key] = deepMerge({}, val);
404 + } else {
405 + result[key] = val;
406 + }
407 + }
408 +
409 + for (var i = 0, l = arguments.length; i < l; i++) {
410 + forEach(arguments[i], assignValue);
411 + }
412 + return result;
413 + }
414 +
415 + /**
385 * Extends object a by mutably adding to it the properties of object b. 416 * Extends object a by mutably adding to it the properties of object b.
386 * 417 *
387 * @param {Object} a The object to be extended 418 * @param {Object} a The object to be extended
...@@ -419,14 +450,15 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -419,14 +450,15 @@ return /******/ (function(modules) { // webpackBootstrap
419 isStandardBrowserEnv: isStandardBrowserEnv, 450 isStandardBrowserEnv: isStandardBrowserEnv,
420 forEach: forEach, 451 forEach: forEach,
421 merge: merge, 452 merge: merge,
453 + deepMerge: deepMerge,
422 extend: extend, 454 extend: extend,
423 trim: trim 455 trim: trim
424 }; 456 };
425 457
426 458
427 -/***/ }, 459 +/***/ }),
428 /* 3 */ 460 /* 3 */
429 -/***/ function(module, exports) { 461 +/***/ (function(module, exports) {
430 462
431 'use strict'; 463 'use strict';
432 464
...@@ -441,45 +473,34 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -441,45 +473,34 @@ return /******/ (function(modules) { // webpackBootstrap
441 }; 473 };
442 474
443 475
444 -/***/ }, 476 +/***/ }),
445 /* 4 */ 477 /* 4 */
446 -/***/ function(module, exports) { 478 +/***/ (function(module, exports) {
447 479
448 /*! 480 /*!
449 * Determine if an object is a Buffer 481 * Determine if an object is a Buffer
450 * 482 *
451 - * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> 483 + * @author Feross Aboukhadijeh <https://feross.org>
452 * @license MIT 484 * @license MIT
453 */ 485 */
454 486
455 - // The _isBuffer check is for Safari 5-7 support, because it's missing 487 + module.exports = function isBuffer (obj) {
456 - // Object.prototype.constructor. Remove this eventually 488 + return obj != null && obj.constructor != null &&
457 - module.exports = function (obj) { 489 + typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
458 - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
459 - }
460 -
461 - function isBuffer (obj) {
462 - return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
463 - }
464 -
465 - // For Node v0.10 support. Remove this eventually.
466 - function isSlowBuffer (obj) {
467 - return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
468 } 490 }
469 491
470 492
471 -/***/ }, 493 +/***/ }),
472 /* 5 */ 494 /* 5 */
473 -/***/ function(module, exports, __webpack_require__) { 495 +/***/ (function(module, exports, __webpack_require__) {
474 496
475 'use strict'; 497 'use strict';
476 498
477 - var defaults = __webpack_require__(6);
478 var utils = __webpack_require__(2); 499 var utils = __webpack_require__(2);
479 - var InterceptorManager = __webpack_require__(17); 500 + var buildURL = __webpack_require__(6);
480 - var dispatchRequest = __webpack_require__(18); 501 + var InterceptorManager = __webpack_require__(7);
481 - var isAbsoluteURL = __webpack_require__(21); 502 + var dispatchRequest = __webpack_require__(8);
482 - var combineURLs = __webpack_require__(22); 503 + var mergeConfig = __webpack_require__(22);
483 504
484 /** 505 /**
485 * Create a new instance of Axios 506 * Create a new instance of Axios
...@@ -503,18 +524,14 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -503,18 +524,14 @@ return /******/ (function(modules) { // webpackBootstrap
503 /*eslint no-param-reassign:0*/ 524 /*eslint no-param-reassign:0*/
504 // Allow for axios('example/url'[, config]) a la fetch API 525 // Allow for axios('example/url'[, config]) a la fetch API
505 if (typeof config === 'string') { 526 if (typeof config === 'string') {
506 - config = utils.merge({ 527 + config = arguments[1] || {};
507 - url: arguments[0] 528 + config.url = arguments[0];
508 - }, arguments[1]); 529 + } else {
530 + config = config || {};
509 } 531 }
510 532
511 - config = utils.merge(defaults, this.defaults, { method: 'get' }, config); 533 + config = mergeConfig(this.defaults, config);
512 - config.method = config.method.toLowerCase(); 534 + config.method = config.method ? config.method.toLowerCase() : 'get';
513 -
514 - // Support baseURL config
515 - if (config.baseURL && !isAbsoluteURL(config.url)) {
516 - config.url = combineURLs(config.baseURL, config.url);
517 - }
518 535
519 // Hook up interceptors middleware 536 // Hook up interceptors middleware
520 var chain = [dispatchRequest, undefined]; 537 var chain = [dispatchRequest, undefined];
...@@ -535,6 +552,11 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -535,6 +552,11 @@ return /******/ (function(modules) { // webpackBootstrap
535 return promise; 552 return promise;
536 }; 553 };
537 554
555 + Axios.prototype.getUri = function getUri(config) {
556 + config = mergeConfig(this.defaults, config);
557 + return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
558 + };
559 +
538 // Provide aliases for supported request methods 560 // Provide aliases for supported request methods
539 utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 561 utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
540 /*eslint func-names:0*/ 562 /*eslint func-names:0*/
...@@ -560,180 +582,433 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -560,180 +582,433 @@ return /******/ (function(modules) { // webpackBootstrap
560 module.exports = Axios; 582 module.exports = Axios;
561 583
562 584
563 -/***/ }, 585 +/***/ }),
564 /* 6 */ 586 /* 6 */
565 -/***/ function(module, exports, __webpack_require__) { 587 +/***/ (function(module, exports, __webpack_require__) {
566 588
567 'use strict'; 589 'use strict';
568 590
569 var utils = __webpack_require__(2); 591 var utils = __webpack_require__(2);
570 - var normalizeHeaderName = __webpack_require__(7);
571 -
572 - var DEFAULT_CONTENT_TYPE = {
573 - 'Content-Type': 'application/x-www-form-urlencoded'
574 - };
575 592
576 - function setContentTypeIfUnset(headers, value) { 593 + function encode(val) {
577 - if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 594 + return encodeURIComponent(val).
578 - headers['Content-Type'] = value; 595 + replace(/%40/gi, '@').
579 - } 596 + replace(/%3A/gi, ':').
597 + replace(/%24/g, '$').
598 + replace(/%2C/gi, ',').
599 + replace(/%20/g, '+').
600 + replace(/%5B/gi, '[').
601 + replace(/%5D/gi, ']');
580 } 602 }
581 603
582 - function getDefaultAdapter() { 604 + /**
583 - var adapter; 605 + * Build a URL by appending params to the end
584 - if (typeof XMLHttpRequest !== 'undefined') { 606 + *
585 - // For browsers use XHR adapter 607 + * @param {string} url The base of the url (e.g., http://www.google.com)
586 - adapter = __webpack_require__(8); 608 + * @param {object} [params] The params to be appended
587 - } else if (typeof process !== 'undefined') { 609 + * @returns {string} The formatted url
588 - // For node use HTTP adapter 610 + */
589 - adapter = __webpack_require__(8); 611 + module.exports = function buildURL(url, params, paramsSerializer) {
612 + /*eslint no-param-reassign:0*/
613 + if (!params) {
614 + return url;
590 } 615 }
591 - return adapter;
592 - }
593 616
594 - var defaults = { 617 + var serializedParams;
595 - adapter: getDefaultAdapter(), 618 + if (paramsSerializer) {
619 + serializedParams = paramsSerializer(params);
620 + } else if (utils.isURLSearchParams(params)) {
621 + serializedParams = params.toString();
622 + } else {
623 + var parts = [];
596 624
597 - transformRequest: [function transformRequest(data, headers) { 625 + utils.forEach(params, function serialize(val, key) {
598 - normalizeHeaderName(headers, 'Content-Type'); 626 + if (val === null || typeof val === 'undefined') {
599 - if (utils.isFormData(data) || 627 + return;
600 - utils.isArrayBuffer(data) || 628 + }
601 - utils.isBuffer(data) ||
602 - utils.isStream(data) ||
603 - utils.isFile(data) ||
604 - utils.isBlob(data)
605 - ) {
606 - return data;
607 - }
608 - if (utils.isArrayBufferView(data)) {
609 - return data.buffer;
610 - }
611 - if (utils.isURLSearchParams(data)) {
612 - setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
613 - return data.toString();
614 - }
615 - if (utils.isObject(data)) {
616 - setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
617 - return JSON.stringify(data);
618 - }
619 - return data;
620 - }],
621 629
622 - transformResponse: [function transformResponse(data) { 630 + if (utils.isArray(val)) {
623 - /*eslint no-param-reassign:0*/ 631 + key = key + '[]';
624 - if (typeof data === 'string') { 632 + } else {
625 - try { 633 + val = [val];
626 - data = JSON.parse(data); 634 + }
627 - } catch (e) { /* Ignore */ }
628 - }
629 - return data;
630 - }],
631 635
632 - timeout: 0, 636 + utils.forEach(val, function parseValue(v) {
637 + if (utils.isDate(v)) {
638 + v = v.toISOString();
639 + } else if (utils.isObject(v)) {
640 + v = JSON.stringify(v);
641 + }
642 + parts.push(encode(key) + '=' + encode(v));
643 + });
644 + });
633 645
634 - xsrfCookieName: 'XSRF-TOKEN', 646 + serializedParams = parts.join('&');
635 - xsrfHeaderName: 'X-XSRF-TOKEN', 647 + }
636 648
637 - maxContentLength: -1, 649 + if (serializedParams) {
650 + var hashmarkIndex = url.indexOf('#');
651 + if (hashmarkIndex !== -1) {
652 + url = url.slice(0, hashmarkIndex);
653 + }
638 654
639 - validateStatus: function validateStatus(status) { 655 + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
640 - return status >= 200 && status < 300;
641 } 656 }
642 - };
643 657
644 - defaults.headers = { 658 + return url;
645 - common: {
646 - 'Accept': 'application/json, text/plain, */*'
647 - }
648 }; 659 };
649 -
650 - utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
651 - defaults.headers[method] = {};
652 - });
653 -
654 - utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
655 - defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
656 - });
657 -
658 - module.exports = defaults;
659 660
660 661
661 -/***/ }, 662 +/***/ }),
662 /* 7 */ 663 /* 7 */
663 -/***/ function(module, exports, __webpack_require__) { 664 +/***/ (function(module, exports, __webpack_require__) {
664 665
665 'use strict'; 666 'use strict';
666 667
667 var utils = __webpack_require__(2); 668 var utils = __webpack_require__(2);
668 669
669 - module.exports = function normalizeHeaderName(headers, normalizedName) { 670 + function InterceptorManager() {
670 - utils.forEach(headers, function processHeader(value, name) { 671 + this.handlers = [];
671 - if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 672 + }
672 - headers[normalizedName] = value; 673 +
673 - delete headers[name]; 674 + /**
675 + * Add a new interceptor to the stack
676 + *
677 + * @param {Function} fulfilled The function to handle `then` for a `Promise`
678 + * @param {Function} rejected The function to handle `reject` for a `Promise`
679 + *
680 + * @return {Number} An ID used to remove interceptor later
681 + */
682 + InterceptorManager.prototype.use = function use(fulfilled, rejected) {
683 + this.handlers.push({
684 + fulfilled: fulfilled,
685 + rejected: rejected
686 + });
687 + return this.handlers.length - 1;
688 + };
689 +
690 + /**
691 + * Remove an interceptor from the stack
692 + *
693 + * @param {Number} id The ID that was returned by `use`
694 + */
695 + InterceptorManager.prototype.eject = function eject(id) {
696 + if (this.handlers[id]) {
697 + this.handlers[id] = null;
698 + }
699 + };
700 +
701 + /**
702 + * Iterate over all the registered interceptors
703 + *
704 + * This method is particularly useful for skipping over any
705 + * interceptors that may have become `null` calling `eject`.
706 + *
707 + * @param {Function} fn The function to call for each interceptor
708 + */
709 + InterceptorManager.prototype.forEach = function forEach(fn) {
710 + utils.forEach(this.handlers, function forEachHandler(h) {
711 + if (h !== null) {
712 + fn(h);
674 } 713 }
675 }); 714 });
676 }; 715 };
716 +
717 + module.exports = InterceptorManager;
677 718
678 719
679 -/***/ }, 720 +/***/ }),
680 /* 8 */ 721 /* 8 */
681 -/***/ function(module, exports, __webpack_require__) { 722 +/***/ (function(module, exports, __webpack_require__) {
682 723
683 'use strict'; 724 'use strict';
684 725
685 var utils = __webpack_require__(2); 726 var utils = __webpack_require__(2);
686 - var settle = __webpack_require__(9); 727 + var transformData = __webpack_require__(9);
687 - var buildURL = __webpack_require__(12); 728 + var isCancel = __webpack_require__(10);
688 - var parseHeaders = __webpack_require__(13); 729 + var defaults = __webpack_require__(11);
689 - var isURLSameOrigin = __webpack_require__(14); 730 + var isAbsoluteURL = __webpack_require__(20);
690 - var createError = __webpack_require__(10); 731 + var combineURLs = __webpack_require__(21);
691 - var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);
692 732
693 - module.exports = function xhrAdapter(config) { 733 + /**
694 - return new Promise(function dispatchXhrRequest(resolve, reject) { 734 + * Throws a `Cancel` if cancellation has been requested.
695 - var requestData = config.data; 735 + */
696 - var requestHeaders = config.headers; 736 + function throwIfCancellationRequested(config) {
737 + if (config.cancelToken) {
738 + config.cancelToken.throwIfRequested();
739 + }
740 + }
697 741
698 - if (utils.isFormData(requestData)) { 742 + /**
699 - delete requestHeaders['Content-Type']; // Let the browser set it 743 + * Dispatch a request to the server using the configured adapter.
700 - } 744 + *
745 + * @param {object} config The config that is to be used for the request
746 + * @returns {Promise} The Promise to be fulfilled
747 + */
748 + module.exports = function dispatchRequest(config) {
749 + throwIfCancellationRequested(config);
701 750
702 - var request = new XMLHttpRequest(); 751 + // Support baseURL config
703 - var loadEvent = 'onreadystatechange'; 752 + if (config.baseURL && !isAbsoluteURL(config.url)) {
704 - var xDomain = false; 753 + config.url = combineURLs(config.baseURL, config.url);
705 - 754 + }
706 - // For IE 8/9 CORS support
707 - // Only supports POST and GET calls and doesn't returns the response headers.
708 - // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
709 - if (("production") !== 'test' &&
710 - typeof window !== 'undefined' &&
711 - window.XDomainRequest && !('withCredentials' in request) &&
712 - !isURLSameOrigin(config.url)) {
713 - request = new window.XDomainRequest();
714 - loadEvent = 'onload';
715 - xDomain = true;
716 - request.onprogress = function handleProgress() {};
717 - request.ontimeout = function handleTimeout() {};
718 - }
719 755
720 - // HTTP basic authentication 756 + // Ensure headers exist
721 - if (config.auth) { 757 + config.headers = config.headers || {};
722 - var username = config.auth.username || '';
723 - var password = config.auth.password || '';
724 - requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
725 - }
726 758
727 - request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); 759 + // Transform request data
760 + config.data = transformData(
761 + config.data,
762 + config.headers,
763 + config.transformRequest
764 + );
728 765
729 - // Set the request timeout in MS 766 + // Flatten headers
730 - request.timeout = config.timeout; 767 + config.headers = utils.merge(
768 + config.headers.common || {},
769 + config.headers[config.method] || {},
770 + config.headers || {}
771 + );
731 772
732 - // Listen for ready state 773 + utils.forEach(
733 - request[loadEvent] = function handleLoad() { 774 + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
734 - if (!request || (request.readyState !== 4 && !xDomain)) { 775 + function cleanHeaderConfig(method) {
735 - return; 776 + delete config.headers[method];
736 - } 777 + }
778 + );
779 +
780 + var adapter = config.adapter || defaults.adapter;
781 +
782 + return adapter(config).then(function onAdapterResolution(response) {
783 + throwIfCancellationRequested(config);
784 +
785 + // Transform response data
786 + response.data = transformData(
787 + response.data,
788 + response.headers,
789 + config.transformResponse
790 + );
791 +
792 + return response;
793 + }, function onAdapterRejection(reason) {
794 + if (!isCancel(reason)) {
795 + throwIfCancellationRequested(config);
796 +
797 + // Transform response data
798 + if (reason && reason.response) {
799 + reason.response.data = transformData(
800 + reason.response.data,
801 + reason.response.headers,
802 + config.transformResponse
803 + );
804 + }
805 + }
806 +
807 + return Promise.reject(reason);
808 + });
809 + };
810 +
811 +
812 +/***/ }),
813 +/* 9 */
814 +/***/ (function(module, exports, __webpack_require__) {
815 +
816 + 'use strict';
817 +
818 + var utils = __webpack_require__(2);
819 +
820 + /**
821 + * Transform the data for a request or a response
822 + *
823 + * @param {Object|String} data The data to be transformed
824 + * @param {Array} headers The headers for the request or response
825 + * @param {Array|Function} fns A single function or Array of functions
826 + * @returns {*} The resulting transformed data
827 + */
828 + module.exports = function transformData(data, headers, fns) {
829 + /*eslint no-param-reassign:0*/
830 + utils.forEach(fns, function transform(fn) {
831 + data = fn(data, headers);
832 + });
833 +
834 + return data;
835 + };
836 +
837 +
838 +/***/ }),
839 +/* 10 */
840 +/***/ (function(module, exports) {
841 +
842 + 'use strict';
843 +
844 + module.exports = function isCancel(value) {
845 + return !!(value && value.__CANCEL__);
846 + };
847 +
848 +
849 +/***/ }),
850 +/* 11 */
851 +/***/ (function(module, exports, __webpack_require__) {
852 +
853 + 'use strict';
854 +
855 + var utils = __webpack_require__(2);
856 + var normalizeHeaderName = __webpack_require__(12);
857 +
858 + var DEFAULT_CONTENT_TYPE = {
859 + 'Content-Type': 'application/x-www-form-urlencoded'
860 + };
861 +
862 + function setContentTypeIfUnset(headers, value) {
863 + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
864 + headers['Content-Type'] = value;
865 + }
866 + }
867 +
868 + function getDefaultAdapter() {
869 + var adapter;
870 + // Only Node.JS has a process variable that is of [[Class]] process
871 + if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
872 + // For node use HTTP adapter
873 + adapter = __webpack_require__(13);
874 + } else if (typeof XMLHttpRequest !== 'undefined') {
875 + // For browsers use XHR adapter
876 + adapter = __webpack_require__(13);
877 + }
878 + return adapter;
879 + }
880 +
881 + var defaults = {
882 + adapter: getDefaultAdapter(),
883 +
884 + transformRequest: [function transformRequest(data, headers) {
885 + normalizeHeaderName(headers, 'Accept');
886 + normalizeHeaderName(headers, 'Content-Type');
887 + if (utils.isFormData(data) ||
888 + utils.isArrayBuffer(data) ||
889 + utils.isBuffer(data) ||
890 + utils.isStream(data) ||
891 + utils.isFile(data) ||
892 + utils.isBlob(data)
893 + ) {
894 + return data;
895 + }
896 + if (utils.isArrayBufferView(data)) {
897 + return data.buffer;
898 + }
899 + if (utils.isURLSearchParams(data)) {
900 + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
901 + return data.toString();
902 + }
903 + if (utils.isObject(data)) {
904 + setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
905 + return JSON.stringify(data);
906 + }
907 + return data;
908 + }],
909 +
910 + transformResponse: [function transformResponse(data) {
911 + /*eslint no-param-reassign:0*/
912 + if (typeof data === 'string') {
913 + try {
914 + data = JSON.parse(data);
915 + } catch (e) { /* Ignore */ }
916 + }
917 + return data;
918 + }],
919 +
920 + /**
921 + * A timeout in milliseconds to abort a request. If set to 0 (default) a
922 + * timeout is not created.
923 + */
924 + timeout: 0,
925 +
926 + xsrfCookieName: 'XSRF-TOKEN',
927 + xsrfHeaderName: 'X-XSRF-TOKEN',
928 +
929 + maxContentLength: -1,
930 +
931 + validateStatus: function validateStatus(status) {
932 + return status >= 200 && status < 300;
933 + }
934 + };
935 +
936 + defaults.headers = {
937 + common: {
938 + 'Accept': 'application/json, text/plain, */*'
939 + }
940 + };
941 +
942 + utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
943 + defaults.headers[method] = {};
944 + });
945 +
946 + utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
947 + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
948 + });
949 +
950 + module.exports = defaults;
951 +
952 +
953 +/***/ }),
954 +/* 12 */
955 +/***/ (function(module, exports, __webpack_require__) {
956 +
957 + 'use strict';
958 +
959 + var utils = __webpack_require__(2);
960 +
961 + module.exports = function normalizeHeaderName(headers, normalizedName) {
962 + utils.forEach(headers, function processHeader(value, name) {
963 + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
964 + headers[normalizedName] = value;
965 + delete headers[name];
966 + }
967 + });
968 + };
969 +
970 +
971 +/***/ }),
972 +/* 13 */
973 +/***/ (function(module, exports, __webpack_require__) {
974 +
975 + 'use strict';
976 +
977 + var utils = __webpack_require__(2);
978 + var settle = __webpack_require__(14);
979 + var buildURL = __webpack_require__(6);
980 + var parseHeaders = __webpack_require__(17);
981 + var isURLSameOrigin = __webpack_require__(18);
982 + var createError = __webpack_require__(15);
983 +
984 + module.exports = function xhrAdapter(config) {
985 + return new Promise(function dispatchXhrRequest(resolve, reject) {
986 + var requestData = config.data;
987 + var requestHeaders = config.headers;
988 +
989 + if (utils.isFormData(requestData)) {
990 + delete requestHeaders['Content-Type']; // Let the browser set it
991 + }
992 +
993 + var request = new XMLHttpRequest();
994 +
995 + // HTTP basic authentication
996 + if (config.auth) {
997 + var username = config.auth.username || '';
998 + var password = config.auth.password || '';
999 + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
1000 + }
1001 +
1002 + request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
1003 +
1004 + // Set the request timeout in MS
1005 + request.timeout = config.timeout;
1006 +
1007 + // Listen for ready state
1008 + request.onreadystatechange = function handleLoad() {
1009 + if (!request || request.readyState !== 4) {
1010 + return;
1011 + }
737 1012
738 // The request errored out and we didn't get a response, this will be 1013 // The request errored out and we didn't get a response, this will be
739 // handled by onerror instead 1014 // handled by onerror instead
...@@ -748,9 +1023,8 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -748,9 +1023,8 @@ return /******/ (function(modules) { // webpackBootstrap
748 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; 1023 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
749 var response = { 1024 var response = {
750 data: responseData, 1025 data: responseData,
751 - // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201) 1026 + status: request.status,
752 - status: request.status === 1223 ? 204 : request.status, 1027 + statusText: request.statusText,
753 - statusText: request.status === 1223 ? 'No Content' : request.statusText,
754 headers: responseHeaders, 1028 headers: responseHeaders,
755 config: config, 1029 config: config,
756 request: request 1030 request: request
...@@ -762,6 +1036,18 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -762,6 +1036,18 @@ return /******/ (function(modules) { // webpackBootstrap
762 request = null; 1036 request = null;
763 }; 1037 };
764 1038
1039 + // Handle browser request cancellation (as opposed to a manual cancellation)
1040 + request.onabort = function handleAbort() {
1041 + if (!request) {
1042 + return;
1043 + }
1044 +
1045 + reject(createError('Request aborted', config, 'ECONNABORTED', request));
1046 +
1047 + // Clean up request
1048 + request = null;
1049 + };
1050 +
765 // Handle low level network errors 1051 // Handle low level network errors
766 request.onerror = function handleError() { 1052 request.onerror = function handleError() {
767 // Real errors are hidden from us by the browser 1053 // Real errors are hidden from us by the browser
...@@ -785,12 +1071,12 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -785,12 +1071,12 @@ return /******/ (function(modules) { // webpackBootstrap
785 // This is only done if running in a standard browser environment. 1071 // This is only done if running in a standard browser environment.
786 // Specifically not if we're in a web worker, or react-native. 1072 // Specifically not if we're in a web worker, or react-native.
787 if (utils.isStandardBrowserEnv()) { 1073 if (utils.isStandardBrowserEnv()) {
788 - var cookies = __webpack_require__(16); 1074 + var cookies = __webpack_require__(19);
789 1075
790 // Add xsrf header 1076 // Add xsrf header
791 var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? 1077 var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
792 - cookies.read(config.xsrfCookieName) : 1078 + cookies.read(config.xsrfCookieName) :
793 - undefined; 1079 + undefined;
794 1080
795 if (xsrfValue) { 1081 if (xsrfValue) {
796 requestHeaders[config.xsrfHeaderName] = xsrfValue; 1082 requestHeaders[config.xsrfHeaderName] = xsrfValue;
...@@ -862,13 +1148,13 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -862,13 +1148,13 @@ return /******/ (function(modules) { // webpackBootstrap
862 }; 1148 };
863 1149
864 1150
865 -/***/ }, 1151 +/***/ }),
866 -/* 9 */ 1152 +/* 14 */
867 -/***/ function(module, exports, __webpack_require__) { 1153 +/***/ (function(module, exports, __webpack_require__) {
868 1154
869 'use strict'; 1155 'use strict';
870 1156
871 - var createError = __webpack_require__(10); 1157 + var createError = __webpack_require__(15);
872 1158
873 /** 1159 /**
874 * Resolve or reject a Promise based on response status. 1160 * Resolve or reject a Promise based on response status.
...@@ -879,8 +1165,7 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -879,8 +1165,7 @@ return /******/ (function(modules) { // webpackBootstrap
879 */ 1165 */
880 module.exports = function settle(resolve, reject, response) { 1166 module.exports = function settle(resolve, reject, response) {
881 var validateStatus = response.config.validateStatus; 1167 var validateStatus = response.config.validateStatus;
882 - // Note: status is not exposed by XDomainRequest 1168 + if (!validateStatus || validateStatus(response.status)) {
883 - if (!response.status || !validateStatus || validateStatus(response.status)) {
884 resolve(response); 1169 resolve(response);
885 } else { 1170 } else {
886 reject(createError( 1171 reject(createError(
...@@ -894,13 +1179,13 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -894,13 +1179,13 @@ return /******/ (function(modules) { // webpackBootstrap
894 }; 1179 };
895 1180
896 1181
897 -/***/ }, 1182 +/***/ }),
898 -/* 10 */ 1183 +/* 15 */
899 -/***/ function(module, exports, __webpack_require__) { 1184 +/***/ (function(module, exports, __webpack_require__) {
900 1185
901 'use strict'; 1186 'use strict';
902 1187
903 - var enhanceError = __webpack_require__(11); 1188 + var enhanceError = __webpack_require__(16);
904 1189
905 /** 1190 /**
906 * Create an Error with the specified message, config, error code, request and response. 1191 * Create an Error with the specified message, config, error code, request and response.
...@@ -918,9 +1203,9 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -918,9 +1203,9 @@ return /******/ (function(modules) { // webpackBootstrap
918 }; 1203 };
919 1204
920 1205
921 -/***/ }, 1206 +/***/ }),
922 -/* 11 */ 1207 +/* 16 */
923 -/***/ function(module, exports) { 1208 +/***/ (function(module, exports) {
924 1209
925 'use strict'; 1210 'use strict';
926 1211
...@@ -939,106 +1224,62 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -939,106 +1224,62 @@ return /******/ (function(modules) { // webpackBootstrap
939 if (code) { 1224 if (code) {
940 error.code = code; 1225 error.code = code;
941 } 1226 }
1227 +
942 error.request = request; 1228 error.request = request;
943 error.response = response; 1229 error.response = response;
1230 + error.isAxiosError = true;
1231 +
1232 + error.toJSON = function() {
1233 + return {
1234 + // Standard
1235 + message: this.message,
1236 + name: this.name,
1237 + // Microsoft
1238 + description: this.description,
1239 + number: this.number,
1240 + // Mozilla
1241 + fileName: this.fileName,
1242 + lineNumber: this.lineNumber,
1243 + columnNumber: this.columnNumber,
1244 + stack: this.stack,
1245 + // Axios
1246 + config: this.config,
1247 + code: this.code
1248 + };
1249 + };
944 return error; 1250 return error;
945 }; 1251 };
946 1252
947 1253
948 -/***/ }, 1254 +/***/ }),
949 -/* 12 */ 1255 +/* 17 */
950 -/***/ function(module, exports, __webpack_require__) { 1256 +/***/ (function(module, exports, __webpack_require__) {
951 1257
952 'use strict'; 1258 'use strict';
953 1259
954 var utils = __webpack_require__(2); 1260 var utils = __webpack_require__(2);
955 1261
956 - function encode(val) { 1262 + // Headers whose duplicates are ignored by node
957 - return encodeURIComponent(val). 1263 + // c.f. https://nodejs.org/api/http.html#http_message_headers
958 - replace(/%40/gi, '@'). 1264 + var ignoreDuplicateOf = [
959 - replace(/%3A/gi, ':'). 1265 + 'age', 'authorization', 'content-length', 'content-type', 'etag',
960 - replace(/%24/g, '$'). 1266 + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
961 - replace(/%2C/gi, ','). 1267 + 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
962 - replace(/%20/g, '+'). 1268 + 'referer', 'retry-after', 'user-agent'
963 - replace(/%5B/gi, '['). 1269 + ];
964 - replace(/%5D/gi, ']');
965 - }
966 1270
967 /** 1271 /**
968 - * Build a URL by appending params to the end 1272 + * Parse headers into an object
969 * 1273 *
970 - * @param {string} url The base of the url (e.g., http://www.google.com) 1274 + * ```
971 - * @param {object} [params] The params to be appended 1275 + * Date: Wed, 27 Aug 2014 08:58:49 GMT
972 - * @returns {string} The formatted url 1276 + * Content-Type: application/json
973 - */ 1277 + * Connection: keep-alive
974 - module.exports = function buildURL(url, params, paramsSerializer) { 1278 + * Transfer-Encoding: chunked
975 - /*eslint no-param-reassign:0*/ 1279 + * ```
976 - if (!params) { 1280 + *
977 - return url; 1281 + * @param {String} headers Headers needing to be parsed
978 - } 1282 + * @returns {Object} Headers parsed into an object
979 -
980 - var serializedParams;
981 - if (paramsSerializer) {
982 - serializedParams = paramsSerializer(params);
983 - } else if (utils.isURLSearchParams(params)) {
984 - serializedParams = params.toString();
985 - } else {
986 - var parts = [];
987 -
988 - utils.forEach(params, function serialize(val, key) {
989 - if (val === null || typeof val === 'undefined') {
990 - return;
991 - }
992 -
993 - if (utils.isArray(val)) {
994 - key = key + '[]';
995 - }
996 -
997 - if (!utils.isArray(val)) {
998 - val = [val];
999 - }
1000 -
1001 - utils.forEach(val, function parseValue(v) {
1002 - if (utils.isDate(v)) {
1003 - v = v.toISOString();
1004 - } else if (utils.isObject(v)) {
1005 - v = JSON.stringify(v);
1006 - }
1007 - parts.push(encode(key) + '=' + encode(v));
1008 - });
1009 - });
1010 -
1011 - serializedParams = parts.join('&');
1012 - }
1013 -
1014 - if (serializedParams) {
1015 - url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1016 - }
1017 -
1018 - return url;
1019 - };
1020 -
1021 -
1022 -/***/ },
1023 -/* 13 */
1024 -/***/ function(module, exports, __webpack_require__) {
1025 -
1026 - 'use strict';
1027 -
1028 - var utils = __webpack_require__(2);
1029 -
1030 - /**
1031 - * Parse headers into an object
1032 - *
1033 - * ```
1034 - * Date: Wed, 27 Aug 2014 08:58:49 GMT
1035 - * Content-Type: application/json
1036 - * Connection: keep-alive
1037 - * Transfer-Encoding: chunked
1038 - * ```
1039 - *
1040 - * @param {String} headers Headers needing to be parsed
1041 - * @returns {Object} Headers parsed into an object
1042 */ 1283 */
1043 module.exports = function parseHeaders(headers) { 1284 module.exports = function parseHeaders(headers) {
1044 var parsed = {}; 1285 var parsed = {};
...@@ -1054,7 +1295,14 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1054,7 +1295,14 @@ return /******/ (function(modules) { // webpackBootstrap
1054 val = utils.trim(line.substr(i + 1)); 1295 val = utils.trim(line.substr(i + 1));
1055 1296
1056 if (key) { 1297 if (key) {
1057 - parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 1298 + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
1299 + return;
1300 + }
1301 + if (key === 'set-cookie') {
1302 + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
1303 + } else {
1304 + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1305 + }
1058 } 1306 }
1059 }); 1307 });
1060 1308
...@@ -1062,9 +1310,9 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1062,9 +1310,9 @@ return /******/ (function(modules) { // webpackBootstrap
1062 }; 1310 };
1063 1311
1064 1312
1065 -/***/ }, 1313 +/***/ }),
1066 -/* 14 */ 1314 +/* 18 */
1067 -/***/ function(module, exports, __webpack_require__) { 1315 +/***/ (function(module, exports, __webpack_require__) {
1068 1316
1069 'use strict'; 1317 'use strict';
1070 1318
...@@ -1075,112 +1323,70 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1075,112 +1323,70 @@ return /******/ (function(modules) { // webpackBootstrap
1075 1323
1076 // Standard browser envs have full support of the APIs needed to test 1324 // Standard browser envs have full support of the APIs needed to test
1077 // whether the request URL is of the same origin as current location. 1325 // whether the request URL is of the same origin as current location.
1078 - (function standardBrowserEnv() { 1326 + (function standardBrowserEnv() {
1079 - var msie = /(msie|trident)/i.test(navigator.userAgent); 1327 + var msie = /(msie|trident)/i.test(navigator.userAgent);
1080 - var urlParsingNode = document.createElement('a'); 1328 + var urlParsingNode = document.createElement('a');
1081 - var originURL; 1329 + var originURL;
1082 1330
1083 - /** 1331 + /**
1084 * Parse a URL to discover it's components 1332 * Parse a URL to discover it's components
1085 * 1333 *
1086 * @param {String} url The URL to be parsed 1334 * @param {String} url The URL to be parsed
1087 * @returns {Object} 1335 * @returns {Object}
1088 */ 1336 */
1089 - function resolveURL(url) { 1337 + function resolveURL(url) {
1090 - var href = url; 1338 + var href = url;
1091 1339
1092 - if (msie) { 1340 + if (msie) {
1093 // IE needs attribute set twice to normalize properties 1341 // IE needs attribute set twice to normalize properties
1094 - urlParsingNode.setAttribute('href', href); 1342 + urlParsingNode.setAttribute('href', href);
1095 - href = urlParsingNode.href; 1343 + href = urlParsingNode.href;
1096 - } 1344 + }
1097 1345
1098 - urlParsingNode.setAttribute('href', href); 1346 + urlParsingNode.setAttribute('href', href);
1099 1347
1100 - // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 1348 + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
1101 - return { 1349 + return {
1102 - href: urlParsingNode.href, 1350 + href: urlParsingNode.href,
1103 - protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 1351 + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
1104 - host: urlParsingNode.host, 1352 + host: urlParsingNode.host,
1105 - search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 1353 + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1106 - hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 1354 + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1107 - hostname: urlParsingNode.hostname, 1355 + hostname: urlParsingNode.hostname,
1108 - port: urlParsingNode.port, 1356 + port: urlParsingNode.port,
1109 - pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 1357 + pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
1110 - urlParsingNode.pathname : 1358 + urlParsingNode.pathname :
1111 - '/' + urlParsingNode.pathname 1359 + '/' + urlParsingNode.pathname
1112 - }; 1360 + };
1113 - } 1361 + }
1114 1362
1115 - originURL = resolveURL(window.location.href); 1363 + originURL = resolveURL(window.location.href);
1116 1364
1117 - /** 1365 + /**
1118 * Determine if a URL shares the same origin as the current location 1366 * Determine if a URL shares the same origin as the current location
1119 * 1367 *
1120 * @param {String} requestURL The URL to test 1368 * @param {String} requestURL The URL to test
1121 * @returns {boolean} True if URL shares the same origin, otherwise false 1369 * @returns {boolean} True if URL shares the same origin, otherwise false
1122 */ 1370 */
1123 - return function isURLSameOrigin(requestURL) { 1371 + return function isURLSameOrigin(requestURL) {
1124 - var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 1372 + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
1125 - return (parsed.protocol === originURL.protocol && 1373 + return (parsed.protocol === originURL.protocol &&
1126 parsed.host === originURL.host); 1374 parsed.host === originURL.host);
1127 - }; 1375 + };
1128 - })() : 1376 + })() :
1129 1377
1130 // Non standard browser envs (web workers, react-native) lack needed support. 1378 // Non standard browser envs (web workers, react-native) lack needed support.
1131 - (function nonStandardBrowserEnv() { 1379 + (function nonStandardBrowserEnv() {
1132 - return function isURLSameOrigin() { 1380 + return function isURLSameOrigin() {
1133 - return true; 1381 + return true;
1134 - }; 1382 + };
1135 - })() 1383 + })()
1136 ); 1384 );
1137 1385
1138 1386
1139 -/***/ }, 1387 +/***/ }),
1140 -/* 15 */ 1388 +/* 19 */
1141 -/***/ function(module, exports) { 1389 +/***/ (function(module, exports, __webpack_require__) {
1142 -
1143 - 'use strict';
1144 -
1145 - // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
1146 -
1147 - var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
1148 -
1149 - function E() {
1150 - this.message = 'String contains an invalid character';
1151 - }
1152 - E.prototype = new Error;
1153 - E.prototype.code = 5;
1154 - E.prototype.name = 'InvalidCharacterError';
1155 -
1156 - function btoa(input) {
1157 - var str = String(input);
1158 - var output = '';
1159 - for (
1160 - // initialize result and counter
1161 - var block, charCode, idx = 0, map = chars;
1162 - // if the next str index does not exist:
1163 - // change the mapping table to "="
1164 - // check if d has no fractional digits
1165 - str.charAt(idx | 0) || (map = '=', idx % 1);
1166 - // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
1167 - output += map.charAt(63 & block >> 8 - idx % 1 * 8)
1168 - ) {
1169 - charCode = str.charCodeAt(idx += 3 / 4);
1170 - if (charCode > 0xFF) {
1171 - throw new E();
1172 - }
1173 - block = block << 8 | charCode;
1174 - }
1175 - return output;
1176 - }
1177 -
1178 - module.exports = btoa;
1179 -
1180 -
1181 -/***/ },
1182 -/* 16 */
1183 -/***/ function(module, exports, __webpack_require__) {
1184 1390
1185 'use strict'; 1391 'use strict';
1186 1392
...@@ -1190,236 +1396,56 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1190,236 +1396,56 @@ return /******/ (function(modules) { // webpackBootstrap
1190 utils.isStandardBrowserEnv() ? 1396 utils.isStandardBrowserEnv() ?
1191 1397
1192 // Standard browser envs support document.cookie 1398 // Standard browser envs support document.cookie
1193 - (function standardBrowserEnv() { 1399 + (function standardBrowserEnv() {
1194 - return { 1400 + return {
1195 - write: function write(name, value, expires, path, domain, secure) { 1401 + write: function write(name, value, expires, path, domain, secure) {
1196 - var cookie = []; 1402 + var cookie = [];
1197 - cookie.push(name + '=' + encodeURIComponent(value)); 1403 + cookie.push(name + '=' + encodeURIComponent(value));
1198 1404
1199 - if (utils.isNumber(expires)) { 1405 + if (utils.isNumber(expires)) {
1200 - cookie.push('expires=' + new Date(expires).toGMTString()); 1406 + cookie.push('expires=' + new Date(expires).toGMTString());
1201 - } 1407 + }
1202 1408
1203 - if (utils.isString(path)) { 1409 + if (utils.isString(path)) {
1204 - cookie.push('path=' + path); 1410 + cookie.push('path=' + path);
1205 - } 1411 + }
1206 1412
1207 - if (utils.isString(domain)) { 1413 + if (utils.isString(domain)) {
1208 - cookie.push('domain=' + domain); 1414 + cookie.push('domain=' + domain);
1209 - } 1415 + }
1210 1416
1211 - if (secure === true) { 1417 + if (secure === true) {
1212 - cookie.push('secure'); 1418 + cookie.push('secure');
1213 - } 1419 + }
1214 1420
1215 - document.cookie = cookie.join('; '); 1421 + document.cookie = cookie.join('; ');
1216 - }, 1422 + },
1217 1423
1218 - read: function read(name) { 1424 + read: function read(name) {
1219 - var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 1425 + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1220 - return (match ? decodeURIComponent(match[3]) : null); 1426 + return (match ? decodeURIComponent(match[3]) : null);
1221 - }, 1427 + },
1222 1428
1223 - remove: function remove(name) { 1429 + remove: function remove(name) {
1224 - this.write(name, '', Date.now() - 86400000); 1430 + this.write(name, '', Date.now() - 86400000);
1225 - } 1431 + }
1226 - }; 1432 + };
1227 - })() : 1433 + })() :
1228 1434
1229 // Non standard browser env (web workers, react-native) lack needed support. 1435 // Non standard browser env (web workers, react-native) lack needed support.
1230 - (function nonStandardBrowserEnv() { 1436 + (function nonStandardBrowserEnv() {
1231 - return { 1437 + return {
1232 - write: function write() {}, 1438 + write: function write() {},
1233 - read: function read() { return null; }, 1439 + read: function read() { return null; },
1234 - remove: function remove() {} 1440 + remove: function remove() {}
1235 - }; 1441 + };
1236 - })() 1442 + })()
1237 ); 1443 );
1238 1444
1239 1445
1240 -/***/ }, 1446 +/***/ }),
1241 -/* 17 */
1242 -/***/ function(module, exports, __webpack_require__) {
1243 -
1244 - 'use strict';
1245 -
1246 - var utils = __webpack_require__(2);
1247 -
1248 - function InterceptorManager() {
1249 - this.handlers = [];
1250 - }
1251 -
1252 - /**
1253 - * Add a new interceptor to the stack
1254 - *
1255 - * @param {Function} fulfilled The function to handle `then` for a `Promise`
1256 - * @param {Function} rejected The function to handle `reject` for a `Promise`
1257 - *
1258 - * @return {Number} An ID used to remove interceptor later
1259 - */
1260 - InterceptorManager.prototype.use = function use(fulfilled, rejected) {
1261 - this.handlers.push({
1262 - fulfilled: fulfilled,
1263 - rejected: rejected
1264 - });
1265 - return this.handlers.length - 1;
1266 - };
1267 -
1268 - /**
1269 - * Remove an interceptor from the stack
1270 - *
1271 - * @param {Number} id The ID that was returned by `use`
1272 - */
1273 - InterceptorManager.prototype.eject = function eject(id) {
1274 - if (this.handlers[id]) {
1275 - this.handlers[id] = null;
1276 - }
1277 - };
1278 -
1279 - /**
1280 - * Iterate over all the registered interceptors
1281 - *
1282 - * This method is particularly useful for skipping over any
1283 - * interceptors that may have become `null` calling `eject`.
1284 - *
1285 - * @param {Function} fn The function to call for each interceptor
1286 - */
1287 - InterceptorManager.prototype.forEach = function forEach(fn) {
1288 - utils.forEach(this.handlers, function forEachHandler(h) {
1289 - if (h !== null) {
1290 - fn(h);
1291 - }
1292 - });
1293 - };
1294 -
1295 - module.exports = InterceptorManager;
1296 -
1297 -
1298 -/***/ },
1299 -/* 18 */
1300 -/***/ function(module, exports, __webpack_require__) {
1301 -
1302 - 'use strict';
1303 -
1304 - var utils = __webpack_require__(2);
1305 - var transformData = __webpack_require__(19);
1306 - var isCancel = __webpack_require__(20);
1307 - var defaults = __webpack_require__(6);
1308 -
1309 - /**
1310 - * Throws a `Cancel` if cancellation has been requested.
1311 - */
1312 - function throwIfCancellationRequested(config) {
1313 - if (config.cancelToken) {
1314 - config.cancelToken.throwIfRequested();
1315 - }
1316 - }
1317 -
1318 - /**
1319 - * Dispatch a request to the server using the configured adapter.
1320 - *
1321 - * @param {object} config The config that is to be used for the request
1322 - * @returns {Promise} The Promise to be fulfilled
1323 - */
1324 - module.exports = function dispatchRequest(config) {
1325 - throwIfCancellationRequested(config);
1326 -
1327 - // Ensure headers exist
1328 - config.headers = config.headers || {};
1329 -
1330 - // Transform request data
1331 - config.data = transformData(
1332 - config.data,
1333 - config.headers,
1334 - config.transformRequest
1335 - );
1336 -
1337 - // Flatten headers
1338 - config.headers = utils.merge(
1339 - config.headers.common || {},
1340 - config.headers[config.method] || {},
1341 - config.headers || {}
1342 - );
1343 -
1344 - utils.forEach(
1345 - ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
1346 - function cleanHeaderConfig(method) {
1347 - delete config.headers[method];
1348 - }
1349 - );
1350 -
1351 - var adapter = config.adapter || defaults.adapter;
1352 -
1353 - return adapter(config).then(function onAdapterResolution(response) {
1354 - throwIfCancellationRequested(config);
1355 -
1356 - // Transform response data
1357 - response.data = transformData(
1358 - response.data,
1359 - response.headers,
1360 - config.transformResponse
1361 - );
1362 -
1363 - return response;
1364 - }, function onAdapterRejection(reason) {
1365 - if (!isCancel(reason)) {
1366 - throwIfCancellationRequested(config);
1367 -
1368 - // Transform response data
1369 - if (reason && reason.response) {
1370 - reason.response.data = transformData(
1371 - reason.response.data,
1372 - reason.response.headers,
1373 - config.transformResponse
1374 - );
1375 - }
1376 - }
1377 -
1378 - return Promise.reject(reason);
1379 - });
1380 - };
1381 -
1382 -
1383 -/***/ },
1384 -/* 19 */
1385 -/***/ function(module, exports, __webpack_require__) {
1386 -
1387 - 'use strict';
1388 -
1389 - var utils = __webpack_require__(2);
1390 -
1391 - /**
1392 - * Transform the data for a request or a response
1393 - *
1394 - * @param {Object|String} data The data to be transformed
1395 - * @param {Array} headers The headers for the request or response
1396 - * @param {Array|Function} fns A single function or Array of functions
1397 - * @returns {*} The resulting transformed data
1398 - */
1399 - module.exports = function transformData(data, headers, fns) {
1400 - /*eslint no-param-reassign:0*/
1401 - utils.forEach(fns, function transform(fn) {
1402 - data = fn(data, headers);
1403 - });
1404 -
1405 - return data;
1406 - };
1407 -
1408 -
1409 -/***/ },
1410 /* 20 */ 1447 /* 20 */
1411 -/***/ function(module, exports) { 1448 +/***/ (function(module, exports) {
1412 -
1413 - 'use strict';
1414 -
1415 - module.exports = function isCancel(value) {
1416 - return !!(value && value.__CANCEL__);
1417 - };
1418 -
1419 -
1420 -/***/ },
1421 -/* 21 */
1422 -/***/ function(module, exports) {
1423 1449
1424 'use strict'; 1450 'use strict';
1425 1451
...@@ -1437,9 +1463,9 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1437,9 +1463,9 @@ return /******/ (function(modules) { // webpackBootstrap
1437 }; 1463 };
1438 1464
1439 1465
1440 -/***/ }, 1466 +/***/ }),
1441 -/* 22 */ 1467 +/* 21 */
1442 -/***/ function(module, exports) { 1468 +/***/ (function(module, exports) {
1443 1469
1444 'use strict'; 1470 'use strict';
1445 1471
...@@ -1457,9 +1483,66 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1457,9 +1483,66 @@ return /******/ (function(modules) { // webpackBootstrap
1457 }; 1483 };
1458 1484
1459 1485
1460 -/***/ }, 1486 +/***/ }),
1487 +/* 22 */
1488 +/***/ (function(module, exports, __webpack_require__) {
1489 +
1490 + 'use strict';
1491 +
1492 + var utils = __webpack_require__(2);
1493 +
1494 + /**
1495 + * Config-specific merge-function which creates a new config-object
1496 + * by merging two configuration objects together.
1497 + *
1498 + * @param {Object} config1
1499 + * @param {Object} config2
1500 + * @returns {Object} New object resulting from merging config2 to config1
1501 + */
1502 + module.exports = function mergeConfig(config1, config2) {
1503 + // eslint-disable-next-line no-param-reassign
1504 + config2 = config2 || {};
1505 + var config = {};
1506 +
1507 + utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
1508 + if (typeof config2[prop] !== 'undefined') {
1509 + config[prop] = config2[prop];
1510 + }
1511 + });
1512 +
1513 + utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
1514 + if (utils.isObject(config2[prop])) {
1515 + config[prop] = utils.deepMerge(config1[prop], config2[prop]);
1516 + } else if (typeof config2[prop] !== 'undefined') {
1517 + config[prop] = config2[prop];
1518 + } else if (utils.isObject(config1[prop])) {
1519 + config[prop] = utils.deepMerge(config1[prop]);
1520 + } else if (typeof config1[prop] !== 'undefined') {
1521 + config[prop] = config1[prop];
1522 + }
1523 + });
1524 +
1525 + utils.forEach([
1526 + 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
1527 + 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
1528 + 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
1529 + 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
1530 + 'socketPath'
1531 + ], function defaultToConfig2(prop) {
1532 + if (typeof config2[prop] !== 'undefined') {
1533 + config[prop] = config2[prop];
1534 + } else if (typeof config1[prop] !== 'undefined') {
1535 + config[prop] = config1[prop];
1536 + }
1537 + });
1538 +
1539 + return config;
1540 + };
1541 +
1542 +
1543 +/***/ }),
1461 /* 23 */ 1544 /* 23 */
1462 -/***/ function(module, exports) { 1545 +/***/ (function(module, exports) {
1463 1546
1464 'use strict'; 1547 'use strict';
1465 1548
...@@ -1482,9 +1565,9 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1482,9 +1565,9 @@ return /******/ (function(modules) { // webpackBootstrap
1482 module.exports = Cancel; 1565 module.exports = Cancel;
1483 1566
1484 1567
1485 -/***/ }, 1568 +/***/ }),
1486 /* 24 */ 1569 /* 24 */
1487 -/***/ function(module, exports, __webpack_require__) { 1570 +/***/ (function(module, exports, __webpack_require__) {
1488 1571
1489 'use strict'; 1572 'use strict';
1490 1573
...@@ -1545,9 +1628,9 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1545,9 +1628,9 @@ return /******/ (function(modules) { // webpackBootstrap
1545 module.exports = CancelToken; 1628 module.exports = CancelToken;
1546 1629
1547 1630
1548 -/***/ }, 1631 +/***/ }),
1549 /* 25 */ 1632 /* 25 */
1550 -/***/ function(module, exports) { 1633 +/***/ (function(module, exports) {
1551 1634
1552 'use strict'; 1635 'use strict';
1553 1636
...@@ -1578,7 +1661,7 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -1578,7 +1661,7 @@ return /******/ (function(modules) { // webpackBootstrap
1578 }; 1661 };
1579 1662
1580 1663
1581 -/***/ } 1664 +/***/ })
1582 /******/ ]) 1665 /******/ ])
1583 }); 1666 });
1584 ; 1667 ;
......
This diff could not be displayed because it is too large.
1 -/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */ 1 +/* axios v0.19.0 | (c) 2019 by Matt Zabriskie */
2 -!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))}/*! 2 +!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){/*!
3 * Determine if an object is a Buffer 3 * Determine if an object is a Buffer
4 * 4 *
5 - * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> 5 + * @author Feross Aboukhadijeh <https://feross.org>
6 * @license MIT 6 * @license MIT
7 */ 7 */
8 -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)}}}])}); 8 +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)}}}])});
9 //# sourceMappingURL=axios.min.map 9 //# sourceMappingURL=axios.min.map
...\ No newline at end of file ...\ No newline at end of file
......
This diff could not be displayed because it is too large.
1 export interface AxiosTransformer { 1 export interface AxiosTransformer {
2 - (data: any): any; 2 + (data: any, headers?: any): any;
3 } 3 }
4 4
5 export interface AxiosAdapter { 5 export interface AxiosAdapter {
6 - (config: AxiosRequestConfig): AxiosPromise; 6 + (config: AxiosRequestConfig): AxiosPromise<any>;
7 } 7 }
8 8
9 export interface AxiosBasicCredentials { 9 export interface AxiosBasicCredentials {
...@@ -14,11 +14,33 @@ export interface AxiosBasicCredentials { ...@@ -14,11 +14,33 @@ export interface AxiosBasicCredentials {
14 export interface AxiosProxyConfig { 14 export interface AxiosProxyConfig {
15 host: string; 15 host: string;
16 port: number; 16 port: number;
17 -} 17 + auth?: {
18 + username: string;
19 + password:string;
20 + };
21 + protocol?: string;
22 +}
23 +
24 +export type Method =
25 + | 'get' | 'GET'
26 + | 'delete' | 'DELETE'
27 + | 'head' | 'HEAD'
28 + | 'options' | 'OPTIONS'
29 + | 'post' | 'POST'
30 + | 'put' | 'PUT'
31 + | 'patch' | 'PATCH'
32 +
33 +export type ResponseType =
34 + | 'arraybuffer'
35 + | 'blob'
36 + | 'document'
37 + | 'json'
38 + | 'text'
39 + | 'stream'
18 40
19 export interface AxiosRequestConfig { 41 export interface AxiosRequestConfig {
20 url?: string; 42 url?: string;
21 - method?: string; 43 + method?: Method;
22 baseURL?: string; 44 baseURL?: string;
23 transformRequest?: AxiosTransformer | AxiosTransformer[]; 45 transformRequest?: AxiosTransformer | AxiosTransformer[];
24 transformResponse?: AxiosTransformer | AxiosTransformer[]; 46 transformResponse?: AxiosTransformer | AxiosTransformer[];
...@@ -30,7 +52,7 @@ export interface AxiosRequestConfig { ...@@ -30,7 +52,7 @@ export interface AxiosRequestConfig {
30 withCredentials?: boolean; 52 withCredentials?: boolean;
31 adapter?: AxiosAdapter; 53 adapter?: AxiosAdapter;
32 auth?: AxiosBasicCredentials; 54 auth?: AxiosBasicCredentials;
33 - responseType?: string; 55 + responseType?: ResponseType;
34 xsrfCookieName?: string; 56 xsrfCookieName?: string;
35 xsrfHeaderName?: string; 57 xsrfHeaderName?: string;
36 onUploadProgress?: (progressEvent: any) => void; 58 onUploadProgress?: (progressEvent: any) => void;
...@@ -38,27 +60,31 @@ export interface AxiosRequestConfig { ...@@ -38,27 +60,31 @@ export interface AxiosRequestConfig {
38 maxContentLength?: number; 60 maxContentLength?: number;
39 validateStatus?: (status: number) => boolean; 61 validateStatus?: (status: number) => boolean;
40 maxRedirects?: number; 62 maxRedirects?: number;
63 + socketPath?: string | null;
41 httpAgent?: any; 64 httpAgent?: any;
42 httpsAgent?: any; 65 httpsAgent?: any;
43 - proxy?: AxiosProxyConfig; 66 + proxy?: AxiosProxyConfig | false;
44 cancelToken?: CancelToken; 67 cancelToken?: CancelToken;
45 } 68 }
46 69
47 -export interface AxiosResponse { 70 +export interface AxiosResponse<T = any> {
48 - data: any; 71 + data: T;
49 status: number; 72 status: number;
50 statusText: string; 73 statusText: string;
51 headers: any; 74 headers: any;
52 config: AxiosRequestConfig; 75 config: AxiosRequestConfig;
76 + request?: any;
53 } 77 }
54 78
55 -export interface AxiosError extends Error { 79 +export interface AxiosError<T = any> extends Error {
56 config: AxiosRequestConfig; 80 config: AxiosRequestConfig;
57 code?: string; 81 code?: string;
58 - response?: AxiosResponse; 82 + request?: any;
83 + response?: AxiosResponse<T>;
84 + isAxiosError: boolean;
59 } 85 }
60 86
61 -export interface AxiosPromise extends Promise<AxiosResponse> { 87 +export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
62 } 88 }
63 89
64 export interface CancelStatic { 90 export interface CancelStatic {
...@@ -90,28 +116,29 @@ export interface CancelTokenSource { ...@@ -90,28 +116,29 @@ export interface CancelTokenSource {
90 } 116 }
91 117
92 export interface AxiosInterceptorManager<V> { 118 export interface AxiosInterceptorManager<V> {
93 - use(onFulfilled: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number; 119 + use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
94 eject(id: number): void; 120 eject(id: number): void;
95 } 121 }
96 122
97 export interface AxiosInstance { 123 export interface AxiosInstance {
124 + (config: AxiosRequestConfig): AxiosPromise;
125 + (url: string, config?: AxiosRequestConfig): AxiosPromise;
98 defaults: AxiosRequestConfig; 126 defaults: AxiosRequestConfig;
99 interceptors: { 127 interceptors: {
100 request: AxiosInterceptorManager<AxiosRequestConfig>; 128 request: AxiosInterceptorManager<AxiosRequestConfig>;
101 response: AxiosInterceptorManager<AxiosResponse>; 129 response: AxiosInterceptorManager<AxiosResponse>;
102 }; 130 };
103 - request(config: AxiosRequestConfig): AxiosPromise; 131 + getUri(config?: AxiosRequestConfig): string;
104 - get(url: string, config?: AxiosRequestConfig): AxiosPromise; 132 + request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>;
105 - delete(url: string, config?: AxiosRequestConfig): AxiosPromise; 133 + get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
106 - head(url: string, config?: AxiosRequestConfig): AxiosPromise; 134 + delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
107 - post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; 135 + head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
108 - put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; 136 + post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
109 - patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; 137 + put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
138 + patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
110 } 139 }
111 140
112 export interface AxiosStatic extends AxiosInstance { 141 export interface AxiosStatic extends AxiosInstance {
113 - (config: AxiosRequestConfig): AxiosPromise;
114 - (url: string, config?: AxiosRequestConfig): AxiosPromise;
115 create(config?: AxiosRequestConfig): AxiosInstance; 142 create(config?: AxiosRequestConfig): AxiosInstance;
116 Cancel: CancelStatic; 143 Cancel: CancelStatic;
117 CancelToken: CancelTokenStatic; 144 CancelToken: CancelTokenStatic;
......
...@@ -13,17 +13,26 @@ var pkg = require('./../../package.json'); ...@@ -13,17 +13,26 @@ var pkg = require('./../../package.json');
13 var createError = require('../core/createError'); 13 var createError = require('../core/createError');
14 var enhanceError = require('../core/enhanceError'); 14 var enhanceError = require('../core/enhanceError');
15 15
16 +var isHttps = /https:?/;
17 +
16 /*eslint consistent-return:0*/ 18 /*eslint consistent-return:0*/
17 module.exports = function httpAdapter(config) { 19 module.exports = function httpAdapter(config) {
18 - return new Promise(function dispatchHttpRequest(resolve, reject) { 20 + return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
21 + var timer;
22 + var resolve = function resolve(value) {
23 + clearTimeout(timer);
24 + resolvePromise(value);
25 + };
26 + var reject = function reject(value) {
27 + clearTimeout(timer);
28 + rejectPromise(value);
29 + };
19 var data = config.data; 30 var data = config.data;
20 var headers = config.headers; 31 var headers = config.headers;
21 - var timer;
22 - var aborted = false;
23 32
24 // Set User-Agent (required by some servers) 33 // Set User-Agent (required by some servers)
25 // Only set header if it hasn't been set in config 34 // Only set header if it hasn't been set in config
26 - // See https://github.com/mzabriskie/axios/issues/69 35 + // See https://github.com/axios/axios/issues/69
27 if (!headers['User-Agent'] && !headers['user-agent']) { 36 if (!headers['User-Agent'] && !headers['user-agent']) {
28 headers['User-Agent'] = 'axios/' + pkg.version; 37 headers['User-Agent'] = 'axios/' + pkg.version;
29 } 38 }
...@@ -32,9 +41,9 @@ module.exports = function httpAdapter(config) { ...@@ -32,9 +41,9 @@ module.exports = function httpAdapter(config) {
32 if (Buffer.isBuffer(data)) { 41 if (Buffer.isBuffer(data)) {
33 // Nothing to do... 42 // Nothing to do...
34 } else if (utils.isArrayBuffer(data)) { 43 } else if (utils.isArrayBuffer(data)) {
35 - data = new Buffer(new Uint8Array(data)); 44 + data = Buffer.from(new Uint8Array(data));
36 } else if (utils.isString(data)) { 45 } else if (utils.isString(data)) {
37 - data = new Buffer(data, 'utf-8'); 46 + data = Buffer.from(data, 'utf-8');
38 } else { 47 } else {
39 return reject(createError( 48 return reject(createError(
40 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', 49 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
...@@ -69,36 +78,69 @@ module.exports = function httpAdapter(config) { ...@@ -69,36 +78,69 @@ module.exports = function httpAdapter(config) {
69 delete headers.Authorization; 78 delete headers.Authorization;
70 } 79 }
71 80
72 - var isHttps = protocol === 'https:'; 81 + var isHttpsRequest = isHttps.test(protocol);
73 - var agent = isHttps ? config.httpsAgent : config.httpAgent; 82 + var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
74 83
75 var options = { 84 var options = {
76 - hostname: parsed.hostname,
77 - port: parsed.port,
78 path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), 85 path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
79 - method: config.method, 86 + method: config.method.toUpperCase(),
80 headers: headers, 87 headers: headers,
81 agent: agent, 88 agent: agent,
82 auth: auth 89 auth: auth
83 }; 90 };
84 91
92 + if (config.socketPath) {
93 + options.socketPath = config.socketPath;
94 + } else {
95 + options.hostname = parsed.hostname;
96 + options.port = parsed.port;
97 + }
98 +
85 var proxy = config.proxy; 99 var proxy = config.proxy;
86 - if (!proxy) { 100 + if (!proxy && proxy !== false) {
87 var proxyEnv = protocol.slice(0, -1) + '_proxy'; 101 var proxyEnv = protocol.slice(0, -1) + '_proxy';
88 var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; 102 var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
89 if (proxyUrl) { 103 if (proxyUrl) {
90 var parsedProxyUrl = url.parse(proxyUrl); 104 var parsedProxyUrl = url.parse(proxyUrl);
91 - proxy = { 105 + var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
92 - host: parsedProxyUrl.hostname, 106 + var shouldProxy = true;
93 - port: parsedProxyUrl.port 107 +
94 - }; 108 + if (noProxyEnv) {
95 - 109 + var noProxy = noProxyEnv.split(',').map(function trim(s) {
96 - if (parsedProxyUrl.auth) { 110 + return s.trim();
97 - var proxyUrlAuth = parsedProxyUrl.auth.split(':'); 111 + });
98 - proxy.auth = { 112 +
99 - username: proxyUrlAuth[0], 113 + shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
100 - password: proxyUrlAuth[1] 114 + if (!proxyElement) {
115 + return false;
116 + }
117 + if (proxyElement === '*') {
118 + return true;
119 + }
120 + if (proxyElement[0] === '.' &&
121 + parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement &&
122 + proxyElement.match(/\./g).length === parsed.hostname.match(/\./g).length) {
123 + return true;
124 + }
125 +
126 + return parsed.hostname === proxyElement;
127 + });
128 + }
129 +
130 +
131 + if (shouldProxy) {
132 + proxy = {
133 + host: parsedProxyUrl.hostname,
134 + port: parsedProxyUrl.port
101 }; 135 };
136 +
137 + if (parsedProxyUrl.auth) {
138 + var proxyUrlAuth = parsedProxyUrl.auth.split(':');
139 + proxy.auth = {
140 + username: proxyUrlAuth[0],
141 + password: proxyUrlAuth[1]
142 + };
143 + }
102 } 144 }
103 } 145 }
104 } 146 }
...@@ -112,28 +154,31 @@ module.exports = function httpAdapter(config) { ...@@ -112,28 +154,31 @@ module.exports = function httpAdapter(config) {
112 154
113 // Basic proxy authorization 155 // Basic proxy authorization
114 if (proxy.auth) { 156 if (proxy.auth) {
115 - var base64 = new Buffer(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); 157 + var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
116 options.headers['Proxy-Authorization'] = 'Basic ' + base64; 158 options.headers['Proxy-Authorization'] = 'Basic ' + base64;
117 } 159 }
118 } 160 }
119 161
120 var transport; 162 var transport;
121 - if (config.maxRedirects === 0) { 163 + var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
122 - transport = isHttps ? https : http; 164 + if (config.transport) {
165 + transport = config.transport;
166 + } else if (config.maxRedirects === 0) {
167 + transport = isHttpsProxy ? https : http;
123 } else { 168 } else {
124 if (config.maxRedirects) { 169 if (config.maxRedirects) {
125 options.maxRedirects = config.maxRedirects; 170 options.maxRedirects = config.maxRedirects;
126 } 171 }
127 - transport = isHttps ? httpsFollow : httpFollow; 172 + transport = isHttpsProxy ? httpsFollow : httpFollow;
173 + }
174 +
175 + if (config.maxContentLength && config.maxContentLength > -1) {
176 + options.maxBodyLength = config.maxContentLength;
128 } 177 }
129 178
130 // Create the request 179 // Create the request
131 var req = transport.request(options, function handleResponse(res) { 180 var req = transport.request(options, function handleResponse(res) {
132 - if (aborted) return; 181 + if (req.aborted) return;
133 -
134 - // Response has been received so kill timer that handles request timeout
135 - clearTimeout(timer);
136 - timer = null;
137 182
138 // uncompress the response body transparently if required 183 // uncompress the response body transparently if required
139 var stream = res; 184 var stream = res;
...@@ -143,7 +188,7 @@ module.exports = function httpAdapter(config) { ...@@ -143,7 +188,7 @@ module.exports = function httpAdapter(config) {
143 case 'compress': 188 case 'compress':
144 case 'deflate': 189 case 'deflate':
145 // add the unzipper to the body stream processing pipeline 190 // add the unzipper to the body stream processing pipeline
146 - stream = stream.pipe(zlib.createUnzip()); 191 + stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
147 192
148 // remove the content-encoding in order to not confuse downstream operations 193 // remove the content-encoding in order to not confuse downstream operations
149 delete res.headers['content-encoding']; 194 delete res.headers['content-encoding'];
...@@ -171,20 +216,21 @@ module.exports = function httpAdapter(config) { ...@@ -171,20 +216,21 @@ module.exports = function httpAdapter(config) {
171 216
172 // make sure the content length is not over the maxContentLength if specified 217 // make sure the content length is not over the maxContentLength if specified
173 if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) { 218 if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
219 + stream.destroy();
174 reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', 220 reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
175 config, null, lastRequest)); 221 config, null, lastRequest));
176 } 222 }
177 }); 223 });
178 224
179 stream.on('error', function handleStreamError(err) { 225 stream.on('error', function handleStreamError(err) {
180 - if (aborted) return; 226 + if (req.aborted) return;
181 reject(enhanceError(err, config, null, lastRequest)); 227 reject(enhanceError(err, config, null, lastRequest));
182 }); 228 });
183 229
184 stream.on('end', function handleStreamEnd() { 230 stream.on('end', function handleStreamEnd() {
185 var responseData = Buffer.concat(responseBuffer); 231 var responseData = Buffer.concat(responseBuffer);
186 if (config.responseType !== 'arraybuffer') { 232 if (config.responseType !== 'arraybuffer') {
187 - responseData = responseData.toString('utf8'); 233 + responseData = responseData.toString(config.responseEncoding);
188 } 234 }
189 235
190 response.data = responseData; 236 response.data = responseData;
...@@ -195,35 +241,33 @@ module.exports = function httpAdapter(config) { ...@@ -195,35 +241,33 @@ module.exports = function httpAdapter(config) {
195 241
196 // Handle errors 242 // Handle errors
197 req.on('error', function handleRequestError(err) { 243 req.on('error', function handleRequestError(err) {
198 - if (aborted) return; 244 + if (req.aborted) return;
199 reject(enhanceError(err, config, null, req)); 245 reject(enhanceError(err, config, null, req));
200 }); 246 });
201 247
202 // Handle request timeout 248 // Handle request timeout
203 - if (config.timeout && !timer) { 249 + if (config.timeout) {
204 timer = setTimeout(function handleRequestTimeout() { 250 timer = setTimeout(function handleRequestTimeout() {
205 req.abort(); 251 req.abort();
206 reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req)); 252 reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
207 - aborted = true;
208 }, config.timeout); 253 }, config.timeout);
209 } 254 }
210 255
211 if (config.cancelToken) { 256 if (config.cancelToken) {
212 // Handle cancellation 257 // Handle cancellation
213 config.cancelToken.promise.then(function onCanceled(cancel) { 258 config.cancelToken.promise.then(function onCanceled(cancel) {
214 - if (aborted) { 259 + if (req.aborted) return;
215 - return;
216 - }
217 260
218 req.abort(); 261 req.abort();
219 reject(cancel); 262 reject(cancel);
220 - aborted = true;
221 }); 263 });
222 } 264 }
223 265
224 // Send the request 266 // Send the request
225 if (utils.isStream(data)) { 267 if (utils.isStream(data)) {
226 - data.pipe(req); 268 + data.on('error', function handleStreamError(err) {
269 + reject(enhanceError(err, config, null, req));
270 + }).pipe(req);
227 } else { 271 } else {
228 req.end(data); 272 req.end(data);
229 } 273 }
......
...@@ -6,7 +6,6 @@ var buildURL = require('./../helpers/buildURL'); ...@@ -6,7 +6,6 @@ var buildURL = require('./../helpers/buildURL');
6 var parseHeaders = require('./../helpers/parseHeaders'); 6 var parseHeaders = require('./../helpers/parseHeaders');
7 var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); 7 var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
8 var createError = require('../core/createError'); 8 var createError = require('../core/createError');
9 -var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
10 9
11 module.exports = function xhrAdapter(config) { 10 module.exports = function xhrAdapter(config) {
12 return new Promise(function dispatchXhrRequest(resolve, reject) { 11 return new Promise(function dispatchXhrRequest(resolve, reject) {
...@@ -18,22 +17,6 @@ module.exports = function xhrAdapter(config) { ...@@ -18,22 +17,6 @@ module.exports = function xhrAdapter(config) {
18 } 17 }
19 18
20 var request = new XMLHttpRequest(); 19 var request = new XMLHttpRequest();
21 - var loadEvent = 'onreadystatechange';
22 - var xDomain = false;
23 -
24 - // For IE 8/9 CORS support
25 - // Only supports POST and GET calls and doesn't returns the response headers.
26 - // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
27 - if (process.env.NODE_ENV !== 'test' &&
28 - typeof window !== 'undefined' &&
29 - window.XDomainRequest && !('withCredentials' in request) &&
30 - !isURLSameOrigin(config.url)) {
31 - request = new window.XDomainRequest();
32 - loadEvent = 'onload';
33 - xDomain = true;
34 - request.onprogress = function handleProgress() {};
35 - request.ontimeout = function handleTimeout() {};
36 - }
37 20
38 // HTTP basic authentication 21 // HTTP basic authentication
39 if (config.auth) { 22 if (config.auth) {
...@@ -48,8 +31,8 @@ module.exports = function xhrAdapter(config) { ...@@ -48,8 +31,8 @@ module.exports = function xhrAdapter(config) {
48 request.timeout = config.timeout; 31 request.timeout = config.timeout;
49 32
50 // Listen for ready state 33 // Listen for ready state
51 - request[loadEvent] = function handleLoad() { 34 + request.onreadystatechange = function handleLoad() {
52 - if (!request || (request.readyState !== 4 && !xDomain)) { 35 + if (!request || request.readyState !== 4) {
53 return; 36 return;
54 } 37 }
55 38
...@@ -66,9 +49,8 @@ module.exports = function xhrAdapter(config) { ...@@ -66,9 +49,8 @@ module.exports = function xhrAdapter(config) {
66 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; 49 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
67 var response = { 50 var response = {
68 data: responseData, 51 data: responseData,
69 - // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201) 52 + status: request.status,
70 - status: request.status === 1223 ? 204 : request.status, 53 + statusText: request.statusText,
71 - statusText: request.status === 1223 ? 'No Content' : request.statusText,
72 headers: responseHeaders, 54 headers: responseHeaders,
73 config: config, 55 config: config,
74 request: request 56 request: request
...@@ -80,6 +62,18 @@ module.exports = function xhrAdapter(config) { ...@@ -80,6 +62,18 @@ module.exports = function xhrAdapter(config) {
80 request = null; 62 request = null;
81 }; 63 };
82 64
65 + // Handle browser request cancellation (as opposed to a manual cancellation)
66 + request.onabort = function handleAbort() {
67 + if (!request) {
68 + return;
69 + }
70 +
71 + reject(createError('Request aborted', config, 'ECONNABORTED', request));
72 +
73 + // Clean up request
74 + request = null;
75 + };
76 +
83 // Handle low level network errors 77 // Handle low level network errors
84 request.onerror = function handleError() { 78 request.onerror = function handleError() {
85 // Real errors are hidden from us by the browser 79 // Real errors are hidden from us by the browser
...@@ -107,8 +101,8 @@ module.exports = function xhrAdapter(config) { ...@@ -107,8 +101,8 @@ module.exports = function xhrAdapter(config) {
107 101
108 // Add xsrf header 102 // Add xsrf header
109 var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? 103 var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
110 - cookies.read(config.xsrfCookieName) : 104 + cookies.read(config.xsrfCookieName) :
111 - undefined; 105 + undefined;
112 106
113 if (xsrfValue) { 107 if (xsrfValue) {
114 requestHeaders[config.xsrfHeaderName] = xsrfValue; 108 requestHeaders[config.xsrfHeaderName] = xsrfValue;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
3 var utils = require('./utils'); 3 var utils = require('./utils');
4 var bind = require('./helpers/bind'); 4 var bind = require('./helpers/bind');
5 var Axios = require('./core/Axios'); 5 var Axios = require('./core/Axios');
6 +var mergeConfig = require('./core/mergeConfig');
6 var defaults = require('./defaults'); 7 var defaults = require('./defaults');
7 8
8 /** 9 /**
...@@ -32,7 +33,7 @@ axios.Axios = Axios; ...@@ -32,7 +33,7 @@ axios.Axios = Axios;
32 33
33 // Factory for creating new instances 34 // Factory for creating new instances
34 axios.create = function create(instanceConfig) { 35 axios.create = function create(instanceConfig) {
35 - return createInstance(utils.merge(defaults, instanceConfig)); 36 + return createInstance(mergeConfig(axios.defaults, instanceConfig));
36 }; 37 };
37 38
38 // Expose Cancel & CancelToken 39 // Expose Cancel & CancelToken
......
1 'use strict'; 1 'use strict';
2 2
3 -var defaults = require('./../defaults');
4 var utils = require('./../utils'); 3 var utils = require('./../utils');
4 +var buildURL = require('../helpers/buildURL');
5 var InterceptorManager = require('./InterceptorManager'); 5 var InterceptorManager = require('./InterceptorManager');
6 var dispatchRequest = require('./dispatchRequest'); 6 var dispatchRequest = require('./dispatchRequest');
7 -var isAbsoluteURL = require('./../helpers/isAbsoluteURL'); 7 +var mergeConfig = require('./mergeConfig');
8 -var combineURLs = require('./../helpers/combineURLs');
9 8
10 /** 9 /**
11 * Create a new instance of Axios 10 * Create a new instance of Axios
...@@ -29,18 +28,14 @@ Axios.prototype.request = function request(config) { ...@@ -29,18 +28,14 @@ Axios.prototype.request = function request(config) {
29 /*eslint no-param-reassign:0*/ 28 /*eslint no-param-reassign:0*/
30 // Allow for axios('example/url'[, config]) a la fetch API 29 // Allow for axios('example/url'[, config]) a la fetch API
31 if (typeof config === 'string') { 30 if (typeof config === 'string') {
32 - config = utils.merge({ 31 + config = arguments[1] || {};
33 - url: arguments[0] 32 + config.url = arguments[0];
34 - }, arguments[1]); 33 + } else {
34 + config = config || {};
35 } 35 }
36 36
37 - config = utils.merge(defaults, this.defaults, { method: 'get' }, config); 37 + config = mergeConfig(this.defaults, config);
38 - config.method = config.method.toLowerCase(); 38 + config.method = config.method ? config.method.toLowerCase() : 'get';
39 -
40 - // Support baseURL config
41 - if (config.baseURL && !isAbsoluteURL(config.url)) {
42 - config.url = combineURLs(config.baseURL, config.url);
43 - }
44 39
45 // Hook up interceptors middleware 40 // Hook up interceptors middleware
46 var chain = [dispatchRequest, undefined]; 41 var chain = [dispatchRequest, undefined];
...@@ -61,6 +56,11 @@ Axios.prototype.request = function request(config) { ...@@ -61,6 +56,11 @@ Axios.prototype.request = function request(config) {
61 return promise; 56 return promise;
62 }; 57 };
63 58
59 +Axios.prototype.getUri = function getUri(config) {
60 + config = mergeConfig(this.defaults, config);
61 + return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
62 +};
63 +
64 // Provide aliases for supported request methods 64 // Provide aliases for supported request methods
65 utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 65 utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
66 /*eslint func-names:0*/ 66 /*eslint func-names:0*/
......
...@@ -4,6 +4,8 @@ var utils = require('./../utils'); ...@@ -4,6 +4,8 @@ var utils = require('./../utils');
4 var transformData = require('./transformData'); 4 var transformData = require('./transformData');
5 var isCancel = require('../cancel/isCancel'); 5 var isCancel = require('../cancel/isCancel');
6 var defaults = require('../defaults'); 6 var defaults = require('../defaults');
7 +var isAbsoluteURL = require('./../helpers/isAbsoluteURL');
8 +var combineURLs = require('./../helpers/combineURLs');
7 9
8 /** 10 /**
9 * Throws a `Cancel` if cancellation has been requested. 11 * Throws a `Cancel` if cancellation has been requested.
...@@ -23,6 +25,11 @@ function throwIfCancellationRequested(config) { ...@@ -23,6 +25,11 @@ function throwIfCancellationRequested(config) {
23 module.exports = function dispatchRequest(config) { 25 module.exports = function dispatchRequest(config) {
24 throwIfCancellationRequested(config); 26 throwIfCancellationRequested(config);
25 27
28 + // Support baseURL config
29 + if (config.baseURL && !isAbsoluteURL(config.url)) {
30 + config.url = combineURLs(config.baseURL, config.url);
31 + }
32 +
26 // Ensure headers exist 33 // Ensure headers exist
27 config.headers = config.headers || {}; 34 config.headers = config.headers || {};
28 35
......
...@@ -15,7 +15,28 @@ module.exports = function enhanceError(error, config, code, request, response) { ...@@ -15,7 +15,28 @@ module.exports = function enhanceError(error, config, code, request, response) {
15 if (code) { 15 if (code) {
16 error.code = code; 16 error.code = code;
17 } 17 }
18 +
18 error.request = request; 19 error.request = request;
19 error.response = response; 20 error.response = response;
21 + error.isAxiosError = true;
22 +
23 + error.toJSON = function() {
24 + return {
25 + // Standard
26 + message: this.message,
27 + name: this.name,
28 + // Microsoft
29 + description: this.description,
30 + number: this.number,
31 + // Mozilla
32 + fileName: this.fileName,
33 + lineNumber: this.lineNumber,
34 + columnNumber: this.columnNumber,
35 + stack: this.stack,
36 + // Axios
37 + config: this.config,
38 + code: this.code
39 + };
40 + };
20 return error; 41 return error;
21 }; 42 };
......
1 +'use strict';
2 +
3 +var utils = require('../utils');
4 +
5 +/**
6 + * Config-specific merge-function which creates a new config-object
7 + * by merging two configuration objects together.
8 + *
9 + * @param {Object} config1
10 + * @param {Object} config2
11 + * @returns {Object} New object resulting from merging config2 to config1
12 + */
13 +module.exports = function mergeConfig(config1, config2) {
14 + // eslint-disable-next-line no-param-reassign
15 + config2 = config2 || {};
16 + var config = {};
17 +
18 + utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
19 + if (typeof config2[prop] !== 'undefined') {
20 + config[prop] = config2[prop];
21 + }
22 + });
23 +
24 + utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
25 + if (utils.isObject(config2[prop])) {
26 + config[prop] = utils.deepMerge(config1[prop], config2[prop]);
27 + } else if (typeof config2[prop] !== 'undefined') {
28 + config[prop] = config2[prop];
29 + } else if (utils.isObject(config1[prop])) {
30 + config[prop] = utils.deepMerge(config1[prop]);
31 + } else if (typeof config1[prop] !== 'undefined') {
32 + config[prop] = config1[prop];
33 + }
34 + });
35 +
36 + utils.forEach([
37 + 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
38 + 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
39 + 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
40 + 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
41 + 'socketPath'
42 + ], function defaultToConfig2(prop) {
43 + if (typeof config2[prop] !== 'undefined') {
44 + config[prop] = config2[prop];
45 + } else if (typeof config1[prop] !== 'undefined') {
46 + config[prop] = config1[prop];
47 + }
48 + });
49 +
50 + return config;
51 +};
...@@ -11,8 +11,7 @@ var createError = require('./createError'); ...@@ -11,8 +11,7 @@ var createError = require('./createError');
11 */ 11 */
12 module.exports = function settle(resolve, reject, response) { 12 module.exports = function settle(resolve, reject, response) {
13 var validateStatus = response.config.validateStatus; 13 var validateStatus = response.config.validateStatus;
14 - // Note: status is not exposed by XDomainRequest 14 + if (!validateStatus || validateStatus(response.status)) {
15 - if (!response.status || !validateStatus || validateStatus(response.status)) {
16 resolve(response); 15 resolve(response);
17 } else { 16 } else {
18 reject(createError( 17 reject(createError(
......
...@@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) { ...@@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) {
15 15
16 function getDefaultAdapter() { 16 function getDefaultAdapter() {
17 var adapter; 17 var adapter;
18 - if (typeof XMLHttpRequest !== 'undefined') { 18 + // Only Node.JS has a process variable that is of [[Class]] process
19 - // For browsers use XHR adapter 19 + if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
20 - adapter = require('./adapters/xhr');
21 - } else if (typeof process !== 'undefined') {
22 // For node use HTTP adapter 20 // For node use HTTP adapter
23 adapter = require('./adapters/http'); 21 adapter = require('./adapters/http');
22 + } else if (typeof XMLHttpRequest !== 'undefined') {
23 + // For browsers use XHR adapter
24 + adapter = require('./adapters/xhr');
24 } 25 }
25 return adapter; 26 return adapter;
26 } 27 }
...@@ -29,6 +30,7 @@ var defaults = { ...@@ -29,6 +30,7 @@ var defaults = {
29 adapter: getDefaultAdapter(), 30 adapter: getDefaultAdapter(),
30 31
31 transformRequest: [function transformRequest(data, headers) { 32 transformRequest: [function transformRequest(data, headers) {
33 + normalizeHeaderName(headers, 'Accept');
32 normalizeHeaderName(headers, 'Content-Type'); 34 normalizeHeaderName(headers, 'Content-Type');
33 if (utils.isFormData(data) || 35 if (utils.isFormData(data) ||
34 utils.isArrayBuffer(data) || 36 utils.isArrayBuffer(data) ||
...@@ -63,6 +65,10 @@ var defaults = { ...@@ -63,6 +65,10 @@ var defaults = {
63 return data; 65 return data;
64 }], 66 }],
65 67
68 + /**
69 + * A timeout in milliseconds to abort a request. If set to 0 (default) a
70 + * timeout is not created.
71 + */
66 timeout: 0, 72 timeout: 0,
67 73
68 xsrfCookieName: 'XSRF-TOKEN', 74 xsrfCookieName: 'XSRF-TOKEN',
......
1 -'use strict';
2 -
3 -// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
4 -
5 -var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
6 -
7 -function E() {
8 - this.message = 'String contains an invalid character';
9 -}
10 -E.prototype = new Error;
11 -E.prototype.code = 5;
12 -E.prototype.name = 'InvalidCharacterError';
13 -
14 -function btoa(input) {
15 - var str = String(input);
16 - var output = '';
17 - for (
18 - // initialize result and counter
19 - var block, charCode, idx = 0, map = chars;
20 - // if the next str index does not exist:
21 - // change the mapping table to "="
22 - // check if d has no fractional digits
23 - str.charAt(idx | 0) || (map = '=', idx % 1);
24 - // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
25 - output += map.charAt(63 & block >> 8 - idx % 1 * 8)
26 - ) {
27 - charCode = str.charCodeAt(idx += 3 / 4);
28 - if (charCode > 0xFF) {
29 - throw new E();
30 - }
31 - block = block << 8 | charCode;
32 - }
33 - return output;
34 -}
35 -
36 -module.exports = btoa;
...@@ -41,9 +41,7 @@ module.exports = function buildURL(url, params, paramsSerializer) { ...@@ -41,9 +41,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
41 41
42 if (utils.isArray(val)) { 42 if (utils.isArray(val)) {
43 key = key + '[]'; 43 key = key + '[]';
44 - } 44 + } else {
45 -
46 - if (!utils.isArray(val)) {
47 val = [val]; 45 val = [val];
48 } 46 }
49 47
...@@ -61,6 +59,11 @@ module.exports = function buildURL(url, params, paramsSerializer) { ...@@ -61,6 +59,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
61 } 59 }
62 60
63 if (serializedParams) { 61 if (serializedParams) {
62 + var hashmarkIndex = url.indexOf('#');
63 + if (hashmarkIndex !== -1) {
64 + url = url.slice(0, hashmarkIndex);
65 + }
66 +
64 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 67 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
65 } 68 }
66 69
......
...@@ -6,48 +6,48 @@ module.exports = ( ...@@ -6,48 +6,48 @@ module.exports = (
6 utils.isStandardBrowserEnv() ? 6 utils.isStandardBrowserEnv() ?
7 7
8 // Standard browser envs support document.cookie 8 // Standard browser envs support document.cookie
9 - (function standardBrowserEnv() { 9 + (function standardBrowserEnv() {
10 - return { 10 + return {
11 - write: function write(name, value, expires, path, domain, secure) { 11 + write: function write(name, value, expires, path, domain, secure) {
12 - var cookie = []; 12 + var cookie = [];
13 - cookie.push(name + '=' + encodeURIComponent(value)); 13 + cookie.push(name + '=' + encodeURIComponent(value));
14 - 14 +
15 - if (utils.isNumber(expires)) { 15 + if (utils.isNumber(expires)) {
16 - cookie.push('expires=' + new Date(expires).toGMTString()); 16 + cookie.push('expires=' + new Date(expires).toGMTString());
17 + }
18 +
19 + if (utils.isString(path)) {
20 + cookie.push('path=' + path);
21 + }
22 +
23 + if (utils.isString(domain)) {
24 + cookie.push('domain=' + domain);
25 + }
26 +
27 + if (secure === true) {
28 + cookie.push('secure');
29 + }
30 +
31 + document.cookie = cookie.join('; ');
32 + },
33 +
34 + read: function read(name) {
35 + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36 + return (match ? decodeURIComponent(match[3]) : null);
37 + },
38 +
39 + remove: function remove(name) {
40 + this.write(name, '', Date.now() - 86400000);
17 } 41 }
18 - 42 + };
19 - if (utils.isString(path)) { 43 + })() :
20 - cookie.push('path=' + path);
21 - }
22 -
23 - if (utils.isString(domain)) {
24 - cookie.push('domain=' + domain);
25 - }
26 -
27 - if (secure === true) {
28 - cookie.push('secure');
29 - }
30 -
31 - document.cookie = cookie.join('; ');
32 - },
33 -
34 - read: function read(name) {
35 - var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36 - return (match ? decodeURIComponent(match[3]) : null);
37 - },
38 -
39 - remove: function remove(name) {
40 - this.write(name, '', Date.now() - 86400000);
41 - }
42 - };
43 - })() :
44 44
45 // Non standard browser env (web workers, react-native) lack needed support. 45 // Non standard browser env (web workers, react-native) lack needed support.
46 - (function nonStandardBrowserEnv() { 46 + (function nonStandardBrowserEnv() {
47 - return { 47 + return {
48 - write: function write() {}, 48 + write: function write() {},
49 - read: function read() { return null; }, 49 + read: function read() { return null; },
50 - remove: function remove() {} 50 + remove: function remove() {}
51 - }; 51 + };
52 - })() 52 + })()
53 ); 53 );
......
...@@ -7,62 +7,62 @@ module.exports = ( ...@@ -7,62 +7,62 @@ module.exports = (
7 7
8 // Standard browser envs have full support of the APIs needed to test 8 // Standard browser envs have full support of the APIs needed to test
9 // whether the request URL is of the same origin as current location. 9 // whether the request URL is of the same origin as current location.
10 - (function standardBrowserEnv() { 10 + (function standardBrowserEnv() {
11 - var msie = /(msie|trident)/i.test(navigator.userAgent); 11 + var msie = /(msie|trident)/i.test(navigator.userAgent);
12 - var urlParsingNode = document.createElement('a'); 12 + var urlParsingNode = document.createElement('a');
13 - var originURL; 13 + var originURL;
14 14
15 - /** 15 + /**
16 * Parse a URL to discover it's components 16 * Parse a URL to discover it's components
17 * 17 *
18 * @param {String} url The URL to be parsed 18 * @param {String} url The URL to be parsed
19 * @returns {Object} 19 * @returns {Object}
20 */ 20 */
21 - function resolveURL(url) { 21 + function resolveURL(url) {
22 - var href = url; 22 + var href = url;
23 23
24 - if (msie) { 24 + if (msie) {
25 // IE needs attribute set twice to normalize properties 25 // IE needs attribute set twice to normalize properties
26 - urlParsingNode.setAttribute('href', href); 26 + urlParsingNode.setAttribute('href', href);
27 - href = urlParsingNode.href; 27 + href = urlParsingNode.href;
28 - } 28 + }
29 29
30 - urlParsingNode.setAttribute('href', href); 30 + urlParsingNode.setAttribute('href', href);
31 31
32 - // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 32 + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33 - return { 33 + return {
34 - href: urlParsingNode.href, 34 + href: urlParsingNode.href,
35 - protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 35 + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36 - host: urlParsingNode.host, 36 + host: urlParsingNode.host,
37 - search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 37 + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38 - hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 38 + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39 - hostname: urlParsingNode.hostname, 39 + hostname: urlParsingNode.hostname,
40 - port: urlParsingNode.port, 40 + port: urlParsingNode.port,
41 - pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 41 + pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42 - urlParsingNode.pathname : 42 + urlParsingNode.pathname :
43 - '/' + urlParsingNode.pathname 43 + '/' + urlParsingNode.pathname
44 - }; 44 + };
45 - } 45 + }
46 46
47 - originURL = resolveURL(window.location.href); 47 + originURL = resolveURL(window.location.href);
48 48
49 - /** 49 + /**
50 * Determine if a URL shares the same origin as the current location 50 * Determine if a URL shares the same origin as the current location
51 * 51 *
52 * @param {String} requestURL The URL to test 52 * @param {String} requestURL The URL to test
53 * @returns {boolean} True if URL shares the same origin, otherwise false 53 * @returns {boolean} True if URL shares the same origin, otherwise false
54 */ 54 */
55 - return function isURLSameOrigin(requestURL) { 55 + return function isURLSameOrigin(requestURL) {
56 - var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 56 + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57 - return (parsed.protocol === originURL.protocol && 57 + return (parsed.protocol === originURL.protocol &&
58 parsed.host === originURL.host); 58 parsed.host === originURL.host);
59 - }; 59 + };
60 - })() : 60 + })() :
61 61
62 // Non standard browser envs (web workers, react-native) lack needed support. 62 // Non standard browser envs (web workers, react-native) lack needed support.
63 - (function nonStandardBrowserEnv() { 63 + (function nonStandardBrowserEnv() {
64 - return function isURLSameOrigin() { 64 + return function isURLSameOrigin() {
65 - return true; 65 + return true;
66 - }; 66 + };
67 - })() 67 + })()
68 ); 68 );
......
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
2 2
3 var utils = require('./../utils'); 3 var utils = require('./../utils');
4 4
5 +// Headers whose duplicates are ignored by node
6 +// c.f. https://nodejs.org/api/http.html#http_message_headers
7 +var ignoreDuplicateOf = [
8 + 'age', 'authorization', 'content-length', 'content-type', 'etag',
9 + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
10 + 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
11 + 'referer', 'retry-after', 'user-agent'
12 +];
13 +
5 /** 14 /**
6 * Parse headers into an object 15 * Parse headers into an object
7 * 16 *
...@@ -29,7 +38,14 @@ module.exports = function parseHeaders(headers) { ...@@ -29,7 +38,14 @@ module.exports = function parseHeaders(headers) {
29 val = utils.trim(line.substr(i + 1)); 38 val = utils.trim(line.substr(i + 1));
30 39
31 if (key) { 40 if (key) {
32 - parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 41 + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
42 + return;
43 + }
44 + if (key === 'set-cookie') {
45 + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
46 + } else {
47 + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
48 + }
33 } 49 }
34 }); 50 });
35 51
......
...@@ -177,9 +177,13 @@ function trim(str) { ...@@ -177,9 +177,13 @@ function trim(str) {
177 * 177 *
178 * react-native: 178 * react-native:
179 * navigator.product -> 'ReactNative' 179 * navigator.product -> 'ReactNative'
180 + * nativescript
181 + * navigator.product -> 'NativeScript' or 'NS'
180 */ 182 */
181 function isStandardBrowserEnv() { 183 function isStandardBrowserEnv() {
182 - if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { 184 + if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
185 + navigator.product === 'NativeScript' ||
186 + navigator.product === 'NS')) {
183 return false; 187 return false;
184 } 188 }
185 return ( 189 return (
...@@ -207,7 +211,7 @@ function forEach(obj, fn) { ...@@ -207,7 +211,7 @@ function forEach(obj, fn) {
207 } 211 }
208 212
209 // Force an array if not already something iterable 213 // Force an array if not already something iterable
210 - if (typeof obj !== 'object' && !isArray(obj)) { 214 + if (typeof obj !== 'object') {
211 /*eslint no-param-reassign:0*/ 215 /*eslint no-param-reassign:0*/
212 obj = [obj]; 216 obj = [obj];
213 } 217 }
...@@ -261,6 +265,32 @@ function merge(/* obj1, obj2, obj3, ... */) { ...@@ -261,6 +265,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
261 } 265 }
262 266
263 /** 267 /**
268 + * Function equal to merge with the difference being that no reference
269 + * to original objects is kept.
270 + *
271 + * @see merge
272 + * @param {Object} obj1 Object to merge
273 + * @returns {Object} Result of all merge properties
274 + */
275 +function deepMerge(/* obj1, obj2, obj3, ... */) {
276 + var result = {};
277 + function assignValue(val, key) {
278 + if (typeof result[key] === 'object' && typeof val === 'object') {
279 + result[key] = deepMerge(result[key], val);
280 + } else if (typeof val === 'object') {
281 + result[key] = deepMerge({}, val);
282 + } else {
283 + result[key] = val;
284 + }
285 + }
286 +
287 + for (var i = 0, l = arguments.length; i < l; i++) {
288 + forEach(arguments[i], assignValue);
289 + }
290 + return result;
291 +}
292 +
293 +/**
264 * Extends object a by mutably adding to it the properties of object b. 294 * Extends object a by mutably adding to it the properties of object b.
265 * 295 *
266 * @param {Object} a The object to be extended 296 * @param {Object} a The object to be extended
...@@ -298,6 +328,7 @@ module.exports = { ...@@ -298,6 +328,7 @@ module.exports = {
298 isStandardBrowserEnv: isStandardBrowserEnv, 328 isStandardBrowserEnv: isStandardBrowserEnv,
299 forEach: forEach, 329 forEach: forEach,
300 merge: merge, 330 merge: merge,
331 + deepMerge: deepMerge,
301 extend: extend, 332 extend: extend,
302 trim: trim 333 trim: trim
303 }; 334 };
......
1 { 1 {
2 - "_from": "axios@^0.16.2", 2 + "_from": "axios@^0.19.0",
3 - "_id": "axios@0.16.2", 3 + "_id": "axios@0.19.0",
4 "_inBundle": false, 4 "_inBundle": false,
5 - "_integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=", 5 + "_integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
6 "_location": "/axios", 6 "_location": "/axios",
7 "_phantomChildren": {}, 7 "_phantomChildren": {},
8 "_requested": { 8 "_requested": {
9 "type": "range", 9 "type": "range",
10 "registry": true, 10 "registry": true,
11 - "raw": "axios@^0.16.2", 11 + "raw": "axios@^0.19.0",
12 "name": "axios", 12 "name": "axios",
13 "escapedName": "axios", 13 "escapedName": "axios",
14 - "rawSpec": "^0.16.2", 14 + "rawSpec": "^0.19.0",
15 "saveSpec": null, 15 "saveSpec": null,
16 - "fetchSpec": "^0.16.2" 16 + "fetchSpec": "^0.19.0"
17 }, 17 },
18 "_requiredBy": [ 18 "_requiredBy": [
19 "/@line/bot-sdk" 19 "/@line/bot-sdk"
20 ], 20 ],
21 - "_resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz", 21 + "_resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
22 - "_shasum": "ba4f92f17167dfbab40983785454b9ac149c3c6d", 22 + "_shasum": "8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8",
23 - "_spec": "axios@^0.16.2", 23 + "_spec": "axios@^0.19.0",
24 - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk", 24 + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk",
25 "author": { 25 "author": {
26 "name": "Matt Zabriskie" 26 "name": "Matt Zabriskie"
27 }, 27 },
...@@ -29,53 +29,59 @@ ...@@ -29,53 +29,59 @@
29 "./lib/adapters/http.js": "./lib/adapters/xhr.js" 29 "./lib/adapters/http.js": "./lib/adapters/xhr.js"
30 }, 30 },
31 "bugs": { 31 "bugs": {
32 - "url": "https://github.com/mzabriskie/axios/issues" 32 + "url": "https://github.com/axios/axios/issues"
33 }, 33 },
34 "bundleDependencies": false, 34 "bundleDependencies": false,
35 + "bundlesize": [
36 + {
37 + "path": "./dist/axios.min.js",
38 + "threshold": "5kB"
39 + }
40 + ],
35 "dependencies": { 41 "dependencies": {
36 - "follow-redirects": "^1.2.3", 42 + "follow-redirects": "1.5.10",
37 - "is-buffer": "^1.1.5" 43 + "is-buffer": "^2.0.2"
38 }, 44 },
39 "deprecated": false, 45 "deprecated": false,
40 "description": "Promise based HTTP client for the browser and node.js", 46 "description": "Promise based HTTP client for the browser and node.js",
41 "devDependencies": { 47 "devDependencies": {
42 - "coveralls": "^2.11.9", 48 + "bundlesize": "^0.17.0",
43 - "es6-promise": "^4.0.5", 49 + "coveralls": "^3.0.0",
44 - "grunt": "^1.0.1", 50 + "es6-promise": "^4.2.4",
51 + "grunt": "^1.0.2",
45 "grunt-banner": "^0.6.0", 52 "grunt-banner": "^0.6.0",
46 "grunt-cli": "^1.2.0", 53 "grunt-cli": "^1.2.0",
47 - "grunt-contrib-clean": "^1.0.0", 54 + "grunt-contrib-clean": "^1.1.0",
48 - "grunt-contrib-nodeunit": "^1.0.0",
49 "grunt-contrib-watch": "^1.0.0", 55 "grunt-contrib-watch": "^1.0.0",
50 - "grunt-eslint": "^19.0.0", 56 + "grunt-eslint": "^20.1.0",
51 "grunt-karma": "^2.0.0", 57 "grunt-karma": "^2.0.0",
52 - "grunt-ts": "^6.0.0-beta.3", 58 + "grunt-mocha-test": "^0.13.3",
59 + "grunt-ts": "^6.0.0-beta.19",
53 "grunt-webpack": "^1.0.18", 60 "grunt-webpack": "^1.0.18",
54 "istanbul-instrumenter-loader": "^1.0.0", 61 "istanbul-instrumenter-loader": "^1.0.0",
55 "jasmine-core": "^2.4.1", 62 "jasmine-core": "^2.4.1",
56 "karma": "^1.3.0", 63 "karma": "^1.3.0",
57 - "karma-chrome-launcher": "^2.0.0", 64 + "karma-chrome-launcher": "^2.2.0",
58 - "karma-coverage": "^1.0.0", 65 + "karma-coverage": "^1.1.1",
59 - "karma-firefox-launcher": "^1.0.0", 66 + "karma-firefox-launcher": "^1.1.0",
60 - "karma-jasmine": "^1.0.2", 67 + "karma-jasmine": "^1.1.1",
61 "karma-jasmine-ajax": "^0.1.13", 68 "karma-jasmine-ajax": "^0.1.13",
62 "karma-opera-launcher": "^1.0.0", 69 "karma-opera-launcher": "^1.0.0",
63 - "karma-phantomjs-launcher": "^1.0.0",
64 "karma-safari-launcher": "^1.0.0", 70 "karma-safari-launcher": "^1.0.0",
65 - "karma-sauce-launcher": "^1.1.0", 71 + "karma-sauce-launcher": "^1.2.0",
66 "karma-sinon": "^1.0.5", 72 "karma-sinon": "^1.0.5",
67 "karma-sourcemap-loader": "^0.3.7", 73 "karma-sourcemap-loader": "^0.3.7",
68 "karma-webpack": "^1.7.0", 74 "karma-webpack": "^1.7.0",
69 "load-grunt-tasks": "^3.5.2", 75 "load-grunt-tasks": "^3.5.2",
70 "minimist": "^1.2.0", 76 "minimist": "^1.2.0",
71 - "phantomjs-prebuilt": "^2.1.7", 77 + "mocha": "^5.2.0",
72 - "sinon": "^1.17.4", 78 + "sinon": "^4.5.0",
73 - "typescript": "^2.0.3", 79 + "typescript": "^2.8.1",
74 - "url-search-params": "^0.6.1", 80 + "url-search-params": "^0.10.0",
75 "webpack": "^1.13.1", 81 "webpack": "^1.13.1",
76 "webpack-dev-server": "^1.14.1" 82 "webpack-dev-server": "^1.14.1"
77 }, 83 },
78 - "homepage": "https://github.com/mzabriskie/axios", 84 + "homepage": "https://github.com/axios/axios",
79 "keywords": [ 85 "keywords": [
80 "xhr", 86 "xhr",
81 "http", 87 "http",
...@@ -88,18 +94,19 @@ ...@@ -88,18 +94,19 @@
88 "name": "axios", 94 "name": "axios",
89 "repository": { 95 "repository": {
90 "type": "git", 96 "type": "git",
91 - "url": "git+https://github.com/mzabriskie/axios.git" 97 + "url": "git+https://github.com/axios/axios.git"
92 }, 98 },
93 "scripts": { 99 "scripts": {
94 "build": "NODE_ENV=production grunt build", 100 "build": "NODE_ENV=production grunt build",
95 "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", 101 "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
96 "examples": "node ./examples/server.js", 102 "examples": "node ./examples/server.js",
103 + "fix": "eslint --fix lib/**/*.js",
97 "postversion": "git push && git push --tags", 104 "postversion": "git push && git push --tags",
98 "preversion": "npm test", 105 "preversion": "npm test",
99 "start": "node ./sandbox/server.js", 106 "start": "node ./sandbox/server.js",
100 - "test": "grunt test", 107 + "test": "grunt test && bundlesize",
101 "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json" 108 "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"
102 }, 109 },
103 "typings": "./index.d.ts", 110 "typings": "./index.d.ts",
104 - "version": "0.16.2" 111 + "version": "0.19.0"
105 } 112 }
......
...@@ -28,12 +28,15 @@ It's future-proof and works in node too! ...@@ -28,12 +28,15 @@ It's future-proof and works in node too!
28 npm install is-buffer 28 npm install is-buffer
29 ``` 29 ```
30 30
31 +[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)
32 +
31 ## usage 33 ## usage
32 34
33 ```js 35 ```js
34 var isBuffer = require('is-buffer') 36 var isBuffer = require('is-buffer')
35 37
36 isBuffer(new Buffer(4)) // true 38 isBuffer(new Buffer(4)) // true
39 +isBuffer(Buffer.alloc(4)) //true
37 40
38 isBuffer(undefined) // false 41 isBuffer(undefined) // false
39 isBuffer(null) // false 42 isBuffer(null) // false
......
1 +declare function isBuffer(obj: any): boolean
2 +export = isBuffer
...@@ -5,17 +5,7 @@ ...@@ -5,17 +5,7 @@
5 * @license MIT 5 * @license MIT
6 */ 6 */
7 7
8 -// The _isBuffer check is for Safari 5-7 support, because it's missing 8 +module.exports = function isBuffer (obj) {
9 -// Object.prototype.constructor. Remove this eventually 9 + return obj != null && obj.constructor != null &&
10 -module.exports = function (obj) { 10 + typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
11 - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
12 -}
13 -
14 -function isBuffer (obj) {
15 - return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
16 -}
17 -
18 -// For Node v0.10 support. Remove this eventually.
19 -function isSlowBuffer (obj) {
20 - return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
21 } 11 }
......
1 { 1 {
2 - "_from": "is-buffer@^1.1.5", 2 + "_from": "is-buffer@^2.0.2",
3 - "_id": "is-buffer@1.1.6", 3 + "_id": "is-buffer@2.0.4",
4 "_inBundle": false, 4 "_inBundle": false,
5 - "_integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", 5 + "_integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==",
6 "_location": "/is-buffer", 6 "_location": "/is-buffer",
7 "_phantomChildren": {}, 7 "_phantomChildren": {},
8 "_requested": { 8 "_requested": {
9 "type": "range", 9 "type": "range",
10 "registry": true, 10 "registry": true,
11 - "raw": "is-buffer@^1.1.5", 11 + "raw": "is-buffer@^2.0.2",
12 "name": "is-buffer", 12 "name": "is-buffer",
13 "escapedName": "is-buffer", 13 "escapedName": "is-buffer",
14 - "rawSpec": "^1.1.5", 14 + "rawSpec": "^2.0.2",
15 "saveSpec": null, 15 "saveSpec": null,
16 - "fetchSpec": "^1.1.5" 16 + "fetchSpec": "^2.0.2"
17 }, 17 },
18 "_requiredBy": [ 18 "_requiredBy": [
19 "/axios" 19 "/axios"
20 ], 20 ],
21 - "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", 21 + "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
22 - "_shasum": "efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be", 22 + "_shasum": "3e572f23c8411a5cfd9557c849e3665e0b290623",
23 - "_spec": "is-buffer@^1.1.5", 23 + "_spec": "is-buffer@^2.0.2",
24 - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\axios", 24 + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\axios",
25 "author": { 25 "author": {
26 "name": "Feross Aboukhadijeh", 26 "name": "Feross Aboukhadijeh",
27 "email": "feross@feross.org", 27 "email": "feross@feross.org",
28 - "url": "http://feross.org/" 28 + "url": "https://feross.org"
29 }, 29 },
30 "bugs": { 30 "bugs": {
31 "url": "https://github.com/feross/is-buffer/issues" 31 "url": "https://github.com/feross/is-buffer/issues"
...@@ -35,27 +35,30 @@ ...@@ -35,27 +35,30 @@
35 "deprecated": false, 35 "deprecated": false,
36 "description": "Determine if an object is a Buffer", 36 "description": "Determine if an object is a Buffer",
37 "devDependencies": { 37 "devDependencies": {
38 + "airtap": "^2.0.3",
38 "standard": "*", 39 "standard": "*",
39 - "tape": "^4.0.0", 40 + "tape": "^4.11.0"
40 - "zuul": "^3.0.0" 41 + },
42 + "engines": {
43 + "node": ">=4"
41 }, 44 },
42 "homepage": "https://github.com/feross/is-buffer#readme", 45 "homepage": "https://github.com/feross/is-buffer#readme",
43 "keywords": [ 46 "keywords": [
47 + "arraybuffer",
48 + "browser",
49 + "browser buffer",
50 + "browserify",
44 "buffer", 51 "buffer",
45 "buffers", 52 "buffers",
46 - "type",
47 "core buffer", 53 "core buffer",
48 - "browser buffer", 54 + "dataview",
49 - "browserify",
50 - "typed array",
51 - "uint32array",
52 - "int16array",
53 - "int32array",
54 "float32array", 55 "float32array",
55 "float64array", 56 "float64array",
56 - "browser", 57 + "int16array",
57 - "arraybuffer", 58 + "int32array",
58 - "dataview" 59 + "type",
60 + "typed array",
61 + "uint32array"
59 ], 62 ],
60 "license": "MIT", 63 "license": "MIT",
61 "main": "index.js", 64 "main": "index.js",
...@@ -66,12 +69,9 @@ ...@@ -66,12 +69,9 @@
66 }, 69 },
67 "scripts": { 70 "scripts": {
68 "test": "standard && npm run test-node && npm run test-browser", 71 "test": "standard && npm run test-node && npm run test-browser",
69 - "test-browser": "zuul -- test/*.js", 72 + "test-browser": "airtap -- test/*.js",
70 - "test-browser-local": "zuul --local -- test/*.js", 73 + "test-browser-local": "airtap --local -- test/*.js",
71 "test-node": "tape test/*.js" 74 "test-node": "tape test/*.js"
72 }, 75 },
73 - "testling": { 76 + "version": "2.0.4"
74 - "files": "test/*.js"
75 - },
76 - "version": "1.1.6"
77 } 77 }
......
1 -var isBuffer = require('../')
2 -var test = require('tape')
3 -
4 -test('is-buffer', function (t) {
5 - t.equal(isBuffer(Buffer.alloc(4)), true, 'new Buffer(4)')
6 - t.equal(isBuffer(Buffer.allocUnsafeSlow(100)), true, 'SlowBuffer(100)')
7 -
8 - t.equal(isBuffer(undefined), false, 'undefined')
9 - t.equal(isBuffer(null), false, 'null')
10 - t.equal(isBuffer(''), false, 'empty string')
11 - t.equal(isBuffer(true), false, 'true')
12 - t.equal(isBuffer(false), false, 'false')
13 - t.equal(isBuffer(0), false, '0')
14 - t.equal(isBuffer(1), false, '1')
15 - t.equal(isBuffer(1.0), false, '1.0')
16 - t.equal(isBuffer('string'), false, 'string')
17 - t.equal(isBuffer({}), false, '{}')
18 - t.equal(isBuffer([]), false, '[]')
19 - t.equal(isBuffer(function foo () {}), false, 'function foo () {}')
20 - t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }')
21 - t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }')
22 -
23 - t.end()
24 -})
...@@ -5,22 +5,22 @@ ...@@ -5,22 +5,22 @@
5 "requires": true, 5 "requires": true,
6 "dependencies": { 6 "dependencies": {
7 "@line/bot-sdk": { 7 "@line/bot-sdk": {
8 - "version": "6.4.0", 8 + "version": "6.8.3",
9 - "resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.4.0.tgz", 9 + "resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.8.3.tgz",
10 - "integrity": "sha512-N0FkrqFxTTleOpD6y7DTK8qbMYHr9Q8qZfrAmSYEFAGedM1HLJdbNNkStj5GT+svx+w+/ePF/n7nAEts0aJwkA==", 10 + "integrity": "sha512-nj2T4CQxw0W/juAlpj0kMTDScOh5QUK6xMCR2dZp+pN8B0vj/c+5uX3TyGB4ijz/NIsehgfKujPgzw7LhtYtJw==",
11 "requires": { 11 "requires": {
12 "@types/body-parser": "^1.16.8", 12 "@types/body-parser": "^1.16.8",
13 "@types/file-type": "^5.2.1", 13 "@types/file-type": "^5.2.1",
14 "@types/node": "^7.0.31", 14 "@types/node": "^7.0.31",
15 - "axios": "^0.16.2", 15 + "axios": "^0.19.0",
16 "body-parser": "^1.18.2", 16 "body-parser": "^1.18.2",
17 "file-type": "^7.2.0" 17 "file-type": "^7.2.0"
18 } 18 }
19 }, 19 },
20 "@types/body-parser": { 20 "@types/body-parser": {
21 - "version": "1.17.0", 21 + "version": "1.17.1",
22 - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", 22 + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz",
23 - "integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==", 23 + "integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==",
24 "requires": { 24 "requires": {
25 "@types/connect": "*", 25 "@types/connect": "*",
26 "@types/node": "*" 26 "@types/node": "*"
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
43 } 43 }
44 }, 44 },
45 "@types/node": { 45 "@types/node": {
46 - "version": "7.10.2", 46 + "version": "7.10.9",
47 - "resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.2.tgz", 47 + "resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz",
48 - "integrity": "sha512-RO4ig5taKmcrU4Rex8ojG1gpwFkjddzug9iPQSDvbewHN9vDpcFewevkaOK+KT+w1LeZnxbgOyfXwV4pxsQ4GQ==" 48 + "integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw=="
49 }, 49 },
50 "accepts": { 50 "accepts": {
51 "version": "1.3.5", 51 "version": "1.3.5",
...@@ -62,12 +62,12 @@ ...@@ -62,12 +62,12 @@
62 "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 62 "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
63 }, 63 },
64 "axios": { 64 "axios": {
65 - "version": "0.16.2", 65 + "version": "0.19.0",
66 - "resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz", 66 + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
67 - "integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=", 67 + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
68 "requires": { 68 "requires": {
69 - "follow-redirects": "^1.2.3", 69 + "follow-redirects": "1.5.10",
70 - "is-buffer": "^1.1.5" 70 + "is-buffer": "^2.0.2"
71 } 71 }
72 }, 72 },
73 "body-parser": { 73 "body-parser": {
...@@ -264,9 +264,9 @@ ...@@ -264,9 +264,9 @@
264 "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" 264 "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4="
265 }, 265 },
266 "is-buffer": { 266 "is-buffer": {
267 - "version": "1.1.6", 267 + "version": "2.0.4",
268 - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", 268 + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
269 - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" 269 + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
270 }, 270 },
271 "media-typer": { 271 "media-typer": {
272 "version": "0.3.0", 272 "version": "0.3.0",
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
10 "author": "강수인", 10 "author": "강수인",
11 "license": "MIT", 11 "license": "MIT",
12 "dependencies": { 12 "dependencies": {
13 - "@line/bot-sdk": "^6.4.0", 13 + "@line/bot-sdk": "^6.8.3",
14 "express": "^4.16.4" 14 "express": "^4.16.4"
15 } 15 }
16 } 16 }
......