sckim

package.json is updated

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