최한솔

modify files

Showing 59 changed files with 0 additions and 3640 deletions
This diff is collapsed. Click to expand it.
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 -
92 -## 6.4.0 (19 Nov 2018)
93 -
94 -### Feature
95 -
96 -* Add `getLinkToken` API (#96)
97 -* Handle `req.rawBody` in Google Cloud Functions (#101)
98 -* [Kitchensink] Add ngrok functionality (#99)
99 -
100 -### Type
101 -
102 -* Add types for video in imagemap message (#100)
103 -* Add `contentProvider` fields to content messages (#103)
104 -* Add `destination` field to webhook request body (#102)
105 -* Add `MemberJoinEvent` and `MemberLeaveEvent` types (#107)
106 -
107 -### Misc
108 -
109 -* Don't include doc in released source
110 -* Upgrade TypeScript to 3.1.6 (#94)
111 -* Refactoring (#94, #98, #99)
112 -* Remove webhook-tester tool
113 -
114 -
115 -## 6.3.0 (21 Sep 2018)
116 -
117 -### Feature
118 -
119 -* Add default rich menu APIs (#87)
120 -
121 -### Type
122 -
123 -* Add missing `defaultAction` field to `TemplateColumn`
124 -
125 -### Misc
126 -
127 -* Use VuePress as documentation engine (#85)
128 -* Upgrade minimum supported Node.js version to 6
129 -
130 -
131 -## 6.2.1 (16 Aug 2018)
132 -
133 -### Misc
134 -
135 -* Remove gitbook-cli from dev dependencies
136 -
137 -
138 -## 6.2.0 (15 Aug 2018)
139 -
140 -#### Type
141 -
142 -* Add QuickReply types (#83)
143 -* Format type comments
144 -
145 -#### Misc
146 -
147 -* Upgrade TypeScript to 3
148 -
149 -
150 -## 6.1.1 (14 Aug 2018)
151 -
152 -#### Type
153 -
154 -* Update FlexMessage types (#81)
155 -
156 -#### Misc
157 -
158 -* Add test coverage (#78)
159 -* Add JSDoc comments (#80)
160 -
161 -
162 -## 6.1.0 (19 June 2018)
163 -
164 -#### Type
165 -
166 -* Add types for flex message (#74)
167 -* Simplify type definition for `Action`
168 -
169 -
170 -## 6.0.3 (18 June 2018)
171 -
172 -#### Misc
173 -
174 -* Move get-audio-duration dep to proper package.json (#73)
175 -* Vulnerability fix with `npm audit fix`
176 -
177 -
178 -## 6.0.2 (21 May 2018)
179 -
180 -#### Type
181 -
182 -* Add missing `displayText` field to postback action (#63)
183 -* Add missing `FileEventMessage` to `EventMessage` (#71)
184 -
185 -#### Misc
186 -
187 -* Add audio duration lib to kitchensink example (#68)
188 -
189 -
190 -## 6.0.1 (13 Mar 2018)
191 -
192 -#### Type
193 -
194 -* Fix misimplemented 'AudioMessage' type (#61)
195 -
196 -
197 -## 6.0.0 (27 Feb 2018)
198 -
199 -#### Major
200 -
201 -* Fix misimplemented 'unlinkRichMenuFromUser' API
202 -
203 -#### Type
204 -
205 -* Fix TemplateColumn type definition (#48)
206 -
207 -#### Misc
208 -
209 -* Update GitHub issue template (#43)
210 -* Add Code of Conduct (#50)
211 -* Catch errors properly in examples (#52)
212 -
213 -
214 -## 5.2.0 (11 Dec 2017)
215 -
216 -#### Minor
217 -
218 -* Set Content-Length manually for postBinary (#42)
219 -
220 -
221 -## 5.1.0 (7 Dec 2017)
222 -
223 -#### Minor
224 -
225 -* Add new fields (#39)
226 -
227 -#### Misc
228 -
229 -* Fix Windows build (#38)
230 -* Add start scripts and webhook info to examples
231 -
232 -
233 -## 5.0.1 (14 Nov 2017)
234 -
235 -#### Minor
236 -
237 -* Fix typo in `ImageMapMessage` type
238 -* Add kitchensink example (#36)
239 -
240 -
241 -## 5.0.0 (2 Nov 2017)
242 -
243 -#### Major
244 -
245 -* Implement rich menu API (#34)
246 -
247 -#### Type
248 -
249 -* Rename `ImageMapArea` and `TemplateAction`s into general ones
250 -
251 -#### Misc
252 -
253 -* Do not enforce `checkJSON` for some APIs where it means nothing
254 -* Change how to check request object in test cases
255 -
256 -
257 -## 4.0.0 (25 Oct 2017)
258 -
259 -#### Major
260 -
261 -* Make index script export exceptions and types (#31)
262 -
263 -#### Type
264 -
265 -* Simplify config types for client and middleware (#31)
266 -
267 -#### Misc
268 -
269 -* Fix information and links in doc
270 -* Use Prettier instead of TSLint (#30)
271 -* Install git hooks for precommit and prepush (#30)
272 -
273 -
274 -## 3.1.1 (19 Sep 2017)
275 -
276 -#### Type
277 -
278 -* Fix type of postback.params
279 -
280 -
281 -## 3.1.0 (19 Sep 2017)
282 -
283 -#### Major
284 -
285 -* Make middleware return `SignatureValidationFailed` for no signature (#26)
286 -
287 -#### Type
288 -
289 -* Add `FileEventMessage` type
290 -
291 -
292 -## 3.0.0 (8 Sep 2017)
293 -
294 -#### Major
295 -
296 -* Implement "Get group/room member profile" API (#15)
297 -* Implement "Get group/room member IDs" API (#23)
298 -* `getMessageContent` now returns `Promise<ReadableStream>` (#20)
299 -
300 -#### Type
301 -
302 -* Add "datetimepicker" support (#21)
303 -* Fix typo in `TemplateURIAction` type (#21)
304 -
305 -#### Misc
306 -
307 -* Package updates and corresponding fixes
308 -* Use npm 5 instead of Yarn in dev
309 -* Fix `clean` script to work in Windows
310 -* Use "axios" for internal HTTP client instead of "got" (#20)
311 -
312 -
313 -## 2.0.0 (12 June 2017)
314 -
315 -#### Type
316 -
317 -* Use literal types for 'type' fields
318 -
319 -#### Misc
320 -
321 -* Update yarn.lock with the latest Yarn
322 -
323 -
324 -## 1.1.0 (31 May 2017)
325 -
326 -* Handle pre-parsed body (string and buffer only)
327 -
328 -#### Type
329 -
330 -* Separate config type into client and middleware types
331 -* Add `userId` to group and room event sources
332 -
333 -#### Misc
334 -
335 -* Create issue template (#4)
336 -
337 -
338 -## 1.0.0 (11 May 2017)
339 -
340 -* Initial release
1 -# LINE Messaging API SDK for nodejs
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)
4 -[![npmjs](https://badge.fury.io/js/%40line%2Fbot-sdk.svg)](https://www.npmjs.com/package/@line/bot-sdk)
5 -
6 -
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 -
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
24 -
25 -Using [npm](https://www.npmjs.com/):
26 -
27 -``` bash
28 -$ npm install @line/bot-sdk --save
29 -```
30 -
31 -## Help and media
32 -FAQ: https://developers.line.biz/en/faq/
33 -
34 -Community Q&A: https://www.line-community.me/questions
35 -
36 -News: https://developers.line.biz/en/news/
37 -
38 -Twitter: @LINE_DEV
39 -
40 -## Versioning
41 -This project respects semantic versioning
42 -
43 -See http://semver.org/
44 -
45 -## Contributing
46 -
47 -Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.
48 -
49 -## License
50 -```
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 -```
1 -/// <reference types="node" />
2 -import { Readable } from "stream";
3 -import * as Types from "./types";
4 -export default class Client {
5 - config: Types.ClientConfig;
6 - private http;
7 - constructor(config: Types.ClientConfig);
8 - private parseHTTPResponse;
9 - pushMessage(to: string, messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
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>;
13 - getProfile(userId: string): Promise<Types.Profile>;
14 - private getChatMemberProfile;
15 - getGroupMemberProfile(groupId: string, userId: string): Promise<Types.Profile>;
16 - getRoomMemberProfile(roomId: string, userId: string): Promise<Types.Profile>;
17 - private getChatMemberIds;
18 - getGroupMemberIds(groupId: string): Promise<string[]>;
19 - getRoomMemberIds(roomId: string): Promise<string[]>;
20 - getMessageContent(messageId: string): Promise<Readable>;
21 - private leaveChat;
22 - leaveGroup(groupId: string): Promise<any>;
23 - leaveRoom(roomId: string): Promise<any>;
24 - getRichMenu(richMenuId: string): Promise<Types.RichMenuResponse>;
25 - createRichMenu(richMenu: Types.RichMenu): Promise<string>;
26 - deleteRichMenu(richMenuId: string): Promise<any>;
27 - getRichMenuIdOfUser(userId: string): Promise<string>;
28 - linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>;
29 - unlinkRichMenuFromUser(userId: string): Promise<any>;
30 - linkRichMenuToMultipleUsers(richMenuId: string, userIds: string[]): Promise<any>;
31 - unlinkRichMenusFromMultipleUsers(userIds: string[]): Promise<any>;
32 - getRichMenuImage(richMenuId: string): Promise<Readable>;
33 - setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>;
34 - getRichMenuList(): Promise<Array<Types.RichMenuResponse>>;
35 - setDefaultRichMenu(richMenuId: string): Promise<{}>;
36 - getDefaultRichMenuId(): Promise<string>;
37 - deleteDefaultRichMenu(): Promise<{}>;
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<{}>;
58 -}
1 -"use strict";
2 -Object.defineProperty(exports, "__esModule", { value: true });
3 -const http_1 = require("./http");
4 -const Types = require("./types");
5 -const exceptions_1 = require("./exceptions");
6 -function toArray(maybeArr) {
7 - return Array.isArray(maybeArr) ? maybeArr : [maybeArr];
8 -}
9 -function ensureJSON(raw) {
10 - if (typeof raw === "object") {
11 - return raw;
12 - }
13 - else {
14 - throw new exceptions_1.JSONParseError("Failed to parse response body as JSON", raw);
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/`;
20 -class Client {
21 - constructor(config) {
22 - if (!config.channelAccessToken) {
23 - throw new Error("no channel access token");
24 - }
25 - this.config = config;
26 - this.http = new http_1.default({
27 - baseURL: BOT_BASE_URL,
28 - defaultHeaders: {
29 - Authorization: "Bearer " + this.config.channelAccessToken,
30 - },
31 - responseParser: this.parseHTTPResponse.bind(this),
32 - });
33 - }
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) {
44 - return this.http.post("/message/push", {
45 - messages: toArray(messages),
46 - to,
47 - notificationDisabled,
48 - });
49 - }
50 - replyMessage(replyToken, messages, notificationDisabled = false) {
51 - return this.http.post("/message/reply", {
52 - messages: toArray(messages),
53 - replyToken,
54 - notificationDisabled,
55 - });
56 - }
57 - async multicast(to, messages, notificationDisabled = false) {
58 - return this.http.post("/message/multicast", {
59 - messages: toArray(messages),
60 - to,
61 - notificationDisabled,
62 - });
63 - }
64 - async broadcast(messages, notificationDisabled = false) {
65 - return this.http.post("/message/broadcast", {
66 - messages: toArray(messages),
67 - notificationDisabled,
68 - });
69 - }
70 - async getProfile(userId) {
71 - const profile = await this.http.get(`/profile/${userId}`);
72 - return ensureJSON(profile);
73 - }
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) {
79 - return this.getChatMemberProfile("group", groupId, userId);
80 - }
81 - async getRoomMemberProfile(roomId, userId) {
82 - return this.getChatMemberProfile("room", roomId, userId);
83 - }
84 - async getChatMemberIds(chatType, chatId) {
85 - let memberIds = [];
86 - let start;
87 - do {
88 - const res = await this.http.get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null);
89 - ensureJSON(res);
90 - memberIds = memberIds.concat(res.memberIds);
91 - start = res.next;
92 - } while (start);
93 - return memberIds;
94 - }
95 - async getGroupMemberIds(groupId) {
96 - return this.getChatMemberIds("group", groupId);
97 - }
98 - async getRoomMemberIds(roomId) {
99 - return this.getChatMemberIds("room", roomId);
100 - }
101 - async getMessageContent(messageId) {
102 - return this.http.getStream(`/message/${messageId}/content`);
103 - }
104 - leaveChat(chatType, chatId) {
105 - return this.http.post(`/${chatType}/${chatId}/leave`);
106 - }
107 - async leaveGroup(groupId) {
108 - return this.leaveChat("group", groupId);
109 - }
110 - async leaveRoom(roomId) {
111 - return this.leaveChat("room", roomId);
112 - }
113 - async getRichMenu(richMenuId) {
114 - const res = await this.http.get(`/richmenu/${richMenuId}`);
115 - return ensureJSON(res);
116 - }
117 - async createRichMenu(richMenu) {
118 - const res = await this.http.post("/richmenu", richMenu);
119 - return ensureJSON(res).richMenuId;
120 - }
121 - async deleteRichMenu(richMenuId) {
122 - return this.http.delete(`/richmenu/${richMenuId}`);
123 - }
124 - async getRichMenuIdOfUser(userId) {
125 - const res = await this.http.get(`/user/${userId}/richmenu`);
126 - return ensureJSON(res).richMenuId;
127 - }
128 - async linkRichMenuToUser(userId, richMenuId) {
129 - return this.http.post(`/user/${userId}/richmenu/${richMenuId}`);
130 - }
131 - async unlinkRichMenuFromUser(userId) {
132 - return this.http.delete(`/user/${userId}/richmenu`);
133 - }
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) {
146 - return this.http.getStream(`/richmenu/${richMenuId}/content`);
147 - }
148 - async setRichMenuImage(richMenuId, data, contentType) {
149 - return this.http.postBinary(`/richmenu/${richMenuId}/content`, data, contentType);
150 - }
151 - async getRichMenuList() {
152 - const res = await this.http.get(`/richmenu/list`);
153 - return ensureJSON(res).richmenus;
154 - }
155 - async setDefaultRichMenu(richMenuId) {
156 - return this.http.post(`/user/all/richmenu/${richMenuId}`);
157 - }
158 - async getDefaultRichMenuId() {
159 - const res = await this.http.get("/user/all/richmenu");
160 - return ensureJSON(res).richMenuId;
161 - }
162 - async deleteDefaultRichMenu() {
163 - return this.http.delete("/user/all/richmenu");
164 - }
165 - async getLinkToken(userId) {
166 - const res = await this.http.post(`/user/${userId}/linkToken`);
167 - return ensureJSON(res).linkToken;
168 - }
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);
204 - }
205 -}
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" />
2 -import { AxiosResponse } from "axios";
3 -import { Readable } from "stream";
4 -declare type httpClientConfig = {
5 - baseURL?: string;
6 - defaultHeaders?: any;
7 - responseParser?: <T>(res: AxiosResponse) => T;
8 -};
9 -export default class HTTPClient {
10 - private instance;
11 - private config;
12 - constructor(config?: httpClientConfig);
13 - get<T>(url: string, params?: any): Promise<T>;
14 - getStream(url: string, params?: any): Promise<Readable>;
15 - post<T>(url: string, body?: any): Promise<T>;
16 - postForm<T>(url: string, body?: any): Promise<T>;
17 - postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>;
18 - delete<T>(url: string, params?: any): Promise<T>;
19 - private wrapError;
20 -}
21 -export {};
1 -"use strict";
2 -Object.defineProperty(exports, "__esModule", { value: true });
3 -const axios_1 = require("axios");
4 -const stream_1 = require("stream");
5 -const exceptions_1 = require("./exceptions");
6 -const fileType = require("file-type");
7 -const qs = require("querystring");
8 -const pkg = require("../package.json");
9 -class HTTPClient {
10 - constructor(config = {}) {
11 - this.config = config;
12 - const { baseURL, defaultHeaders } = config;
13 - this.instance = axios_1.default.create({
14 - baseURL,
15 - headers: Object.assign({}, defaultHeaders, {
16 - "User-Agent": `${pkg.name}/${pkg.version}`,
17 - }),
18 - });
19 - this.instance.interceptors.response.use(res => res, err => Promise.reject(this.wrapError(err)));
20 - }
21 - async get(url, params) {
22 - const res = await this.instance.get(url, { params });
23 - return res.data;
24 - }
25 - async getStream(url, params) {
26 - const res = await this.instance.get(url, {
27 - params,
28 - responseType: "stream",
29 - });
30 - return res.data;
31 - }
32 - async post(url, body) {
33 - const res = await this.instance.post(url, body, {
34 - headers: { "Content-Type": "application/json" },
35 - });
36 - const { responseParser } = this.config;
37 - if (responseParser)
38 - return responseParser(res);
39 - else
40 - return res.data;
41 - }
42 - async postForm(url, body) {
43 - const res = await this.instance.post(url, qs.stringify(body), {
44 - headers: { "Content-Type": "application/x-www-form-urlencoded" },
45 - });
46 - return res.data;
47 - }
48 - async postBinary(url, data, contentType) {
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) => {
55 - const buffers = [];
56 - let size = 0;
57 - data.on("data", (chunk) => {
58 - buffers.push(chunk);
59 - size += chunk.length;
60 - });
61 - data.on("end", () => resolve(Buffer.concat(buffers, size)));
62 - data.on("error", reject);
63 - });
64 - }
65 - else {
66 - throw new Error("invalid data type for postBinary");
67 - }
68 - })();
69 - const res = await this.instance.post(url, buffer, {
70 - headers: {
71 - "Content-Type": contentType || fileType(buffer).mime,
72 - "Content-Length": buffer.length,
73 - },
74 - });
75 - return res.data;
76 - }
77 - async delete(url, params) {
78 - const res = await this.instance.delete(url, { params });
79 - return res.data;
80 - }
81 - wrapError(err) {
82 - if (err.response) {
83 - return new exceptions_1.HTTPError(err.message, err.response.status, err.response.statusText, err);
84 - }
85 - else if (err.code) {
86 - return new exceptions_1.RequestError(err.message, err.code, err);
87 - }
88 - else if (err.config) {
89 - // unknown, but from axios
90 - return new exceptions_1.ReadError(err);
91 - }
92 - // otherwise, just rethrow
93 - return err;
94 - }
95 -}
96 -exports.default = HTTPClient;
1 -import Client, { OAuth } from "./client";
2 -import middleware from "./middleware";
3 -import validateSignature from "./validate-signature";
4 -export { Client, middleware, validateSignature, OAuth };
5 -export * from "./exceptions";
6 -export * from "./types";
1 -"use strict";
2 -function __export(m) {
3 - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4 -}
5 -Object.defineProperty(exports, "__esModule", { value: true });
6 -const client_1 = require("./client");
7 -exports.Client = client_1.default;
8 -exports.OAuth = client_1.OAuth;
9 -const middleware_1 = require("./middleware");
10 -exports.middleware = middleware_1.default;
11 -const validate_signature_1 = require("./validate-signature");
12 -exports.validateSignature = validate_signature_1.default;
13 -// re-export exceptions and types
14 -__export(require("./exceptions"));
15 -__export(require("./types"));
1 -/// <reference types="node" />
2 -import * as http from "http";
3 -import * as Types from "./types";
4 -export declare type Request = http.IncomingMessage & {
5 - body: any;
6 -};
7 -export declare type Response = http.ServerResponse;
8 -export declare type NextCallback = (err?: Error) => void;
9 -export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void | Promise<void>;
10 -export default function middleware(config: Types.MiddlewareConfig): Middleware;
1 -"use strict";
2 -Object.defineProperty(exports, "__esModule", { value: true });
3 -const body_parser_1 = require("body-parser");
4 -const exceptions_1 = require("./exceptions");
5 -const validate_signature_1 = require("./validate-signature");
6 -function isValidBody(body) {
7 - return (body && typeof body === "string") || Buffer.isBuffer(body);
8 -}
9 -function middleware(config) {
10 - if (!config.channelSecret) {
11 - throw new Error("no channel secret");
12 - }
13 - const secret = config.channelSecret;
14 - const _middleware = async (req, res, next) => {
15 - // header names are lower-cased
16 - // https://nodejs.org/api/http.html#http_message_headers
17 - const signature = req.headers["x-line-signature"];
18 - if (!signature) {
19 - next(new exceptions_1.SignatureValidationFailed("no signature"));
20 - return;
21 - }
22 - const body = await (async () => {
23 - if (isValidBody(req.rawBody)) {
24 - // rawBody is provided in Google Cloud Functions and others
25 - return req.rawBody;
26 - }
27 - else if (isValidBody(req.body)) {
28 - return req.body;
29 - }
30 - else {
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)));
33 - }
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 - };
51 -}
52 -exports.default = middleware;
This diff is collapsed. Click to expand it.
1 -"use strict";
2 -Object.defineProperty(exports, "__esModule", { value: true });
3 -exports.LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
1 -"use strict";
2 -Object.defineProperty(exports, "__esModule", { value: true });
3 -const crypto_1 = require("crypto");
4 -function s2b(str, encoding) {
5 - return Buffer.from(str, encoding);
6 -}
7 -function safeCompare(a, b) {
8 - if (a.length !== b.length) {
9 - return false;
10 - }
11 - return crypto_1.timingSafeEqual(a, b);
12 -}
13 -function validateSignature(body, channelSecret, signature) {
14 - return safeCompare(crypto_1.createHmac("SHA256", channelSecret)
15 - .update(body)
16 - .digest(), s2b(signature, "base64"));
17 -}
18 -exports.default = validateSignature;
This diff is collapsed. Click to expand it.
1 -import axios, { AxiosInstance, AxiosError, AxiosResponse } from "axios";
2 -import { Readable } from "stream";
3 -import { HTTPError, ReadError, RequestError } from "./exceptions";
4 -import * as fileType from "file-type";
5 -import * as qs from "querystring";
6 -
7 -const pkg = require("../package.json");
8 -
9 -type httpClientConfig = {
10 - baseURL?: string;
11 - defaultHeaders?: any;
12 - responseParser?: <T>(res: AxiosResponse) => T;
13 -};
14 -
15 -export default class HTTPClient {
16 - private instance: AxiosInstance;
17 - private config: httpClientConfig;
18 -
19 - constructor(config: httpClientConfig = {}) {
20 - this.config = config;
21 - const { baseURL, defaultHeaders } = config;
22 - this.instance = axios.create({
23 - baseURL,
24 - headers: Object.assign({}, defaultHeaders, {
25 - "User-Agent": `${pkg.name}/${pkg.version}`,
26 - }),
27 - });
28 -
29 - this.instance.interceptors.response.use(
30 - res => res,
31 - err => Promise.reject(this.wrapError(err)),
32 - );
33 - }
34 -
35 - public async get<T>(url: string, params?: any): Promise<T> {
36 - const res = await this.instance.get(url, { params });
37 - return res.data;
38 - }
39 -
40 - public async getStream(url: string, params?: any): Promise<Readable> {
41 - const res = await this.instance.get(url, {
42 - params,
43 - responseType: "stream",
44 - });
45 - return res.data as Readable;
46 - }
47 -
48 - public async post<T>(url: string, body?: any): Promise<T> {
49 - const res = await this.instance.post(url, body, {
50 - headers: { "Content-Type": "application/json" },
51 - });
52 -
53 - const { responseParser } = this.config;
54 - if (responseParser) return responseParser<T>(res);
55 - else return res.data;
56 - }
57 -
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>(
67 - url: string,
68 - data: Buffer | Readable,
69 - contentType?: string,
70 - ): Promise<T> {
71 - const buffer = await (async (): Promise<Buffer> => {
72 - if (Buffer.isBuffer(data)) {
73 - return data;
74 - } else if (data instanceof Readable) {
75 - return new Promise<Buffer>((resolve, reject) => {
76 - const buffers: Buffer[] = [];
77 - let size = 0;
78 - data.on("data", (chunk: Buffer) => {
79 - buffers.push(chunk);
80 - size += chunk.length;
81 - });
82 - data.on("end", () => resolve(Buffer.concat(buffers, size)));
83 - data.on("error", reject);
84 - });
85 - } else {
86 - throw new Error("invalid data type for postBinary");
87 - }
88 - })();
89 -
90 - const res = await this.instance.post(url, buffer, {
91 - headers: {
92 - "Content-Type": contentType || fileType(buffer).mime,
93 - "Content-Length": buffer.length,
94 - },
95 - });
96 -
97 - return res.data;
98 - }
99 -
100 - public async delete<T>(url: string, params?: any): Promise<T> {
101 - const res = await this.instance.delete(url, { params });
102 - return res.data;
103 - }
104 -
105 - private wrapError(err: AxiosError): Error {
106 - if (err.response) {
107 - return new HTTPError(
108 - err.message,
109 - err.response.status,
110 - err.response.statusText,
111 - err,
112 - );
113 - } else if (err.code) {
114 - return new RequestError(err.message, err.code, err);
115 - } else if (err.config) {
116 - // unknown, but from axios
117 - return new ReadError(err);
118 - }
119 -
120 - // otherwise, just rethrow
121 - return err;
122 - }
123 -}
1 -import Client, { OAuth } from "./client";
2 -import middleware from "./middleware";
3 -import validateSignature from "./validate-signature";
4 -
5 -export { Client, middleware, validateSignature, OAuth };
6 -
7 -// re-export exceptions and types
8 -export * from "./exceptions";
9 -export * from "./types";
1 -import { raw } from "body-parser";
2 -import * as http from "http";
3 -import { JSONParseError, SignatureValidationFailed } from "./exceptions";
4 -import * as Types from "./types";
5 -import validateSignature from "./validate-signature";
6 -
7 -export type Request = http.IncomingMessage & { body: any };
8 -export type Response = http.ServerResponse;
9 -export type NextCallback = (err?: Error) => void;
10 -
11 -export type Middleware = (
12 - req: Request,
13 - res: Response,
14 - next: NextCallback,
15 -) => void | Promise<void>;
16 -
17 -function isValidBody(body?: any): body is string | Buffer {
18 - return (body && typeof body === "string") || Buffer.isBuffer(body);
19 -}
20 -
21 -export default function middleware(config: Types.MiddlewareConfig): Middleware {
22 - if (!config.channelSecret) {
23 - throw new Error("no channel secret");
24 - }
25 -
26 - const secret = config.channelSecret;
27 -
28 - const _middleware: Middleware = async (req, res, next) => {
29 - // header names are lower-cased
30 - // https://nodejs.org/api/http.html#http_message_headers
31 - const signature = req.headers["x-line-signature"] as string;
32 -
33 - if (!signature) {
34 - next(new SignatureValidationFailed("no signature"));
35 - return;
36 - }
37 -
38 - const body = await (async (): Promise<string | Buffer> => {
39 - if (isValidBody((req as any).rawBody)) {
40 - // rawBody is provided in Google Cloud Functions and others
41 - return (req as any).rawBody;
42 - } else if (isValidBody(req.body)) {
43 - return req.body;
44 - } else {
45 - // body may not be parsed yet, parse it to a buffer
46 - return new Promise<Buffer>((resolve, reject) =>
47 - raw({ type: "*/*" })(req as any, res as any, (error: Error) =>
48 - error ? reject(error) : resolve(req.body),
49 - ),
50 - );
51 - }
52 - })();
53 -
54 - if (!validateSignature(body, secret, signature)) {
55 - next(
56 - new SignatureValidationFailed("signature validation failed", signature),
57 - );
58 - return;
59 - }
60 -
61 - const strBody = Buffer.isBuffer(body) ? body.toString() : body;
62 -
63 - try {
64 - req.body = JSON.parse(strBody);
65 - next();
66 - } catch (err) {
67 - next(new JSONParseError(err.message, strBody));
68 - }
69 - };
70 - return (req, res, next): void => {
71 - (<Promise<void>>_middleware(req, res, next)).catch(next);
72 - };
73 -}
This diff is collapsed. Click to expand it.
1 -import { createHmac, timingSafeEqual } from "crypto";
2 -
3 -function s2b(str: string, encoding: string): Buffer {
4 - return Buffer.from(str, encoding);
5 -}
6 -
7 -function safeCompare(a: Buffer, b: Buffer): boolean {
8 - if (a.length !== b.length) {
9 - return false;
10 - }
11 - return timingSafeEqual(a, b);
12 -}
13 -
14 -export default function validateSignature(
15 - body: string | Buffer,
16 - channelSecret: string,
17 - signature: string,
18 -): boolean {
19 - return safeCompare(
20 - createHmac("SHA256", channelSecret)
21 - .update(body)
22 - .digest(),
23 - s2b(signature, "base64"),
24 - );
25 -}
1 -{
2 - "_from": "@line/bot-sdk@^6.4.0",
3 - "_id": "@line/bot-sdk@6.8.3",
4 - "_inBundle": false,
5 - "_integrity": "sha512-nj2T4CQxw0W/juAlpj0kMTDScOh5QUK6xMCR2dZp+pN8B0vj/c+5uX3TyGB4ijz/NIsehgfKujPgzw7LhtYtJw==",
6 - "_location": "/@line/bot-sdk",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@line/bot-sdk@^6.4.0",
12 - "name": "@line/bot-sdk",
13 - "escapedName": "@line%2fbot-sdk",
14 - "scope": "@line",
15 - "rawSpec": "^6.4.0",
16 - "saveSpec": null,
17 - "fetchSpec": "^6.4.0"
18 - },
19 - "_requiredBy": [
20 - "#USER",
21 - "/"
22 - ],
23 - "_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.8.3.tgz",
24 - "_shasum": "0a886461e8c16a8c89091fd5338f6071335636a6",
25 - "_spec": "@line/bot-sdk@^6.4.0",
26 - "_where": "C:\\Users\\Home\\Documents\\윤동주\\경희\\2019-2 오픈소스SW개발\\Term Project\\LINEBOT",
27 - "bugs": {
28 - "url": "https://github.com/line/line-bot-sdk-nodejs/issues"
29 - },
30 - "bundleDependencies": false,
31 - "dependencies": {
32 - "@types/body-parser": "^1.16.8",
33 - "@types/file-type": "^5.2.1",
34 - "@types/node": "^7.0.31",
35 - "axios": "^0.19.0",
36 - "body-parser": "^1.18.2",
37 - "file-type": "^7.2.0"
38 - },
39 - "deprecated": false,
40 - "description": "Node.js SDK for LINE Messaging API",
41 - "devDependencies": {
42 - "@types/express": "^4.0.35",
43 - "@types/finalhandler": "^1.1.0",
44 - "@types/mocha": "^2.2.41",
45 - "del-cli": "^1.1.0",
46 - "express": "^4.16.3",
47 - "finalhandler": "^1.1.2",
48 - "husky": "^0.14.3",
49 - "mocha": "^5.2.0",
50 - "nyc": "^14.1.1",
51 - "prettier": "^1.15.2",
52 - "ts-node": "^8.3.0",
53 - "typescript": "^3.1.6",
54 - "vuepress": "^0.14.10"
55 - },
56 - "engines": {
57 - "node": ">=8"
58 - },
59 - "files": [
60 - "dist",
61 - "lib"
62 - ],
63 - "homepage": "https://github.com/line/line-bot-sdk-nodejs#readme",
64 - "keywords": [
65 - "node",
66 - "line",
67 - "sdk"
68 - ],
69 - "license": "Apache-2.0",
70 - "main": "dist/index.js",
71 - "name": "@line/bot-sdk",
72 - "nyc": {
73 - "require": [
74 - "ts-node/register"
75 - ],
76 - "extension": [
77 - ".ts"
78 - ],
79 - "reporter": [
80 - "lcov",
81 - "text-summary"
82 - ],
83 - "sourceMap": true,
84 - "instrument": true
85 - },
86 - "repository": {
87 - "type": "git",
88 - "url": "git+ssh://git@github.com/line/line-bot-sdk-nodejs.git"
89 - },
90 - "scripts": {
91 - "build": "tsc",
92 - "clean": "del-cli dist",
93 - "docs": "vuepress dev docs",
94 - "docs:build": "vuepress build docs",
95 - "docs:deploy": "./deploy-docs.sh",
96 - "format": "npm run prettier -- --write",
97 - "format:check": "npm run prettier -- -l",
98 - "prebuild": "npm run format:check && npm run clean",
99 - "precommit": "npm run format:check",
100 - "prepush": "npm run format:check && npm run build && npm run test",
101 - "pretest": "npm run build",
102 - "prettier": "prettier --parser typescript --trailing-comma all \"{lib,test}/**/*.ts\"",
103 - "release": "npm run build && npm publish --access public",
104 - "test": "API_BASE_URL=http://localhost:1234/ TEST_PORT=1234 TS_NODE_CACHE=0 nyc mocha"
105 - },
106 - "types": "dist/index.d.ts",
107 - "version": "6.8.3"
108 -}
1 -# Installation
2 -> `npm install --save @types/body-parser`
3 -
4 -# Summary
5 -This package contains type definitions for body-parser (https://github.com/expressjs/body-parser).
6 -
7 -# Details
8 -Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser
9 -
10 -Additional Details
11 - * Last updated: Mon, 19 Aug 2019 00:51:08 GMT
12 - * Dependencies: @types/connect, @types/node
13 - * Global values: none
14 -
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>, and Jason Walton <https://github.com/jwalton>.
1 -// Type definitions for body-parser 1.17
2 -// Project: https://github.com/expressjs/body-parser
3 -// Definitions by: Santi Albo <https://github.com/santialbo>
4 -// Vilic Vane <https://github.com/vilic>
5 -// Jonathan Häberle <https://github.com/dreampulse>
6 -// Gevik Babakhani <https://github.com/blendsdk>
7 -// Tomasz Łaziuk <https://github.com/tlaziuk>
8 -// Jason Walton <https://github.com/jwalton>
9 -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10 -// TypeScript Version: 2.3
11 -
12 -/// <reference types="node" />
13 -
14 -import { NextHandleFunction } from 'connect';
15 -import * as http from 'http';
16 -
17 -// for docs go to https://github.com/expressjs/body-parser/tree/1.16.0#body-parser
18 -
19 -// @deprecated
20 -declare function bodyParser(options?: bodyParser.OptionsJson & bodyParser.OptionsText & bodyParser.OptionsUrlencoded): NextHandleFunction;
21 -
22 -declare namespace bodyParser {
23 - interface Options {
24 - inflate?: boolean;
25 - limit?: number | string;
26 - type?: string | string[] | ((req: http.IncomingMessage) => any);
27 - verify?(req: http.IncomingMessage, res: http.ServerResponse, buf: Buffer, encoding: string): void;
28 - }
29 -
30 - interface OptionsJson extends Options {
31 - reviver?(key: string, value: any): any;
32 - strict?: boolean;
33 - }
34 -
35 - interface OptionsText extends Options {
36 - defaultCharset?: string;
37 - }
38 -
39 - interface OptionsUrlencoded extends Options {
40 - extended?: boolean;
41 - parameterLimit?: number;
42 - }
43 -
44 - function json(options?: OptionsJson): NextHandleFunction;
45 -
46 - function raw(options?: Options): NextHandleFunction;
47 -
48 - function text(options?: OptionsText): NextHandleFunction;
49 -
50 - function urlencoded(options?: OptionsUrlencoded): NextHandleFunction;
51 -}
52 -
53 -export = bodyParser;
1 -{
2 - "_from": "@types/body-parser@^1.16.8",
3 - "_id": "@types/body-parser@1.17.1",
4 - "_inBundle": false,
5 - "_integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==",
6 - "_location": "/@types/body-parser",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@types/body-parser@^1.16.8",
12 - "name": "@types/body-parser",
13 - "escapedName": "@types%2fbody-parser",
14 - "scope": "@types",
15 - "rawSpec": "^1.16.8",
16 - "saveSpec": null,
17 - "fetchSpec": "^1.16.8"
18 - },
19 - "_requiredBy": [
20 - "/@line/bot-sdk"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz",
23 - "_shasum": "18fcf61768fb5c30ccc508c21d6fd2e8b3bf7897",
24 - "_spec": "@types/body-parser@^1.16.8",
25 - "_where": "C:\\Users\\Home\\Documents\\윤동주\\경희\\2019-2 오픈소스SW개발\\Term Project\\LINEBOT\\node_modules\\@line\\bot-sdk",
26 - "bugs": {
27 - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28 - },
29 - "bundleDependencies": false,
30 - "contributors": [
31 - {
32 - "name": "Santi Albo",
33 - "url": "https://github.com/santialbo"
34 - },
35 - {
36 - "name": "Vilic Vane",
37 - "url": "https://github.com/vilic"
38 - },
39 - {
40 - "name": "Jonathan Häberle",
41 - "url": "https://github.com/dreampulse"
42 - },
43 - {
44 - "name": "Gevik Babakhani",
45 - "url": "https://github.com/blendsdk"
46 - },
47 - {
48 - "name": "Tomasz Łaziuk",
49 - "url": "https://github.com/tlaziuk"
50 - },
51 - {
52 - "name": "Jason Walton",
53 - "url": "https://github.com/jwalton"
54 - }
55 - ],
56 - "dependencies": {
57 - "@types/connect": "*",
58 - "@types/node": "*"
59 - },
60 - "deprecated": false,
61 - "description": "TypeScript definitions for body-parser",
62 - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
63 - "license": "MIT",
64 - "main": "",
65 - "name": "@types/body-parser",
66 - "repository": {
67 - "type": "git",
68 - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
69 - "directory": "types/body-parser"
70 - },
71 - "scripts": {},
72 - "typeScriptVersion": "2.3",
73 - "types": "index",
74 - "typesPublisherContentHash": "ada1b55777df6de5327f420d23285a5c476895faa88cacf6b80a1a791eef0f67",
75 - "version": "1.17.1"
76 -}
1 -# Installation
2 -> `npm install --save @types/node`
3 -
4 -# Summary
5 -This package contains type definitions for Node.js (http://nodejs.org/).
6 -
7 -# Details
8 -Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v7
9 -
10 -Additional Details
11 - * Last updated: Wed, 30 Oct 2019 15:44:46 GMT
12 - * Dependencies: none
13 - * Global values: Buffer, NodeJS, SlowBuffer, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, require, setImmediate, setInterval, setTimeout
14 -
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>, and Jordi Oliveras Rovira <https://github.com/j-oliveras>.
This diff could not be displayed because it is too large.
1 -// Type definitions for Node.js 7.10
2 -// Project: http://nodejs.org/
3 -// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4 -// DefinitelyTyped <https://github.com/DefinitelyTyped>
5 -// Parambir Singh <https://github.com/parambirs>
6 -// Christian Vaagland Tellnes <https://github.com/tellnes>
7 -// Wilco Bakker <https://github.com/WilcoBakker>
8 -// Sebastian Silbermann <https://github.com/eps1lon>
9 -// Hoàng Văn Khải <https://github.com/KSXGitHub>
10 -// Sander Koenders <https://github.com/Archcry>
11 -// Jordi Oliveras Rovira <https://github.com/j-oliveras>
12 -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
13 -/************************************************
14 -* *
15 -* Node.js v7.x API *
16 -* *
17 -************************************************/
18 -// NOTE: These definitions support NodeJS and TypeScript 3.1.
19 -
20 -// NOTE: TypeScript version-specific augmentations can be found in the following paths:
21 -// - ~/base.d.ts - Shared definitions common to all TypeScript versions
22 -// - ~/index.d.ts - Definitions specific to TypeScript 2.1
23 -// - ~/ts3.1/index.d.ts - Definitions specific to TypeScript 3.1
24 -
25 -// NOTE: Augmentations for TypeScript 3.1 and later should use individual files for overrides
26 -// within the respective ~/ts3.1 (or later) folder. However, this is disallowed for versions
27 -// prior to TypeScript 3.1, so the older definitions will be found here.
28 -
29 -// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
30 -/// <reference path="base.d.ts" />
31 -
32 -// TypeScript 2.1-specific augmentations:
33 -
34 -// Forward-declarations for needed types from es2015 and later (in case users are using `--lib es5`)
35 -interface MapConstructor { }
36 -interface WeakMapConstructor { }
37 -interface SetConstructor { }
38 -interface WeakSetConstructor { }
39 -interface IteratorResult<T> {}
40 -interface Iterable<T> {}
41 -interface Iterator<T> {
42 - next(value?: any): IteratorResult<T>;
43 -}
44 -interface IterableIterator<T> { }
45 -interface SymbolConstructor {
46 - readonly iterator: symbol;
47 -}
48 -declare var Symbol: SymbolConstructor;
1 -{
2 - "_from": "@types/node@^7.0.31",
3 - "_id": "@types/node@7.10.9",
4 - "_inBundle": false,
5 - "_integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw==",
6 - "_location": "/@types/node",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@types/node@^7.0.31",
12 - "name": "@types/node",
13 - "escapedName": "@types%2fnode",
14 - "scope": "@types",
15 - "rawSpec": "^7.0.31",
16 - "saveSpec": null,
17 - "fetchSpec": "^7.0.31"
18 - },
19 - "_requiredBy": [
20 - "/@line/bot-sdk",
21 - "/@types/body-parser",
22 - "/@types/connect",
23 - "/@types/file-type"
24 - ],
25 - "_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz",
26 - "_shasum": "4343e3b009f8cf5e1ed685e36097b74b4101e880",
27 - "_spec": "@types/node@^7.0.31",
28 - "_where": "C:\\Users\\Home\\Documents\\윤동주\\경희\\2019-2 오픈소스SW개발\\Term Project\\LINEBOT\\node_modules\\@line\\bot-sdk",
29 - "bugs": {
30 - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
31 - },
32 - "bundleDependencies": false,
33 - "contributors": [
34 - {
35 - "name": "Microsoft TypeScript",
36 - "url": "https://github.com/Microsoft"
37 - },
38 - {
39 - "name": "DefinitelyTyped",
40 - "url": "https://github.com/DefinitelyTyped"
41 - },
42 - {
43 - "name": "Parambir Singh",
44 - "url": "https://github.com/parambirs"
45 - },
46 - {
47 - "name": "Christian Vaagland Tellnes",
48 - "url": "https://github.com/tellnes"
49 - },
50 - {
51 - "name": "Wilco Bakker",
52 - "url": "https://github.com/WilcoBakker"
53 - },
54 - {
55 - "name": "Sebastian Silbermann",
56 - "url": "https://github.com/eps1lon"
57 - },
58 - {
59 - "name": "Hoàng Văn Khải",
60 - "url": "https://github.com/KSXGitHub"
61 - },
62 - {
63 - "name": "Sander Koenders",
64 - "url": "https://github.com/Archcry"
65 - },
66 - {
67 - "name": "Jordi Oliveras Rovira",
68 - "url": "https://github.com/j-oliveras"
69 - }
70 - ],
71 - "dependencies": {},
72 - "deprecated": false,
73 - "description": "TypeScript definitions for Node.js",
74 - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
75 - "license": "MIT",
76 - "main": "",
77 - "name": "@types/node",
78 - "repository": {
79 - "type": "git",
80 - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
81 - "directory": "types/node"
82 - },
83 - "scripts": {},
84 - "typeScriptVersion": "2.0",
85 - "types": "index",
86 - "typesPublisherContentHash": "0c534d9103600d73c97ec8a474420c4d9262b941ae93e66c175cb27e62683e84",
87 - "typesVersions": {
88 - ">=3.2.0-0": {
89 - "*": [
90 - "ts3.2/*"
91 - ]
92 - }
93 - },
94 - "version": "7.10.9"
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:
This diff is collapsed. Click to expand it.
1 -Copyright (c) 2014-present Matt Zabriskie
2 -
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
5 -in the Software without restriction, including without limitation the rights
6 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -copies of the Software, and to permit persons to whom the Software is
8 -furnished to do so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in
11 -all copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -THE SOFTWARE.
This diff is collapsed. Click to expand it.
1 -# Upgrade Guide
2 -
3 -### 0.15.x -> 0.16.0
4 -
5 -#### `Promise` Type Declarations
6 -
7 -The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details.
8 -
9 -### 0.13.x -> 0.14.0
10 -
11 -#### TypeScript Definitions
12 -
13 -The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax.
14 -
15 -Please use the following `import` statement to import axios in TypeScript:
16 -
17 -```typescript
18 -import axios from 'axios';
19 -
20 -axios.get('/foo')
21 - .then(response => console.log(response))
22 - .catch(error => console.log(error));
23 -```
24 -
25 -#### `agent` Config Option
26 -
27 -The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead.
28 -
29 -```js
30 -{
31 - // Define a custom agent for HTTP
32 - httpAgent: new http.Agent({ keepAlive: true }),
33 - // Define a custom agent for HTTPS
34 - httpsAgent: new https.Agent({ keepAlive: true })
35 -}
36 -```
37 -
38 -#### `progress` Config Option
39 -
40 -The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options.
41 -
42 -```js
43 -{
44 - // Define a handler for upload progress events
45 - onUploadProgress: function (progressEvent) {
46 - // ...
47 - },
48 -
49 - // Define a handler for download progress events
50 - onDownloadProgress: function (progressEvent) {
51 - // ...
52 - }
53 -}
54 -```
55 -
56 -### 0.12.x -> 0.13.0
57 -
58 -The `0.13.0` release contains several changes to custom adapters and error handling.
59 -
60 -#### Error Handling
61 -
62 -Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response.
63 -
64 -```js
65 -axios.get('/user/12345')
66 - .catch((error) => {
67 - console.log(error.message);
68 - console.log(error.code); // Not always specified
69 - console.log(error.config); // The config that was used to make the request
70 - console.log(error.response); // Only available if response was received from the server
71 - });
72 -```
73 -
74 -#### Request Adapters
75 -
76 -This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter.
77 -
78 -1. Response transformer is now called outside of adapter.
79 -2. Request adapter returns a `Promise`.
80 -
81 -This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter.
82 -
83 -Previous code:
84 -
85 -```js
86 -function myAdapter(resolve, reject, config) {
87 - var response = {
88 - data: transformData(
89 - responseData,
90 - responseHeaders,
91 - config.transformResponse
92 - ),
93 - status: request.status,
94 - statusText: request.statusText,
95 - headers: responseHeaders
96 - };
97 - settle(resolve, reject, response);
98 -}
99 -```
100 -
101 -New code:
102 -
103 -```js
104 -function myAdapter(config) {
105 - return new Promise(function (resolve, reject) {
106 - var response = {
107 - data: responseData,
108 - status: request.status,
109 - statusText: request.statusText,
110 - headers: responseHeaders
111 - };
112 - settle(resolve, reject, response);
113 - });
114 -}
115 -```
116 -
117 -See the related commits for more details:
118 -- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
119 -- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
120 -
121 -### 0.5.x -> 0.6.0
122 -
123 -The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading.
124 -
125 -#### ES6 Promise Polyfill
126 -
127 -Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it.
128 -
129 -```js
130 -require('es6-promise').polyfill();
131 -var axios = require('axios');
132 -```
133 -
134 -This will polyfill the global environment, and only needs to be done once.
135 -
136 -#### `axios.success`/`axios.error`
137 -
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 -
140 -```js
141 -axios.get('some/url')
142 - .then(function (res) {
143 - /* ... */
144 - })
145 - .catch(function (err) {
146 - /* ... */
147 - });
148 -```
149 -
150 -#### UMD
151 -
152 -Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build.
153 -
154 -```js
155 -// AMD
156 -require(['bower_components/axios/dist/axios'], function (axios) {
157 - /* ... */
158 -});
159 -
160 -// CommonJS
161 -var axios = require('axios/dist/axios');
162 -```
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
1 -export interface AxiosTransformer {
2 - (data: any, headers?: any): any;
3 -}
4 -
5 -export interface AxiosAdapter {
6 - (config: AxiosRequestConfig): AxiosPromise<any>;
7 -}
8 -
9 -export interface AxiosBasicCredentials {
10 - username: string;
11 - password: string;
12 -}
13 -
14 -export interface AxiosProxyConfig {
15 - host: string;
16 - port: number;
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'
40 -
41 -export interface AxiosRequestConfig {
42 - url?: string;
43 - method?: Method;
44 - baseURL?: string;
45 - transformRequest?: AxiosTransformer | AxiosTransformer[];
46 - transformResponse?: AxiosTransformer | AxiosTransformer[];
47 - headers?: any;
48 - params?: any;
49 - paramsSerializer?: (params: any) => string;
50 - data?: any;
51 - timeout?: number;
52 - withCredentials?: boolean;
53 - adapter?: AxiosAdapter;
54 - auth?: AxiosBasicCredentials;
55 - responseType?: ResponseType;
56 - xsrfCookieName?: string;
57 - xsrfHeaderName?: string;
58 - onUploadProgress?: (progressEvent: any) => void;
59 - onDownloadProgress?: (progressEvent: any) => void;
60 - maxContentLength?: number;
61 - validateStatus?: (status: number) => boolean;
62 - maxRedirects?: number;
63 - socketPath?: string | null;
64 - httpAgent?: any;
65 - httpsAgent?: any;
66 - proxy?: AxiosProxyConfig | false;
67 - cancelToken?: CancelToken;
68 -}
69 -
70 -export interface AxiosResponse<T = any> {
71 - data: T;
72 - status: number;
73 - statusText: string;
74 - headers: any;
75 - config: AxiosRequestConfig;
76 - request?: any;
77 -}
78 -
79 -export interface AxiosError<T = any> extends Error {
80 - config: AxiosRequestConfig;
81 - code?: string;
82 - request?: any;
83 - response?: AxiosResponse<T>;
84 - isAxiosError: boolean;
85 -}
86 -
87 -export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
88 -}
89 -
90 -export interface CancelStatic {
91 - new (message?: string): Cancel;
92 -}
93 -
94 -export interface Cancel {
95 - message: string;
96 -}
97 -
98 -export interface Canceler {
99 - (message?: string): void;
100 -}
101 -
102 -export interface CancelTokenStatic {
103 - new (executor: (cancel: Canceler) => void): CancelToken;
104 - source(): CancelTokenSource;
105 -}
106 -
107 -export interface CancelToken {
108 - promise: Promise<Cancel>;
109 - reason?: Cancel;
110 - throwIfRequested(): void;
111 -}
112 -
113 -export interface CancelTokenSource {
114 - token: CancelToken;
115 - cancel: Canceler;
116 -}
117 -
118 -export interface AxiosInterceptorManager<V> {
119 - use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
120 - eject(id: number): void;
121 -}
122 -
123 -export interface AxiosInstance {
124 - (config: AxiosRequestConfig): AxiosPromise;
125 - (url: string, config?: AxiosRequestConfig): AxiosPromise;
126 - defaults: AxiosRequestConfig;
127 - interceptors: {
128 - request: AxiosInterceptorManager<AxiosRequestConfig>;
129 - response: AxiosInterceptorManager<AxiosResponse>;
130 - };
131 - getUri(config?: AxiosRequestConfig): string;
132 - request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>;
133 - get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
134 - delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
135 - head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
136 - post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
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>;
139 -}
140 -
141 -export interface AxiosStatic extends AxiosInstance {
142 - create(config?: AxiosRequestConfig): AxiosInstance;
143 - Cancel: CancelStatic;
144 - CancelToken: CancelTokenStatic;
145 - isCancel(value: any): boolean;
146 - all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
147 - spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
148 -}
149 -
150 -declare const Axios: AxiosStatic;
151 -
152 -export default Axios;
1 -'use strict';
2 -
3 -var utils = require('./../utils');
4 -var settle = require('./../core/settle');
5 -var buildURL = require('./../helpers/buildURL');
6 -var http = require('http');
7 -var https = require('https');
8 -var httpFollow = require('follow-redirects').http;
9 -var httpsFollow = require('follow-redirects').https;
10 -var url = require('url');
11 -var zlib = require('zlib');
12 -var pkg = require('./../../package.json');
13 -var createError = require('../core/createError');
14 -var enhanceError = require('../core/enhanceError');
15 -
16 -var isHttps = /https:?/;
17 -
18 -/*eslint consistent-return:0*/
19 -module.exports = function httpAdapter(config) {
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 - };
30 - var data = config.data;
31 - var headers = config.headers;
32 -
33 - // Set User-Agent (required by some servers)
34 - // Only set header if it hasn't been set in config
35 - // See https://github.com/axios/axios/issues/69
36 - if (!headers['User-Agent'] && !headers['user-agent']) {
37 - headers['User-Agent'] = 'axios/' + pkg.version;
38 - }
39 -
40 - if (data && !utils.isStream(data)) {
41 - if (Buffer.isBuffer(data)) {
42 - // Nothing to do...
43 - } else if (utils.isArrayBuffer(data)) {
44 - data = Buffer.from(new Uint8Array(data));
45 - } else if (utils.isString(data)) {
46 - data = Buffer.from(data, 'utf-8');
47 - } else {
48 - return reject(createError(
49 - 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
50 - config
51 - ));
52 - }
53 -
54 - // Add Content-Length header if data exists
55 - headers['Content-Length'] = data.length;
56 - }
57 -
58 - // HTTP basic authentication
59 - var auth = undefined;
60 - if (config.auth) {
61 - var username = config.auth.username || '';
62 - var password = config.auth.password || '';
63 - auth = username + ':' + password;
64 - }
65 -
66 - // Parse url
67 - var parsed = url.parse(config.url);
68 - var protocol = parsed.protocol || 'http:';
69 -
70 - if (!auth && parsed.auth) {
71 - var urlAuth = parsed.auth.split(':');
72 - var urlUsername = urlAuth[0] || '';
73 - var urlPassword = urlAuth[1] || '';
74 - auth = urlUsername + ':' + urlPassword;
75 - }
76 -
77 - if (auth) {
78 - delete headers.Authorization;
79 - }
80 -
81 - var isHttpsRequest = isHttps.test(protocol);
82 - var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
83 -
84 - var options = {
85 - path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
86 - method: config.method.toUpperCase(),
87 - headers: headers,
88 - agent: agent,
89 - auth: auth
90 - };
91 -
92 - if (config.socketPath) {
93 - options.socketPath = config.socketPath;
94 - } else {
95 - options.hostname = parsed.hostname;
96 - options.port = parsed.port;
97 - }
98 -
99 - var proxy = config.proxy;
100 - if (!proxy && proxy !== false) {
101 - var proxyEnv = protocol.slice(0, -1) + '_proxy';
102 - var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
103 - if (proxyUrl) {
104 - var parsedProxyUrl = url.parse(proxyUrl);
105 - var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
106 - var shouldProxy = true;
107 -
108 - if (noProxyEnv) {
109 - var noProxy = noProxyEnv.split(',').map(function trim(s) {
110 - return s.trim();
111 - });
112 -
113 - shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
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
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 - }
144 - }
145 - }
146 - }
147 -
148 - if (proxy) {
149 - options.hostname = proxy.host;
150 - options.host = proxy.host;
151 - options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
152 - options.port = proxy.port;
153 - options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path;
154 -
155 - // Basic proxy authorization
156 - if (proxy.auth) {
157 - var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
158 - options.headers['Proxy-Authorization'] = 'Basic ' + base64;
159 - }
160 - }
161 -
162 - var transport;
163 - var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
164 - if (config.transport) {
165 - transport = config.transport;
166 - } else if (config.maxRedirects === 0) {
167 - transport = isHttpsProxy ? https : http;
168 - } else {
169 - if (config.maxRedirects) {
170 - options.maxRedirects = config.maxRedirects;
171 - }
172 - transport = isHttpsProxy ? httpsFollow : httpFollow;
173 - }
174 -
175 - if (config.maxContentLength && config.maxContentLength > -1) {
176 - options.maxBodyLength = config.maxContentLength;
177 - }
178 -
179 - // Create the request
180 - var req = transport.request(options, function handleResponse(res) {
181 - if (req.aborted) return;
182 -
183 - // uncompress the response body transparently if required
184 - var stream = res;
185 - switch (res.headers['content-encoding']) {
186 - /*eslint default-case:0*/
187 - case 'gzip':
188 - case 'compress':
189 - case 'deflate':
190 - // add the unzipper to the body stream processing pipeline
191 - stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
192 -
193 - // remove the content-encoding in order to not confuse downstream operations
194 - delete res.headers['content-encoding'];
195 - break;
196 - }
197 -
198 - // return the last request in case of redirects
199 - var lastRequest = res.req || req;
200 -
201 - var response = {
202 - status: res.statusCode,
203 - statusText: res.statusMessage,
204 - headers: res.headers,
205 - config: config,
206 - request: lastRequest
207 - };
208 -
209 - if (config.responseType === 'stream') {
210 - response.data = stream;
211 - settle(resolve, reject, response);
212 - } else {
213 - var responseBuffer = [];
214 - stream.on('data', function handleStreamData(chunk) {
215 - responseBuffer.push(chunk);
216 -
217 - // make sure the content length is not over the maxContentLength if specified
218 - if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
219 - stream.destroy();
220 - reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
221 - config, null, lastRequest));
222 - }
223 - });
224 -
225 - stream.on('error', function handleStreamError(err) {
226 - if (req.aborted) return;
227 - reject(enhanceError(err, config, null, lastRequest));
228 - });
229 -
230 - stream.on('end', function handleStreamEnd() {
231 - var responseData = Buffer.concat(responseBuffer);
232 - if (config.responseType !== 'arraybuffer') {
233 - responseData = responseData.toString(config.responseEncoding);
234 - }
235 -
236 - response.data = responseData;
237 - settle(resolve, reject, response);
238 - });
239 - }
240 - });
241 -
242 - // Handle errors
243 - req.on('error', function handleRequestError(err) {
244 - if (req.aborted) return;
245 - reject(enhanceError(err, config, null, req));
246 - });
247 -
248 - // Handle request timeout
249 - if (config.timeout) {
250 - timer = setTimeout(function handleRequestTimeout() {
251 - req.abort();
252 - reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
253 - }, config.timeout);
254 - }
255 -
256 - if (config.cancelToken) {
257 - // Handle cancellation
258 - config.cancelToken.promise.then(function onCanceled(cancel) {
259 - if (req.aborted) return;
260 -
261 - req.abort();
262 - reject(cancel);
263 - });
264 - }
265 -
266 - // Send the request
267 - if (utils.isStream(data)) {
268 - data.on('error', function handleStreamError(err) {
269 - reject(enhanceError(err, config, null, req));
270 - }).pipe(req);
271 - } else {
272 - req.end(data);
273 - }
274 - });
275 -};
1 -'use strict';
2 -
3 -var utils = require('./../utils');
4 -var settle = require('./../core/settle');
5 -var buildURL = require('./../helpers/buildURL');
6 -var parseHeaders = require('./../helpers/parseHeaders');
7 -var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
8 -var createError = require('../core/createError');
9 -
10 -module.exports = function xhrAdapter(config) {
11 - return new Promise(function dispatchXhrRequest(resolve, reject) {
12 - var requestData = config.data;
13 - var requestHeaders = config.headers;
14 -
15 - if (utils.isFormData(requestData)) {
16 - delete requestHeaders['Content-Type']; // Let the browser set it
17 - }
18 -
19 - var request = new XMLHttpRequest();
20 -
21 - // HTTP basic authentication
22 - if (config.auth) {
23 - var username = config.auth.username || '';
24 - var password = config.auth.password || '';
25 - requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
26 - }
27 -
28 - request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
29 -
30 - // Set the request timeout in MS
31 - request.timeout = config.timeout;
32 -
33 - // Listen for ready state
34 - request.onreadystatechange = function handleLoad() {
35 - if (!request || request.readyState !== 4) {
36 - return;
37 - }
38 -
39 - // The request errored out and we didn't get a response, this will be
40 - // handled by onerror instead
41 - // With one exception: request that using file: protocol, most browsers
42 - // will return status as 0 even though it's a successful request
43 - if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
44 - return;
45 - }
46 -
47 - // Prepare the response
48 - var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
49 - var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
50 - var response = {
51 - data: responseData,
52 - status: request.status,
53 - statusText: request.statusText,
54 - headers: responseHeaders,
55 - config: config,
56 - request: request
57 - };
58 -
59 - settle(resolve, reject, response);
60 -
61 - // Clean up request
62 - request = null;
63 - };
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 -
77 - // Handle low level network errors
78 - request.onerror = function handleError() {
79 - // Real errors are hidden from us by the browser
80 - // onerror should only fire if it's a network error
81 - reject(createError('Network Error', config, null, request));
82 -
83 - // Clean up request
84 - request = null;
85 - };
86 -
87 - // Handle timeout
88 - request.ontimeout = function handleTimeout() {
89 - reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
90 - request));
91 -
92 - // Clean up request
93 - request = null;
94 - };
95 -
96 - // Add xsrf header
97 - // This is only done if running in a standard browser environment.
98 - // Specifically not if we're in a web worker, or react-native.
99 - if (utils.isStandardBrowserEnv()) {
100 - var cookies = require('./../helpers/cookies');
101 -
102 - // Add xsrf header
103 - var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
104 - cookies.read(config.xsrfCookieName) :
105 - undefined;
106 -
107 - if (xsrfValue) {
108 - requestHeaders[config.xsrfHeaderName] = xsrfValue;
109 - }
110 - }
111 -
112 - // Add headers to the request
113 - if ('setRequestHeader' in request) {
114 - utils.forEach(requestHeaders, function setRequestHeader(val, key) {
115 - if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
116 - // Remove Content-Type if data is undefined
117 - delete requestHeaders[key];
118 - } else {
119 - // Otherwise add header to the request
120 - request.setRequestHeader(key, val);
121 - }
122 - });
123 - }
124 -
125 - // Add withCredentials to request if needed
126 - if (config.withCredentials) {
127 - request.withCredentials = true;
128 - }
129 -
130 - // Add responseType to request if needed
131 - if (config.responseType) {
132 - try {
133 - request.responseType = config.responseType;
134 - } catch (e) {
135 - // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
136 - // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
137 - if (config.responseType !== 'json') {
138 - throw e;
139 - }
140 - }
141 - }
142 -
143 - // Handle progress if needed
144 - if (typeof config.onDownloadProgress === 'function') {
145 - request.addEventListener('progress', config.onDownloadProgress);
146 - }
147 -
148 - // Not all browsers support upload events
149 - if (typeof config.onUploadProgress === 'function' && request.upload) {
150 - request.upload.addEventListener('progress', config.onUploadProgress);
151 - }
152 -
153 - if (config.cancelToken) {
154 - // Handle cancellation
155 - config.cancelToken.promise.then(function onCanceled(cancel) {
156 - if (!request) {
157 - return;
158 - }
159 -
160 - request.abort();
161 - reject(cancel);
162 - // Clean up request
163 - request = null;
164 - });
165 - }
166 -
167 - if (requestData === undefined) {
168 - requestData = null;
169 - }
170 -
171 - // Send the request
172 - request.send(requestData);
173 - });
174 -};
1 -'use strict';
2 -
3 -var utils = require('./utils');
4 -var bind = require('./helpers/bind');
5 -var Axios = require('./core/Axios');
6 -var mergeConfig = require('./core/mergeConfig');
7 -var defaults = require('./defaults');
8 -
9 -/**
10 - * Create an instance of Axios
11 - *
12 - * @param {Object} defaultConfig The default config for the instance
13 - * @return {Axios} A new instance of Axios
14 - */
15 -function createInstance(defaultConfig) {
16 - var context = new Axios(defaultConfig);
17 - var instance = bind(Axios.prototype.request, context);
18 -
19 - // Copy axios.prototype to instance
20 - utils.extend(instance, Axios.prototype, context);
21 -
22 - // Copy context to instance
23 - utils.extend(instance, context);
24 -
25 - return instance;
26 -}
27 -
28 -// Create the default instance to be exported
29 -var axios = createInstance(defaults);
30 -
31 -// Expose Axios class to allow class inheritance
32 -axios.Axios = Axios;
33 -
34 -// Factory for creating new instances
35 -axios.create = function create(instanceConfig) {
36 - return createInstance(mergeConfig(axios.defaults, instanceConfig));
37 -};
38 -
39 -// Expose Cancel & CancelToken
40 -axios.Cancel = require('./cancel/Cancel');
41 -axios.CancelToken = require('./cancel/CancelToken');
42 -axios.isCancel = require('./cancel/isCancel');
43 -
44 -// Expose all/spread
45 -axios.all = function all(promises) {
46 - return Promise.all(promises);
47 -};
48 -axios.spread = require('./helpers/spread');
49 -
50 -module.exports = axios;
51 -
52 -// Allow use of default import syntax in TypeScript
53 -module.exports.default = axios;
1 -'use strict';
2 -
3 -var utils = require('./../utils');
4 -var buildURL = require('../helpers/buildURL');
5 -var InterceptorManager = require('./InterceptorManager');
6 -var dispatchRequest = require('./dispatchRequest');
7 -var mergeConfig = require('./mergeConfig');
8 -
9 -/**
10 - * Create a new instance of Axios
11 - *
12 - * @param {Object} instanceConfig The default config for the instance
13 - */
14 -function Axios(instanceConfig) {
15 - this.defaults = instanceConfig;
16 - this.interceptors = {
17 - request: new InterceptorManager(),
18 - response: new InterceptorManager()
19 - };
20 -}
21 -
22 -/**
23 - * Dispatch a request
24 - *
25 - * @param {Object} config The config specific for this request (merged with this.defaults)
26 - */
27 -Axios.prototype.request = function request(config) {
28 - /*eslint no-param-reassign:0*/
29 - // Allow for axios('example/url'[, config]) a la fetch API
30 - if (typeof config === 'string') {
31 - config = arguments[1] || {};
32 - config.url = arguments[0];
33 - } else {
34 - config = config || {};
35 - }
36 -
37 - config = mergeConfig(this.defaults, config);
38 - config.method = config.method ? config.method.toLowerCase() : 'get';
39 -
40 - // Hook up interceptors middleware
41 - var chain = [dispatchRequest, undefined];
42 - var promise = Promise.resolve(config);
43 -
44 - this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
45 - chain.unshift(interceptor.fulfilled, interceptor.rejected);
46 - });
47 -
48 - this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
49 - chain.push(interceptor.fulfilled, interceptor.rejected);
50 - });
51 -
52 - while (chain.length) {
53 - promise = promise.then(chain.shift(), chain.shift());
54 - }
55 -
56 - return promise;
57 -};
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
65 -utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
66 - /*eslint func-names:0*/
67 - Axios.prototype[method] = function(url, config) {
68 - return this.request(utils.merge(config || {}, {
69 - method: method,
70 - url: url
71 - }));
72 - };
73 -});
74 -
75 -utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
76 - /*eslint func-names:0*/
77 - Axios.prototype[method] = function(url, data, config) {
78 - return this.request(utils.merge(config || {}, {
79 - method: method,
80 - url: url,
81 - data: data
82 - }));
83 - };
84 -});
85 -
86 -module.exports = Axios;
1 -'use strict';
2 -
3 -var utils = require('./../utils');
4 -var transformData = require('./transformData');
5 -var isCancel = require('../cancel/isCancel');
6 -var defaults = require('../defaults');
7 -var isAbsoluteURL = require('./../helpers/isAbsoluteURL');
8 -var combineURLs = require('./../helpers/combineURLs');
9 -
10 -/**
11 - * Throws a `Cancel` if cancellation has been requested.
12 - */
13 -function throwIfCancellationRequested(config) {
14 - if (config.cancelToken) {
15 - config.cancelToken.throwIfRequested();
16 - }
17 -}
18 -
19 -/**
20 - * Dispatch a request to the server using the configured adapter.
21 - *
22 - * @param {object} config The config that is to be used for the request
23 - * @returns {Promise} The Promise to be fulfilled
24 - */
25 -module.exports = function dispatchRequest(config) {
26 - throwIfCancellationRequested(config);
27 -
28 - // Support baseURL config
29 - if (config.baseURL && !isAbsoluteURL(config.url)) {
30 - config.url = combineURLs(config.baseURL, config.url);
31 - }
32 -
33 - // Ensure headers exist
34 - config.headers = config.headers || {};
35 -
36 - // Transform request data
37 - config.data = transformData(
38 - config.data,
39 - config.headers,
40 - config.transformRequest
41 - );
42 -
43 - // Flatten headers
44 - config.headers = utils.merge(
45 - config.headers.common || {},
46 - config.headers[config.method] || {},
47 - config.headers || {}
48 - );
49 -
50 - utils.forEach(
51 - ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
52 - function cleanHeaderConfig(method) {
53 - delete config.headers[method];
54 - }
55 - );
56 -
57 - var adapter = config.adapter || defaults.adapter;
58 -
59 - return adapter(config).then(function onAdapterResolution(response) {
60 - throwIfCancellationRequested(config);
61 -
62 - // Transform response data
63 - response.data = transformData(
64 - response.data,
65 - response.headers,
66 - config.transformResponse
67 - );
68 -
69 - return response;
70 - }, function onAdapterRejection(reason) {
71 - if (!isCancel(reason)) {
72 - throwIfCancellationRequested(config);
73 -
74 - // Transform response data
75 - if (reason && reason.response) {
76 - reason.response.data = transformData(
77 - reason.response.data,
78 - reason.response.headers,
79 - config.transformResponse
80 - );
81 - }
82 - }
83 -
84 - return Promise.reject(reason);
85 - });
86 -};
1 -'use strict';
2 -
3 -/**
4 - * Update an Error with the specified config, error code, and response.
5 - *
6 - * @param {Error} error The error to update.
7 - * @param {Object} config The config.
8 - * @param {string} [code] The error code (for example, 'ECONNABORTED').
9 - * @param {Object} [request] The request.
10 - * @param {Object} [response] The response.
11 - * @returns {Error} The error.
12 - */
13 -module.exports = function enhanceError(error, config, code, request, response) {
14 - error.config = config;
15 - if (code) {
16 - error.code = code;
17 - }
18 -
19 - error.request = request;
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 - };
41 - return error;
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 -};
1 -'use strict';
2 -
3 -var createError = require('./createError');
4 -
5 -/**
6 - * Resolve or reject a Promise based on response status.
7 - *
8 - * @param {Function} resolve A function that resolves the promise.
9 - * @param {Function} reject A function that rejects the promise.
10 - * @param {object} response The response.
11 - */
12 -module.exports = function settle(resolve, reject, response) {
13 - var validateStatus = response.config.validateStatus;
14 - if (!validateStatus || validateStatus(response.status)) {
15 - resolve(response);
16 - } else {
17 - reject(createError(
18 - 'Request failed with status code ' + response.status,
19 - response.config,
20 - null,
21 - response.request,
22 - response
23 - ));
24 - }
25 -};
1 -'use strict';
2 -
3 -var utils = require('./utils');
4 -var normalizeHeaderName = require('./helpers/normalizeHeaderName');
5 -
6 -var DEFAULT_CONTENT_TYPE = {
7 - 'Content-Type': 'application/x-www-form-urlencoded'
8 -};
9 -
10 -function setContentTypeIfUnset(headers, value) {
11 - if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
12 - headers['Content-Type'] = value;
13 - }
14 -}
15 -
16 -function getDefaultAdapter() {
17 - var adapter;
18 - // Only Node.JS has a process variable that is of [[Class]] process
19 - if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
20 - // For node use HTTP adapter
21 - adapter = require('./adapters/http');
22 - } else if (typeof XMLHttpRequest !== 'undefined') {
23 - // For browsers use XHR adapter
24 - adapter = require('./adapters/xhr');
25 - }
26 - return adapter;
27 -}
28 -
29 -var defaults = {
30 - adapter: getDefaultAdapter(),
31 -
32 - transformRequest: [function transformRequest(data, headers) {
33 - normalizeHeaderName(headers, 'Accept');
34 - normalizeHeaderName(headers, 'Content-Type');
35 - if (utils.isFormData(data) ||
36 - utils.isArrayBuffer(data) ||
37 - utils.isBuffer(data) ||
38 - utils.isStream(data) ||
39 - utils.isFile(data) ||
40 - utils.isBlob(data)
41 - ) {
42 - return data;
43 - }
44 - if (utils.isArrayBufferView(data)) {
45 - return data.buffer;
46 - }
47 - if (utils.isURLSearchParams(data)) {
48 - setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
49 - return data.toString();
50 - }
51 - if (utils.isObject(data)) {
52 - setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
53 - return JSON.stringify(data);
54 - }
55 - return data;
56 - }],
57 -
58 - transformResponse: [function transformResponse(data) {
59 - /*eslint no-param-reassign:0*/
60 - if (typeof data === 'string') {
61 - try {
62 - data = JSON.parse(data);
63 - } catch (e) { /* Ignore */ }
64 - }
65 - return data;
66 - }],
67 -
68 - /**
69 - * A timeout in milliseconds to abort a request. If set to 0 (default) a
70 - * timeout is not created.
71 - */
72 - timeout: 0,
73 -
74 - xsrfCookieName: 'XSRF-TOKEN',
75 - xsrfHeaderName: 'X-XSRF-TOKEN',
76 -
77 - maxContentLength: -1,
78 -
79 - validateStatus: function validateStatus(status) {
80 - return status >= 200 && status < 300;
81 - }
82 -};
83 -
84 -defaults.headers = {
85 - common: {
86 - 'Accept': 'application/json, text/plain, */*'
87 - }
88 -};
89 -
90 -utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
91 - defaults.headers[method] = {};
92 -});
93 -
94 -utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
95 - defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
96 -});
97 -
98 -module.exports = defaults;
1 -'use strict';
2 -
3 -var utils = require('./../utils');
4 -
5 -function encode(val) {
6 - return encodeURIComponent(val).
7 - replace(/%40/gi, '@').
8 - replace(/%3A/gi, ':').
9 - replace(/%24/g, '$').
10 - replace(/%2C/gi, ',').
11 - replace(/%20/g, '+').
12 - replace(/%5B/gi, '[').
13 - replace(/%5D/gi, ']');
14 -}
15 -
16 -/**
17 - * Build a URL by appending params to the end
18 - *
19 - * @param {string} url The base of the url (e.g., http://www.google.com)
20 - * @param {object} [params] The params to be appended
21 - * @returns {string} The formatted url
22 - */
23 -module.exports = function buildURL(url, params, paramsSerializer) {
24 - /*eslint no-param-reassign:0*/
25 - if (!params) {
26 - return url;
27 - }
28 -
29 - var serializedParams;
30 - if (paramsSerializer) {
31 - serializedParams = paramsSerializer(params);
32 - } else if (utils.isURLSearchParams(params)) {
33 - serializedParams = params.toString();
34 - } else {
35 - var parts = [];
36 -
37 - utils.forEach(params, function serialize(val, key) {
38 - if (val === null || typeof val === 'undefined') {
39 - return;
40 - }
41 -
42 - if (utils.isArray(val)) {
43 - key = key + '[]';
44 - } else {
45 - val = [val];
46 - }
47 -
48 - utils.forEach(val, function parseValue(v) {
49 - if (utils.isDate(v)) {
50 - v = v.toISOString();
51 - } else if (utils.isObject(v)) {
52 - v = JSON.stringify(v);
53 - }
54 - parts.push(encode(key) + '=' + encode(v));
55 - });
56 - });
57 -
58 - serializedParams = parts.join('&');
59 - }
60 -
61 - if (serializedParams) {
62 - var hashmarkIndex = url.indexOf('#');
63 - if (hashmarkIndex !== -1) {
64 - url = url.slice(0, hashmarkIndex);
65 - }
66 -
67 - url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
68 - }
69 -
70 - return url;
71 -};
1 -'use strict';
2 -
3 -var utils = require('./../utils');
4 -
5 -module.exports = (
6 - utils.isStandardBrowserEnv() ?
7 -
8 - // Standard browser envs support document.cookie
9 - (function standardBrowserEnv() {
10 - return {
11 - write: function write(name, value, expires, path, domain, secure) {
12 - var cookie = [];
13 - cookie.push(name + '=' + encodeURIComponent(value));
14 -
15 - if (utils.isNumber(expires)) {
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);
41 - }
42 - };
43 - })() :
44 -
45 - // Non standard browser env (web workers, react-native) lack needed support.
46 - (function nonStandardBrowserEnv() {
47 - return {
48 - write: function write() {},
49 - read: function read() { return null; },
50 - remove: function remove() {}
51 - };
52 - })()
53 -);
1 -'use strict';
2 -
3 -var utils = require('./../utils');
4 -
5 -module.exports = (
6 - utils.isStandardBrowserEnv() ?
7 -
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.
10 - (function standardBrowserEnv() {
11 - var msie = /(msie|trident)/i.test(navigator.userAgent);
12 - var urlParsingNode = document.createElement('a');
13 - var originURL;
14 -
15 - /**
16 - * Parse a URL to discover it's components
17 - *
18 - * @param {String} url The URL to be parsed
19 - * @returns {Object}
20 - */
21 - function resolveURL(url) {
22 - var href = url;
23 -
24 - if (msie) {
25 - // IE needs attribute set twice to normalize properties
26 - urlParsingNode.setAttribute('href', href);
27 - href = urlParsingNode.href;
28 - }
29 -
30 - urlParsingNode.setAttribute('href', href);
31 -
32 - // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33 - return {
34 - href: urlParsingNode.href,
35 - protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36 - host: urlParsingNode.host,
37 - search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38 - hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39 - hostname: urlParsingNode.hostname,
40 - port: urlParsingNode.port,
41 - pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42 - urlParsingNode.pathname :
43 - '/' + urlParsingNode.pathname
44 - };
45 - }
46 -
47 - originURL = resolveURL(window.location.href);
48 -
49 - /**
50 - * Determine if a URL shares the same origin as the current location
51 - *
52 - * @param {String} requestURL The URL to test
53 - * @returns {boolean} True if URL shares the same origin, otherwise false
54 - */
55 - return function isURLSameOrigin(requestURL) {
56 - var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57 - return (parsed.protocol === originURL.protocol &&
58 - parsed.host === originURL.host);
59 - };
60 - })() :
61 -
62 - // Non standard browser envs (web workers, react-native) lack needed support.
63 - (function nonStandardBrowserEnv() {
64 - return function isURLSameOrigin() {
65 - return true;
66 - };
67 - })()
68 -);
1 -'use strict';
2 -
3 -var utils = require('./../utils');
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 -
14 -/**
15 - * Parse headers into an object
16 - *
17 - * ```
18 - * Date: Wed, 27 Aug 2014 08:58:49 GMT
19 - * Content-Type: application/json
20 - * Connection: keep-alive
21 - * Transfer-Encoding: chunked
22 - * ```
23 - *
24 - * @param {String} headers Headers needing to be parsed
25 - * @returns {Object} Headers parsed into an object
26 - */
27 -module.exports = function parseHeaders(headers) {
28 - var parsed = {};
29 - var key;
30 - var val;
31 - var i;
32 -
33 - if (!headers) { return parsed; }
34 -
35 - utils.forEach(headers.split('\n'), function parser(line) {
36 - i = line.indexOf(':');
37 - key = utils.trim(line.substr(0, i)).toLowerCase();
38 - val = utils.trim(line.substr(i + 1));
39 -
40 - if (key) {
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 - }
49 - }
50 - });
51 -
52 - return parsed;
53 -};
1 -'use strict';
2 -
3 -var bind = require('./helpers/bind');
4 -var isBuffer = require('is-buffer');
5 -
6 -/*global toString:true*/
7 -
8 -// utils is a library of generic helper functions non-specific to axios
9 -
10 -var toString = Object.prototype.toString;
11 -
12 -/**
13 - * Determine if a value is an Array
14 - *
15 - * @param {Object} val The value to test
16 - * @returns {boolean} True if value is an Array, otherwise false
17 - */
18 -function isArray(val) {
19 - return toString.call(val) === '[object Array]';
20 -}
21 -
22 -/**
23 - * Determine if a value is an ArrayBuffer
24 - *
25 - * @param {Object} val The value to test
26 - * @returns {boolean} True if value is an ArrayBuffer, otherwise false
27 - */
28 -function isArrayBuffer(val) {
29 - return toString.call(val) === '[object ArrayBuffer]';
30 -}
31 -
32 -/**
33 - * Determine if a value is a FormData
34 - *
35 - * @param {Object} val The value to test
36 - * @returns {boolean} True if value is an FormData, otherwise false
37 - */
38 -function isFormData(val) {
39 - return (typeof FormData !== 'undefined') && (val instanceof FormData);
40 -}
41 -
42 -/**
43 - * Determine if a value is a view on an ArrayBuffer
44 - *
45 - * @param {Object} val The value to test
46 - * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
47 - */
48 -function isArrayBufferView(val) {
49 - var result;
50 - if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
51 - result = ArrayBuffer.isView(val);
52 - } else {
53 - result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
54 - }
55 - return result;
56 -}
57 -
58 -/**
59 - * Determine if a value is a String
60 - *
61 - * @param {Object} val The value to test
62 - * @returns {boolean} True if value is a String, otherwise false
63 - */
64 -function isString(val) {
65 - return typeof val === 'string';
66 -}
67 -
68 -/**
69 - * Determine if a value is a Number
70 - *
71 - * @param {Object} val The value to test
72 - * @returns {boolean} True if value is a Number, otherwise false
73 - */
74 -function isNumber(val) {
75 - return typeof val === 'number';
76 -}
77 -
78 -/**
79 - * Determine if a value is undefined
80 - *
81 - * @param {Object} val The value to test
82 - * @returns {boolean} True if the value is undefined, otherwise false
83 - */
84 -function isUndefined(val) {
85 - return typeof val === 'undefined';
86 -}
87 -
88 -/**
89 - * Determine if a value is an Object
90 - *
91 - * @param {Object} val The value to test
92 - * @returns {boolean} True if value is an Object, otherwise false
93 - */
94 -function isObject(val) {
95 - return val !== null && typeof val === 'object';
96 -}
97 -
98 -/**
99 - * Determine if a value is a Date
100 - *
101 - * @param {Object} val The value to test
102 - * @returns {boolean} True if value is a Date, otherwise false
103 - */
104 -function isDate(val) {
105 - return toString.call(val) === '[object Date]';
106 -}
107 -
108 -/**
109 - * Determine if a value is a File
110 - *
111 - * @param {Object} val The value to test
112 - * @returns {boolean} True if value is a File, otherwise false
113 - */
114 -function isFile(val) {
115 - return toString.call(val) === '[object File]';
116 -}
117 -
118 -/**
119 - * Determine if a value is a Blob
120 - *
121 - * @param {Object} val The value to test
122 - * @returns {boolean} True if value is a Blob, otherwise false
123 - */
124 -function isBlob(val) {
125 - return toString.call(val) === '[object Blob]';
126 -}
127 -
128 -/**
129 - * Determine if a value is a Function
130 - *
131 - * @param {Object} val The value to test
132 - * @returns {boolean} True if value is a Function, otherwise false
133 - */
134 -function isFunction(val) {
135 - return toString.call(val) === '[object Function]';
136 -}
137 -
138 -/**
139 - * Determine if a value is a Stream
140 - *
141 - * @param {Object} val The value to test
142 - * @returns {boolean} True if value is a Stream, otherwise false
143 - */
144 -function isStream(val) {
145 - return isObject(val) && isFunction(val.pipe);
146 -}
147 -
148 -/**
149 - * Determine if a value is a URLSearchParams object
150 - *
151 - * @param {Object} val The value to test
152 - * @returns {boolean} True if value is a URLSearchParams object, otherwise false
153 - */
154 -function isURLSearchParams(val) {
155 - return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
156 -}
157 -
158 -/**
159 - * Trim excess whitespace off the beginning and end of a string
160 - *
161 - * @param {String} str The String to trim
162 - * @returns {String} The String freed of excess whitespace
163 - */
164 -function trim(str) {
165 - return str.replace(/^\s*/, '').replace(/\s*$/, '');
166 -}
167 -
168 -/**
169 - * Determine if we're running in a standard browser environment
170 - *
171 - * This allows axios to run in a web worker, and react-native.
172 - * Both environments support XMLHttpRequest, but not fully standard globals.
173 - *
174 - * web workers:
175 - * typeof window -> undefined
176 - * typeof document -> undefined
177 - *
178 - * react-native:
179 - * navigator.product -> 'ReactNative'
180 - * nativescript
181 - * navigator.product -> 'NativeScript' or 'NS'
182 - */
183 -function isStandardBrowserEnv() {
184 - if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
185 - navigator.product === 'NativeScript' ||
186 - navigator.product === 'NS')) {
187 - return false;
188 - }
189 - return (
190 - typeof window !== 'undefined' &&
191 - typeof document !== 'undefined'
192 - );
193 -}
194 -
195 -/**
196 - * Iterate over an Array or an Object invoking a function for each item.
197 - *
198 - * If `obj` is an Array callback will be called passing
199 - * the value, index, and complete array for each item.
200 - *
201 - * If 'obj' is an Object callback will be called passing
202 - * the value, key, and complete object for each property.
203 - *
204 - * @param {Object|Array} obj The object to iterate
205 - * @param {Function} fn The callback to invoke for each item
206 - */
207 -function forEach(obj, fn) {
208 - // Don't bother if no value provided
209 - if (obj === null || typeof obj === 'undefined') {
210 - return;
211 - }
212 -
213 - // Force an array if not already something iterable
214 - if (typeof obj !== 'object') {
215 - /*eslint no-param-reassign:0*/
216 - obj = [obj];
217 - }
218 -
219 - if (isArray(obj)) {
220 - // Iterate over array values
221 - for (var i = 0, l = obj.length; i < l; i++) {
222 - fn.call(null, obj[i], i, obj);
223 - }
224 - } else {
225 - // Iterate over object keys
226 - for (var key in obj) {
227 - if (Object.prototype.hasOwnProperty.call(obj, key)) {
228 - fn.call(null, obj[key], key, obj);
229 - }
230 - }
231 - }
232 -}
233 -
234 -/**
235 - * Accepts varargs expecting each argument to be an object, then
236 - * immutably merges the properties of each object and returns result.
237 - *
238 - * When multiple objects contain the same key the later object in
239 - * the arguments list will take precedence.
240 - *
241 - * Example:
242 - *
243 - * ```js
244 - * var result = merge({foo: 123}, {foo: 456});
245 - * console.log(result.foo); // outputs 456
246 - * ```
247 - *
248 - * @param {Object} obj1 Object to merge
249 - * @returns {Object} Result of all merge properties
250 - */
251 -function merge(/* obj1, obj2, obj3, ... */) {
252 - var result = {};
253 - function assignValue(val, key) {
254 - if (typeof result[key] === 'object' && typeof val === 'object') {
255 - result[key] = merge(result[key], val);
256 - } else {
257 - result[key] = val;
258 - }
259 - }
260 -
261 - for (var i = 0, l = arguments.length; i < l; i++) {
262 - forEach(arguments[i], assignValue);
263 - }
264 - return result;
265 -}
266 -
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 -/**
294 - * Extends object a by mutably adding to it the properties of object b.
295 - *
296 - * @param {Object} a The object to be extended
297 - * @param {Object} b The object to copy properties from
298 - * @param {Object} thisArg The object to bind function to
299 - * @return {Object} The resulting value of object a
300 - */
301 -function extend(a, b, thisArg) {
302 - forEach(b, function assignValue(val, key) {
303 - if (thisArg && typeof val === 'function') {
304 - a[key] = bind(val, thisArg);
305 - } else {
306 - a[key] = val;
307 - }
308 - });
309 - return a;
310 -}
311 -
312 -module.exports = {
313 - isArray: isArray,
314 - isArrayBuffer: isArrayBuffer,
315 - isBuffer: isBuffer,
316 - isFormData: isFormData,
317 - isArrayBufferView: isArrayBufferView,
318 - isString: isString,
319 - isNumber: isNumber,
320 - isObject: isObject,
321 - isUndefined: isUndefined,
322 - isDate: isDate,
323 - isFile: isFile,
324 - isBlob: isBlob,
325 - isFunction: isFunction,
326 - isStream: isStream,
327 - isURLSearchParams: isURLSearchParams,
328 - isStandardBrowserEnv: isStandardBrowserEnv,
329 - forEach: forEach,
330 - merge: merge,
331 - deepMerge: deepMerge,
332 - extend: extend,
333 - trim: trim
334 -};
1 -{
2 - "_from": "axios@^0.19.0",
3 - "_id": "axios@0.19.0",
4 - "_inBundle": false,
5 - "_integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
6 - "_location": "/axios",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "axios@^0.19.0",
12 - "name": "axios",
13 - "escapedName": "axios",
14 - "rawSpec": "^0.19.0",
15 - "saveSpec": null,
16 - "fetchSpec": "^0.19.0"
17 - },
18 - "_requiredBy": [
19 - "/@line/bot-sdk"
20 - ],
21 - "_resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
22 - "_shasum": "8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8",
23 - "_spec": "axios@^0.19.0",
24 - "_where": "C:\\Users\\Home\\Documents\\윤동주\\경희\\2019-2 오픈소스SW개발\\Term Project\\LINEBOT\\node_modules\\@line\\bot-sdk",
25 - "author": {
26 - "name": "Matt Zabriskie"
27 - },
28 - "browser": {
29 - "./lib/adapters/http.js": "./lib/adapters/xhr.js"
30 - },
31 - "bugs": {
32 - "url": "https://github.com/axios/axios/issues"
33 - },
34 - "bundleDependencies": false,
35 - "bundlesize": [
36 - {
37 - "path": "./dist/axios.min.js",
38 - "threshold": "5kB"
39 - }
40 - ],
41 - "dependencies": {
42 - "follow-redirects": "1.5.10",
43 - "is-buffer": "^2.0.2"
44 - },
45 - "deprecated": false,
46 - "description": "Promise based HTTP client for the browser and node.js",
47 - "devDependencies": {
48 - "bundlesize": "^0.17.0",
49 - "coveralls": "^3.0.0",
50 - "es6-promise": "^4.2.4",
51 - "grunt": "^1.0.2",
52 - "grunt-banner": "^0.6.0",
53 - "grunt-cli": "^1.2.0",
54 - "grunt-contrib-clean": "^1.1.0",
55 - "grunt-contrib-watch": "^1.0.0",
56 - "grunt-eslint": "^20.1.0",
57 - "grunt-karma": "^2.0.0",
58 - "grunt-mocha-test": "^0.13.3",
59 - "grunt-ts": "^6.0.0-beta.19",
60 - "grunt-webpack": "^1.0.18",
61 - "istanbul-instrumenter-loader": "^1.0.0",
62 - "jasmine-core": "^2.4.1",
63 - "karma": "^1.3.0",
64 - "karma-chrome-launcher": "^2.2.0",
65 - "karma-coverage": "^1.1.1",
66 - "karma-firefox-launcher": "^1.1.0",
67 - "karma-jasmine": "^1.1.1",
68 - "karma-jasmine-ajax": "^0.1.13",
69 - "karma-opera-launcher": "^1.0.0",
70 - "karma-safari-launcher": "^1.0.0",
71 - "karma-sauce-launcher": "^1.2.0",
72 - "karma-sinon": "^1.0.5",
73 - "karma-sourcemap-loader": "^0.3.7",
74 - "karma-webpack": "^1.7.0",
75 - "load-grunt-tasks": "^3.5.2",
76 - "minimist": "^1.2.0",
77 - "mocha": "^5.2.0",
78 - "sinon": "^4.5.0",
79 - "typescript": "^2.8.1",
80 - "url-search-params": "^0.10.0",
81 - "webpack": "^1.13.1",
82 - "webpack-dev-server": "^1.14.1"
83 - },
84 - "homepage": "https://github.com/axios/axios",
85 - "keywords": [
86 - "xhr",
87 - "http",
88 - "ajax",
89 - "promise",
90 - "node"
91 - ],
92 - "license": "MIT",
93 - "main": "index.js",
94 - "name": "axios",
95 - "repository": {
96 - "type": "git",
97 - "url": "git+https://github.com/axios/axios.git"
98 - },
99 - "scripts": {
100 - "build": "NODE_ENV=production grunt build",
101 - "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
102 - "examples": "node ./examples/server.js",
103 - "fix": "eslint --fix lib/**/*.js",
104 - "postversion": "git push && git push --tags",
105 - "preversion": "npm test",
106 - "start": "node ./sandbox/server.js",
107 - "test": "grunt test && bundlesize",
108 - "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"
109 - },
110 - "typings": "./index.d.ts",
111 - "version": "0.19.0"
112 -}
1 -# is-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
2 -
3 -[travis-image]: https://img.shields.io/travis/feross/is-buffer/master.svg
4 -[travis-url]: https://travis-ci.org/feross/is-buffer
5 -[npm-image]: https://img.shields.io/npm/v/is-buffer.svg
6 -[npm-url]: https://npmjs.org/package/is-buffer
7 -[downloads-image]: https://img.shields.io/npm/dm/is-buffer.svg
8 -[downloads-url]: https://npmjs.org/package/is-buffer
9 -[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
10 -[standard-url]: https://standardjs.com
11 -
12 -#### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (including the [browserify Buffer](https://github.com/feross/buffer))
13 -
14 -[![saucelabs][saucelabs-image]][saucelabs-url]
15 -
16 -[saucelabs-image]: https://saucelabs.com/browser-matrix/is-buffer.svg
17 -[saucelabs-url]: https://saucelabs.com/u/is-buffer
18 -
19 -## Why not use `Buffer.isBuffer`?
20 -
21 -This module lets you check if an object is a `Buffer` without using `Buffer.isBuffer` (which includes the whole [buffer](https://github.com/feross/buffer) module in [browserify](http://browserify.org/)).
22 -
23 -It's future-proof and works in node too!
24 -
25 -## install
26 -
27 -```bash
28 -npm install is-buffer
29 -```
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 -
33 -## usage
34 -
35 -```js
36 -var isBuffer = require('is-buffer')
37 -
38 -isBuffer(new Buffer(4)) // true
39 -isBuffer(Buffer.alloc(4)) //true
40 -
41 -isBuffer(undefined) // false
42 -isBuffer(null) // false
43 -isBuffer('') // false
44 -isBuffer(true) // false
45 -isBuffer(false) // false
46 -isBuffer(0) // false
47 -isBuffer(1) // false
48 -isBuffer(1.0) // false
49 -isBuffer('string') // false
50 -isBuffer({}) // false
51 -isBuffer(function foo () {}) // false
52 -```
53 -
54 -## license
55 -
56 -MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org).
1 -declare function isBuffer(obj: any): boolean
2 -export = isBuffer
1 -/*!
2 - * Determine if an object is a Buffer
3 - *
4 - * @author Feross Aboukhadijeh <https://feross.org>
5 - * @license MIT
6 - */
7 -
8 -module.exports = function isBuffer (obj) {
9 - return obj != null && obj.constructor != null &&
10 - typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
11 -}
1 -{
2 - "_from": "is-buffer@^2.0.2",
3 - "_id": "is-buffer@2.0.4",
4 - "_inBundle": false,
5 - "_integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==",
6 - "_location": "/is-buffer",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "is-buffer@^2.0.2",
12 - "name": "is-buffer",
13 - "escapedName": "is-buffer",
14 - "rawSpec": "^2.0.2",
15 - "saveSpec": null,
16 - "fetchSpec": "^2.0.2"
17 - },
18 - "_requiredBy": [
19 - "/axios"
20 - ],
21 - "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
22 - "_shasum": "3e572f23c8411a5cfd9557c849e3665e0b290623",
23 - "_spec": "is-buffer@^2.0.2",
24 - "_where": "C:\\Users\\Home\\Documents\\윤동주\\경희\\2019-2 오픈소스SW개발\\Term Project\\LINEBOT\\node_modules\\axios",
25 - "author": {
26 - "name": "Feross Aboukhadijeh",
27 - "email": "feross@feross.org",
28 - "url": "https://feross.org"
29 - },
30 - "bugs": {
31 - "url": "https://github.com/feross/is-buffer/issues"
32 - },
33 - "bundleDependencies": false,
34 - "dependencies": {},
35 - "deprecated": false,
36 - "description": "Determine if an object is a Buffer",
37 - "devDependencies": {
38 - "airtap": "^2.0.3",
39 - "standard": "*",
40 - "tape": "^4.11.0"
41 - },
42 - "engines": {
43 - "node": ">=4"
44 - },
45 - "homepage": "https://github.com/feross/is-buffer#readme",
46 - "keywords": [
47 - "arraybuffer",
48 - "browser",
49 - "browser buffer",
50 - "browserify",
51 - "buffer",
52 - "buffers",
53 - "core buffer",
54 - "dataview",
55 - "float32array",
56 - "float64array",
57 - "int16array",
58 - "int32array",
59 - "type",
60 - "typed array",
61 - "uint32array"
62 - ],
63 - "license": "MIT",
64 - "main": "index.js",
65 - "name": "is-buffer",
66 - "repository": {
67 - "type": "git",
68 - "url": "git://github.com/feross/is-buffer.git"
69 - },
70 - "scripts": {
71 - "test": "standard && npm run test-node && npm run test-browser",
72 - "test-browser": "airtap -- test/*.js",
73 - "test-browser-local": "airtap --local -- test/*.js",
74 - "test-node": "tape test/*.js"
75 - },
76 - "version": "2.0.4"
77 -}
This diff is collapsed. Click to expand it.
1 -{
2 - "name": "linebot",
3 - "version": "1.0.0",
4 - "description": "",
5 - "main": "app.js",
6 - "scripts": {
7 - "test": "echo \"Error: no test specified\" && exit 1",
8 - "start": "node server.js"
9 - },
10 - "author": "강수인",
11 - "license": "MIT",
12 - "dependencies": {
13 - "@line/bot-sdk": "^6.8.3",
14 - "express": "^4.16.4"
15 - }
16 -}