Showing
60 changed files
with
910 additions
and
596 deletions
1 | +## 6.8.3 (05 Nov 2019) | ||
2 | + | ||
3 | +### Bug fix | ||
4 | + | ||
5 | +* Add exception handler in middleware (#153) | ||
6 | + | ||
7 | +### Feature | ||
8 | + | ||
9 | +* Flex Message Update 1 (#173) | ||
10 | +* Support friend statistics API (#161) | ||
11 | + | ||
12 | +### Misc | ||
13 | + | ||
14 | +* Update dependencies (#174) | ||
15 | + | ||
16 | +## 6.8.2 (08 Aug 2019) | ||
17 | + | ||
18 | +### Bug fix | ||
19 | + | ||
20 | +* Fix LINEThings Scenario Execution Event Types (#158) | ||
21 | + | ||
22 | +## 6.8.1 (29 Jul 2019) | ||
23 | + | ||
24 | +### Bug fix | ||
25 | + | ||
26 | +* Fix a type wrong in Template Message (#163) | ||
27 | + | ||
28 | +### Feature | ||
29 | +* Get `X-LINE-Request-Id` by using `responseData['x-line-request-id']` (#151 #157) | ||
30 | + | ||
31 | +## 6.8.0 (25 Jun 2019) | ||
32 | + | ||
33 | +### Feature | ||
34 | + | ||
35 | +* Add new parameter in push/reply/multicast/broadcast API to catch up the newest bot API (#147) | ||
36 | +* Add new APIs in bot API (#147) | ||
37 | + - Get the target limit for additional messages | ||
38 | + - Get number of messages sent this month | ||
39 | + - Get number of sent broadcast messages | ||
40 | + - Send broadcast message | ||
41 | + | ||
42 | +### Breaking changes | ||
43 | +* Deprecate Node 6 and start to support Node 12 (#139) | ||
44 | +* Remove polyfills for Node 6 (#149) | ||
45 | + | ||
46 | +### Type | ||
47 | + | ||
48 | +* Add LINE Things Event (#150) | ||
49 | + | ||
50 | +### Misc | ||
51 | +* Update axios and other dependencies by running `npm audit fix` to fix vulnerabilities. (#148 #154) | ||
52 | + | ||
53 | +## 6.7.0 (18 Apr 2019) | ||
54 | + | ||
55 | +### Feature | ||
56 | + | ||
57 | +* Add alt URL field to URI action (#135) | ||
58 | +* Implement (un)linkRichMenuToMultipleUsers (#135) | ||
59 | + | ||
60 | +### Type | ||
61 | + | ||
62 | +* Fix typo in a type (#124) | ||
63 | + | ||
64 | + | ||
65 | +## 6.6.0 (4 Mar 2019) | ||
66 | + | ||
67 | +### Feature | ||
68 | + | ||
69 | +* Add DeviceLinkEvent / DeviceUnlinkEvent (#123) | ||
70 | + | ||
71 | +### Type | ||
72 | + | ||
73 | +* Fix FlexSpacer to have optional 'size' property (#122) | ||
74 | + | ||
75 | +### Misc | ||
76 | + | ||
77 | +* Run `npm audit fix` to fix minor dependency vulnerability. | ||
78 | + | ||
79 | + | ||
80 | +## 6.5.0 (16 Feb 2019) | ||
81 | + | ||
82 | +### Feature | ||
83 | + | ||
84 | +* Add APIs to get number of sent messages (#116) | ||
85 | +* Add account link event (#117) | ||
86 | + | ||
87 | +### Misc | ||
88 | + | ||
89 | +* Fix a typo in doc (#119) | ||
90 | + | ||
91 | + | ||
1 | ## 6.4.0 (19 Nov 2018) | 92 | ## 6.4.0 (19 Nov 2018) |
2 | 93 | ||
3 | ### Feature | 94 | ### Feature | ... | ... |
1 | -# line-bot-sdk-nodejs | 1 | +# LINE Messaging API SDK for nodejs |
2 | 2 | ||
3 | [![Travis CI](https://travis-ci.org/line/line-bot-sdk-nodejs.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-nodejs) | 3 | [![Travis CI](https://travis-ci.org/line/line-bot-sdk-nodejs.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-nodejs) |
4 | [![npmjs](https://badge.fury.io/js/%40line%2Fbot-sdk.svg)](https://www.npmjs.com/package/@line/bot-sdk) | 4 | [![npmjs](https://badge.fury.io/js/%40line%2Fbot-sdk.svg)](https://www.npmjs.com/package/@line/bot-sdk) |
5 | 5 | ||
6 | -Node.js SDK for LINE Messaging API | ||
7 | 6 | ||
8 | -## Getting Started | 7 | +## Introduction |
8 | +The LINE Messaging API SDK for nodejs makes it easy to develop bots using LINE Messaging API, and you can create a sample bot within minutes. | ||
9 | 9 | ||
10 | -### Install | 10 | +## Documentation |
11 | + | ||
12 | +See the official API documentation for more information | ||
13 | + | ||
14 | +- English: https://developers.line.biz/en/docs/messaging-api/overview/ | ||
15 | +- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/ | ||
16 | + | ||
17 | +line-bot-sdk-nodejs documentation: https://line.github.io/line-bot-sdk-nodejs/#getting-started | ||
18 | + | ||
19 | +## Requirements | ||
20 | + | ||
21 | +* **Node.js** 8 or higher | ||
22 | + | ||
23 | +## Installation | ||
11 | 24 | ||
12 | Using [npm](https://www.npmjs.com/): | 25 | Using [npm](https://www.npmjs.com/): |
13 | 26 | ||
... | @@ -15,30 +28,37 @@ Using [npm](https://www.npmjs.com/): | ... | @@ -15,30 +28,37 @@ Using [npm](https://www.npmjs.com/): |
15 | $ npm install @line/bot-sdk --save | 28 | $ npm install @line/bot-sdk --save |
16 | ``` | 29 | ``` |
17 | 30 | ||
18 | -### Documentation | 31 | +## Help and media |
19 | - | 32 | +FAQ: https://developers.line.biz/en/faq/ |
20 | -For guide, API reference, and other information, please refer to | ||
21 | -the [documentation](https://line.github.io/line-bot-sdk-nodejs/). | ||
22 | 33 | ||
23 | -### LINE Messaging API References | 34 | +Community Q&A: https://www.line-community.me/questions |
24 | 35 | ||
25 | -Here are links to official references for LINE Messaging API. It is recommended | 36 | +News: https://developers.line.biz/en/news/ |
26 | -reading them beforehand. | ||
27 | 37 | ||
28 | -* LINE API Reference [EN](https://developers.line.me/en/docs/messaging-api/reference/) [JA](https://developers.line.me/ja/docs/messaging-api/reference/) | 38 | +Twitter: @LINE_DEV |
29 | -* LINE Developers - Messaging API | ||
30 | - * [Overview](https://developers.line.me/messaging-api/overview) | ||
31 | - * [Getting started](https://developers.line.me/messaging-api/getting-started) | ||
32 | - * [Joining groups and rooms](https://developers.line.me/messaging-api/joining-groups-and-rooms) | ||
33 | 39 | ||
34 | -## Requirements | 40 | +## Versioning |
41 | +This project respects semantic versioning | ||
35 | 42 | ||
36 | -* **Node.js** 6 or higher | 43 | +See http://semver.org/ |
37 | 44 | ||
38 | ## Contributing | 45 | ## Contributing |
39 | 46 | ||
40 | Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution. | 47 | Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution. |
41 | 48 | ||
42 | ## License | 49 | ## License |
43 | - | 50 | +``` |
44 | -[Apache License Version 2.0](LICENSE) | 51 | +Copyright (C) 2016 LINE Corp. |
52 | + | ||
53 | +Licensed under the Apache License, Version 2.0 (the "License"); | ||
54 | +you may not use this file except in compliance with the License. | ||
55 | +You may obtain a copy of the License at | ||
56 | + | ||
57 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
58 | + | ||
59 | +Unless required by applicable law or agreed to in writing, software | ||
60 | +distributed under the License is distributed on an "AS IS" BASIS, | ||
61 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
62 | +See the License for the specific language governing permissions and | ||
63 | +limitations under the License. | ||
64 | +``` | ... | ... |
... | @@ -5,9 +5,11 @@ export default class Client { | ... | @@ -5,9 +5,11 @@ export default class Client { |
5 | config: Types.ClientConfig; | 5 | config: Types.ClientConfig; |
6 | private http; | 6 | private http; |
7 | constructor(config: Types.ClientConfig); | 7 | constructor(config: Types.ClientConfig); |
8 | - pushMessage(to: string, messages: Types.Message | Types.Message[]): Promise<any>; | 8 | + private parseHTTPResponse; |
9 | - replyMessage(replyToken: string, messages: Types.Message | Types.Message[]): Promise<any>; | 9 | + pushMessage(to: string, messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>; |
10 | - multicast(to: string[], messages: Types.Message | Types.Message[]): Promise<any>; | 10 | + replyMessage(replyToken: string, messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>; |
11 | + multicast(to: string[], messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>; | ||
12 | + broadcast(messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>; | ||
11 | getProfile(userId: string): Promise<Types.Profile>; | 13 | getProfile(userId: string): Promise<Types.Profile>; |
12 | private getChatMemberProfile; | 14 | private getChatMemberProfile; |
13 | getGroupMemberProfile(groupId: string, userId: string): Promise<Types.Profile>; | 15 | getGroupMemberProfile(groupId: string, userId: string): Promise<Types.Profile>; |
... | @@ -25,6 +27,8 @@ export default class Client { | ... | @@ -25,6 +27,8 @@ export default class Client { |
25 | getRichMenuIdOfUser(userId: string): Promise<string>; | 27 | getRichMenuIdOfUser(userId: string): Promise<string>; |
26 | linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>; | 28 | linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>; |
27 | unlinkRichMenuFromUser(userId: string): Promise<any>; | 29 | unlinkRichMenuFromUser(userId: string): Promise<any>; |
30 | + linkRichMenuToMultipleUsers(richMenuId: string, userIds: string[]): Promise<any>; | ||
31 | + unlinkRichMenusFromMultipleUsers(userIds: string[]): Promise<any>; | ||
28 | getRichMenuImage(richMenuId: string): Promise<Readable>; | 32 | getRichMenuImage(richMenuId: string): Promise<Readable>; |
29 | setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>; | 33 | setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>; |
30 | getRichMenuList(): Promise<Array<Types.RichMenuResponse>>; | 34 | getRichMenuList(): Promise<Array<Types.RichMenuResponse>>; |
... | @@ -32,4 +36,23 @@ export default class Client { | ... | @@ -32,4 +36,23 @@ export default class Client { |
32 | getDefaultRichMenuId(): Promise<string>; | 36 | getDefaultRichMenuId(): Promise<string>; |
33 | deleteDefaultRichMenu(): Promise<{}>; | 37 | deleteDefaultRichMenu(): Promise<{}>; |
34 | getLinkToken(userId: string): Promise<string>; | 38 | getLinkToken(userId: string): Promise<string>; |
39 | + getNumberOfSentReplyMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>; | ||
40 | + getNumberOfSentPushMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>; | ||
41 | + getNumberOfSentMulticastMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>; | ||
42 | + getTargetLimitForAdditionalMessages(): Promise<Types.TargetLimitForAdditionalMessages>; | ||
43 | + getNumberOfMessagesSentThisMonth(): Promise<Types.NumberOfMessagesSentThisMonth>; | ||
44 | + getNumberOfSentBroadcastMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>; | ||
45 | + getNumberOfMessageDeliveries(date: string): Promise<Types.NumberOfMessageDeliveriesResponse>; | ||
46 | + getNumberOfFollowers(date: string): Promise<Types.NumberOfFollowersResponse>; | ||
47 | + getFriendDemographics(): Promise<Types.FriendDemoGraphics>; | ||
48 | +} | ||
49 | +export declare class OAuth { | ||
50 | + private http; | ||
51 | + constructor(); | ||
52 | + issueAccessToken(client_id: string, client_secret: string): Promise<{ | ||
53 | + access_token: string; | ||
54 | + expires_in: number; | ||
55 | + token_type: "Bearer"; | ||
56 | + }>; | ||
57 | + revokeAccessToken(access_token: string): Promise<{}>; | ||
35 | } | 58 | } | ... | ... |
This diff is collapsed. Click to expand it.
1 | /// <reference types="node" /> | 1 | /// <reference types="node" /> |
2 | +import { AxiosResponse } from "axios"; | ||
2 | import { Readable } from "stream"; | 3 | import { Readable } from "stream"; |
4 | +declare type httpClientConfig = { | ||
5 | + baseURL?: string; | ||
6 | + defaultHeaders?: any; | ||
7 | + responseParser?: <T>(res: AxiosResponse) => T; | ||
8 | +}; | ||
3 | export default class HTTPClient { | 9 | export default class HTTPClient { |
4 | private instance; | 10 | private instance; |
5 | - constructor(baseURL?: string, defaultHeaders?: any); | 11 | + private config; |
12 | + constructor(config?: httpClientConfig); | ||
6 | get<T>(url: string, params?: any): Promise<T>; | 13 | get<T>(url: string, params?: any): Promise<T>; |
7 | getStream(url: string, params?: any): Promise<Readable>; | 14 | getStream(url: string, params?: any): Promise<Readable>; |
8 | - post<T>(url: string, data?: any): Promise<T>; | 15 | + post<T>(url: string, body?: any): Promise<T>; |
16 | + postForm<T>(url: string, body?: any): Promise<T>; | ||
9 | postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>; | 17 | postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>; |
10 | delete<T>(url: string, params?: any): Promise<T>; | 18 | delete<T>(url: string, params?: any): Promise<T>; |
11 | private wrapError; | 19 | private wrapError; |
12 | } | 20 | } |
21 | +export {}; | ... | ... |
... | @@ -4,9 +4,12 @@ const axios_1 = require("axios"); | ... | @@ -4,9 +4,12 @@ const axios_1 = require("axios"); |
4 | const stream_1 = require("stream"); | 4 | const stream_1 = require("stream"); |
5 | const exceptions_1 = require("./exceptions"); | 5 | const exceptions_1 = require("./exceptions"); |
6 | const fileType = require("file-type"); | 6 | const fileType = require("file-type"); |
7 | +const qs = require("querystring"); | ||
7 | const pkg = require("../package.json"); | 8 | const pkg = require("../package.json"); |
8 | class HTTPClient { | 9 | class HTTPClient { |
9 | - constructor(baseURL, defaultHeaders) { | 10 | + constructor(config = {}) { |
11 | + this.config = config; | ||
12 | + const { baseURL, defaultHeaders } = config; | ||
10 | this.instance = axios_1.default.create({ | 13 | this.instance = axios_1.default.create({ |
11 | baseURL, | 14 | baseURL, |
12 | headers: Object.assign({}, defaultHeaders, { | 15 | headers: Object.assign({}, defaultHeaders, { |
... | @@ -15,27 +18,40 @@ class HTTPClient { | ... | @@ -15,27 +18,40 @@ class HTTPClient { |
15 | }); | 18 | }); |
16 | this.instance.interceptors.response.use(res => res, err => Promise.reject(this.wrapError(err))); | 19 | this.instance.interceptors.response.use(res => res, err => Promise.reject(this.wrapError(err))); |
17 | } | 20 | } |
18 | - get(url, params) { | 21 | + async get(url, params) { |
19 | - return this.instance.get(url, { params }).then(res => res.data); | 22 | + const res = await this.instance.get(url, { params }); |
23 | + return res.data; | ||
20 | } | 24 | } |
21 | - getStream(url, params) { | 25 | + async getStream(url, params) { |
22 | - return this.instance | 26 | + const res = await this.instance.get(url, { |
23 | - .get(url, { params, responseType: "stream" }) | 27 | + params, |
24 | - .then(res => res.data); | 28 | + responseType: "stream", |
29 | + }); | ||
30 | + return res.data; | ||
25 | } | 31 | } |
26 | - post(url, data) { | 32 | + async post(url, body) { |
27 | - return this.instance | 33 | + const res = await this.instance.post(url, body, { |
28 | - .post(url, data, { headers: { "Content-Type": "application/json" } }) | 34 | + headers: { "Content-Type": "application/json" }, |
29 | - .then(res => res.data); | 35 | + }); |
36 | + const { responseParser } = this.config; | ||
37 | + if (responseParser) | ||
38 | + return responseParser(res); | ||
39 | + else | ||
40 | + return res.data; | ||
30 | } | 41 | } |
31 | - postBinary(url, data, contentType) { | 42 | + async postForm(url, body) { |
32 | - let getBuffer; | 43 | + const res = await this.instance.post(url, qs.stringify(body), { |
33 | - if (Buffer.isBuffer(data)) { | 44 | + headers: { "Content-Type": "application/x-www-form-urlencoded" }, |
34 | - getBuffer = Promise.resolve(data); | 45 | + }); |
35 | - } | 46 | + return res.data; |
36 | - else { | 47 | + } |
37 | - getBuffer = new Promise((resolve, reject) => { | 48 | + async postBinary(url, data, contentType) { |
38 | - if (data instanceof stream_1.Readable) { | 49 | + const buffer = await (async () => { |
50 | + if (Buffer.isBuffer(data)) { | ||
51 | + return data; | ||
52 | + } | ||
53 | + else if (data instanceof stream_1.Readable) { | ||
54 | + return new Promise((resolve, reject) => { | ||
39 | const buffers = []; | 55 | const buffers = []; |
40 | let size = 0; | 56 | let size = 0; |
41 | data.on("data", (chunk) => { | 57 | data.on("data", (chunk) => { |
... | @@ -44,25 +60,23 @@ class HTTPClient { | ... | @@ -44,25 +60,23 @@ class HTTPClient { |
44 | }); | 60 | }); |
45 | data.on("end", () => resolve(Buffer.concat(buffers, size))); | 61 | data.on("end", () => resolve(Buffer.concat(buffers, size))); |
46 | data.on("error", reject); | 62 | data.on("error", reject); |
47 | - } | 63 | + }); |
48 | - else { | 64 | + } |
49 | - reject(new Error("invalid data type for postBinary")); | 65 | + else { |
50 | - } | 66 | + throw new Error("invalid data type for postBinary"); |
51 | - }); | 67 | + } |
52 | - } | 68 | + })(); |
53 | - return getBuffer.then(data => { | 69 | + const res = await this.instance.post(url, buffer, { |
54 | - return this.instance | 70 | + headers: { |
55 | - .post(url, data, { | 71 | + "Content-Type": contentType || fileType(buffer).mime, |
56 | - headers: { | 72 | + "Content-Length": buffer.length, |
57 | - "Content-Type": contentType || fileType(data).mime, | 73 | + }, |
58 | - "Content-Length": data.length, | ||
59 | - }, | ||
60 | - }) | ||
61 | - .then(res => res.data); | ||
62 | }); | 74 | }); |
75 | + return res.data; | ||
63 | } | 76 | } |
64 | - delete(url, params) { | 77 | + async delete(url, params) { |
65 | - return this.instance.delete(url, { params }).then(res => res.data); | 78 | + const res = await this.instance.delete(url, { params }); |
79 | + return res.data; | ||
66 | } | 80 | } |
67 | wrapError(err) { | 81 | wrapError(err) { |
68 | if (err.response) { | 82 | if (err.response) { | ... | ... |
1 | -import Client from "./client"; | 1 | +import Client, { OAuth } from "./client"; |
2 | import middleware from "./middleware"; | 2 | import middleware from "./middleware"; |
3 | import validateSignature from "./validate-signature"; | 3 | import validateSignature from "./validate-signature"; |
4 | -export { Client, middleware, validateSignature }; | 4 | +export { Client, middleware, validateSignature, OAuth }; |
5 | export * from "./exceptions"; | 5 | export * from "./exceptions"; |
6 | export * from "./types"; | 6 | export * from "./types"; | ... | ... |
... | @@ -5,9 +5,11 @@ function __export(m) { | ... | @@ -5,9 +5,11 @@ function __export(m) { |
5 | Object.defineProperty(exports, "__esModule", { value: true }); | 5 | Object.defineProperty(exports, "__esModule", { value: true }); |
6 | const client_1 = require("./client"); | 6 | const client_1 = require("./client"); |
7 | exports.Client = client_1.default; | 7 | exports.Client = client_1.default; |
8 | +exports.OAuth = client_1.OAuth; | ||
8 | const middleware_1 = require("./middleware"); | 9 | const middleware_1 = require("./middleware"); |
9 | exports.middleware = middleware_1.default; | 10 | exports.middleware = middleware_1.default; |
10 | const validate_signature_1 = require("./validate-signature"); | 11 | const validate_signature_1 = require("./validate-signature"); |
11 | exports.validateSignature = validate_signature_1.default; | 12 | exports.validateSignature = validate_signature_1.default; |
12 | // re-export exceptions and types | 13 | // re-export exceptions and types |
13 | __export(require("./exceptions")); | 14 | __export(require("./exceptions")); |
15 | +__export(require("./types")); | ... | ... |
... | @@ -6,5 +6,5 @@ export declare type Request = http.IncomingMessage & { | ... | @@ -6,5 +6,5 @@ export declare type Request = http.IncomingMessage & { |
6 | }; | 6 | }; |
7 | export declare type Response = http.ServerResponse; | 7 | export declare type Response = http.ServerResponse; |
8 | export declare type NextCallback = (err?: Error) => void; | 8 | export declare type NextCallback = (err?: Error) => void; |
9 | -export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void; | 9 | +export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void | Promise<void>; |
10 | export default function middleware(config: Types.MiddlewareConfig): Middleware; | 10 | export default function middleware(config: Types.MiddlewareConfig): Middleware; | ... | ... |
... | @@ -11,7 +11,7 @@ function middleware(config) { | ... | @@ -11,7 +11,7 @@ function middleware(config) { |
11 | throw new Error("no channel secret"); | 11 | throw new Error("no channel secret"); |
12 | } | 12 | } |
13 | const secret = config.channelSecret; | 13 | const secret = config.channelSecret; |
14 | - return (req, res, next) => { | 14 | + const _middleware = async (req, res, next) => { |
15 | // header names are lower-cased | 15 | // header names are lower-cased |
16 | // https://nodejs.org/api/http.html#http_message_headers | 16 | // https://nodejs.org/api/http.html#http_message_headers |
17 | const signature = req.headers["x-line-signature"]; | 17 | const signature = req.headers["x-line-signature"]; |
... | @@ -19,34 +19,34 @@ function middleware(config) { | ... | @@ -19,34 +19,34 @@ function middleware(config) { |
19 | next(new exceptions_1.SignatureValidationFailed("no signature")); | 19 | next(new exceptions_1.SignatureValidationFailed("no signature")); |
20 | return; | 20 | return; |
21 | } | 21 | } |
22 | - let getBody; | 22 | + const body = await (async () => { |
23 | - if (isValidBody(req.rawBody)) { | 23 | + if (isValidBody(req.rawBody)) { |
24 | - // rawBody is provided in Google Cloud Functions and others | 24 | + // rawBody is provided in Google Cloud Functions and others |
25 | - getBody = Promise.resolve(req.rawBody); | 25 | + return req.rawBody; |
26 | - } | ||
27 | - else if (isValidBody(req.body)) { | ||
28 | - getBody = Promise.resolve(req.body); | ||
29 | - } | ||
30 | - else { | ||
31 | - // body may not be parsed yet, parse it to a buffer | ||
32 | - getBody = new Promise(resolve => { | ||
33 | - body_parser_1.raw({ type: "*/*" })(req, res, () => resolve(req.body)); | ||
34 | - }); | ||
35 | - } | ||
36 | - getBody.then(body => { | ||
37 | - if (!validate_signature_1.default(body, secret, signature)) { | ||
38 | - next(new exceptions_1.SignatureValidationFailed("signature validation failed", signature)); | ||
39 | - return; | ||
40 | } | 26 | } |
41 | - const strBody = Buffer.isBuffer(body) ? body.toString() : body; | 27 | + else if (isValidBody(req.body)) { |
42 | - try { | 28 | + return req.body; |
43 | - req.body = JSON.parse(strBody); | ||
44 | - next(); | ||
45 | } | 29 | } |
46 | - catch (err) { | 30 | + else { |
47 | - next(new exceptions_1.JSONParseError(err.message, strBody)); | 31 | + // body may not be parsed yet, parse it to a buffer |
32 | + return new Promise((resolve, reject) => body_parser_1.raw({ type: "*/*" })(req, res, (error) => error ? reject(error) : resolve(req.body))); | ||
48 | } | 33 | } |
49 | - }); | 34 | + })(); |
35 | + if (!validate_signature_1.default(body, secret, signature)) { | ||
36 | + next(new exceptions_1.SignatureValidationFailed("signature validation failed", signature)); | ||
37 | + return; | ||
38 | + } | ||
39 | + const strBody = Buffer.isBuffer(body) ? body.toString() : body; | ||
40 | + try { | ||
41 | + req.body = JSON.parse(strBody); | ||
42 | + next(); | ||
43 | + } | ||
44 | + catch (err) { | ||
45 | + next(new exceptions_1.JSONParseError(err.message, strBody)); | ||
46 | + } | ||
47 | + }; | ||
48 | + return (req, res, next) => { | ||
49 | + _middleware(req, res, next).catch(next); | ||
50 | }; | 50 | }; |
51 | } | 51 | } |
52 | exports.default = middleware; | 52 | exports.default = middleware; | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -2,35 +2,13 @@ | ... | @@ -2,35 +2,13 @@ |
2 | Object.defineProperty(exports, "__esModule", { value: true }); | 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
3 | const crypto_1 = require("crypto"); | 3 | const crypto_1 = require("crypto"); |
4 | function s2b(str, encoding) { | 4 | function s2b(str, encoding) { |
5 | - if (Buffer.from) { | 5 | + return Buffer.from(str, encoding); |
6 | - try { | ||
7 | - return Buffer.from(str, encoding); | ||
8 | - } | ||
9 | - catch (err) { | ||
10 | - if (err.name === "TypeError") { | ||
11 | - return new Buffer(str, encoding); | ||
12 | - } | ||
13 | - throw err; | ||
14 | - } | ||
15 | - } | ||
16 | - else { | ||
17 | - return new Buffer(str, encoding); | ||
18 | - } | ||
19 | } | 6 | } |
20 | function safeCompare(a, b) { | 7 | function safeCompare(a, b) { |
21 | if (a.length !== b.length) { | 8 | if (a.length !== b.length) { |
22 | return false; | 9 | return false; |
23 | } | 10 | } |
24 | - if (crypto_1.timingSafeEqual) { | 11 | + return crypto_1.timingSafeEqual(a, b); |
25 | - return crypto_1.timingSafeEqual(a, b); | ||
26 | - } | ||
27 | - else { | ||
28 | - let result = 0; | ||
29 | - for (let i = 0; i < a.length; i++) { | ||
30 | - result |= a[i] ^ b[i]; | ||
31 | - } | ||
32 | - return result === 0; | ||
33 | - } | ||
34 | } | 12 | } |
35 | function validateSignature(body, channelSecret, signature) { | 13 | function validateSignature(body, channelSecret, signature) { |
36 | return safeCompare(crypto_1.createHmac("SHA256", channelSecret) | 14 | return safeCompare(crypto_1.createHmac("SHA256", channelSecret) | ... | ... |
This diff is collapsed. Click to expand it.
1 | -import axios, { AxiosInstance, AxiosError } from "axios"; | 1 | +import axios, { AxiosInstance, AxiosError, AxiosResponse } from "axios"; |
2 | import { Readable } from "stream"; | 2 | import { Readable } from "stream"; |
3 | import { HTTPError, ReadError, RequestError } from "./exceptions"; | 3 | import { HTTPError, ReadError, RequestError } from "./exceptions"; |
4 | import * as fileType from "file-type"; | 4 | import * as fileType from "file-type"; |
5 | +import * as qs from "querystring"; | ||
5 | 6 | ||
6 | const pkg = require("../package.json"); | 7 | const pkg = require("../package.json"); |
7 | 8 | ||
9 | +type httpClientConfig = { | ||
10 | + baseURL?: string; | ||
11 | + defaultHeaders?: any; | ||
12 | + responseParser?: <T>(res: AxiosResponse) => T; | ||
13 | +}; | ||
14 | + | ||
8 | export default class HTTPClient { | 15 | export default class HTTPClient { |
9 | private instance: AxiosInstance; | 16 | private instance: AxiosInstance; |
17 | + private config: httpClientConfig; | ||
10 | 18 | ||
11 | - constructor(baseURL?: string, defaultHeaders?: any) { | 19 | + constructor(config: httpClientConfig = {}) { |
20 | + this.config = config; | ||
21 | + const { baseURL, defaultHeaders } = config; | ||
12 | this.instance = axios.create({ | 22 | this.instance = axios.create({ |
13 | baseURL, | 23 | baseURL, |
14 | headers: Object.assign({}, defaultHeaders, { | 24 | headers: Object.assign({}, defaultHeaders, { |
... | @@ -22,34 +32,47 @@ export default class HTTPClient { | ... | @@ -22,34 +32,47 @@ export default class HTTPClient { |
22 | ); | 32 | ); |
23 | } | 33 | } |
24 | 34 | ||
25 | - public get<T>(url: string, params?: any): Promise<T> { | 35 | + public async get<T>(url: string, params?: any): Promise<T> { |
26 | - return this.instance.get(url, { params }).then(res => res.data); | 36 | + const res = await this.instance.get(url, { params }); |
37 | + return res.data; | ||
27 | } | 38 | } |
28 | 39 | ||
29 | - public getStream(url: string, params?: any): Promise<Readable> { | 40 | + public async getStream(url: string, params?: any): Promise<Readable> { |
30 | - return this.instance | 41 | + const res = await this.instance.get(url, { |
31 | - .get(url, { params, responseType: "stream" }) | 42 | + params, |
32 | - .then(res => res.data as Readable); | 43 | + responseType: "stream", |
44 | + }); | ||
45 | + return res.data as Readable; | ||
33 | } | 46 | } |
34 | 47 | ||
35 | - public post<T>(url: string, data?: any): Promise<T> { | 48 | + public async post<T>(url: string, body?: any): Promise<T> { |
36 | - return this.instance | 49 | + const res = await this.instance.post(url, body, { |
37 | - .post(url, data, { headers: { "Content-Type": "application/json" } }) | 50 | + headers: { "Content-Type": "application/json" }, |
38 | - .then(res => res.data); | 51 | + }); |
52 | + | ||
53 | + const { responseParser } = this.config; | ||
54 | + if (responseParser) return responseParser<T>(res); | ||
55 | + else return res.data; | ||
39 | } | 56 | } |
40 | 57 | ||
41 | - public postBinary<T>( | 58 | + public async postForm<T>(url: string, body?: any): Promise<T> { |
59 | + const res = await this.instance.post(url, qs.stringify(body), { | ||
60 | + headers: { "Content-Type": "application/x-www-form-urlencoded" }, | ||
61 | + }); | ||
62 | + | ||
63 | + return res.data; | ||
64 | + } | ||
65 | + | ||
66 | + public async postBinary<T>( | ||
42 | url: string, | 67 | url: string, |
43 | data: Buffer | Readable, | 68 | data: Buffer | Readable, |
44 | contentType?: string, | 69 | contentType?: string, |
45 | ): Promise<T> { | 70 | ): Promise<T> { |
46 | - let getBuffer: Promise<Buffer>; | 71 | + const buffer = await (async (): Promise<Buffer> => { |
47 | - | 72 | + if (Buffer.isBuffer(data)) { |
48 | - if (Buffer.isBuffer(data)) { | 73 | + return data; |
49 | - getBuffer = Promise.resolve(data); | 74 | + } else if (data instanceof Readable) { |
50 | - } else { | 75 | + return new Promise<Buffer>((resolve, reject) => { |
51 | - getBuffer = new Promise((resolve, reject) => { | ||
52 | - if (data instanceof Readable) { | ||
53 | const buffers: Buffer[] = []; | 76 | const buffers: Buffer[] = []; |
54 | let size = 0; | 77 | let size = 0; |
55 | data.on("data", (chunk: Buffer) => { | 78 | data.on("data", (chunk: Buffer) => { |
... | @@ -58,26 +81,25 @@ export default class HTTPClient { | ... | @@ -58,26 +81,25 @@ export default class HTTPClient { |
58 | }); | 81 | }); |
59 | data.on("end", () => resolve(Buffer.concat(buffers, size))); | 82 | data.on("end", () => resolve(Buffer.concat(buffers, size))); |
60 | data.on("error", reject); | 83 | data.on("error", reject); |
61 | - } else { | 84 | + }); |
62 | - reject(new Error("invalid data type for postBinary")); | 85 | + } else { |
63 | - } | 86 | + throw new Error("invalid data type for postBinary"); |
64 | - }); | 87 | + } |
65 | - } | 88 | + })(); |
66 | 89 | ||
67 | - return getBuffer.then(data => { | 90 | + const res = await this.instance.post(url, buffer, { |
68 | - return this.instance | 91 | + headers: { |
69 | - .post(url, data, { | 92 | + "Content-Type": contentType || fileType(buffer).mime, |
70 | - headers: { | 93 | + "Content-Length": buffer.length, |
71 | - "Content-Type": contentType || fileType(data).mime, | 94 | + }, |
72 | - "Content-Length": data.length, | ||
73 | - }, | ||
74 | - }) | ||
75 | - .then(res => res.data); | ||
76 | }); | 95 | }); |
96 | + | ||
97 | + return res.data; | ||
77 | } | 98 | } |
78 | 99 | ||
79 | - public delete<T>(url: string, params?: any): Promise<T> { | 100 | + public async delete<T>(url: string, params?: any): Promise<T> { |
80 | - return this.instance.delete(url, { params }).then(res => res.data); | 101 | + const res = await this.instance.delete(url, { params }); |
102 | + return res.data; | ||
81 | } | 103 | } |
82 | 104 | ||
83 | private wrapError(err: AxiosError): Error { | 105 | private wrapError(err: AxiosError): Error { | ... | ... |
1 | -import Client from "./client"; | 1 | +import Client, { OAuth } from "./client"; |
2 | import middleware from "./middleware"; | 2 | import middleware from "./middleware"; |
3 | import validateSignature from "./validate-signature"; | 3 | import validateSignature from "./validate-signature"; |
4 | 4 | ||
5 | -export { Client, middleware, validateSignature }; | 5 | +export { Client, middleware, validateSignature, OAuth }; |
6 | 6 | ||
7 | // re-export exceptions and types | 7 | // re-export exceptions and types |
8 | export * from "./exceptions"; | 8 | export * from "./exceptions"; | ... | ... |
... | @@ -12,7 +12,7 @@ export type Middleware = ( | ... | @@ -12,7 +12,7 @@ export type Middleware = ( |
12 | req: Request, | 12 | req: Request, |
13 | res: Response, | 13 | res: Response, |
14 | next: NextCallback, | 14 | next: NextCallback, |
15 | -) => void; | 15 | +) => void | Promise<void>; |
16 | 16 | ||
17 | function isValidBody(body?: any): body is string | Buffer { | 17 | function isValidBody(body?: any): body is string | Buffer { |
18 | return (body && typeof body === "string") || Buffer.isBuffer(body); | 18 | return (body && typeof body === "string") || Buffer.isBuffer(body); |
... | @@ -25,7 +25,7 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware { | ... | @@ -25,7 +25,7 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware { |
25 | 25 | ||
26 | const secret = config.channelSecret; | 26 | const secret = config.channelSecret; |
27 | 27 | ||
28 | - return (req, res, next) => { | 28 | + const _middleware: Middleware = async (req, res, next) => { |
29 | // header names are lower-cased | 29 | // header names are lower-cased |
30 | // https://nodejs.org/api/http.html#http_message_headers | 30 | // https://nodejs.org/api/http.html#http_message_headers |
31 | const signature = req.headers["x-line-signature"] as string; | 31 | const signature = req.headers["x-line-signature"] as string; |
... | @@ -35,38 +35,39 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware { | ... | @@ -35,38 +35,39 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware { |
35 | return; | 35 | return; |
36 | } | 36 | } |
37 | 37 | ||
38 | - let getBody: Promise<string | Buffer>; | 38 | + const body = await (async (): Promise<string | Buffer> => { |
39 | - if (isValidBody((req as any).rawBody)) { | 39 | + if (isValidBody((req as any).rawBody)) { |
40 | - // rawBody is provided in Google Cloud Functions and others | 40 | + // rawBody is provided in Google Cloud Functions and others |
41 | - getBody = Promise.resolve((req as any).rawBody); | 41 | + return (req as any).rawBody; |
42 | - } else if (isValidBody(req.body)) { | 42 | + } else if (isValidBody(req.body)) { |
43 | - getBody = Promise.resolve(req.body); | 43 | + return req.body; |
44 | - } else { | 44 | + } else { |
45 | - // body may not be parsed yet, parse it to a buffer | 45 | + // body may not be parsed yet, parse it to a buffer |
46 | - getBody = new Promise(resolve => { | 46 | + return new Promise<Buffer>((resolve, reject) => |
47 | - raw({ type: "*/*" })(req as any, res as any, () => resolve(req.body)); | 47 | + raw({ type: "*/*" })(req as any, res as any, (error: Error) => |
48 | - }); | 48 | + error ? reject(error) : resolve(req.body), |
49 | - } | ||
50 | - | ||
51 | - getBody.then(body => { | ||
52 | - if (!validateSignature(body, secret, signature)) { | ||
53 | - next( | ||
54 | - new SignatureValidationFailed( | ||
55 | - "signature validation failed", | ||
56 | - signature, | ||
57 | ), | 49 | ), |
58 | ); | 50 | ); |
59 | - return; | ||
60 | } | 51 | } |
52 | + })(); | ||
53 | + | ||
54 | + if (!validateSignature(body, secret, signature)) { | ||
55 | + next( | ||
56 | + new SignatureValidationFailed("signature validation failed", signature), | ||
57 | + ); | ||
58 | + return; | ||
59 | + } | ||
61 | 60 | ||
62 | - const strBody = Buffer.isBuffer(body) ? body.toString() : body; | 61 | + const strBody = Buffer.isBuffer(body) ? body.toString() : body; |
63 | 62 | ||
64 | - try { | 63 | + try { |
65 | - req.body = JSON.parse(strBody); | 64 | + req.body = JSON.parse(strBody); |
66 | - next(); | 65 | + next(); |
67 | - } catch (err) { | 66 | + } catch (err) { |
68 | - next(new JSONParseError(err.message, strBody)); | 67 | + next(new JSONParseError(err.message, strBody)); |
69 | - } | 68 | + } |
70 | - }); | 69 | + }; |
70 | + return (req, res, next): void => { | ||
71 | + (<Promise<void>>_middleware(req, res, next)).catch(next); | ||
71 | }; | 72 | }; |
72 | } | 73 | } | ... | ... |
This diff is collapsed. Click to expand it.
1 | import { createHmac, timingSafeEqual } from "crypto"; | 1 | import { createHmac, timingSafeEqual } from "crypto"; |
2 | 2 | ||
3 | function s2b(str: string, encoding: string): Buffer { | 3 | function s2b(str: string, encoding: string): Buffer { |
4 | - if (Buffer.from) { | 4 | + return Buffer.from(str, encoding); |
5 | - try { | ||
6 | - return Buffer.from(str, encoding); | ||
7 | - } catch (err) { | ||
8 | - if (err.name === "TypeError") { | ||
9 | - return new Buffer(str, encoding); | ||
10 | - } | ||
11 | - throw err; | ||
12 | - } | ||
13 | - } else { | ||
14 | - return new Buffer(str, encoding); | ||
15 | - } | ||
16 | } | 5 | } |
17 | 6 | ||
18 | function safeCompare(a: Buffer, b: Buffer): boolean { | 7 | function safeCompare(a: Buffer, b: Buffer): boolean { |
19 | if (a.length !== b.length) { | 8 | if (a.length !== b.length) { |
20 | return false; | 9 | return false; |
21 | } | 10 | } |
22 | - | 11 | + return timingSafeEqual(a, b); |
23 | - if (timingSafeEqual) { | ||
24 | - return timingSafeEqual(a, b); | ||
25 | - } else { | ||
26 | - let result = 0; | ||
27 | - for (let i = 0; i < a.length; i++) { | ||
28 | - result |= a[i] ^ b[i]; | ||
29 | - } | ||
30 | - return result === 0; | ||
31 | - } | ||
32 | } | 12 | } |
33 | 13 | ||
34 | export default function validateSignature( | 14 | export default function validateSignature( | ... | ... |
1 | { | 1 | { |
2 | - "_from": "@line/bot-sdk", | 2 | + "_from": "@line/bot-sdk@6.8.3", |
3 | - "_id": "@line/bot-sdk@6.4.0", | 3 | + "_id": "@line/bot-sdk@6.8.3", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha512-N0FkrqFxTTleOpD6y7DTK8qbMYHr9Q8qZfrAmSYEFAGedM1HLJdbNNkStj5GT+svx+w+/ePF/n7nAEts0aJwkA==", | 5 | + "_integrity": "sha512-nj2T4CQxw0W/juAlpj0kMTDScOh5QUK6xMCR2dZp+pN8B0vj/c+5uX3TyGB4ijz/NIsehgfKujPgzw7LhtYtJw==", |
6 | "_location": "/@line/bot-sdk", | 6 | "_location": "/@line/bot-sdk", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
9 | - "type": "tag", | 9 | + "type": "version", |
10 | "registry": true, | 10 | "registry": true, |
11 | - "raw": "@line/bot-sdk", | 11 | + "raw": "@line/bot-sdk@6.8.3", |
12 | "name": "@line/bot-sdk", | 12 | "name": "@line/bot-sdk", |
13 | "escapedName": "@line%2fbot-sdk", | 13 | "escapedName": "@line%2fbot-sdk", |
14 | "scope": "@line", | 14 | "scope": "@line", |
15 | - "rawSpec": "", | 15 | + "rawSpec": "6.8.3", |
16 | "saveSpec": null, | 16 | "saveSpec": null, |
17 | - "fetchSpec": "latest" | 17 | + "fetchSpec": "6.8.3" |
18 | }, | 18 | }, |
19 | "_requiredBy": [ | 19 | "_requiredBy": [ |
20 | "#USER", | 20 | "#USER", |
21 | "/" | 21 | "/" |
22 | ], | 22 | ], |
23 | - "_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.4.0.tgz", | 23 | + "_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.8.3.tgz", |
24 | - "_shasum": "18aa7659da26d3a8487614c74ad9ccb80ec4ca59", | 24 | + "_shasum": "0a886461e8c16a8c89091fd5338f6071335636a6", |
25 | - "_spec": "@line/bot-sdk", | 25 | + "_spec": "@line/bot-sdk@6.8.3", |
26 | - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot", | 26 | + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT", |
27 | "bugs": { | 27 | "bugs": { |
28 | "url": "https://github.com/line/line-bot-sdk-nodejs/issues" | 28 | "url": "https://github.com/line/line-bot-sdk-nodejs/issues" |
29 | }, | 29 | }, |
... | @@ -32,7 +32,7 @@ | ... | @@ -32,7 +32,7 @@ |
32 | "@types/body-parser": "^1.16.8", | 32 | "@types/body-parser": "^1.16.8", |
33 | "@types/file-type": "^5.2.1", | 33 | "@types/file-type": "^5.2.1", |
34 | "@types/node": "^7.0.31", | 34 | "@types/node": "^7.0.31", |
35 | - "axios": "^0.16.2", | 35 | + "axios": "^0.19.0", |
36 | "body-parser": "^1.18.2", | 36 | "body-parser": "^1.18.2", |
37 | "file-type": "^7.2.0" | 37 | "file-type": "^7.2.0" |
38 | }, | 38 | }, |
... | @@ -40,19 +40,21 @@ | ... | @@ -40,19 +40,21 @@ |
40 | "description": "Node.js SDK for LINE Messaging API", | 40 | "description": "Node.js SDK for LINE Messaging API", |
41 | "devDependencies": { | 41 | "devDependencies": { |
42 | "@types/express": "^4.0.35", | 42 | "@types/express": "^4.0.35", |
43 | + "@types/finalhandler": "^1.1.0", | ||
43 | "@types/mocha": "^2.2.41", | 44 | "@types/mocha": "^2.2.41", |
44 | "del-cli": "^1.1.0", | 45 | "del-cli": "^1.1.0", |
45 | "express": "^4.16.3", | 46 | "express": "^4.16.3", |
47 | + "finalhandler": "^1.1.2", | ||
46 | "husky": "^0.14.3", | 48 | "husky": "^0.14.3", |
47 | "mocha": "^5.2.0", | 49 | "mocha": "^5.2.0", |
48 | - "nyc": "^12.0.2", | 50 | + "nyc": "^14.1.1", |
49 | "prettier": "^1.15.2", | 51 | "prettier": "^1.15.2", |
50 | - "ts-node": "^3.3.0", | 52 | + "ts-node": "^8.3.0", |
51 | "typescript": "^3.1.6", | 53 | "typescript": "^3.1.6", |
52 | - "vuepress": "^0.14.2" | 54 | + "vuepress": "^0.14.10" |
53 | }, | 55 | }, |
54 | "engines": { | 56 | "engines": { |
55 | - "node": ">=6" | 57 | + "node": ">=8" |
56 | }, | 58 | }, |
57 | "files": [ | 59 | "files": [ |
58 | "dist", | 60 | "dist", |
... | @@ -102,5 +104,5 @@ | ... | @@ -102,5 +104,5 @@ |
102 | "test": "API_BASE_URL=http://localhost:1234/ TEST_PORT=1234 TS_NODE_CACHE=0 nyc mocha" | 104 | "test": "API_BASE_URL=http://localhost:1234/ TEST_PORT=1234 TS_NODE_CACHE=0 nyc mocha" |
103 | }, | 105 | }, |
104 | "types": "dist/index.d.ts", | 106 | "types": "dist/index.d.ts", |
105 | - "version": "6.4.0" | 107 | + "version": "6.8.3" |
106 | } | 108 | } | ... | ... |
... | @@ -5,12 +5,12 @@ | ... | @@ -5,12 +5,12 @@ |
5 | This package contains type definitions for body-parser (https://github.com/expressjs/body-parser). | 5 | This package contains type definitions for body-parser (https://github.com/expressjs/body-parser). |
6 | 6 | ||
7 | # Details | 7 | # Details |
8 | -Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser | 8 | +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser |
9 | 9 | ||
10 | Additional Details | 10 | Additional Details |
11 | - * Last updated: Wed, 25 Apr 2018 00:24:37 GMT | 11 | + * Last updated: Mon, 19 Aug 2019 00:51:08 GMT |
12 | - * Dependencies: connect, http, node | 12 | + * Dependencies: @types/connect, @types/node |
13 | * Global values: none | 13 | * Global values: none |
14 | 14 | ||
15 | # Credits | 15 | # Credits |
16 | -These definitions were written by Santi Albo <https://github.com/santialbo>, Vilic Vane <https://github.com/vilic>, Jonathan Häberle <https://github.com/dreampulse>, Gevik Babakhani <https://github.com/blendsdk>, Tomasz Łaziuk <https://github.com/tlaziuk>, Jason Walton <https://github.com/jwalton>. | 16 | +These definitions were written by Santi Albo <https://github.com/santialbo>, Vilic Vane <https://github.com/vilic>, Jonathan Häberle <https://github.com/dreampulse>, Gevik Babakhani <https://github.com/blendsdk>, Tomasz Łaziuk <https://github.com/tlaziuk>, and Jason Walton <https://github.com/jwalton>. | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | // Tomasz Łaziuk <https://github.com/tlaziuk> | 7 | // Tomasz Łaziuk <https://github.com/tlaziuk> |
8 | // Jason Walton <https://github.com/jwalton> | 8 | // Jason Walton <https://github.com/jwalton> |
9 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | 9 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
10 | -// TypeScript Version: 2.2 | 10 | +// TypeScript Version: 2.3 |
11 | 11 | ||
12 | /// <reference types="node" /> | 12 | /// <reference types="node" /> |
13 | 13 | ... | ... |
1 | { | 1 | { |
2 | "_from": "@types/body-parser@^1.16.8", | 2 | "_from": "@types/body-parser@^1.16.8", |
3 | - "_id": "@types/body-parser@1.17.0", | 3 | + "_id": "@types/body-parser@1.17.1", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==", | 5 | + "_integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==", |
6 | "_location": "/@types/body-parser", | 6 | "_location": "/@types/body-parser", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
... | @@ -19,10 +19,10 @@ | ... | @@ -19,10 +19,10 @@ |
19 | "_requiredBy": [ | 19 | "_requiredBy": [ |
20 | "/@line/bot-sdk" | 20 | "/@line/bot-sdk" |
21 | ], | 21 | ], |
22 | - "_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", | 22 | + "_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz", |
23 | - "_shasum": "9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c", | 23 | + "_shasum": "18fcf61768fb5c30ccc508c21d6fd2e8b3bf7897", |
24 | "_spec": "@types/body-parser@^1.16.8", | 24 | "_spec": "@types/body-parser@^1.16.8", |
25 | - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk", | 25 | + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk", |
26 | "bugs": { | 26 | "bugs": { |
27 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" | 27 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" |
28 | }, | 28 | }, |
... | @@ -65,10 +65,12 @@ | ... | @@ -65,10 +65,12 @@ |
65 | "name": "@types/body-parser", | 65 | "name": "@types/body-parser", |
66 | "repository": { | 66 | "repository": { |
67 | "type": "git", | 67 | "type": "git", |
68 | - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git" | 68 | + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git", |
69 | + "directory": "types/body-parser" | ||
69 | }, | 70 | }, |
70 | "scripts": {}, | 71 | "scripts": {}, |
71 | - "typeScriptVersion": "2.2", | 72 | + "typeScriptVersion": "2.3", |
72 | - "typesPublisherContentHash": "d50d69303022e9f76f6d905e480a7dc98120bbcedb696a9722a4a2e9f08473e6", | 73 | + "types": "index", |
73 | - "version": "1.17.0" | 74 | + "typesPublisherContentHash": "ada1b55777df6de5327f420d23285a5c476895faa88cacf6b80a1a791eef0f67", |
75 | + "version": "1.17.1" | ||
74 | } | 76 | } | ... | ... |
... | @@ -8,9 +8,9 @@ This package contains type definitions for Node.js (http://nodejs.org/). | ... | @@ -8,9 +8,9 @@ This package contains type definitions for Node.js (http://nodejs.org/). |
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v7 | 8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v7 |
9 | 9 | ||
10 | Additional Details | 10 | Additional Details |
11 | - * Last updated: Thu, 15 Nov 2018 00:16:17 GMT | 11 | + * Last updated: Wed, 30 Oct 2019 15:44:46 GMT |
12 | * Dependencies: none | 12 | * Dependencies: none |
13 | * Global values: Buffer, NodeJS, SlowBuffer, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, require, setImmediate, setInterval, setTimeout | 13 | * Global values: Buffer, NodeJS, SlowBuffer, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, require, setImmediate, setInterval, setTimeout |
14 | 14 | ||
15 | # Credits | 15 | # Credits |
16 | -These definitions were written by Microsoft TypeScript <https://github.com/Microsoft>, DefinitelyTyped <https://github.com/DefinitelyTyped>, Parambir Singh <https://github.com/parambirs>, Christian Vaagland Tellnes <https://github.com/tellnes>, Wilco Bakker <https://github.com/WilcoBakker>, Sebastian Silbermann <https://github.com/eps1lon>, Hoàng Văn Khải <https://github.com/KSXGitHub>, Sander Koenders <https://github.com/Archcry>. | 16 | +These definitions were written by Microsoft TypeScript <https://github.com/Microsoft>, DefinitelyTyped <https://github.com/DefinitelyTyped>, Parambir Singh <https://github.com/parambirs>, Christian Vaagland Tellnes <https://github.com/tellnes>, Wilco Bakker <https://github.com/WilcoBakker>, Sebastian Silbermann <https://github.com/eps1lon>, Hoàng Văn Khải <https://github.com/KSXGitHub>, Sander Koenders <https://github.com/Archcry>, and Jordi Oliveras Rovira <https://github.com/j-oliveras>. | ... | ... |
node_modules/@types/node/base.d.ts
0 → 100644
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
1 | { | 1 | { |
2 | "_from": "@types/node@^7.0.31", | 2 | "_from": "@types/node@^7.0.31", |
3 | - "_id": "@types/node@7.10.2", | 3 | + "_id": "@types/node@7.10.9", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha512-RO4ig5taKmcrU4Rex8ojG1gpwFkjddzug9iPQSDvbewHN9vDpcFewevkaOK+KT+w1LeZnxbgOyfXwV4pxsQ4GQ==", | 5 | + "_integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw==", |
6 | "_location": "/@types/node", | 6 | "_location": "/@types/node", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
... | @@ -22,10 +22,10 @@ | ... | @@ -22,10 +22,10 @@ |
22 | "/@types/connect", | 22 | "/@types/connect", |
23 | "/@types/file-type" | 23 | "/@types/file-type" |
24 | ], | 24 | ], |
25 | - "_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.2.tgz", | 25 | + "_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz", |
26 | - "_shasum": "a98845168012d7a63a84d50e738829da43bdb0de", | 26 | + "_shasum": "4343e3b009f8cf5e1ed685e36097b74b4101e880", |
27 | "_spec": "@types/node@^7.0.31", | 27 | "_spec": "@types/node@^7.0.31", |
28 | - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk", | 28 | + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk", |
29 | "bugs": { | 29 | "bugs": { |
30 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" | 30 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" |
31 | }, | 31 | }, |
... | @@ -62,6 +62,10 @@ | ... | @@ -62,6 +62,10 @@ |
62 | { | 62 | { |
63 | "name": "Sander Koenders", | 63 | "name": "Sander Koenders", |
64 | "url": "https://github.com/Archcry" | 64 | "url": "https://github.com/Archcry" |
65 | + }, | ||
66 | + { | ||
67 | + "name": "Jordi Oliveras Rovira", | ||
68 | + "url": "https://github.com/j-oliveras" | ||
65 | } | 69 | } |
66 | ], | 70 | ], |
67 | "dependencies": {}, | 71 | "dependencies": {}, |
... | @@ -73,11 +77,19 @@ | ... | @@ -73,11 +77,19 @@ |
73 | "name": "@types/node", | 77 | "name": "@types/node", |
74 | "repository": { | 78 | "repository": { |
75 | "type": "git", | 79 | "type": "git", |
76 | - "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git" | 80 | + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git", |
81 | + "directory": "types/node" | ||
77 | }, | 82 | }, |
78 | "scripts": {}, | 83 | "scripts": {}, |
79 | "typeScriptVersion": "2.0", | 84 | "typeScriptVersion": "2.0", |
80 | "types": "index", | 85 | "types": "index", |
81 | - "typesPublisherContentHash": "55896a12ed8765c021f335913ef256ce4eb8ac2fc4b0c93611d7ce514e2906ea", | 86 | + "typesPublisherContentHash": "0c534d9103600d73c97ec8a474420c4d9262b941ae93e66c175cb27e62683e84", |
82 | - "version": "7.10.2" | 87 | + "typesVersions": { |
88 | + ">=3.2.0-0": { | ||
89 | + "*": [ | ||
90 | + "ts3.2/*" | ||
91 | + ] | ||
92 | + } | ||
93 | + }, | ||
94 | + "version": "7.10.9" | ||
83 | } | 95 | } | ... | ... |
node_modules/@types/node/ts3.2/index.d.ts
0 → 100644
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 Matt Zabriskie | 1 | +Copyright (c) 2014-present Matt Zabriskie |
2 | 2 | ||
3 | Permission is hereby granted, free of charge, to any person obtaining a copy | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy |
4 | of this software and associated documentation files (the "Software"), to deal | 4 | of this software and associated documentation files (the "Software"), to deal | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -115,8 +115,8 @@ function myAdapter(config) { | ... | @@ -115,8 +115,8 @@ function myAdapter(config) { |
115 | ``` | 115 | ``` |
116 | 116 | ||
117 | See the related commits for more details: | 117 | See the related commits for more details: |
118 | -- [Response transformers](https://github.com/mzabriskie/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) | 118 | +- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) |
119 | -- [Request adapter Promise](https://github.com/mzabriskie/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) | 119 | +- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) |
120 | 120 | ||
121 | ### 0.5.x -> 0.6.0 | 121 | ### 0.5.x -> 0.6.0 |
122 | 122 | ||
... | @@ -135,7 +135,7 @@ This will polyfill the global environment, and only needs to be done once. | ... | @@ -135,7 +135,7 @@ This will polyfill the global environment, and only needs to be done once. |
135 | 135 | ||
136 | #### `axios.success`/`axios.error` | 136 | #### `axios.success`/`axios.error` |
137 | 137 | ||
138 | -The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/mzabriskie/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. | 138 | +The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. |
139 | 139 | ||
140 | ```js | 140 | ```js |
141 | axios.get('some/url') | 141 | axios.get('some/url') | ... | ... |
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
1 | export interface AxiosTransformer { | 1 | export interface AxiosTransformer { |
2 | - (data: any): any; | 2 | + (data: any, headers?: any): any; |
3 | } | 3 | } |
4 | 4 | ||
5 | export interface AxiosAdapter { | 5 | export interface AxiosAdapter { |
6 | - (config: AxiosRequestConfig): AxiosPromise; | 6 | + (config: AxiosRequestConfig): AxiosPromise<any>; |
7 | } | 7 | } |
8 | 8 | ||
9 | export interface AxiosBasicCredentials { | 9 | export interface AxiosBasicCredentials { |
... | @@ -14,11 +14,33 @@ export interface AxiosBasicCredentials { | ... | @@ -14,11 +14,33 @@ export interface AxiosBasicCredentials { |
14 | export interface AxiosProxyConfig { | 14 | export interface AxiosProxyConfig { |
15 | host: string; | 15 | host: string; |
16 | port: number; | 16 | port: number; |
17 | -} | 17 | + auth?: { |
18 | + username: string; | ||
19 | + password:string; | ||
20 | + }; | ||
21 | + protocol?: string; | ||
22 | +} | ||
23 | + | ||
24 | +export type Method = | ||
25 | + | 'get' | 'GET' | ||
26 | + | 'delete' | 'DELETE' | ||
27 | + | 'head' | 'HEAD' | ||
28 | + | 'options' | 'OPTIONS' | ||
29 | + | 'post' | 'POST' | ||
30 | + | 'put' | 'PUT' | ||
31 | + | 'patch' | 'PATCH' | ||
32 | + | ||
33 | +export type ResponseType = | ||
34 | + | 'arraybuffer' | ||
35 | + | 'blob' | ||
36 | + | 'document' | ||
37 | + | 'json' | ||
38 | + | 'text' | ||
39 | + | 'stream' | ||
18 | 40 | ||
19 | export interface AxiosRequestConfig { | 41 | export interface AxiosRequestConfig { |
20 | url?: string; | 42 | url?: string; |
21 | - method?: string; | 43 | + method?: Method; |
22 | baseURL?: string; | 44 | baseURL?: string; |
23 | transformRequest?: AxiosTransformer | AxiosTransformer[]; | 45 | transformRequest?: AxiosTransformer | AxiosTransformer[]; |
24 | transformResponse?: AxiosTransformer | AxiosTransformer[]; | 46 | transformResponse?: AxiosTransformer | AxiosTransformer[]; |
... | @@ -30,7 +52,7 @@ export interface AxiosRequestConfig { | ... | @@ -30,7 +52,7 @@ export interface AxiosRequestConfig { |
30 | withCredentials?: boolean; | 52 | withCredentials?: boolean; |
31 | adapter?: AxiosAdapter; | 53 | adapter?: AxiosAdapter; |
32 | auth?: AxiosBasicCredentials; | 54 | auth?: AxiosBasicCredentials; |
33 | - responseType?: string; | 55 | + responseType?: ResponseType; |
34 | xsrfCookieName?: string; | 56 | xsrfCookieName?: string; |
35 | xsrfHeaderName?: string; | 57 | xsrfHeaderName?: string; |
36 | onUploadProgress?: (progressEvent: any) => void; | 58 | onUploadProgress?: (progressEvent: any) => void; |
... | @@ -38,27 +60,31 @@ export interface AxiosRequestConfig { | ... | @@ -38,27 +60,31 @@ export interface AxiosRequestConfig { |
38 | maxContentLength?: number; | 60 | maxContentLength?: number; |
39 | validateStatus?: (status: number) => boolean; | 61 | validateStatus?: (status: number) => boolean; |
40 | maxRedirects?: number; | 62 | maxRedirects?: number; |
63 | + socketPath?: string | null; | ||
41 | httpAgent?: any; | 64 | httpAgent?: any; |
42 | httpsAgent?: any; | 65 | httpsAgent?: any; |
43 | - proxy?: AxiosProxyConfig; | 66 | + proxy?: AxiosProxyConfig | false; |
44 | cancelToken?: CancelToken; | 67 | cancelToken?: CancelToken; |
45 | } | 68 | } |
46 | 69 | ||
47 | -export interface AxiosResponse { | 70 | +export interface AxiosResponse<T = any> { |
48 | - data: any; | 71 | + data: T; |
49 | status: number; | 72 | status: number; |
50 | statusText: string; | 73 | statusText: string; |
51 | headers: any; | 74 | headers: any; |
52 | config: AxiosRequestConfig; | 75 | config: AxiosRequestConfig; |
76 | + request?: any; | ||
53 | } | 77 | } |
54 | 78 | ||
55 | -export interface AxiosError extends Error { | 79 | +export interface AxiosError<T = any> extends Error { |
56 | config: AxiosRequestConfig; | 80 | config: AxiosRequestConfig; |
57 | code?: string; | 81 | code?: string; |
58 | - response?: AxiosResponse; | 82 | + request?: any; |
83 | + response?: AxiosResponse<T>; | ||
84 | + isAxiosError: boolean; | ||
59 | } | 85 | } |
60 | 86 | ||
61 | -export interface AxiosPromise extends Promise<AxiosResponse> { | 87 | +export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> { |
62 | } | 88 | } |
63 | 89 | ||
64 | export interface CancelStatic { | 90 | export interface CancelStatic { |
... | @@ -90,28 +116,29 @@ export interface CancelTokenSource { | ... | @@ -90,28 +116,29 @@ export interface CancelTokenSource { |
90 | } | 116 | } |
91 | 117 | ||
92 | export interface AxiosInterceptorManager<V> { | 118 | export interface AxiosInterceptorManager<V> { |
93 | - use(onFulfilled: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number; | 119 | + use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number; |
94 | eject(id: number): void; | 120 | eject(id: number): void; |
95 | } | 121 | } |
96 | 122 | ||
97 | export interface AxiosInstance { | 123 | export interface AxiosInstance { |
124 | + (config: AxiosRequestConfig): AxiosPromise; | ||
125 | + (url: string, config?: AxiosRequestConfig): AxiosPromise; | ||
98 | defaults: AxiosRequestConfig; | 126 | defaults: AxiosRequestConfig; |
99 | interceptors: { | 127 | interceptors: { |
100 | request: AxiosInterceptorManager<AxiosRequestConfig>; | 128 | request: AxiosInterceptorManager<AxiosRequestConfig>; |
101 | response: AxiosInterceptorManager<AxiosResponse>; | 129 | response: AxiosInterceptorManager<AxiosResponse>; |
102 | }; | 130 | }; |
103 | - request(config: AxiosRequestConfig): AxiosPromise; | 131 | + getUri(config?: AxiosRequestConfig): string; |
104 | - get(url: string, config?: AxiosRequestConfig): AxiosPromise; | 132 | + request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>; |
105 | - delete(url: string, config?: AxiosRequestConfig): AxiosPromise; | 133 | + get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>; |
106 | - head(url: string, config?: AxiosRequestConfig): AxiosPromise; | 134 | + delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>; |
107 | - post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; | 135 | + head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>; |
108 | - put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; | 136 | + post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>; |
109 | - patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise; | 137 | + put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>; |
138 | + patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>; | ||
110 | } | 139 | } |
111 | 140 | ||
112 | export interface AxiosStatic extends AxiosInstance { | 141 | export interface AxiosStatic extends AxiosInstance { |
113 | - (config: AxiosRequestConfig): AxiosPromise; | ||
114 | - (url: string, config?: AxiosRequestConfig): AxiosPromise; | ||
115 | create(config?: AxiosRequestConfig): AxiosInstance; | 142 | create(config?: AxiosRequestConfig): AxiosInstance; |
116 | Cancel: CancelStatic; | 143 | Cancel: CancelStatic; |
117 | CancelToken: CancelTokenStatic; | 144 | CancelToken: CancelTokenStatic; | ... | ... |
... | @@ -13,17 +13,26 @@ var pkg = require('./../../package.json'); | ... | @@ -13,17 +13,26 @@ var pkg = require('./../../package.json'); |
13 | var createError = require('../core/createError'); | 13 | var createError = require('../core/createError'); |
14 | var enhanceError = require('../core/enhanceError'); | 14 | var enhanceError = require('../core/enhanceError'); |
15 | 15 | ||
16 | +var isHttps = /https:?/; | ||
17 | + | ||
16 | /*eslint consistent-return:0*/ | 18 | /*eslint consistent-return:0*/ |
17 | module.exports = function httpAdapter(config) { | 19 | module.exports = function httpAdapter(config) { |
18 | - return new Promise(function dispatchHttpRequest(resolve, reject) { | 20 | + return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { |
21 | + var timer; | ||
22 | + var resolve = function resolve(value) { | ||
23 | + clearTimeout(timer); | ||
24 | + resolvePromise(value); | ||
25 | + }; | ||
26 | + var reject = function reject(value) { | ||
27 | + clearTimeout(timer); | ||
28 | + rejectPromise(value); | ||
29 | + }; | ||
19 | var data = config.data; | 30 | var data = config.data; |
20 | var headers = config.headers; | 31 | var headers = config.headers; |
21 | - var timer; | ||
22 | - var aborted = false; | ||
23 | 32 | ||
24 | // Set User-Agent (required by some servers) | 33 | // Set User-Agent (required by some servers) |
25 | // Only set header if it hasn't been set in config | 34 | // Only set header if it hasn't been set in config |
26 | - // See https://github.com/mzabriskie/axios/issues/69 | 35 | + // See https://github.com/axios/axios/issues/69 |
27 | if (!headers['User-Agent'] && !headers['user-agent']) { | 36 | if (!headers['User-Agent'] && !headers['user-agent']) { |
28 | headers['User-Agent'] = 'axios/' + pkg.version; | 37 | headers['User-Agent'] = 'axios/' + pkg.version; |
29 | } | 38 | } |
... | @@ -32,9 +41,9 @@ module.exports = function httpAdapter(config) { | ... | @@ -32,9 +41,9 @@ module.exports = function httpAdapter(config) { |
32 | if (Buffer.isBuffer(data)) { | 41 | if (Buffer.isBuffer(data)) { |
33 | // Nothing to do... | 42 | // Nothing to do... |
34 | } else if (utils.isArrayBuffer(data)) { | 43 | } else if (utils.isArrayBuffer(data)) { |
35 | - data = new Buffer(new Uint8Array(data)); | 44 | + data = Buffer.from(new Uint8Array(data)); |
36 | } else if (utils.isString(data)) { | 45 | } else if (utils.isString(data)) { |
37 | - data = new Buffer(data, 'utf-8'); | 46 | + data = Buffer.from(data, 'utf-8'); |
38 | } else { | 47 | } else { |
39 | return reject(createError( | 48 | return reject(createError( |
40 | 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', | 49 | 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', |
... | @@ -69,36 +78,69 @@ module.exports = function httpAdapter(config) { | ... | @@ -69,36 +78,69 @@ module.exports = function httpAdapter(config) { |
69 | delete headers.Authorization; | 78 | delete headers.Authorization; |
70 | } | 79 | } |
71 | 80 | ||
72 | - var isHttps = protocol === 'https:'; | 81 | + var isHttpsRequest = isHttps.test(protocol); |
73 | - var agent = isHttps ? config.httpsAgent : config.httpAgent; | 82 | + var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; |
74 | 83 | ||
75 | var options = { | 84 | var options = { |
76 | - hostname: parsed.hostname, | ||
77 | - port: parsed.port, | ||
78 | path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), | 85 | path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), |
79 | - method: config.method, | 86 | + method: config.method.toUpperCase(), |
80 | headers: headers, | 87 | headers: headers, |
81 | agent: agent, | 88 | agent: agent, |
82 | auth: auth | 89 | auth: auth |
83 | }; | 90 | }; |
84 | 91 | ||
92 | + if (config.socketPath) { | ||
93 | + options.socketPath = config.socketPath; | ||
94 | + } else { | ||
95 | + options.hostname = parsed.hostname; | ||
96 | + options.port = parsed.port; | ||
97 | + } | ||
98 | + | ||
85 | var proxy = config.proxy; | 99 | var proxy = config.proxy; |
86 | - if (!proxy) { | 100 | + if (!proxy && proxy !== false) { |
87 | var proxyEnv = protocol.slice(0, -1) + '_proxy'; | 101 | var proxyEnv = protocol.slice(0, -1) + '_proxy'; |
88 | var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; | 102 | var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; |
89 | if (proxyUrl) { | 103 | if (proxyUrl) { |
90 | var parsedProxyUrl = url.parse(proxyUrl); | 104 | var parsedProxyUrl = url.parse(proxyUrl); |
91 | - proxy = { | 105 | + var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY; |
92 | - host: parsedProxyUrl.hostname, | 106 | + var shouldProxy = true; |
93 | - port: parsedProxyUrl.port | 107 | + |
94 | - }; | 108 | + if (noProxyEnv) { |
95 | - | 109 | + var noProxy = noProxyEnv.split(',').map(function trim(s) { |
96 | - if (parsedProxyUrl.auth) { | 110 | + return s.trim(); |
97 | - var proxyUrlAuth = parsedProxyUrl.auth.split(':'); | 111 | + }); |
98 | - proxy.auth = { | 112 | + |
99 | - username: proxyUrlAuth[0], | 113 | + shouldProxy = !noProxy.some(function proxyMatch(proxyElement) { |
100 | - password: proxyUrlAuth[1] | 114 | + if (!proxyElement) { |
115 | + return false; | ||
116 | + } | ||
117 | + if (proxyElement === '*') { | ||
118 | + return true; | ||
119 | + } | ||
120 | + if (proxyElement[0] === '.' && | ||
121 | + parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement && | ||
122 | + proxyElement.match(/\./g).length === parsed.hostname.match(/\./g).length) { | ||
123 | + return true; | ||
124 | + } | ||
125 | + | ||
126 | + return parsed.hostname === proxyElement; | ||
127 | + }); | ||
128 | + } | ||
129 | + | ||
130 | + | ||
131 | + if (shouldProxy) { | ||
132 | + proxy = { | ||
133 | + host: parsedProxyUrl.hostname, | ||
134 | + port: parsedProxyUrl.port | ||
101 | }; | 135 | }; |
136 | + | ||
137 | + if (parsedProxyUrl.auth) { | ||
138 | + var proxyUrlAuth = parsedProxyUrl.auth.split(':'); | ||
139 | + proxy.auth = { | ||
140 | + username: proxyUrlAuth[0], | ||
141 | + password: proxyUrlAuth[1] | ||
142 | + }; | ||
143 | + } | ||
102 | } | 144 | } |
103 | } | 145 | } |
104 | } | 146 | } |
... | @@ -112,28 +154,31 @@ module.exports = function httpAdapter(config) { | ... | @@ -112,28 +154,31 @@ module.exports = function httpAdapter(config) { |
112 | 154 | ||
113 | // Basic proxy authorization | 155 | // Basic proxy authorization |
114 | if (proxy.auth) { | 156 | if (proxy.auth) { |
115 | - var base64 = new Buffer(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); | 157 | + var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); |
116 | options.headers['Proxy-Authorization'] = 'Basic ' + base64; | 158 | options.headers['Proxy-Authorization'] = 'Basic ' + base64; |
117 | } | 159 | } |
118 | } | 160 | } |
119 | 161 | ||
120 | var transport; | 162 | var transport; |
121 | - if (config.maxRedirects === 0) { | 163 | + var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true); |
122 | - transport = isHttps ? https : http; | 164 | + if (config.transport) { |
165 | + transport = config.transport; | ||
166 | + } else if (config.maxRedirects === 0) { | ||
167 | + transport = isHttpsProxy ? https : http; | ||
123 | } else { | 168 | } else { |
124 | if (config.maxRedirects) { | 169 | if (config.maxRedirects) { |
125 | options.maxRedirects = config.maxRedirects; | 170 | options.maxRedirects = config.maxRedirects; |
126 | } | 171 | } |
127 | - transport = isHttps ? httpsFollow : httpFollow; | 172 | + transport = isHttpsProxy ? httpsFollow : httpFollow; |
173 | + } | ||
174 | + | ||
175 | + if (config.maxContentLength && config.maxContentLength > -1) { | ||
176 | + options.maxBodyLength = config.maxContentLength; | ||
128 | } | 177 | } |
129 | 178 | ||
130 | // Create the request | 179 | // Create the request |
131 | var req = transport.request(options, function handleResponse(res) { | 180 | var req = transport.request(options, function handleResponse(res) { |
132 | - if (aborted) return; | 181 | + if (req.aborted) return; |
133 | - | ||
134 | - // Response has been received so kill timer that handles request timeout | ||
135 | - clearTimeout(timer); | ||
136 | - timer = null; | ||
137 | 182 | ||
138 | // uncompress the response body transparently if required | 183 | // uncompress the response body transparently if required |
139 | var stream = res; | 184 | var stream = res; |
... | @@ -143,7 +188,7 @@ module.exports = function httpAdapter(config) { | ... | @@ -143,7 +188,7 @@ module.exports = function httpAdapter(config) { |
143 | case 'compress': | 188 | case 'compress': |
144 | case 'deflate': | 189 | case 'deflate': |
145 | // add the unzipper to the body stream processing pipeline | 190 | // add the unzipper to the body stream processing pipeline |
146 | - stream = stream.pipe(zlib.createUnzip()); | 191 | + stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip()); |
147 | 192 | ||
148 | // remove the content-encoding in order to not confuse downstream operations | 193 | // remove the content-encoding in order to not confuse downstream operations |
149 | delete res.headers['content-encoding']; | 194 | delete res.headers['content-encoding']; |
... | @@ -171,20 +216,21 @@ module.exports = function httpAdapter(config) { | ... | @@ -171,20 +216,21 @@ module.exports = function httpAdapter(config) { |
171 | 216 | ||
172 | // make sure the content length is not over the maxContentLength if specified | 217 | // make sure the content length is not over the maxContentLength if specified |
173 | if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) { | 218 | if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) { |
219 | + stream.destroy(); | ||
174 | reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | 220 | reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', |
175 | config, null, lastRequest)); | 221 | config, null, lastRequest)); |
176 | } | 222 | } |
177 | }); | 223 | }); |
178 | 224 | ||
179 | stream.on('error', function handleStreamError(err) { | 225 | stream.on('error', function handleStreamError(err) { |
180 | - if (aborted) return; | 226 | + if (req.aborted) return; |
181 | reject(enhanceError(err, config, null, lastRequest)); | 227 | reject(enhanceError(err, config, null, lastRequest)); |
182 | }); | 228 | }); |
183 | 229 | ||
184 | stream.on('end', function handleStreamEnd() { | 230 | stream.on('end', function handleStreamEnd() { |
185 | var responseData = Buffer.concat(responseBuffer); | 231 | var responseData = Buffer.concat(responseBuffer); |
186 | if (config.responseType !== 'arraybuffer') { | 232 | if (config.responseType !== 'arraybuffer') { |
187 | - responseData = responseData.toString('utf8'); | 233 | + responseData = responseData.toString(config.responseEncoding); |
188 | } | 234 | } |
189 | 235 | ||
190 | response.data = responseData; | 236 | response.data = responseData; |
... | @@ -195,35 +241,33 @@ module.exports = function httpAdapter(config) { | ... | @@ -195,35 +241,33 @@ module.exports = function httpAdapter(config) { |
195 | 241 | ||
196 | // Handle errors | 242 | // Handle errors |
197 | req.on('error', function handleRequestError(err) { | 243 | req.on('error', function handleRequestError(err) { |
198 | - if (aborted) return; | 244 | + if (req.aborted) return; |
199 | reject(enhanceError(err, config, null, req)); | 245 | reject(enhanceError(err, config, null, req)); |
200 | }); | 246 | }); |
201 | 247 | ||
202 | // Handle request timeout | 248 | // Handle request timeout |
203 | - if (config.timeout && !timer) { | 249 | + if (config.timeout) { |
204 | timer = setTimeout(function handleRequestTimeout() { | 250 | timer = setTimeout(function handleRequestTimeout() { |
205 | req.abort(); | 251 | req.abort(); |
206 | reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req)); | 252 | reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req)); |
207 | - aborted = true; | ||
208 | }, config.timeout); | 253 | }, config.timeout); |
209 | } | 254 | } |
210 | 255 | ||
211 | if (config.cancelToken) { | 256 | if (config.cancelToken) { |
212 | // Handle cancellation | 257 | // Handle cancellation |
213 | config.cancelToken.promise.then(function onCanceled(cancel) { | 258 | config.cancelToken.promise.then(function onCanceled(cancel) { |
214 | - if (aborted) { | 259 | + if (req.aborted) return; |
215 | - return; | ||
216 | - } | ||
217 | 260 | ||
218 | req.abort(); | 261 | req.abort(); |
219 | reject(cancel); | 262 | reject(cancel); |
220 | - aborted = true; | ||
221 | }); | 263 | }); |
222 | } | 264 | } |
223 | 265 | ||
224 | // Send the request | 266 | // Send the request |
225 | if (utils.isStream(data)) { | 267 | if (utils.isStream(data)) { |
226 | - data.pipe(req); | 268 | + data.on('error', function handleStreamError(err) { |
269 | + reject(enhanceError(err, config, null, req)); | ||
270 | + }).pipe(req); | ||
227 | } else { | 271 | } else { |
228 | req.end(data); | 272 | req.end(data); |
229 | } | 273 | } | ... | ... |
... | @@ -6,7 +6,6 @@ var buildURL = require('./../helpers/buildURL'); | ... | @@ -6,7 +6,6 @@ var buildURL = require('./../helpers/buildURL'); |
6 | var parseHeaders = require('./../helpers/parseHeaders'); | 6 | var parseHeaders = require('./../helpers/parseHeaders'); |
7 | var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); | 7 | var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); |
8 | var createError = require('../core/createError'); | 8 | var createError = require('../core/createError'); |
9 | -var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa'); | ||
10 | 9 | ||
11 | module.exports = function xhrAdapter(config) { | 10 | module.exports = function xhrAdapter(config) { |
12 | return new Promise(function dispatchXhrRequest(resolve, reject) { | 11 | return new Promise(function dispatchXhrRequest(resolve, reject) { |
... | @@ -18,22 +17,6 @@ module.exports = function xhrAdapter(config) { | ... | @@ -18,22 +17,6 @@ module.exports = function xhrAdapter(config) { |
18 | } | 17 | } |
19 | 18 | ||
20 | var request = new XMLHttpRequest(); | 19 | var request = new XMLHttpRequest(); |
21 | - var loadEvent = 'onreadystatechange'; | ||
22 | - var xDomain = false; | ||
23 | - | ||
24 | - // For IE 8/9 CORS support | ||
25 | - // Only supports POST and GET calls and doesn't returns the response headers. | ||
26 | - // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest. | ||
27 | - if (process.env.NODE_ENV !== 'test' && | ||
28 | - typeof window !== 'undefined' && | ||
29 | - window.XDomainRequest && !('withCredentials' in request) && | ||
30 | - !isURLSameOrigin(config.url)) { | ||
31 | - request = new window.XDomainRequest(); | ||
32 | - loadEvent = 'onload'; | ||
33 | - xDomain = true; | ||
34 | - request.onprogress = function handleProgress() {}; | ||
35 | - request.ontimeout = function handleTimeout() {}; | ||
36 | - } | ||
37 | 20 | ||
38 | // HTTP basic authentication | 21 | // HTTP basic authentication |
39 | if (config.auth) { | 22 | if (config.auth) { |
... | @@ -48,8 +31,8 @@ module.exports = function xhrAdapter(config) { | ... | @@ -48,8 +31,8 @@ module.exports = function xhrAdapter(config) { |
48 | request.timeout = config.timeout; | 31 | request.timeout = config.timeout; |
49 | 32 | ||
50 | // Listen for ready state | 33 | // Listen for ready state |
51 | - request[loadEvent] = function handleLoad() { | 34 | + request.onreadystatechange = function handleLoad() { |
52 | - if (!request || (request.readyState !== 4 && !xDomain)) { | 35 | + if (!request || request.readyState !== 4) { |
53 | return; | 36 | return; |
54 | } | 37 | } |
55 | 38 | ||
... | @@ -66,9 +49,8 @@ module.exports = function xhrAdapter(config) { | ... | @@ -66,9 +49,8 @@ module.exports = function xhrAdapter(config) { |
66 | var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; | 49 | var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; |
67 | var response = { | 50 | var response = { |
68 | data: responseData, | 51 | data: responseData, |
69 | - // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201) | 52 | + status: request.status, |
70 | - status: request.status === 1223 ? 204 : request.status, | 53 | + statusText: request.statusText, |
71 | - statusText: request.status === 1223 ? 'No Content' : request.statusText, | ||
72 | headers: responseHeaders, | 54 | headers: responseHeaders, |
73 | config: config, | 55 | config: config, |
74 | request: request | 56 | request: request |
... | @@ -80,6 +62,18 @@ module.exports = function xhrAdapter(config) { | ... | @@ -80,6 +62,18 @@ module.exports = function xhrAdapter(config) { |
80 | request = null; | 62 | request = null; |
81 | }; | 63 | }; |
82 | 64 | ||
65 | + // Handle browser request cancellation (as opposed to a manual cancellation) | ||
66 | + request.onabort = function handleAbort() { | ||
67 | + if (!request) { | ||
68 | + return; | ||
69 | + } | ||
70 | + | ||
71 | + reject(createError('Request aborted', config, 'ECONNABORTED', request)); | ||
72 | + | ||
73 | + // Clean up request | ||
74 | + request = null; | ||
75 | + }; | ||
76 | + | ||
83 | // Handle low level network errors | 77 | // Handle low level network errors |
84 | request.onerror = function handleError() { | 78 | request.onerror = function handleError() { |
85 | // Real errors are hidden from us by the browser | 79 | // Real errors are hidden from us by the browser |
... | @@ -107,8 +101,8 @@ module.exports = function xhrAdapter(config) { | ... | @@ -107,8 +101,8 @@ module.exports = function xhrAdapter(config) { |
107 | 101 | ||
108 | // Add xsrf header | 102 | // Add xsrf header |
109 | var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? | 103 | var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? |
110 | - cookies.read(config.xsrfCookieName) : | 104 | + cookies.read(config.xsrfCookieName) : |
111 | - undefined; | 105 | + undefined; |
112 | 106 | ||
113 | if (xsrfValue) { | 107 | if (xsrfValue) { |
114 | requestHeaders[config.xsrfHeaderName] = xsrfValue; | 108 | requestHeaders[config.xsrfHeaderName] = xsrfValue; | ... | ... |
... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
3 | var utils = require('./utils'); | 3 | var utils = require('./utils'); |
4 | var bind = require('./helpers/bind'); | 4 | var bind = require('./helpers/bind'); |
5 | var Axios = require('./core/Axios'); | 5 | var Axios = require('./core/Axios'); |
6 | +var mergeConfig = require('./core/mergeConfig'); | ||
6 | var defaults = require('./defaults'); | 7 | var defaults = require('./defaults'); |
7 | 8 | ||
8 | /** | 9 | /** |
... | @@ -32,7 +33,7 @@ axios.Axios = Axios; | ... | @@ -32,7 +33,7 @@ axios.Axios = Axios; |
32 | 33 | ||
33 | // Factory for creating new instances | 34 | // Factory for creating new instances |
34 | axios.create = function create(instanceConfig) { | 35 | axios.create = function create(instanceConfig) { |
35 | - return createInstance(utils.merge(defaults, instanceConfig)); | 36 | + return createInstance(mergeConfig(axios.defaults, instanceConfig)); |
36 | }; | 37 | }; |
37 | 38 | ||
38 | // Expose Cancel & CancelToken | 39 | // Expose Cancel & CancelToken | ... | ... |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -var defaults = require('./../defaults'); | ||
4 | var utils = require('./../utils'); | 3 | var utils = require('./../utils'); |
4 | +var buildURL = require('../helpers/buildURL'); | ||
5 | var InterceptorManager = require('./InterceptorManager'); | 5 | var InterceptorManager = require('./InterceptorManager'); |
6 | var dispatchRequest = require('./dispatchRequest'); | 6 | var dispatchRequest = require('./dispatchRequest'); |
7 | -var isAbsoluteURL = require('./../helpers/isAbsoluteURL'); | 7 | +var mergeConfig = require('./mergeConfig'); |
8 | -var combineURLs = require('./../helpers/combineURLs'); | ||
9 | 8 | ||
10 | /** | 9 | /** |
11 | * Create a new instance of Axios | 10 | * Create a new instance of Axios |
... | @@ -29,18 +28,14 @@ Axios.prototype.request = function request(config) { | ... | @@ -29,18 +28,14 @@ Axios.prototype.request = function request(config) { |
29 | /*eslint no-param-reassign:0*/ | 28 | /*eslint no-param-reassign:0*/ |
30 | // Allow for axios('example/url'[, config]) a la fetch API | 29 | // Allow for axios('example/url'[, config]) a la fetch API |
31 | if (typeof config === 'string') { | 30 | if (typeof config === 'string') { |
32 | - config = utils.merge({ | 31 | + config = arguments[1] || {}; |
33 | - url: arguments[0] | 32 | + config.url = arguments[0]; |
34 | - }, arguments[1]); | 33 | + } else { |
34 | + config = config || {}; | ||
35 | } | 35 | } |
36 | 36 | ||
37 | - config = utils.merge(defaults, this.defaults, { method: 'get' }, config); | 37 | + config = mergeConfig(this.defaults, config); |
38 | - config.method = config.method.toLowerCase(); | 38 | + config.method = config.method ? config.method.toLowerCase() : 'get'; |
39 | - | ||
40 | - // Support baseURL config | ||
41 | - if (config.baseURL && !isAbsoluteURL(config.url)) { | ||
42 | - config.url = combineURLs(config.baseURL, config.url); | ||
43 | - } | ||
44 | 39 | ||
45 | // Hook up interceptors middleware | 40 | // Hook up interceptors middleware |
46 | var chain = [dispatchRequest, undefined]; | 41 | var chain = [dispatchRequest, undefined]; |
... | @@ -61,6 +56,11 @@ Axios.prototype.request = function request(config) { | ... | @@ -61,6 +56,11 @@ Axios.prototype.request = function request(config) { |
61 | return promise; | 56 | return promise; |
62 | }; | 57 | }; |
63 | 58 | ||
59 | +Axios.prototype.getUri = function getUri(config) { | ||
60 | + config = mergeConfig(this.defaults, config); | ||
61 | + return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
62 | +}; | ||
63 | + | ||
64 | // Provide aliases for supported request methods | 64 | // Provide aliases for supported request methods |
65 | utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { | 65 | utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { |
66 | /*eslint func-names:0*/ | 66 | /*eslint func-names:0*/ | ... | ... |
... | @@ -4,6 +4,8 @@ var utils = require('./../utils'); | ... | @@ -4,6 +4,8 @@ var utils = require('./../utils'); |
4 | var transformData = require('./transformData'); | 4 | var transformData = require('./transformData'); |
5 | var isCancel = require('../cancel/isCancel'); | 5 | var isCancel = require('../cancel/isCancel'); |
6 | var defaults = require('../defaults'); | 6 | var defaults = require('../defaults'); |
7 | +var isAbsoluteURL = require('./../helpers/isAbsoluteURL'); | ||
8 | +var combineURLs = require('./../helpers/combineURLs'); | ||
7 | 9 | ||
8 | /** | 10 | /** |
9 | * Throws a `Cancel` if cancellation has been requested. | 11 | * Throws a `Cancel` if cancellation has been requested. |
... | @@ -23,6 +25,11 @@ function throwIfCancellationRequested(config) { | ... | @@ -23,6 +25,11 @@ function throwIfCancellationRequested(config) { |
23 | module.exports = function dispatchRequest(config) { | 25 | module.exports = function dispatchRequest(config) { |
24 | throwIfCancellationRequested(config); | 26 | throwIfCancellationRequested(config); |
25 | 27 | ||
28 | + // Support baseURL config | ||
29 | + if (config.baseURL && !isAbsoluteURL(config.url)) { | ||
30 | + config.url = combineURLs(config.baseURL, config.url); | ||
31 | + } | ||
32 | + | ||
26 | // Ensure headers exist | 33 | // Ensure headers exist |
27 | config.headers = config.headers || {}; | 34 | config.headers = config.headers || {}; |
28 | 35 | ... | ... |
... | @@ -15,7 +15,28 @@ module.exports = function enhanceError(error, config, code, request, response) { | ... | @@ -15,7 +15,28 @@ module.exports = function enhanceError(error, config, code, request, response) { |
15 | if (code) { | 15 | if (code) { |
16 | error.code = code; | 16 | error.code = code; |
17 | } | 17 | } |
18 | + | ||
18 | error.request = request; | 19 | error.request = request; |
19 | error.response = response; | 20 | error.response = response; |
21 | + error.isAxiosError = true; | ||
22 | + | ||
23 | + error.toJSON = function() { | ||
24 | + return { | ||
25 | + // Standard | ||
26 | + message: this.message, | ||
27 | + name: this.name, | ||
28 | + // Microsoft | ||
29 | + description: this.description, | ||
30 | + number: this.number, | ||
31 | + // Mozilla | ||
32 | + fileName: this.fileName, | ||
33 | + lineNumber: this.lineNumber, | ||
34 | + columnNumber: this.columnNumber, | ||
35 | + stack: this.stack, | ||
36 | + // Axios | ||
37 | + config: this.config, | ||
38 | + code: this.code | ||
39 | + }; | ||
40 | + }; | ||
20 | return error; | 41 | return error; |
21 | }; | 42 | }; | ... | ... |
node_modules/axios/lib/core/mergeConfig.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +var utils = require('../utils'); | ||
4 | + | ||
5 | +/** | ||
6 | + * Config-specific merge-function which creates a new config-object | ||
7 | + * by merging two configuration objects together. | ||
8 | + * | ||
9 | + * @param {Object} config1 | ||
10 | + * @param {Object} config2 | ||
11 | + * @returns {Object} New object resulting from merging config2 to config1 | ||
12 | + */ | ||
13 | +module.exports = function mergeConfig(config1, config2) { | ||
14 | + // eslint-disable-next-line no-param-reassign | ||
15 | + config2 = config2 || {}; | ||
16 | + var config = {}; | ||
17 | + | ||
18 | + utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) { | ||
19 | + if (typeof config2[prop] !== 'undefined') { | ||
20 | + config[prop] = config2[prop]; | ||
21 | + } | ||
22 | + }); | ||
23 | + | ||
24 | + utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) { | ||
25 | + if (utils.isObject(config2[prop])) { | ||
26 | + config[prop] = utils.deepMerge(config1[prop], config2[prop]); | ||
27 | + } else if (typeof config2[prop] !== 'undefined') { | ||
28 | + config[prop] = config2[prop]; | ||
29 | + } else if (utils.isObject(config1[prop])) { | ||
30 | + config[prop] = utils.deepMerge(config1[prop]); | ||
31 | + } else if (typeof config1[prop] !== 'undefined') { | ||
32 | + config[prop] = config1[prop]; | ||
33 | + } | ||
34 | + }); | ||
35 | + | ||
36 | + utils.forEach([ | ||
37 | + 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', | ||
38 | + 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', | ||
39 | + 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength', | ||
40 | + 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken', | ||
41 | + 'socketPath' | ||
42 | + ], function defaultToConfig2(prop) { | ||
43 | + if (typeof config2[prop] !== 'undefined') { | ||
44 | + config[prop] = config2[prop]; | ||
45 | + } else if (typeof config1[prop] !== 'undefined') { | ||
46 | + config[prop] = config1[prop]; | ||
47 | + } | ||
48 | + }); | ||
49 | + | ||
50 | + return config; | ||
51 | +}; |
... | @@ -11,8 +11,7 @@ var createError = require('./createError'); | ... | @@ -11,8 +11,7 @@ var createError = require('./createError'); |
11 | */ | 11 | */ |
12 | module.exports = function settle(resolve, reject, response) { | 12 | module.exports = function settle(resolve, reject, response) { |
13 | var validateStatus = response.config.validateStatus; | 13 | var validateStatus = response.config.validateStatus; |
14 | - // Note: status is not exposed by XDomainRequest | 14 | + if (!validateStatus || validateStatus(response.status)) { |
15 | - if (!response.status || !validateStatus || validateStatus(response.status)) { | ||
16 | resolve(response); | 15 | resolve(response); |
17 | } else { | 16 | } else { |
18 | reject(createError( | 17 | reject(createError( | ... | ... |
... | @@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) { | ... | @@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) { |
15 | 15 | ||
16 | function getDefaultAdapter() { | 16 | function getDefaultAdapter() { |
17 | var adapter; | 17 | var adapter; |
18 | - if (typeof XMLHttpRequest !== 'undefined') { | 18 | + // Only Node.JS has a process variable that is of [[Class]] process |
19 | - // For browsers use XHR adapter | 19 | + if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { |
20 | - adapter = require('./adapters/xhr'); | ||
21 | - } else if (typeof process !== 'undefined') { | ||
22 | // For node use HTTP adapter | 20 | // For node use HTTP adapter |
23 | adapter = require('./adapters/http'); | 21 | adapter = require('./adapters/http'); |
22 | + } else if (typeof XMLHttpRequest !== 'undefined') { | ||
23 | + // For browsers use XHR adapter | ||
24 | + adapter = require('./adapters/xhr'); | ||
24 | } | 25 | } |
25 | return adapter; | 26 | return adapter; |
26 | } | 27 | } |
... | @@ -29,6 +30,7 @@ var defaults = { | ... | @@ -29,6 +30,7 @@ var defaults = { |
29 | adapter: getDefaultAdapter(), | 30 | adapter: getDefaultAdapter(), |
30 | 31 | ||
31 | transformRequest: [function transformRequest(data, headers) { | 32 | transformRequest: [function transformRequest(data, headers) { |
33 | + normalizeHeaderName(headers, 'Accept'); | ||
32 | normalizeHeaderName(headers, 'Content-Type'); | 34 | normalizeHeaderName(headers, 'Content-Type'); |
33 | if (utils.isFormData(data) || | 35 | if (utils.isFormData(data) || |
34 | utils.isArrayBuffer(data) || | 36 | utils.isArrayBuffer(data) || |
... | @@ -63,6 +65,10 @@ var defaults = { | ... | @@ -63,6 +65,10 @@ var defaults = { |
63 | return data; | 65 | return data; |
64 | }], | 66 | }], |
65 | 67 | ||
68 | + /** | ||
69 | + * A timeout in milliseconds to abort a request. If set to 0 (default) a | ||
70 | + * timeout is not created. | ||
71 | + */ | ||
66 | timeout: 0, | 72 | timeout: 0, |
67 | 73 | ||
68 | xsrfCookieName: 'XSRF-TOKEN', | 74 | xsrfCookieName: 'XSRF-TOKEN', | ... | ... |
1 | -'use strict'; | ||
2 | - | ||
3 | -// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js | ||
4 | - | ||
5 | -var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | ||
6 | - | ||
7 | -function E() { | ||
8 | - this.message = 'String contains an invalid character'; | ||
9 | -} | ||
10 | -E.prototype = new Error; | ||
11 | -E.prototype.code = 5; | ||
12 | -E.prototype.name = 'InvalidCharacterError'; | ||
13 | - | ||
14 | -function btoa(input) { | ||
15 | - var str = String(input); | ||
16 | - var output = ''; | ||
17 | - for ( | ||
18 | - // initialize result and counter | ||
19 | - var block, charCode, idx = 0, map = chars; | ||
20 | - // if the next str index does not exist: | ||
21 | - // change the mapping table to "=" | ||
22 | - // check if d has no fractional digits | ||
23 | - str.charAt(idx | 0) || (map = '=', idx % 1); | ||
24 | - // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 | ||
25 | - output += map.charAt(63 & block >> 8 - idx % 1 * 8) | ||
26 | - ) { | ||
27 | - charCode = str.charCodeAt(idx += 3 / 4); | ||
28 | - if (charCode > 0xFF) { | ||
29 | - throw new E(); | ||
30 | - } | ||
31 | - block = block << 8 | charCode; | ||
32 | - } | ||
33 | - return output; | ||
34 | -} | ||
35 | - | ||
36 | -module.exports = btoa; |
... | @@ -41,9 +41,7 @@ module.exports = function buildURL(url, params, paramsSerializer) { | ... | @@ -41,9 +41,7 @@ module.exports = function buildURL(url, params, paramsSerializer) { |
41 | 41 | ||
42 | if (utils.isArray(val)) { | 42 | if (utils.isArray(val)) { |
43 | key = key + '[]'; | 43 | key = key + '[]'; |
44 | - } | 44 | + } else { |
45 | - | ||
46 | - if (!utils.isArray(val)) { | ||
47 | val = [val]; | 45 | val = [val]; |
48 | } | 46 | } |
49 | 47 | ||
... | @@ -61,6 +59,11 @@ module.exports = function buildURL(url, params, paramsSerializer) { | ... | @@ -61,6 +59,11 @@ module.exports = function buildURL(url, params, paramsSerializer) { |
61 | } | 59 | } |
62 | 60 | ||
63 | if (serializedParams) { | 61 | if (serializedParams) { |
62 | + var hashmarkIndex = url.indexOf('#'); | ||
63 | + if (hashmarkIndex !== -1) { | ||
64 | + url = url.slice(0, hashmarkIndex); | ||
65 | + } | ||
66 | + | ||
64 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; | 67 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; |
65 | } | 68 | } |
66 | 69 | ... | ... |
... | @@ -6,48 +6,48 @@ module.exports = ( | ... | @@ -6,48 +6,48 @@ module.exports = ( |
6 | utils.isStandardBrowserEnv() ? | 6 | utils.isStandardBrowserEnv() ? |
7 | 7 | ||
8 | // Standard browser envs support document.cookie | 8 | // Standard browser envs support document.cookie |
9 | - (function standardBrowserEnv() { | 9 | + (function standardBrowserEnv() { |
10 | - return { | 10 | + return { |
11 | - write: function write(name, value, expires, path, domain, secure) { | 11 | + write: function write(name, value, expires, path, domain, secure) { |
12 | - var cookie = []; | 12 | + var cookie = []; |
13 | - cookie.push(name + '=' + encodeURIComponent(value)); | 13 | + cookie.push(name + '=' + encodeURIComponent(value)); |
14 | - | 14 | + |
15 | - if (utils.isNumber(expires)) { | 15 | + if (utils.isNumber(expires)) { |
16 | - cookie.push('expires=' + new Date(expires).toGMTString()); | 16 | + cookie.push('expires=' + new Date(expires).toGMTString()); |
17 | + } | ||
18 | + | ||
19 | + if (utils.isString(path)) { | ||
20 | + cookie.push('path=' + path); | ||
21 | + } | ||
22 | + | ||
23 | + if (utils.isString(domain)) { | ||
24 | + cookie.push('domain=' + domain); | ||
25 | + } | ||
26 | + | ||
27 | + if (secure === true) { | ||
28 | + cookie.push('secure'); | ||
29 | + } | ||
30 | + | ||
31 | + document.cookie = cookie.join('; '); | ||
32 | + }, | ||
33 | + | ||
34 | + read: function read(name) { | ||
35 | + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
36 | + return (match ? decodeURIComponent(match[3]) : null); | ||
37 | + }, | ||
38 | + | ||
39 | + remove: function remove(name) { | ||
40 | + this.write(name, '', Date.now() - 86400000); | ||
17 | } | 41 | } |
18 | - | 42 | + }; |
19 | - if (utils.isString(path)) { | 43 | + })() : |
20 | - cookie.push('path=' + path); | ||
21 | - } | ||
22 | - | ||
23 | - if (utils.isString(domain)) { | ||
24 | - cookie.push('domain=' + domain); | ||
25 | - } | ||
26 | - | ||
27 | - if (secure === true) { | ||
28 | - cookie.push('secure'); | ||
29 | - } | ||
30 | - | ||
31 | - document.cookie = cookie.join('; '); | ||
32 | - }, | ||
33 | - | ||
34 | - read: function read(name) { | ||
35 | - var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
36 | - return (match ? decodeURIComponent(match[3]) : null); | ||
37 | - }, | ||
38 | - | ||
39 | - remove: function remove(name) { | ||
40 | - this.write(name, '', Date.now() - 86400000); | ||
41 | - } | ||
42 | - }; | ||
43 | - })() : | ||
44 | 44 | ||
45 | // Non standard browser env (web workers, react-native) lack needed support. | 45 | // Non standard browser env (web workers, react-native) lack needed support. |
46 | - (function nonStandardBrowserEnv() { | 46 | + (function nonStandardBrowserEnv() { |
47 | - return { | 47 | + return { |
48 | - write: function write() {}, | 48 | + write: function write() {}, |
49 | - read: function read() { return null; }, | 49 | + read: function read() { return null; }, |
50 | - remove: function remove() {} | 50 | + remove: function remove() {} |
51 | - }; | 51 | + }; |
52 | - })() | 52 | + })() |
53 | ); | 53 | ); | ... | ... |
... | @@ -7,62 +7,62 @@ module.exports = ( | ... | @@ -7,62 +7,62 @@ module.exports = ( |
7 | 7 | ||
8 | // Standard browser envs have full support of the APIs needed to test | 8 | // Standard browser envs have full support of the APIs needed to test |
9 | // whether the request URL is of the same origin as current location. | 9 | // whether the request URL is of the same origin as current location. |
10 | - (function standardBrowserEnv() { | 10 | + (function standardBrowserEnv() { |
11 | - var msie = /(msie|trident)/i.test(navigator.userAgent); | 11 | + var msie = /(msie|trident)/i.test(navigator.userAgent); |
12 | - var urlParsingNode = document.createElement('a'); | 12 | + var urlParsingNode = document.createElement('a'); |
13 | - var originURL; | 13 | + var originURL; |
14 | 14 | ||
15 | - /** | 15 | + /** |
16 | * Parse a URL to discover it's components | 16 | * Parse a URL to discover it's components |
17 | * | 17 | * |
18 | * @param {String} url The URL to be parsed | 18 | * @param {String} url The URL to be parsed |
19 | * @returns {Object} | 19 | * @returns {Object} |
20 | */ | 20 | */ |
21 | - function resolveURL(url) { | 21 | + function resolveURL(url) { |
22 | - var href = url; | 22 | + var href = url; |
23 | 23 | ||
24 | - if (msie) { | 24 | + if (msie) { |
25 | // IE needs attribute set twice to normalize properties | 25 | // IE needs attribute set twice to normalize properties |
26 | - urlParsingNode.setAttribute('href', href); | 26 | + urlParsingNode.setAttribute('href', href); |
27 | - href = urlParsingNode.href; | 27 | + href = urlParsingNode.href; |
28 | - } | 28 | + } |
29 | 29 | ||
30 | - urlParsingNode.setAttribute('href', href); | 30 | + urlParsingNode.setAttribute('href', href); |
31 | 31 | ||
32 | - // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils | 32 | + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils |
33 | - return { | 33 | + return { |
34 | - href: urlParsingNode.href, | 34 | + href: urlParsingNode.href, |
35 | - protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', | 35 | + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', |
36 | - host: urlParsingNode.host, | 36 | + host: urlParsingNode.host, |
37 | - search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', | 37 | + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', |
38 | - hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', | 38 | + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', |
39 | - hostname: urlParsingNode.hostname, | 39 | + hostname: urlParsingNode.hostname, |
40 | - port: urlParsingNode.port, | 40 | + port: urlParsingNode.port, |
41 | - pathname: (urlParsingNode.pathname.charAt(0) === '/') ? | 41 | + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? |
42 | - urlParsingNode.pathname : | 42 | + urlParsingNode.pathname : |
43 | - '/' + urlParsingNode.pathname | 43 | + '/' + urlParsingNode.pathname |
44 | - }; | 44 | + }; |
45 | - } | 45 | + } |
46 | 46 | ||
47 | - originURL = resolveURL(window.location.href); | 47 | + originURL = resolveURL(window.location.href); |
48 | 48 | ||
49 | - /** | 49 | + /** |
50 | * Determine if a URL shares the same origin as the current location | 50 | * Determine if a URL shares the same origin as the current location |
51 | * | 51 | * |
52 | * @param {String} requestURL The URL to test | 52 | * @param {String} requestURL The URL to test |
53 | * @returns {boolean} True if URL shares the same origin, otherwise false | 53 | * @returns {boolean} True if URL shares the same origin, otherwise false |
54 | */ | 54 | */ |
55 | - return function isURLSameOrigin(requestURL) { | 55 | + return function isURLSameOrigin(requestURL) { |
56 | - var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | 56 | + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; |
57 | - return (parsed.protocol === originURL.protocol && | 57 | + return (parsed.protocol === originURL.protocol && |
58 | parsed.host === originURL.host); | 58 | parsed.host === originURL.host); |
59 | - }; | 59 | + }; |
60 | - })() : | 60 | + })() : |
61 | 61 | ||
62 | // Non standard browser envs (web workers, react-native) lack needed support. | 62 | // Non standard browser envs (web workers, react-native) lack needed support. |
63 | - (function nonStandardBrowserEnv() { | 63 | + (function nonStandardBrowserEnv() { |
64 | - return function isURLSameOrigin() { | 64 | + return function isURLSameOrigin() { |
65 | - return true; | 65 | + return true; |
66 | - }; | 66 | + }; |
67 | - })() | 67 | + })() |
68 | ); | 68 | ); | ... | ... |
... | @@ -2,6 +2,15 @@ | ... | @@ -2,6 +2,15 @@ |
2 | 2 | ||
3 | var utils = require('./../utils'); | 3 | var utils = require('./../utils'); |
4 | 4 | ||
5 | +// Headers whose duplicates are ignored by node | ||
6 | +// c.f. https://nodejs.org/api/http.html#http_message_headers | ||
7 | +var ignoreDuplicateOf = [ | ||
8 | + 'age', 'authorization', 'content-length', 'content-type', 'etag', | ||
9 | + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', | ||
10 | + 'last-modified', 'location', 'max-forwards', 'proxy-authorization', | ||
11 | + 'referer', 'retry-after', 'user-agent' | ||
12 | +]; | ||
13 | + | ||
5 | /** | 14 | /** |
6 | * Parse headers into an object | 15 | * Parse headers into an object |
7 | * | 16 | * |
... | @@ -29,7 +38,14 @@ module.exports = function parseHeaders(headers) { | ... | @@ -29,7 +38,14 @@ module.exports = function parseHeaders(headers) { |
29 | val = utils.trim(line.substr(i + 1)); | 38 | val = utils.trim(line.substr(i + 1)); |
30 | 39 | ||
31 | if (key) { | 40 | if (key) { |
32 | - parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | 41 | + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { |
42 | + return; | ||
43 | + } | ||
44 | + if (key === 'set-cookie') { | ||
45 | + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); | ||
46 | + } else { | ||
47 | + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
48 | + } | ||
33 | } | 49 | } |
34 | }); | 50 | }); |
35 | 51 | ... | ... |
... | @@ -177,9 +177,13 @@ function trim(str) { | ... | @@ -177,9 +177,13 @@ function trim(str) { |
177 | * | 177 | * |
178 | * react-native: | 178 | * react-native: |
179 | * navigator.product -> 'ReactNative' | 179 | * navigator.product -> 'ReactNative' |
180 | + * nativescript | ||
181 | + * navigator.product -> 'NativeScript' or 'NS' | ||
180 | */ | 182 | */ |
181 | function isStandardBrowserEnv() { | 183 | function isStandardBrowserEnv() { |
182 | - if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { | 184 | + if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || |
185 | + navigator.product === 'NativeScript' || | ||
186 | + navigator.product === 'NS')) { | ||
183 | return false; | 187 | return false; |
184 | } | 188 | } |
185 | return ( | 189 | return ( |
... | @@ -207,7 +211,7 @@ function forEach(obj, fn) { | ... | @@ -207,7 +211,7 @@ function forEach(obj, fn) { |
207 | } | 211 | } |
208 | 212 | ||
209 | // Force an array if not already something iterable | 213 | // Force an array if not already something iterable |
210 | - if (typeof obj !== 'object' && !isArray(obj)) { | 214 | + if (typeof obj !== 'object') { |
211 | /*eslint no-param-reassign:0*/ | 215 | /*eslint no-param-reassign:0*/ |
212 | obj = [obj]; | 216 | obj = [obj]; |
213 | } | 217 | } |
... | @@ -261,6 +265,32 @@ function merge(/* obj1, obj2, obj3, ... */) { | ... | @@ -261,6 +265,32 @@ function merge(/* obj1, obj2, obj3, ... */) { |
261 | } | 265 | } |
262 | 266 | ||
263 | /** | 267 | /** |
268 | + * Function equal to merge with the difference being that no reference | ||
269 | + * to original objects is kept. | ||
270 | + * | ||
271 | + * @see merge | ||
272 | + * @param {Object} obj1 Object to merge | ||
273 | + * @returns {Object} Result of all merge properties | ||
274 | + */ | ||
275 | +function deepMerge(/* obj1, obj2, obj3, ... */) { | ||
276 | + var result = {}; | ||
277 | + function assignValue(val, key) { | ||
278 | + if (typeof result[key] === 'object' && typeof val === 'object') { | ||
279 | + result[key] = deepMerge(result[key], val); | ||
280 | + } else if (typeof val === 'object') { | ||
281 | + result[key] = deepMerge({}, val); | ||
282 | + } else { | ||
283 | + result[key] = val; | ||
284 | + } | ||
285 | + } | ||
286 | + | ||
287 | + for (var i = 0, l = arguments.length; i < l; i++) { | ||
288 | + forEach(arguments[i], assignValue); | ||
289 | + } | ||
290 | + return result; | ||
291 | +} | ||
292 | + | ||
293 | +/** | ||
264 | * Extends object a by mutably adding to it the properties of object b. | 294 | * Extends object a by mutably adding to it the properties of object b. |
265 | * | 295 | * |
266 | * @param {Object} a The object to be extended | 296 | * @param {Object} a The object to be extended |
... | @@ -298,6 +328,7 @@ module.exports = { | ... | @@ -298,6 +328,7 @@ module.exports = { |
298 | isStandardBrowserEnv: isStandardBrowserEnv, | 328 | isStandardBrowserEnv: isStandardBrowserEnv, |
299 | forEach: forEach, | 329 | forEach: forEach, |
300 | merge: merge, | 330 | merge: merge, |
331 | + deepMerge: deepMerge, | ||
301 | extend: extend, | 332 | extend: extend, |
302 | trim: trim | 333 | trim: trim |
303 | }; | 334 | }; | ... | ... |
1 | { | 1 | { |
2 | - "_from": "axios@^0.16.2", | 2 | + "_from": "axios@^0.19.0", |
3 | - "_id": "axios@0.16.2", | 3 | + "_id": "axios@0.19.0", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=", | 5 | + "_integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", |
6 | "_location": "/axios", | 6 | "_location": "/axios", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
9 | "type": "range", | 9 | "type": "range", |
10 | "registry": true, | 10 | "registry": true, |
11 | - "raw": "axios@^0.16.2", | 11 | + "raw": "axios@^0.19.0", |
12 | "name": "axios", | 12 | "name": "axios", |
13 | "escapedName": "axios", | 13 | "escapedName": "axios", |
14 | - "rawSpec": "^0.16.2", | 14 | + "rawSpec": "^0.19.0", |
15 | "saveSpec": null, | 15 | "saveSpec": null, |
16 | - "fetchSpec": "^0.16.2" | 16 | + "fetchSpec": "^0.19.0" |
17 | }, | 17 | }, |
18 | "_requiredBy": [ | 18 | "_requiredBy": [ |
19 | "/@line/bot-sdk" | 19 | "/@line/bot-sdk" |
20 | ], | 20 | ], |
21 | - "_resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz", | 21 | + "_resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", |
22 | - "_shasum": "ba4f92f17167dfbab40983785454b9ac149c3c6d", | 22 | + "_shasum": "8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8", |
23 | - "_spec": "axios@^0.16.2", | 23 | + "_spec": "axios@^0.19.0", |
24 | - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk", | 24 | + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk", |
25 | "author": { | 25 | "author": { |
26 | "name": "Matt Zabriskie" | 26 | "name": "Matt Zabriskie" |
27 | }, | 27 | }, |
... | @@ -29,53 +29,59 @@ | ... | @@ -29,53 +29,59 @@ |
29 | "./lib/adapters/http.js": "./lib/adapters/xhr.js" | 29 | "./lib/adapters/http.js": "./lib/adapters/xhr.js" |
30 | }, | 30 | }, |
31 | "bugs": { | 31 | "bugs": { |
32 | - "url": "https://github.com/mzabriskie/axios/issues" | 32 | + "url": "https://github.com/axios/axios/issues" |
33 | }, | 33 | }, |
34 | "bundleDependencies": false, | 34 | "bundleDependencies": false, |
35 | + "bundlesize": [ | ||
36 | + { | ||
37 | + "path": "./dist/axios.min.js", | ||
38 | + "threshold": "5kB" | ||
39 | + } | ||
40 | + ], | ||
35 | "dependencies": { | 41 | "dependencies": { |
36 | - "follow-redirects": "^1.2.3", | 42 | + "follow-redirects": "1.5.10", |
37 | - "is-buffer": "^1.1.5" | 43 | + "is-buffer": "^2.0.2" |
38 | }, | 44 | }, |
39 | "deprecated": false, | 45 | "deprecated": false, |
40 | "description": "Promise based HTTP client for the browser and node.js", | 46 | "description": "Promise based HTTP client for the browser and node.js", |
41 | "devDependencies": { | 47 | "devDependencies": { |
42 | - "coveralls": "^2.11.9", | 48 | + "bundlesize": "^0.17.0", |
43 | - "es6-promise": "^4.0.5", | 49 | + "coveralls": "^3.0.0", |
44 | - "grunt": "^1.0.1", | 50 | + "es6-promise": "^4.2.4", |
51 | + "grunt": "^1.0.2", | ||
45 | "grunt-banner": "^0.6.0", | 52 | "grunt-banner": "^0.6.0", |
46 | "grunt-cli": "^1.2.0", | 53 | "grunt-cli": "^1.2.0", |
47 | - "grunt-contrib-clean": "^1.0.0", | 54 | + "grunt-contrib-clean": "^1.1.0", |
48 | - "grunt-contrib-nodeunit": "^1.0.0", | ||
49 | "grunt-contrib-watch": "^1.0.0", | 55 | "grunt-contrib-watch": "^1.0.0", |
50 | - "grunt-eslint": "^19.0.0", | 56 | + "grunt-eslint": "^20.1.0", |
51 | "grunt-karma": "^2.0.0", | 57 | "grunt-karma": "^2.0.0", |
52 | - "grunt-ts": "^6.0.0-beta.3", | 58 | + "grunt-mocha-test": "^0.13.3", |
59 | + "grunt-ts": "^6.0.0-beta.19", | ||
53 | "grunt-webpack": "^1.0.18", | 60 | "grunt-webpack": "^1.0.18", |
54 | "istanbul-instrumenter-loader": "^1.0.0", | 61 | "istanbul-instrumenter-loader": "^1.0.0", |
55 | "jasmine-core": "^2.4.1", | 62 | "jasmine-core": "^2.4.1", |
56 | "karma": "^1.3.0", | 63 | "karma": "^1.3.0", |
57 | - "karma-chrome-launcher": "^2.0.0", | 64 | + "karma-chrome-launcher": "^2.2.0", |
58 | - "karma-coverage": "^1.0.0", | 65 | + "karma-coverage": "^1.1.1", |
59 | - "karma-firefox-launcher": "^1.0.0", | 66 | + "karma-firefox-launcher": "^1.1.0", |
60 | - "karma-jasmine": "^1.0.2", | 67 | + "karma-jasmine": "^1.1.1", |
61 | "karma-jasmine-ajax": "^0.1.13", | 68 | "karma-jasmine-ajax": "^0.1.13", |
62 | "karma-opera-launcher": "^1.0.0", | 69 | "karma-opera-launcher": "^1.0.0", |
63 | - "karma-phantomjs-launcher": "^1.0.0", | ||
64 | "karma-safari-launcher": "^1.0.0", | 70 | "karma-safari-launcher": "^1.0.0", |
65 | - "karma-sauce-launcher": "^1.1.0", | 71 | + "karma-sauce-launcher": "^1.2.0", |
66 | "karma-sinon": "^1.0.5", | 72 | "karma-sinon": "^1.0.5", |
67 | "karma-sourcemap-loader": "^0.3.7", | 73 | "karma-sourcemap-loader": "^0.3.7", |
68 | "karma-webpack": "^1.7.0", | 74 | "karma-webpack": "^1.7.0", |
69 | "load-grunt-tasks": "^3.5.2", | 75 | "load-grunt-tasks": "^3.5.2", |
70 | "minimist": "^1.2.0", | 76 | "minimist": "^1.2.0", |
71 | - "phantomjs-prebuilt": "^2.1.7", | 77 | + "mocha": "^5.2.0", |
72 | - "sinon": "^1.17.4", | 78 | + "sinon": "^4.5.0", |
73 | - "typescript": "^2.0.3", | 79 | + "typescript": "^2.8.1", |
74 | - "url-search-params": "^0.6.1", | 80 | + "url-search-params": "^0.10.0", |
75 | "webpack": "^1.13.1", | 81 | "webpack": "^1.13.1", |
76 | "webpack-dev-server": "^1.14.1" | 82 | "webpack-dev-server": "^1.14.1" |
77 | }, | 83 | }, |
78 | - "homepage": "https://github.com/mzabriskie/axios", | 84 | + "homepage": "https://github.com/axios/axios", |
79 | "keywords": [ | 85 | "keywords": [ |
80 | "xhr", | 86 | "xhr", |
81 | "http", | 87 | "http", |
... | @@ -88,18 +94,19 @@ | ... | @@ -88,18 +94,19 @@ |
88 | "name": "axios", | 94 | "name": "axios", |
89 | "repository": { | 95 | "repository": { |
90 | "type": "git", | 96 | "type": "git", |
91 | - "url": "git+https://github.com/mzabriskie/axios.git" | 97 | + "url": "git+https://github.com/axios/axios.git" |
92 | }, | 98 | }, |
93 | "scripts": { | 99 | "scripts": { |
94 | "build": "NODE_ENV=production grunt build", | 100 | "build": "NODE_ENV=production grunt build", |
95 | "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | 101 | "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", |
96 | "examples": "node ./examples/server.js", | 102 | "examples": "node ./examples/server.js", |
103 | + "fix": "eslint --fix lib/**/*.js", | ||
97 | "postversion": "git push && git push --tags", | 104 | "postversion": "git push && git push --tags", |
98 | "preversion": "npm test", | 105 | "preversion": "npm test", |
99 | "start": "node ./sandbox/server.js", | 106 | "start": "node ./sandbox/server.js", |
100 | - "test": "grunt test", | 107 | + "test": "grunt test && bundlesize", |
101 | "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json" | 108 | "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json" |
102 | }, | 109 | }, |
103 | "typings": "./index.d.ts", | 110 | "typings": "./index.d.ts", |
104 | - "version": "0.16.2" | 111 | + "version": "0.19.0" |
105 | } | 112 | } | ... | ... |
... | @@ -28,12 +28,15 @@ It's future-proof and works in node too! | ... | @@ -28,12 +28,15 @@ It's future-proof and works in node too! |
28 | npm install is-buffer | 28 | npm install is-buffer |
29 | ``` | 29 | ``` |
30 | 30 | ||
31 | +[Get supported is-buffer with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-is-buffer?utm_source=npm-is-buffer&utm_medium=referral&utm_campaign=readme) | ||
32 | + | ||
31 | ## usage | 33 | ## usage |
32 | 34 | ||
33 | ```js | 35 | ```js |
34 | var isBuffer = require('is-buffer') | 36 | var isBuffer = require('is-buffer') |
35 | 37 | ||
36 | isBuffer(new Buffer(4)) // true | 38 | isBuffer(new Buffer(4)) // true |
39 | +isBuffer(Buffer.alloc(4)) //true | ||
37 | 40 | ||
38 | isBuffer(undefined) // false | 41 | isBuffer(undefined) // false |
39 | isBuffer(null) // false | 42 | isBuffer(null) // false | ... | ... |
node_modules/is-buffer/index.d.ts
0 → 100644
... | @@ -5,17 +5,7 @@ | ... | @@ -5,17 +5,7 @@ |
5 | * @license MIT | 5 | * @license MIT |
6 | */ | 6 | */ |
7 | 7 | ||
8 | -// The _isBuffer check is for Safari 5-7 support, because it's missing | 8 | +module.exports = function isBuffer (obj) { |
9 | -// Object.prototype.constructor. Remove this eventually | 9 | + return obj != null && obj.constructor != null && |
10 | -module.exports = function (obj) { | 10 | + typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) |
11 | - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) | ||
12 | -} | ||
13 | - | ||
14 | -function isBuffer (obj) { | ||
15 | - return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) | ||
16 | -} | ||
17 | - | ||
18 | -// For Node v0.10 support. Remove this eventually. | ||
19 | -function isSlowBuffer (obj) { | ||
20 | - return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) | ||
21 | } | 11 | } | ... | ... |
1 | { | 1 | { |
2 | - "_from": "is-buffer@^1.1.5", | 2 | + "_from": "is-buffer@^2.0.2", |
3 | - "_id": "is-buffer@1.1.6", | 3 | + "_id": "is-buffer@2.0.4", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", | 5 | + "_integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", |
6 | "_location": "/is-buffer", | 6 | "_location": "/is-buffer", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
9 | "type": "range", | 9 | "type": "range", |
10 | "registry": true, | 10 | "registry": true, |
11 | - "raw": "is-buffer@^1.1.5", | 11 | + "raw": "is-buffer@^2.0.2", |
12 | "name": "is-buffer", | 12 | "name": "is-buffer", |
13 | "escapedName": "is-buffer", | 13 | "escapedName": "is-buffer", |
14 | - "rawSpec": "^1.1.5", | 14 | + "rawSpec": "^2.0.2", |
15 | "saveSpec": null, | 15 | "saveSpec": null, |
16 | - "fetchSpec": "^1.1.5" | 16 | + "fetchSpec": "^2.0.2" |
17 | }, | 17 | }, |
18 | "_requiredBy": [ | 18 | "_requiredBy": [ |
19 | "/axios" | 19 | "/axios" |
20 | ], | 20 | ], |
21 | - "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", | 21 | + "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", |
22 | - "_shasum": "efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be", | 22 | + "_shasum": "3e572f23c8411a5cfd9557c849e3665e0b290623", |
23 | - "_spec": "is-buffer@^1.1.5", | 23 | + "_spec": "is-buffer@^2.0.2", |
24 | - "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\axios", | 24 | + "_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\axios", |
25 | "author": { | 25 | "author": { |
26 | "name": "Feross Aboukhadijeh", | 26 | "name": "Feross Aboukhadijeh", |
27 | "email": "feross@feross.org", | 27 | "email": "feross@feross.org", |
28 | - "url": "http://feross.org/" | 28 | + "url": "https://feross.org" |
29 | }, | 29 | }, |
30 | "bugs": { | 30 | "bugs": { |
31 | "url": "https://github.com/feross/is-buffer/issues" | 31 | "url": "https://github.com/feross/is-buffer/issues" |
... | @@ -35,27 +35,30 @@ | ... | @@ -35,27 +35,30 @@ |
35 | "deprecated": false, | 35 | "deprecated": false, |
36 | "description": "Determine if an object is a Buffer", | 36 | "description": "Determine if an object is a Buffer", |
37 | "devDependencies": { | 37 | "devDependencies": { |
38 | + "airtap": "^2.0.3", | ||
38 | "standard": "*", | 39 | "standard": "*", |
39 | - "tape": "^4.0.0", | 40 | + "tape": "^4.11.0" |
40 | - "zuul": "^3.0.0" | 41 | + }, |
42 | + "engines": { | ||
43 | + "node": ">=4" | ||
41 | }, | 44 | }, |
42 | "homepage": "https://github.com/feross/is-buffer#readme", | 45 | "homepage": "https://github.com/feross/is-buffer#readme", |
43 | "keywords": [ | 46 | "keywords": [ |
47 | + "arraybuffer", | ||
48 | + "browser", | ||
49 | + "browser buffer", | ||
50 | + "browserify", | ||
44 | "buffer", | 51 | "buffer", |
45 | "buffers", | 52 | "buffers", |
46 | - "type", | ||
47 | "core buffer", | 53 | "core buffer", |
48 | - "browser buffer", | 54 | + "dataview", |
49 | - "browserify", | ||
50 | - "typed array", | ||
51 | - "uint32array", | ||
52 | - "int16array", | ||
53 | - "int32array", | ||
54 | "float32array", | 55 | "float32array", |
55 | "float64array", | 56 | "float64array", |
56 | - "browser", | 57 | + "int16array", |
57 | - "arraybuffer", | 58 | + "int32array", |
58 | - "dataview" | 59 | + "type", |
60 | + "typed array", | ||
61 | + "uint32array" | ||
59 | ], | 62 | ], |
60 | "license": "MIT", | 63 | "license": "MIT", |
61 | "main": "index.js", | 64 | "main": "index.js", |
... | @@ -66,12 +69,9 @@ | ... | @@ -66,12 +69,9 @@ |
66 | }, | 69 | }, |
67 | "scripts": { | 70 | "scripts": { |
68 | "test": "standard && npm run test-node && npm run test-browser", | 71 | "test": "standard && npm run test-node && npm run test-browser", |
69 | - "test-browser": "zuul -- test/*.js", | 72 | + "test-browser": "airtap -- test/*.js", |
70 | - "test-browser-local": "zuul --local -- test/*.js", | 73 | + "test-browser-local": "airtap --local -- test/*.js", |
71 | "test-node": "tape test/*.js" | 74 | "test-node": "tape test/*.js" |
72 | }, | 75 | }, |
73 | - "testling": { | 76 | + "version": "2.0.4" |
74 | - "files": "test/*.js" | ||
75 | - }, | ||
76 | - "version": "1.1.6" | ||
77 | } | 77 | } | ... | ... |
node_modules/is-buffer/test/basic.js
deleted
100644 → 0
1 | -var isBuffer = require('../') | ||
2 | -var test = require('tape') | ||
3 | - | ||
4 | -test('is-buffer', function (t) { | ||
5 | - t.equal(isBuffer(Buffer.alloc(4)), true, 'new Buffer(4)') | ||
6 | - t.equal(isBuffer(Buffer.allocUnsafeSlow(100)), true, 'SlowBuffer(100)') | ||
7 | - | ||
8 | - t.equal(isBuffer(undefined), false, 'undefined') | ||
9 | - t.equal(isBuffer(null), false, 'null') | ||
10 | - t.equal(isBuffer(''), false, 'empty string') | ||
11 | - t.equal(isBuffer(true), false, 'true') | ||
12 | - t.equal(isBuffer(false), false, 'false') | ||
13 | - t.equal(isBuffer(0), false, '0') | ||
14 | - t.equal(isBuffer(1), false, '1') | ||
15 | - t.equal(isBuffer(1.0), false, '1.0') | ||
16 | - t.equal(isBuffer('string'), false, 'string') | ||
17 | - t.equal(isBuffer({}), false, '{}') | ||
18 | - t.equal(isBuffer([]), false, '[]') | ||
19 | - t.equal(isBuffer(function foo () {}), false, 'function foo () {}') | ||
20 | - t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }') | ||
21 | - t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }') | ||
22 | - | ||
23 | - t.end() | ||
24 | -}) |
... | @@ -5,22 +5,22 @@ | ... | @@ -5,22 +5,22 @@ |
5 | "requires": true, | 5 | "requires": true, |
6 | "dependencies": { | 6 | "dependencies": { |
7 | "@line/bot-sdk": { | 7 | "@line/bot-sdk": { |
8 | - "version": "6.4.0", | 8 | + "version": "6.8.3", |
9 | - "resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.4.0.tgz", | 9 | + "resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.8.3.tgz", |
10 | - "integrity": "sha512-N0FkrqFxTTleOpD6y7DTK8qbMYHr9Q8qZfrAmSYEFAGedM1HLJdbNNkStj5GT+svx+w+/ePF/n7nAEts0aJwkA==", | 10 | + "integrity": "sha512-nj2T4CQxw0W/juAlpj0kMTDScOh5QUK6xMCR2dZp+pN8B0vj/c+5uX3TyGB4ijz/NIsehgfKujPgzw7LhtYtJw==", |
11 | "requires": { | 11 | "requires": { |
12 | "@types/body-parser": "^1.16.8", | 12 | "@types/body-parser": "^1.16.8", |
13 | "@types/file-type": "^5.2.1", | 13 | "@types/file-type": "^5.2.1", |
14 | "@types/node": "^7.0.31", | 14 | "@types/node": "^7.0.31", |
15 | - "axios": "^0.16.2", | 15 | + "axios": "^0.19.0", |
16 | "body-parser": "^1.18.2", | 16 | "body-parser": "^1.18.2", |
17 | "file-type": "^7.2.0" | 17 | "file-type": "^7.2.0" |
18 | } | 18 | } |
19 | }, | 19 | }, |
20 | "@types/body-parser": { | 20 | "@types/body-parser": { |
21 | - "version": "1.17.0", | 21 | + "version": "1.17.1", |
22 | - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", | 22 | + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz", |
23 | - "integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==", | 23 | + "integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==", |
24 | "requires": { | 24 | "requires": { |
25 | "@types/connect": "*", | 25 | "@types/connect": "*", |
26 | "@types/node": "*" | 26 | "@types/node": "*" |
... | @@ -43,9 +43,9 @@ | ... | @@ -43,9 +43,9 @@ |
43 | } | 43 | } |
44 | }, | 44 | }, |
45 | "@types/node": { | 45 | "@types/node": { |
46 | - "version": "7.10.2", | 46 | + "version": "7.10.9", |
47 | - "resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.2.tgz", | 47 | + "resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz", |
48 | - "integrity": "sha512-RO4ig5taKmcrU4Rex8ojG1gpwFkjddzug9iPQSDvbewHN9vDpcFewevkaOK+KT+w1LeZnxbgOyfXwV4pxsQ4GQ==" | 48 | + "integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw==" |
49 | }, | 49 | }, |
50 | "accepts": { | 50 | "accepts": { |
51 | "version": "1.3.5", | 51 | "version": "1.3.5", |
... | @@ -62,12 +62,12 @@ | ... | @@ -62,12 +62,12 @@ |
62 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" | 62 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" |
63 | }, | 63 | }, |
64 | "axios": { | 64 | "axios": { |
65 | - "version": "0.16.2", | 65 | + "version": "0.19.0", |
66 | - "resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz", | 66 | + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", |
67 | - "integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=", | 67 | + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", |
68 | "requires": { | 68 | "requires": { |
69 | - "follow-redirects": "^1.2.3", | 69 | + "follow-redirects": "1.5.10", |
70 | - "is-buffer": "^1.1.5" | 70 | + "is-buffer": "^2.0.2" |
71 | } | 71 | } |
72 | }, | 72 | }, |
73 | "body-parser": { | 73 | "body-parser": { |
... | @@ -264,9 +264,9 @@ | ... | @@ -264,9 +264,9 @@ |
264 | "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" | 264 | "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" |
265 | }, | 265 | }, |
266 | "is-buffer": { | 266 | "is-buffer": { |
267 | - "version": "1.1.6", | 267 | + "version": "2.0.4", |
268 | - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", | 268 | + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", |
269 | - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" | 269 | + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" |
270 | }, | 270 | }, |
271 | "media-typer": { | 271 | "media-typer": { |
272 | "version": "0.3.0", | 272 | "version": "0.3.0", | ... | ... |
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | "author": "강수인", | 10 | "author": "강수인", |
11 | "license": "MIT", | 11 | "license": "MIT", |
12 | "dependencies": { | 12 | "dependencies": { |
13 | - "@line/bot-sdk": "^6.4.0", | 13 | + "@line/bot-sdk": "^6.8.3", |
14 | "express": "^4.16.4" | 14 | "express": "^4.16.4" |
15 | } | 15 | } |
16 | } | 16 | } | ... | ... |
-
Please register or login to post a comment