강수인

node-modules & @line/bot-sdk 설치

Showing 429 changed files with 4913 additions and 0 deletions
1 +#!/usr/bin/env node
2 +
3 +/**
4 + * Module dependencies.
5 + */
6 +
7 +var app = require('../app');
8 +var debug = require('debug')('project:server');
9 +var http = require('http');
10 +
11 +/**
12 + * Get port from environment and store in Express.
13 + */
14 +
15 +var port = normalizePort(process.env.PORT || '3000');
16 +app.set('port', port);
17 +
18 +/**
19 + * Create HTTP server.
20 + */
21 +
22 +var server = http.createServer(app);
23 +
24 +/**
25 + * Listen on provided port, on all network interfaces.
26 + */
27 +
28 +server.listen(port);
29 +server.on('error', onError);
30 +server.on('listening', onListening);
31 +
32 +/**
33 + * Normalize a port into a number, string, or false.
34 + */
35 +
36 +function normalizePort(val) {
37 + var port = parseInt(val, 10);
38 +
39 + if (isNaN(port)) {
40 + // named pipe
41 + return val;
42 + }
43 +
44 + if (port >= 0) {
45 + // port number
46 + return port;
47 + }
48 +
49 + return false;
50 +}
51 +
52 +/**
53 + * Event listener for HTTP server "error" event.
54 + */
55 +
56 +function onError(error) {
57 + if (error.syscall !== 'listen') {
58 + throw error;
59 + }
60 +
61 + var bind = typeof port === 'string'
62 + ? 'Pipe ' + port
63 + : 'Port ' + port;
64 +
65 + // handle specific listen errors with friendly messages
66 + switch (error.code) {
67 + case 'EACCES':
68 + console.error(bind + ' requires elevated privileges');
69 + process.exit(1);
70 + break;
71 + case 'EADDRINUSE':
72 + console.error(bind + ' is already in use');
73 + process.exit(1);
74 + break;
75 + default:
76 + throw error;
77 + }
78 +}
79 +
80 +/**
81 + * Event listener for HTTP server "listening" event.
82 + */
83 +
84 +function onListening() {
85 + var addr = server.address();
86 + var bind = typeof addr === 'string'
87 + ? 'pipe ' + addr
88 + : 'port ' + addr.port;
89 + debug('Listening on ' + bind);
90 +}
1 +[ViewState]
2 +Mode=
3 +Vid=
4 +FolderType=Generic
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../mime/cli.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../mime/cli.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\mime\cli.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\mime\cli.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +## 6.4.0 (19 Nov 2018)
2 +
3 +### Feature
4 +
5 +* Add `getLinkToken` API (#96)
6 +* Handle `req.rawBody` in Google Cloud Functions (#101)
7 +* [Kitchensink] Add ngrok functionality (#99)
8 +
9 +### Type
10 +
11 +* Add types for video in imagemap message (#100)
12 +* Add `contentProvider` fields to content messages (#103)
13 +* Add `destination` field to webhook request body (#102)
14 +* Add `MemberJoinEvent` and `MemberLeaveEvent` types (#107)
15 +
16 +### Misc
17 +
18 +* Don't include doc in released source
19 +* Upgrade TypeScript to 3.1.6 (#94)
20 +* Refactoring (#94, #98, #99)
21 +* Remove webhook-tester tool
22 +
23 +
24 +## 6.3.0 (21 Sep 2018)
25 +
26 +### Feature
27 +
28 +* Add default rich menu APIs (#87)
29 +
30 +### Type
31 +
32 +* Add missing `defaultAction` field to `TemplateColumn`
33 +
34 +### Misc
35 +
36 +* Use VuePress as documentation engine (#85)
37 +* Upgrade minimum supported Node.js version to 6
38 +
39 +
40 +## 6.2.1 (16 Aug 2018)
41 +
42 +### Misc
43 +
44 +* Remove gitbook-cli from dev dependencies
45 +
46 +
47 +## 6.2.0 (15 Aug 2018)
48 +
49 +#### Type
50 +
51 +* Add QuickReply types (#83)
52 +* Format type comments
53 +
54 +#### Misc
55 +
56 +* Upgrade TypeScript to 3
57 +
58 +
59 +## 6.1.1 (14 Aug 2018)
60 +
61 +#### Type
62 +
63 +* Update FlexMessage types (#81)
64 +
65 +#### Misc
66 +
67 +* Add test coverage (#78)
68 +* Add JSDoc comments (#80)
69 +
70 +
71 +## 6.1.0 (19 June 2018)
72 +
73 +#### Type
74 +
75 +* Add types for flex message (#74)
76 +* Simplify type definition for `Action`
77 +
78 +
79 +## 6.0.3 (18 June 2018)
80 +
81 +#### Misc
82 +
83 +* Move get-audio-duration dep to proper package.json (#73)
84 +* Vulnerability fix with `npm audit fix`
85 +
86 +
87 +## 6.0.2 (21 May 2018)
88 +
89 +#### Type
90 +
91 +* Add missing `displayText` field to postback action (#63)
92 +* Add missing `FileEventMessage` to `EventMessage` (#71)
93 +
94 +#### Misc
95 +
96 +* Add audio duration lib to kitchensink example (#68)
97 +
98 +
99 +## 6.0.1 (13 Mar 2018)
100 +
101 +#### Type
102 +
103 +* Fix misimplemented 'AudioMessage' type (#61)
104 +
105 +
106 +## 6.0.0 (27 Feb 2018)
107 +
108 +#### Major
109 +
110 +* Fix misimplemented 'unlinkRichMenuFromUser' API
111 +
112 +#### Type
113 +
114 +* Fix TemplateColumn type definition (#48)
115 +
116 +#### Misc
117 +
118 +* Update GitHub issue template (#43)
119 +* Add Code of Conduct (#50)
120 +* Catch errors properly in examples (#52)
121 +
122 +
123 +## 5.2.0 (11 Dec 2017)
124 +
125 +#### Minor
126 +
127 +* Set Content-Length manually for postBinary (#42)
128 +
129 +
130 +## 5.1.0 (7 Dec 2017)
131 +
132 +#### Minor
133 +
134 +* Add new fields (#39)
135 +
136 +#### Misc
137 +
138 +* Fix Windows build (#38)
139 +* Add start scripts and webhook info to examples
140 +
141 +
142 +## 5.0.1 (14 Nov 2017)
143 +
144 +#### Minor
145 +
146 +* Fix typo in `ImageMapMessage` type
147 +* Add kitchensink example (#36)
148 +
149 +
150 +## 5.0.0 (2 Nov 2017)
151 +
152 +#### Major
153 +
154 +* Implement rich menu API (#34)
155 +
156 +#### Type
157 +
158 +* Rename `ImageMapArea` and `TemplateAction`s into general ones
159 +
160 +#### Misc
161 +
162 +* Do not enforce `checkJSON` for some APIs where it means nothing
163 +* Change how to check request object in test cases
164 +
165 +
166 +## 4.0.0 (25 Oct 2017)
167 +
168 +#### Major
169 +
170 +* Make index script export exceptions and types (#31)
171 +
172 +#### Type
173 +
174 +* Simplify config types for client and middleware (#31)
175 +
176 +#### Misc
177 +
178 +* Fix information and links in doc
179 +* Use Prettier instead of TSLint (#30)
180 +* Install git hooks for precommit and prepush (#30)
181 +
182 +
183 +## 3.1.1 (19 Sep 2017)
184 +
185 +#### Type
186 +
187 +* Fix type of postback.params
188 +
189 +
190 +## 3.1.0 (19 Sep 2017)
191 +
192 +#### Major
193 +
194 +* Make middleware return `SignatureValidationFailed` for no signature (#26)
195 +
196 +#### Type
197 +
198 +* Add `FileEventMessage` type
199 +
200 +
201 +## 3.0.0 (8 Sep 2017)
202 +
203 +#### Major
204 +
205 +* Implement "Get group/room member profile" API (#15)
206 +* Implement "Get group/room member IDs" API (#23)
207 +* `getMessageContent` now returns `Promise<ReadableStream>` (#20)
208 +
209 +#### Type
210 +
211 +* Add "datetimepicker" support (#21)
212 +* Fix typo in `TemplateURIAction` type (#21)
213 +
214 +#### Misc
215 +
216 +* Package updates and corresponding fixes
217 +* Use npm 5 instead of Yarn in dev
218 +* Fix `clean` script to work in Windows
219 +* Use "axios" for internal HTTP client instead of "got" (#20)
220 +
221 +
222 +## 2.0.0 (12 June 2017)
223 +
224 +#### Type
225 +
226 +* Use literal types for 'type' fields
227 +
228 +#### Misc
229 +
230 +* Update yarn.lock with the latest Yarn
231 +
232 +
233 +## 1.1.0 (31 May 2017)
234 +
235 +* Handle pre-parsed body (string and buffer only)
236 +
237 +#### Type
238 +
239 +* Separate config type into client and middleware types
240 +* Add `userId` to group and room event sources
241 +
242 +#### Misc
243 +
244 +* Create issue template (#4)
245 +
246 +
247 +## 1.0.0 (11 May 2017)
248 +
249 +* Initial release
This diff is collapsed. Click to expand it.
1 +# line-bot-sdk-nodejs
2 +
3 +[![Travis CI](https://travis-ci.org/line/line-bot-sdk-nodejs.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-nodejs)
4 +[![npmjs](https://badge.fury.io/js/%40line%2Fbot-sdk.svg)](https://www.npmjs.com/package/@line/bot-sdk)
5 +
6 +Node.js SDK for LINE Messaging API
7 +
8 +## Getting Started
9 +
10 +### Install
11 +
12 +Using [npm](https://www.npmjs.com/):
13 +
14 +``` bash
15 +$ npm install @line/bot-sdk --save
16 +```
17 +
18 +### Documentation
19 +
20 +For guide, API reference, and other information, please refer to
21 +the [documentation](https://line.github.io/line-bot-sdk-nodejs/).
22 +
23 +### LINE Messaging API References
24 +
25 +Here are links to official references for LINE Messaging API. It is recommended
26 +reading them beforehand.
27 +
28 +* LINE API Reference [EN](https://developers.line.me/en/docs/messaging-api/reference/) [JA](https://developers.line.me/ja/docs/messaging-api/reference/)
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 +
34 +## Requirements
35 +
36 +* **Node.js** 6 or higher
37 +
38 +## Contributing
39 +
40 +Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.
41 +
42 +## License
43 +
44 +[Apache License Version 2.0](LICENSE)
1 +/// <reference types="node" />
2 +import { Readable } from "stream";
3 +import * as Types from "./types";
4 +export default class Client {
5 + config: Types.ClientConfig;
6 + private http;
7 + constructor(config: Types.ClientConfig);
8 + pushMessage(to: string, messages: Types.Message | Types.Message[]): Promise<any>;
9 + replyMessage(replyToken: string, messages: Types.Message | Types.Message[]): Promise<any>;
10 + multicast(to: string[], messages: Types.Message | Types.Message[]): Promise<any>;
11 + getProfile(userId: string): Promise<Types.Profile>;
12 + private getChatMemberProfile;
13 + getGroupMemberProfile(groupId: string, userId: string): Promise<Types.Profile>;
14 + getRoomMemberProfile(roomId: string, userId: string): Promise<Types.Profile>;
15 + private getChatMemberIds;
16 + getGroupMemberIds(groupId: string): Promise<string[]>;
17 + getRoomMemberIds(roomId: string): Promise<string[]>;
18 + getMessageContent(messageId: string): Promise<Readable>;
19 + private leaveChat;
20 + leaveGroup(groupId: string): Promise<any>;
21 + leaveRoom(roomId: string): Promise<any>;
22 + getRichMenu(richMenuId: string): Promise<Types.RichMenuResponse>;
23 + createRichMenu(richMenu: Types.RichMenu): Promise<string>;
24 + deleteRichMenu(richMenuId: string): Promise<any>;
25 + getRichMenuIdOfUser(userId: string): Promise<string>;
26 + linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>;
27 + unlinkRichMenuFromUser(userId: string): Promise<any>;
28 + getRichMenuImage(richMenuId: string): Promise<Readable>;
29 + setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>;
30 + getRichMenuList(): Promise<Array<Types.RichMenuResponse>>;
31 + setDefaultRichMenu(richMenuId: string): Promise<{}>;
32 + getDefaultRichMenuId(): Promise<string>;
33 + deleteDefaultRichMenu(): Promise<{}>;
34 + getLinkToken(userId: string): Promise<string>;
35 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +const http_1 = require("./http");
4 +const exceptions_1 = require("./exceptions");
5 +function toArray(maybeArr) {
6 + return Array.isArray(maybeArr) ? maybeArr : [maybeArr];
7 +}
8 +function checkJSON(raw) {
9 + if (typeof raw === "object") {
10 + return raw;
11 + }
12 + else {
13 + throw new exceptions_1.JSONParseError("Failed to parse response body as JSON", raw);
14 + }
15 +}
16 +class Client {
17 + constructor(config) {
18 + if (!config.channelAccessToken) {
19 + throw new Error("no channel access token");
20 + }
21 + this.config = config;
22 + this.http = new http_1.default(process.env.API_BASE_URL || "https://api.line.me/v2/bot/", {
23 + Authorization: "Bearer " + this.config.channelAccessToken,
24 + });
25 + }
26 + pushMessage(to, messages) {
27 + return this.http.post("/message/push", {
28 + messages: toArray(messages),
29 + to,
30 + });
31 + }
32 + replyMessage(replyToken, messages) {
33 + return this.http.post("/message/reply", {
34 + messages: toArray(messages),
35 + replyToken,
36 + });
37 + }
38 + multicast(to, messages) {
39 + return this.http.post("/message/multicast", {
40 + messages: toArray(messages),
41 + to,
42 + });
43 + }
44 + getProfile(userId) {
45 + return this.http.get(`/profile/${userId}`).then(checkJSON);
46 + }
47 + getChatMemberProfile(chatType, chatId, userId) {
48 + return this.http
49 + .get(`/${chatType}/${chatId}/member/${userId}`)
50 + .then(checkJSON);
51 + }
52 + getGroupMemberProfile(groupId, userId) {
53 + return this.getChatMemberProfile("group", groupId, userId);
54 + }
55 + getRoomMemberProfile(roomId, userId) {
56 + return this.getChatMemberProfile("room", roomId, userId);
57 + }
58 + getChatMemberIds(chatType, chatId) {
59 + const load = (start) => this.http
60 + .get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null)
61 + .then(checkJSON)
62 + .then((res) => {
63 + if (!res.next) {
64 + return res.memberIds;
65 + }
66 + return load(res.next).then(extraIds => res.memberIds.concat(extraIds));
67 + });
68 + return load();
69 + }
70 + getGroupMemberIds(groupId) {
71 + return this.getChatMemberIds("group", groupId);
72 + }
73 + getRoomMemberIds(roomId) {
74 + return this.getChatMemberIds("room", roomId);
75 + }
76 + getMessageContent(messageId) {
77 + return this.http.getStream(`/message/${messageId}/content`);
78 + }
79 + leaveChat(chatType, chatId) {
80 + return this.http.post(`/${chatType}/${chatId}/leave`);
81 + }
82 + leaveGroup(groupId) {
83 + return this.leaveChat("group", groupId);
84 + }
85 + leaveRoom(roomId) {
86 + return this.leaveChat("room", roomId);
87 + }
88 + getRichMenu(richMenuId) {
89 + return this.http
90 + .get(`/richmenu/${richMenuId}`)
91 + .then(checkJSON);
92 + }
93 + createRichMenu(richMenu) {
94 + return this.http
95 + .post("/richmenu", richMenu)
96 + .then(checkJSON)
97 + .then(res => res.richMenuId);
98 + }
99 + deleteRichMenu(richMenuId) {
100 + return this.http.delete(`/richmenu/${richMenuId}`);
101 + }
102 + getRichMenuIdOfUser(userId) {
103 + return this.http
104 + .get(`/user/${userId}/richmenu`)
105 + .then(checkJSON)
106 + .then(res => res.richMenuId);
107 + }
108 + linkRichMenuToUser(userId, richMenuId) {
109 + return this.http.post(`/user/${userId}/richmenu/${richMenuId}`);
110 + }
111 + unlinkRichMenuFromUser(userId) {
112 + return this.http.delete(`/user/${userId}/richmenu`);
113 + }
114 + getRichMenuImage(richMenuId) {
115 + return this.http.getStream(`/richmenu/${richMenuId}/content`);
116 + }
117 + setRichMenuImage(richMenuId, data, contentType) {
118 + return this.http.postBinary(`/richmenu/${richMenuId}/content`, data, contentType);
119 + }
120 + getRichMenuList() {
121 + return this.http
122 + .get(`/richmenu/list`)
123 + .then(checkJSON)
124 + .then(res => res.richmenus);
125 + }
126 + setDefaultRichMenu(richMenuId) {
127 + return this.http.post(`/user/all/richmenu/${richMenuId}`);
128 + }
129 + getDefaultRichMenuId() {
130 + return this.http
131 + .get("/user/all/richmenu")
132 + .then(checkJSON)
133 + .then(res => res.richMenuId);
134 + }
135 + deleteDefaultRichMenu() {
136 + return this.http.delete("/user/all/richmenu");
137 + }
138 + getLinkToken(userId) {
139 + return this.http
140 + .post(`/user/${userId}/linkToken`)
141 + .then(checkJSON)
142 + .then(res => res.linkToken);
143 + }
144 +}
145 +exports.default = Client;
1 +export declare class SignatureValidationFailed extends Error {
2 + signature?: string;
3 + constructor(message: string, signature?: string);
4 +}
5 +export declare class JSONParseError extends Error {
6 + raw: any;
7 + constructor(message: string, raw: any);
8 +}
9 +export declare class RequestError extends Error {
10 + code: string;
11 + private originalError;
12 + constructor(message: string, code: string, originalError: Error);
13 +}
14 +export declare class ReadError extends Error {
15 + private originalError;
16 + constructor(originalError: Error);
17 +}
18 +export declare class HTTPError extends Error {
19 + statusCode: number;
20 + statusMessage: string;
21 + originalError: any;
22 + constructor(message: string, statusCode: number, statusMessage: string, originalError: any);
23 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +class SignatureValidationFailed extends Error {
4 + constructor(message, signature) {
5 + super(message);
6 + this.signature = signature;
7 + }
8 +}
9 +exports.SignatureValidationFailed = SignatureValidationFailed;
10 +class JSONParseError extends Error {
11 + constructor(message, raw) {
12 + super(message);
13 + this.raw = raw;
14 + }
15 +}
16 +exports.JSONParseError = JSONParseError;
17 +class RequestError extends Error {
18 + constructor(message, code, originalError) {
19 + super(message);
20 + this.code = code;
21 + this.originalError = originalError;
22 + }
23 +}
24 +exports.RequestError = RequestError;
25 +class ReadError extends Error {
26 + constructor(originalError) {
27 + super(originalError.message);
28 + this.originalError = originalError;
29 + }
30 +}
31 +exports.ReadError = ReadError;
32 +class HTTPError extends Error {
33 + constructor(message, statusCode, statusMessage, originalError) {
34 + super(message);
35 + this.statusCode = statusCode;
36 + this.statusMessage = statusMessage;
37 + this.originalError = originalError;
38 + }
39 +}
40 +exports.HTTPError = HTTPError;
1 +/// <reference types="node" />
2 +import { Readable } from "stream";
3 +export default class HTTPClient {
4 + private instance;
5 + constructor(baseURL?: string, defaultHeaders?: any);
6 + get<T>(url: string, params?: any): Promise<T>;
7 + getStream(url: string, params?: any): Promise<Readable>;
8 + post<T>(url: string, data?: any): Promise<T>;
9 + postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>;
10 + delete<T>(url: string, params?: any): Promise<T>;
11 + private wrapError;
12 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +const axios_1 = require("axios");
4 +const stream_1 = require("stream");
5 +const exceptions_1 = require("./exceptions");
6 +const fileType = require("file-type");
7 +const pkg = require("../package.json");
8 +class HTTPClient {
9 + constructor(baseURL, defaultHeaders) {
10 + this.instance = axios_1.default.create({
11 + baseURL,
12 + headers: Object.assign({}, defaultHeaders, {
13 + "User-Agent": `${pkg.name}/${pkg.version}`,
14 + }),
15 + });
16 + this.instance.interceptors.response.use(res => res, err => Promise.reject(this.wrapError(err)));
17 + }
18 + get(url, params) {
19 + return this.instance.get(url, { params }).then(res => res.data);
20 + }
21 + getStream(url, params) {
22 + return this.instance
23 + .get(url, { params, responseType: "stream" })
24 + .then(res => res.data);
25 + }
26 + post(url, data) {
27 + return this.instance
28 + .post(url, data, { headers: { "Content-Type": "application/json" } })
29 + .then(res => res.data);
30 + }
31 + postBinary(url, data, contentType) {
32 + let getBuffer;
33 + if (Buffer.isBuffer(data)) {
34 + getBuffer = Promise.resolve(data);
35 + }
36 + else {
37 + getBuffer = new Promise((resolve, reject) => {
38 + if (data instanceof stream_1.Readable) {
39 + const buffers = [];
40 + let size = 0;
41 + data.on("data", (chunk) => {
42 + buffers.push(chunk);
43 + size += chunk.length;
44 + });
45 + data.on("end", () => resolve(Buffer.concat(buffers, size)));
46 + data.on("error", reject);
47 + }
48 + else {
49 + reject(new Error("invalid data type for postBinary"));
50 + }
51 + });
52 + }
53 + return getBuffer.then(data => {
54 + return this.instance
55 + .post(url, data, {
56 + headers: {
57 + "Content-Type": contentType || fileType(data).mime,
58 + "Content-Length": data.length,
59 + },
60 + })
61 + .then(res => res.data);
62 + });
63 + }
64 + delete(url, params) {
65 + return this.instance.delete(url, { params }).then(res => res.data);
66 + }
67 + wrapError(err) {
68 + if (err.response) {
69 + return new exceptions_1.HTTPError(err.message, err.response.status, err.response.statusText, err);
70 + }
71 + else if (err.code) {
72 + return new exceptions_1.RequestError(err.message, err.code, err);
73 + }
74 + else if (err.config) {
75 + // unknown, but from axios
76 + return new exceptions_1.ReadError(err);
77 + }
78 + // otherwise, just rethrow
79 + return err;
80 + }
81 +}
82 +exports.default = HTTPClient;
1 +import Client from "./client";
2 +import middleware from "./middleware";
3 +import validateSignature from "./validate-signature";
4 +export { Client, middleware, validateSignature };
5 +export * from "./exceptions";
6 +export * from "./types";
1 +"use strict";
2 +function __export(m) {
3 + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4 +}
5 +Object.defineProperty(exports, "__esModule", { value: true });
6 +const client_1 = require("./client");
7 +exports.Client = client_1.default;
8 +const middleware_1 = require("./middleware");
9 +exports.middleware = middleware_1.default;
10 +const validate_signature_1 = require("./validate-signature");
11 +exports.validateSignature = validate_signature_1.default;
12 +// re-export exceptions and types
13 +__export(require("./exceptions"));
1 +/// <reference types="node" />
2 +import * as http from "http";
3 +import * as Types from "./types";
4 +export declare type Request = http.IncomingMessage & {
5 + body: any;
6 +};
7 +export declare type Response = http.ServerResponse;
8 +export declare type NextCallback = (err?: Error) => void;
9 +export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void;
10 +export default function middleware(config: Types.MiddlewareConfig): Middleware;
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +const body_parser_1 = require("body-parser");
4 +const exceptions_1 = require("./exceptions");
5 +const validate_signature_1 = require("./validate-signature");
6 +function isValidBody(body) {
7 + return (body && typeof body === "string") || Buffer.isBuffer(body);
8 +}
9 +function middleware(config) {
10 + if (!config.channelSecret) {
11 + throw new Error("no channel secret");
12 + }
13 + const secret = config.channelSecret;
14 + return (req, res, next) => {
15 + // header names are lower-cased
16 + // https://nodejs.org/api/http.html#http_message_headers
17 + const signature = req.headers["x-line-signature"];
18 + if (!signature) {
19 + next(new exceptions_1.SignatureValidationFailed("no signature"));
20 + return;
21 + }
22 + let getBody;
23 + if (isValidBody(req.rawBody)) {
24 + // rawBody is provided in Google Cloud Functions and others
25 + getBody = Promise.resolve(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 + }
41 + const strBody = Buffer.isBuffer(body) ? body.toString() : body;
42 + try {
43 + req.body = JSON.parse(strBody);
44 + next();
45 + }
46 + catch (err) {
47 + next(new exceptions_1.JSONParseError(err.message, strBody));
48 + }
49 + });
50 + };
51 +}
52 +exports.default = middleware;
This diff is collapsed. Click to expand it.
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
1 +/// <reference types="node" />
2 +export default function validateSignature(body: string | Buffer, channelSecret: string, signature: string): boolean;
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +const crypto_1 = require("crypto");
4 +function s2b(str, encoding) {
5 + if (Buffer.from) {
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 +}
20 +function safeCompare(a, b) {
21 + if (a.length !== b.length) {
22 + return false;
23 + }
24 + if (crypto_1.timingSafeEqual) {
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 +}
35 +function validateSignature(body, channelSecret, signature) {
36 + return safeCompare(crypto_1.createHmac("SHA256", channelSecret)
37 + .update(body)
38 + .digest(), s2b(signature, "base64"));
39 +}
40 +exports.default = validateSignature;
1 +import { Readable } from "stream";
2 +import HTTPClient from "./http";
3 +import * as Types from "./types";
4 +import { JSONParseError } from "./exceptions";
5 +
6 +function toArray<T>(maybeArr: T | T[]): T[] {
7 + return Array.isArray(maybeArr) ? maybeArr : [maybeArr];
8 +}
9 +
10 +function checkJSON<T>(raw: T): T {
11 + if (typeof raw === "object") {
12 + return raw;
13 + } else {
14 + throw new JSONParseError("Failed to parse response body as JSON", raw);
15 + }
16 +}
17 +
18 +type ChatType = "group" | "room";
19 +
20 +export default class Client {
21 + public config: Types.ClientConfig;
22 + private http: HTTPClient;
23 +
24 + constructor(config: Types.ClientConfig) {
25 + if (!config.channelAccessToken) {
26 + throw new Error("no channel access token");
27 + }
28 +
29 + this.config = config;
30 + this.http = new HTTPClient(
31 + process.env.API_BASE_URL || "https://api.line.me/v2/bot/",
32 + {
33 + Authorization: "Bearer " + this.config.channelAccessToken,
34 + },
35 + );
36 + }
37 +
38 + public pushMessage(
39 + to: string,
40 + messages: Types.Message | Types.Message[],
41 + ): Promise<any> {
42 + return this.http.post("/message/push", {
43 + messages: toArray(messages),
44 + to,
45 + });
46 + }
47 +
48 + public replyMessage(
49 + replyToken: string,
50 + messages: Types.Message | Types.Message[],
51 + ): Promise<any> {
52 + return this.http.post("/message/reply", {
53 + messages: toArray(messages),
54 + replyToken,
55 + });
56 + }
57 +
58 + public multicast(
59 + to: string[],
60 + messages: Types.Message | Types.Message[],
61 + ): Promise<any> {
62 + return this.http.post("/message/multicast", {
63 + messages: toArray(messages),
64 + to,
65 + });
66 + }
67 +
68 + public getProfile(userId: string): Promise<Types.Profile> {
69 + return this.http.get<Types.Profile>(`/profile/${userId}`).then(checkJSON);
70 + }
71 +
72 + private getChatMemberProfile(
73 + chatType: ChatType,
74 + chatId: string,
75 + userId: string,
76 + ): Promise<Types.Profile> {
77 + return this.http
78 + .get<Types.Profile>(`/${chatType}/${chatId}/member/${userId}`)
79 + .then(checkJSON);
80 + }
81 +
82 + public getGroupMemberProfile(
83 + groupId: string,
84 + userId: string,
85 + ): Promise<Types.Profile> {
86 + return this.getChatMemberProfile("group", groupId, userId);
87 + }
88 +
89 + public getRoomMemberProfile(
90 + roomId: string,
91 + userId: string,
92 + ): Promise<Types.Profile> {
93 + return this.getChatMemberProfile("room", roomId, userId);
94 + }
95 +
96 + private getChatMemberIds(
97 + chatType: ChatType,
98 + chatId: string,
99 + ): Promise<string[]> {
100 + const load = (start?: string): Promise<string[]> =>
101 + this.http
102 + .get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null)
103 + .then(checkJSON)
104 + .then((res: { memberIds: string[]; next?: string }) => {
105 + if (!res.next) {
106 + return res.memberIds;
107 + }
108 +
109 + return load(res.next).then(extraIds =>
110 + res.memberIds.concat(extraIds),
111 + );
112 + });
113 + return load();
114 + }
115 +
116 + public getGroupMemberIds(groupId: string): Promise<string[]> {
117 + return this.getChatMemberIds("group", groupId);
118 + }
119 +
120 + public getRoomMemberIds(roomId: string): Promise<string[]> {
121 + return this.getChatMemberIds("room", roomId);
122 + }
123 +
124 + public getMessageContent(messageId: string): Promise<Readable> {
125 + return this.http.getStream(`/message/${messageId}/content`);
126 + }
127 +
128 + private leaveChat(chatType: ChatType, chatId: string): Promise<any> {
129 + return this.http.post(`/${chatType}/${chatId}/leave`);
130 + }
131 +
132 + public leaveGroup(groupId: string): Promise<any> {
133 + return this.leaveChat("group", groupId);
134 + }
135 +
136 + public leaveRoom(roomId: string): Promise<any> {
137 + return this.leaveChat("room", roomId);
138 + }
139 +
140 + public getRichMenu(richMenuId: string): Promise<Types.RichMenuResponse> {
141 + return this.http
142 + .get<Types.RichMenuResponse>(`/richmenu/${richMenuId}`)
143 + .then(checkJSON);
144 + }
145 +
146 + public createRichMenu(richMenu: Types.RichMenu): Promise<string> {
147 + return this.http
148 + .post<any>("/richmenu", richMenu)
149 + .then(checkJSON)
150 + .then(res => res.richMenuId);
151 + }
152 +
153 + public deleteRichMenu(richMenuId: string): Promise<any> {
154 + return this.http.delete(`/richmenu/${richMenuId}`);
155 + }
156 +
157 + public getRichMenuIdOfUser(userId: string): Promise<string> {
158 + return this.http
159 + .get<any>(`/user/${userId}/richmenu`)
160 + .then(checkJSON)
161 + .then(res => res.richMenuId);
162 + }
163 +
164 + public linkRichMenuToUser(userId: string, richMenuId: string): Promise<any> {
165 + return this.http.post(`/user/${userId}/richmenu/${richMenuId}`);
166 + }
167 +
168 + public unlinkRichMenuFromUser(userId: string): Promise<any> {
169 + return this.http.delete(`/user/${userId}/richmenu`);
170 + }
171 +
172 + public getRichMenuImage(richMenuId: string): Promise<Readable> {
173 + return this.http.getStream(`/richmenu/${richMenuId}/content`);
174 + }
175 +
176 + public setRichMenuImage(
177 + richMenuId: string,
178 + data: Buffer | Readable,
179 + contentType?: string,
180 + ): Promise<any> {
181 + return this.http.postBinary(
182 + `/richmenu/${richMenuId}/content`,
183 + data,
184 + contentType,
185 + );
186 + }
187 +
188 + public getRichMenuList(): Promise<Array<Types.RichMenuResponse>> {
189 + return this.http
190 + .get<any>(`/richmenu/list`)
191 + .then(checkJSON)
192 + .then(res => res.richmenus);
193 + }
194 +
195 + public setDefaultRichMenu(richMenuId: string): Promise<{}> {
196 + return this.http.post(`/user/all/richmenu/${richMenuId}`);
197 + }
198 +
199 + public getDefaultRichMenuId(): Promise<string> {
200 + return this.http
201 + .get<any>("/user/all/richmenu")
202 + .then(checkJSON)
203 + .then(res => res.richMenuId);
204 + }
205 +
206 + public deleteDefaultRichMenu(): Promise<{}> {
207 + return this.http.delete("/user/all/richmenu");
208 + }
209 +
210 + public getLinkToken(userId: string): Promise<string> {
211 + return this.http
212 + .post<any>(`/user/${userId}/linkToken`)
213 + .then(checkJSON)
214 + .then(res => res.linkToken);
215 + }
216 +}
1 +export class SignatureValidationFailed extends Error {
2 + constructor(message: string, public signature?: string) {
3 + super(message);
4 + }
5 +}
6 +
7 +export class JSONParseError extends Error {
8 + constructor(message: string, public raw: any) {
9 + super(message);
10 + }
11 +}
12 +
13 +export class RequestError extends Error {
14 + constructor(
15 + message: string,
16 + public code: string,
17 + private originalError: Error,
18 + ) {
19 + super(message);
20 + }
21 +}
22 +
23 +export class ReadError extends Error {
24 + constructor(private originalError: Error) {
25 + super(originalError.message);
26 + }
27 +}
28 +
29 +export class HTTPError extends Error {
30 + constructor(
31 + message: string,
32 + public statusCode: number,
33 + public statusMessage: string,
34 + public originalError: any,
35 + ) {
36 + super(message);
37 + }
38 +}
1 +import axios, { AxiosInstance, AxiosError } from "axios";
2 +import { Readable } from "stream";
3 +import { HTTPError, ReadError, RequestError } from "./exceptions";
4 +import * as fileType from "file-type";
5 +
6 +const pkg = require("../package.json");
7 +
8 +export default class HTTPClient {
9 + private instance: AxiosInstance;
10 +
11 + constructor(baseURL?: string, defaultHeaders?: any) {
12 + this.instance = axios.create({
13 + baseURL,
14 + headers: Object.assign({}, defaultHeaders, {
15 + "User-Agent": `${pkg.name}/${pkg.version}`,
16 + }),
17 + });
18 +
19 + this.instance.interceptors.response.use(
20 + res => res,
21 + err => Promise.reject(this.wrapError(err)),
22 + );
23 + }
24 +
25 + public get<T>(url: string, params?: any): Promise<T> {
26 + return this.instance.get(url, { params }).then(res => res.data);
27 + }
28 +
29 + public getStream(url: string, params?: any): Promise<Readable> {
30 + return this.instance
31 + .get(url, { params, responseType: "stream" })
32 + .then(res => res.data as Readable);
33 + }
34 +
35 + public post<T>(url: string, data?: any): Promise<T> {
36 + return this.instance
37 + .post(url, data, { headers: { "Content-Type": "application/json" } })
38 + .then(res => res.data);
39 + }
40 +
41 + public postBinary<T>(
42 + url: string,
43 + data: Buffer | Readable,
44 + contentType?: string,
45 + ): Promise<T> {
46 + let getBuffer: Promise<Buffer>;
47 +
48 + if (Buffer.isBuffer(data)) {
49 + getBuffer = Promise.resolve(data);
50 + } else {
51 + getBuffer = new Promise((resolve, reject) => {
52 + if (data instanceof Readable) {
53 + const buffers: Buffer[] = [];
54 + let size = 0;
55 + data.on("data", (chunk: Buffer) => {
56 + buffers.push(chunk);
57 + size += chunk.length;
58 + });
59 + data.on("end", () => resolve(Buffer.concat(buffers, size)));
60 + data.on("error", reject);
61 + } else {
62 + reject(new Error("invalid data type for postBinary"));
63 + }
64 + });
65 + }
66 +
67 + return getBuffer.then(data => {
68 + return this.instance
69 + .post(url, data, {
70 + headers: {
71 + "Content-Type": contentType || fileType(data).mime,
72 + "Content-Length": data.length,
73 + },
74 + })
75 + .then(res => res.data);
76 + });
77 + }
78 +
79 + public delete<T>(url: string, params?: any): Promise<T> {
80 + return this.instance.delete(url, { params }).then(res => res.data);
81 + }
82 +
83 + private wrapError(err: AxiosError): Error {
84 + if (err.response) {
85 + return new HTTPError(
86 + err.message,
87 + err.response.status,
88 + err.response.statusText,
89 + err,
90 + );
91 + } else if (err.code) {
92 + return new RequestError(err.message, err.code, err);
93 + } else if (err.config) {
94 + // unknown, but from axios
95 + return new ReadError(err);
96 + }
97 +
98 + // otherwise, just rethrow
99 + return err;
100 + }
101 +}
1 +import Client from "./client";
2 +import middleware from "./middleware";
3 +import validateSignature from "./validate-signature";
4 +
5 +export { Client, middleware, validateSignature };
6 +
7 +// re-export exceptions and types
8 +export * from "./exceptions";
9 +export * from "./types";
1 +import { raw } from "body-parser";
2 +import * as http from "http";
3 +import { JSONParseError, SignatureValidationFailed } from "./exceptions";
4 +import * as Types from "./types";
5 +import validateSignature from "./validate-signature";
6 +
7 +export type Request = http.IncomingMessage & { body: any };
8 +export type Response = http.ServerResponse;
9 +export type NextCallback = (err?: Error) => void;
10 +
11 +export type Middleware = (
12 + req: Request,
13 + res: Response,
14 + next: NextCallback,
15 +) => void;
16 +
17 +function isValidBody(body?: any): body is string | Buffer {
18 + return (body && typeof body === "string") || Buffer.isBuffer(body);
19 +}
20 +
21 +export default function middleware(config: Types.MiddlewareConfig): Middleware {
22 + if (!config.channelSecret) {
23 + throw new Error("no channel secret");
24 + }
25 +
26 + const secret = config.channelSecret;
27 +
28 + return (req, res, next) => {
29 + // header names are lower-cased
30 + // https://nodejs.org/api/http.html#http_message_headers
31 + const signature = req.headers["x-line-signature"] as string;
32 +
33 + if (!signature) {
34 + next(new SignatureValidationFailed("no signature"));
35 + return;
36 + }
37 +
38 + let getBody: Promise<string | Buffer>;
39 + if (isValidBody((req as any).rawBody)) {
40 + // rawBody is provided in Google Cloud Functions and others
41 + getBody = Promise.resolve((req as any).rawBody);
42 + } else if (isValidBody(req.body)) {
43 + getBody = Promise.resolve(req.body);
44 + } else {
45 + // body may not be parsed yet, parse it to a buffer
46 + getBody = new Promise(resolve => {
47 + raw({ type: "*/*" })(req as any, res as any, () => resolve(req.body));
48 + });
49 + }
50 +
51 + getBody.then(body => {
52 + if (!validateSignature(body, secret, signature)) {
53 + next(
54 + new SignatureValidationFailed(
55 + "signature validation failed",
56 + signature,
57 + ),
58 + );
59 + return;
60 + }
61 +
62 + const strBody = Buffer.isBuffer(body) ? body.toString() : body;
63 +
64 + try {
65 + req.body = JSON.parse(strBody);
66 + next();
67 + } catch (err) {
68 + next(new JSONParseError(err.message, strBody));
69 + }
70 + });
71 + };
72 +}
This diff is collapsed. Click to expand it.
1 +import { createHmac, timingSafeEqual } from "crypto";
2 +
3 +function s2b(str: string, encoding: string): Buffer {
4 + if (Buffer.from) {
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 +}
17 +
18 +function safeCompare(a: Buffer, b: Buffer): boolean {
19 + if (a.length !== b.length) {
20 + return false;
21 + }
22 +
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 +}
33 +
34 +export default function validateSignature(
35 + body: string | Buffer,
36 + channelSecret: string,
37 + signature: string,
38 +): boolean {
39 + return safeCompare(
40 + createHmac("SHA256", channelSecret)
41 + .update(body)
42 + .digest(),
43 + s2b(signature, "base64"),
44 + );
45 +}
1 +{
2 + "_from": "@line/bot-sdk",
3 + "_id": "@line/bot-sdk@6.4.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-N0FkrqFxTTleOpD6y7DTK8qbMYHr9Q8qZfrAmSYEFAGedM1HLJdbNNkStj5GT+svx+w+/ePF/n7nAEts0aJwkA==",
6 + "_location": "/@line/bot-sdk",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "tag",
10 + "registry": true,
11 + "raw": "@line/bot-sdk",
12 + "name": "@line/bot-sdk",
13 + "escapedName": "@line%2fbot-sdk",
14 + "scope": "@line",
15 + "rawSpec": "",
16 + "saveSpec": null,
17 + "fetchSpec": "latest"
18 + },
19 + "_requiredBy": [
20 + "#USER",
21 + "/"
22 + ],
23 + "_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.4.0.tgz",
24 + "_shasum": "18aa7659da26d3a8487614c74ad9ccb80ec4ca59",
25 + "_spec": "@line/bot-sdk",
26 + "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot",
27 + "bugs": {
28 + "url": "https://github.com/line/line-bot-sdk-nodejs/issues"
29 + },
30 + "bundleDependencies": false,
31 + "dependencies": {
32 + "@types/body-parser": "^1.16.8",
33 + "@types/file-type": "^5.2.1",
34 + "@types/node": "^7.0.31",
35 + "axios": "^0.16.2",
36 + "body-parser": "^1.18.2",
37 + "file-type": "^7.2.0"
38 + },
39 + "deprecated": false,
40 + "description": "Node.js SDK for LINE Messaging API",
41 + "devDependencies": {
42 + "@types/express": "^4.0.35",
43 + "@types/mocha": "^2.2.41",
44 + "del-cli": "^1.1.0",
45 + "express": "^4.16.3",
46 + "husky": "^0.14.3",
47 + "mocha": "^5.2.0",
48 + "nyc": "^12.0.2",
49 + "prettier": "^1.15.2",
50 + "ts-node": "^3.3.0",
51 + "typescript": "^3.1.6",
52 + "vuepress": "^0.14.2"
53 + },
54 + "engines": {
55 + "node": ">=6"
56 + },
57 + "files": [
58 + "dist",
59 + "lib"
60 + ],
61 + "homepage": "https://github.com/line/line-bot-sdk-nodejs#readme",
62 + "keywords": [
63 + "node",
64 + "line",
65 + "sdk"
66 + ],
67 + "license": "Apache-2.0",
68 + "main": "dist/index.js",
69 + "name": "@line/bot-sdk",
70 + "nyc": {
71 + "require": [
72 + "ts-node/register"
73 + ],
74 + "extension": [
75 + ".ts"
76 + ],
77 + "reporter": [
78 + "lcov",
79 + "text-summary"
80 + ],
81 + "sourceMap": true,
82 + "instrument": true
83 + },
84 + "repository": {
85 + "type": "git",
86 + "url": "git+ssh://git@github.com/line/line-bot-sdk-nodejs.git"
87 + },
88 + "scripts": {
89 + "build": "tsc",
90 + "clean": "del-cli dist",
91 + "docs": "vuepress dev docs",
92 + "docs:build": "vuepress build docs",
93 + "docs:deploy": "./deploy-docs.sh",
94 + "format": "npm run prettier -- --write",
95 + "format:check": "npm run prettier -- -l",
96 + "prebuild": "npm run format:check && npm run clean",
97 + "precommit": "npm run format:check",
98 + "prepush": "npm run format:check && npm run build && npm run test",
99 + "pretest": "npm run build",
100 + "prettier": "prettier --parser typescript --trailing-comma all \"{lib,test}/**/*.ts\"",
101 + "release": "npm run build && npm publish --access public",
102 + "test": "API_BASE_URL=http://localhost:1234/ TEST_PORT=1234 TS_NODE_CACHE=0 nyc mocha"
103 + },
104 + "types": "dist/index.d.ts",
105 + "version": "6.4.0"
106 +}
1 + MIT License
2 +
3 + Copyright (c) Microsoft Corporation. All rights reserved.
4 +
5 + Permission is hereby granted, free of charge, to any person obtaining a copy
6 + of this software and associated documentation files (the "Software"), to deal
7 + in the Software without restriction, including without limitation the rights
8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 + copies of the Software, and to permit persons to whom the Software is
10 + furnished to do so, subject to the following conditions:
11 +
12 + The above copyright notice and this permission notice shall be included in all
13 + copies or substantial portions of the Software.
14 +
15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 + SOFTWARE
1 +# Installation
2 +> `npm install --save @types/body-parser`
3 +
4 +# Summary
5 +This package contains type definitions for body-parser (https://github.com/expressjs/body-parser).
6 +
7 +# Details
8 +Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser
9 +
10 +Additional Details
11 + * Last updated: Wed, 25 Apr 2018 00:24:37 GMT
12 + * Dependencies: connect, http, node
13 + * Global values: none
14 +
15 +# Credits
16 +These definitions were written by Santi Albo <https://github.com/santialbo>, Vilic Vane <https://github.com/vilic>, Jonathan Häberle <https://github.com/dreampulse>, Gevik Babakhani <https://github.com/blendsdk>, Tomasz Łaziuk <https://github.com/tlaziuk>, Jason Walton <https://github.com/jwalton>.
1 +// Type definitions for body-parser 1.17
2 +// Project: https://github.com/expressjs/body-parser
3 +// Definitions by: Santi Albo <https://github.com/santialbo>
4 +// Vilic Vane <https://github.com/vilic>
5 +// Jonathan Häberle <https://github.com/dreampulse>
6 +// Gevik Babakhani <https://github.com/blendsdk>
7 +// Tomasz Łaziuk <https://github.com/tlaziuk>
8 +// Jason Walton <https://github.com/jwalton>
9 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10 +// TypeScript Version: 2.2
11 +
12 +/// <reference types="node" />
13 +
14 +import { NextHandleFunction } from 'connect';
15 +import * as http from 'http';
16 +
17 +// for docs go to https://github.com/expressjs/body-parser/tree/1.16.0#body-parser
18 +
19 +// @deprecated
20 +declare function bodyParser(options?: bodyParser.OptionsJson & bodyParser.OptionsText & bodyParser.OptionsUrlencoded): NextHandleFunction;
21 +
22 +declare namespace bodyParser {
23 + interface Options {
24 + inflate?: boolean;
25 + limit?: number | string;
26 + type?: string | string[] | ((req: http.IncomingMessage) => any);
27 + verify?(req: http.IncomingMessage, res: http.ServerResponse, buf: Buffer, encoding: string): void;
28 + }
29 +
30 + interface OptionsJson extends Options {
31 + reviver?(key: string, value: any): any;
32 + strict?: boolean;
33 + }
34 +
35 + interface OptionsText extends Options {
36 + defaultCharset?: string;
37 + }
38 +
39 + interface OptionsUrlencoded extends Options {
40 + extended?: boolean;
41 + parameterLimit?: number;
42 + }
43 +
44 + function json(options?: OptionsJson): NextHandleFunction;
45 +
46 + function raw(options?: Options): NextHandleFunction;
47 +
48 + function text(options?: OptionsText): NextHandleFunction;
49 +
50 + function urlencoded(options?: OptionsUrlencoded): NextHandleFunction;
51 +}
52 +
53 +export = bodyParser;
1 +{
2 + "_from": "@types/body-parser@^1.16.8",
3 + "_id": "@types/body-parser@1.17.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==",
6 + "_location": "/@types/body-parser",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "@types/body-parser@^1.16.8",
12 + "name": "@types/body-parser",
13 + "escapedName": "@types%2fbody-parser",
14 + "scope": "@types",
15 + "rawSpec": "^1.16.8",
16 + "saveSpec": null,
17 + "fetchSpec": "^1.16.8"
18 + },
19 + "_requiredBy": [
20 + "/@line/bot-sdk"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz",
23 + "_shasum": "9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c",
24 + "_spec": "@types/body-parser@^1.16.8",
25 + "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk",
26 + "bugs": {
27 + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28 + },
29 + "bundleDependencies": false,
30 + "contributors": [
31 + {
32 + "name": "Santi Albo",
33 + "url": "https://github.com/santialbo"
34 + },
35 + {
36 + "name": "Vilic Vane",
37 + "url": "https://github.com/vilic"
38 + },
39 + {
40 + "name": "Jonathan Häberle",
41 + "url": "https://github.com/dreampulse"
42 + },
43 + {
44 + "name": "Gevik Babakhani",
45 + "url": "https://github.com/blendsdk"
46 + },
47 + {
48 + "name": "Tomasz Łaziuk",
49 + "url": "https://github.com/tlaziuk"
50 + },
51 + {
52 + "name": "Jason Walton",
53 + "url": "https://github.com/jwalton"
54 + }
55 + ],
56 + "dependencies": {
57 + "@types/connect": "*",
58 + "@types/node": "*"
59 + },
60 + "deprecated": false,
61 + "description": "TypeScript definitions for body-parser",
62 + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
63 + "license": "MIT",
64 + "main": "",
65 + "name": "@types/body-parser",
66 + "repository": {
67 + "type": "git",
68 + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
69 + },
70 + "scripts": {},
71 + "typeScriptVersion": "2.2",
72 + "typesPublisherContentHash": "d50d69303022e9f76f6d905e480a7dc98120bbcedb696a9722a4a2e9f08473e6",
73 + "version": "1.17.0"
74 +}
1 + MIT License
2 +
3 + Copyright (c) Microsoft Corporation. All rights reserved.
4 +
5 + Permission is hereby granted, free of charge, to any person obtaining a copy
6 + of this software and associated documentation files (the "Software"), to deal
7 + in the Software without restriction, including without limitation the rights
8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 + copies of the Software, and to permit persons to whom the Software is
10 + furnished to do so, subject to the following conditions:
11 +
12 + The above copyright notice and this permission notice shall be included in all
13 + copies or substantial portions of the Software.
14 +
15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 + SOFTWARE
1 +# Installation
2 +> `npm install --save @types/connect`
3 +
4 +# Summary
5 +This package contains type definitions for connect (https://github.com/senchalabs/connect).
6 +
7 +# Details
8 +Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/connect
9 +
10 +Additional Details
11 + * Last updated: Tue, 17 Apr 2018 01:01:05 GMT
12 + * Dependencies: http, node
13 + * Global values: none
14 +
15 +# Credits
16 +These definitions were written by Maxime LUCE <https://github.com/SomaticIT>, Evan Hahn <https://github.com/EvanHahn>.
1 +// Type definitions for connect v3.4.0
2 +// Project: https://github.com/senchalabs/connect
3 +// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
4 +// Evan Hahn <https://github.com/EvanHahn>
5 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6 +
7 +/// <reference types="node" />
8 +
9 +
10 +import * as http from "http";
11 +
12 +/**
13 + * Create a new connect server.
14 + * @public
15 + */
16 +declare function createServer(): createServer.Server;
17 +
18 +declare namespace createServer {
19 + export type ServerHandle = HandleFunction | http.Server;
20 +
21 + type NextFunction = (err?: any) => void;
22 +
23 + export type SimpleHandleFunction = (req: http.IncomingMessage, res: http.ServerResponse) => void;
24 + export type NextHandleFunction = (req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
25 + export type ErrorHandleFunction = (err: any, req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
26 + export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
27 +
28 + export interface ServerStackItem {
29 + route: string;
30 + handle: ServerHandle;
31 + }
32 +
33 + export interface Server extends NodeJS.EventEmitter {
34 + (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
35 +
36 + route: string;
37 + stack: ServerStackItem[];
38 +
39 + /**
40 + * Utilize the given middleware `handle` to the given `route`,
41 + * defaulting to _/_. This "route" is the mount-point for the
42 + * middleware, when given a value other than _/_ the middleware
43 + * is only effective when that segment is present in the request's
44 + * pathname.
45 + *
46 + * For example if we were to mount a function at _/admin_, it would
47 + * be invoked on _/admin_, and _/admin/settings_, however it would
48 + * not be invoked for _/_, or _/posts_.
49 + *
50 + * @public
51 + */
52 + use(fn: HandleFunction): Server;
53 + use(route: string, fn: HandleFunction): Server;
54 +
55 + /**
56 + * Handle server requests, punting them down
57 + * the middleware stack.
58 + *
59 + * @private
60 + */
61 + handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
62 +
63 + /**
64 + * Listen for connections.
65 + *
66 + * This method takes the same arguments
67 + * as node's `http.Server#listen()`.
68 + *
69 + * HTTP and HTTPS:
70 + *
71 + * If you run your application both as HTTP
72 + * and HTTPS you may wrap them individually,
73 + * since your Connect "server" is really just
74 + * a JavaScript `Function`.
75 + *
76 + * var connect = require('connect')
77 + * , http = require('http')
78 + * , https = require('https');
79 + *
80 + * var app = connect();
81 + *
82 + * http.createServer(app).listen(80);
83 + * https.createServer(options, app).listen(443);
84 + *
85 + * @api public
86 + */
87 + listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
88 + listen(port: number, hostname?: string, callback?: Function): http.Server;
89 + listen(path: string, callback?: Function): http.Server;
90 + listen(handle: any, listeningListener?: Function): http.Server;
91 + }
92 +}
93 +
94 +export = createServer;
1 +{
2 + "_from": "@types/connect@*",
3 + "_id": "@types/connect@3.4.32",
4 + "_inBundle": false,
5 + "_integrity": "sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg==",
6 + "_location": "/@types/connect",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "@types/connect@*",
12 + "name": "@types/connect",
13 + "escapedName": "@types%2fconnect",
14 + "scope": "@types",
15 + "rawSpec": "*",
16 + "saveSpec": null,
17 + "fetchSpec": "*"
18 + },
19 + "_requiredBy": [
20 + "/@types/body-parser"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.32.tgz",
23 + "_shasum": "aa0e9616b9435ccad02bc52b5b454ffc2c70ba28",
24 + "_spec": "@types/connect@*",
25 + "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@types\\body-parser",
26 + "bugs": {
27 + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28 + },
29 + "bundleDependencies": false,
30 + "contributors": [
31 + {
32 + "name": "Maxime LUCE",
33 + "url": "https://github.com/SomaticIT"
34 + },
35 + {
36 + "name": "Evan Hahn",
37 + "url": "https://github.com/EvanHahn"
38 + }
39 + ],
40 + "dependencies": {
41 + "@types/node": "*"
42 + },
43 + "deprecated": false,
44 + "description": "TypeScript definitions for connect",
45 + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
46 + "license": "MIT",
47 + "main": "",
48 + "name": "@types/connect",
49 + "repository": {
50 + "type": "git",
51 + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
52 + },
53 + "scripts": {},
54 + "typeScriptVersion": "2.0",
55 + "typesPublisherContentHash": "d988cf1d88b273d694c4fcfe3699c4785f7e60ea0c8e094b598922c43ab3fb4e",
56 + "version": "3.4.32"
57 +}
1 + MIT License
2 +
3 + Copyright (c) Microsoft Corporation. All rights reserved.
4 +
5 + Permission is hereby granted, free of charge, to any person obtaining a copy
6 + of this software and associated documentation files (the "Software"), to deal
7 + in the Software without restriction, including without limitation the rights
8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 + copies of the Software, and to permit persons to whom the Software is
10 + furnished to do so, subject to the following conditions:
11 +
12 + The above copyright notice and this permission notice shall be included in all
13 + copies or substantial portions of the Software.
14 +
15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 + SOFTWARE
1 +# Installation
2 +> `npm install --save @types/file-type`
3 +
4 +# Summary
5 +This package contains type definitions for file-type (https://github.com/sindresorhus/file-type).
6 +
7 +# Details
8 +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/file-type
9 +
10 +Additional Details
11 + * Last updated: Thu, 29 Nov 2018 23:28:07 GMT
12 + * Dependencies: node
13 + * Global values: none
14 +
15 +# Credits
16 +These definitions were written by KIM Jaesuck a.k.a. gim tcaesvk <https://github.com/tcaesvk>, BendingBender <https://github.com/BendingBender>.
1 +// Type definitions for file-type 5.2
2 +// Project: https://github.com/sindresorhus/file-type
3 +// Definitions by: KIM Jaesuck a.k.a. gim tcaesvk <https://github.com/tcaesvk>
4 +// BendingBender <https://github.com/BendingBender>
5 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6 +
7 +/// <reference types="node" />
8 +
9 +export = FileType;
10 +
11 +declare function FileType(buf: Buffer | Uint8Array): FileType.FileTypeResult;
12 +
13 +declare namespace FileType {
14 + interface FileTypeResult {
15 + ext: string;
16 + mime: string;
17 + }
18 +
19 + const minimumBytes: number;
20 +}
1 +{
2 + "_from": "@types/file-type@^5.2.1",
3 + "_id": "@types/file-type@5.2.2",
4 + "_inBundle": false,
5 + "_integrity": "sha512-GWtM4fyqfb+bec4ocpo51/y4x0b83Je+iA6eV131LT9wL0//G+1UgwbkMg7w61ceOwR+KkZXK00z44jrrNljWg==",
6 + "_location": "/@types/file-type",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "@types/file-type@^5.2.1",
12 + "name": "@types/file-type",
13 + "escapedName": "@types%2ffile-type",
14 + "scope": "@types",
15 + "rawSpec": "^5.2.1",
16 + "saveSpec": null,
17 + "fetchSpec": "^5.2.1"
18 + },
19 + "_requiredBy": [
20 + "/@line/bot-sdk"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/@types/file-type/-/file-type-5.2.2.tgz",
23 + "_shasum": "901cda395f75780c52bbc7a56fd1f5b5bc96f28f",
24 + "_spec": "@types/file-type@^5.2.1",
25 + "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk",
26 + "bugs": {
27 + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28 + },
29 + "bundleDependencies": false,
30 + "contributors": [
31 + {
32 + "name": "KIM Jaesuck a.k.a. gim tcaesvk",
33 + "url": "https://github.com/tcaesvk"
34 + },
35 + {
36 + "name": "BendingBender",
37 + "url": "https://github.com/BendingBender"
38 + }
39 + ],
40 + "dependencies": {
41 + "@types/node": "*"
42 + },
43 + "deprecated": false,
44 + "description": "TypeScript definitions for file-type",
45 + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
46 + "license": "MIT",
47 + "main": "",
48 + "name": "@types/file-type",
49 + "repository": {
50 + "type": "git",
51 + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
52 + },
53 + "scripts": {},
54 + "typeScriptVersion": "2.0",
55 + "types": "index",
56 + "typesPublisherContentHash": "1e124f27ca50dd322d07954510e787e15c6c0a3ac4a8af6cfa551d89015c98ca",
57 + "version": "5.2.2"
58 +}
1 + MIT License
2 +
3 + Copyright (c) Microsoft Corporation. All rights reserved.
4 +
5 + Permission is hereby granted, free of charge, to any person obtaining a copy
6 + of this software and associated documentation files (the "Software"), to deal
7 + in the Software without restriction, including without limitation the rights
8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 + copies of the Software, and to permit persons to whom the Software is
10 + furnished to do so, subject to the following conditions:
11 +
12 + The above copyright notice and this permission notice shall be included in all
13 + copies or substantial portions of the Software.
14 +
15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 + SOFTWARE
1 +# Installation
2 +> `npm install --save @types/node`
3 +
4 +# Summary
5 +This package contains type definitions for Node.js (http://nodejs.org/).
6 +
7 +# Details
8 +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v7
9 +
10 +Additional Details
11 + * Last updated: Thu, 15 Nov 2018 00:16:17 GMT
12 + * Dependencies: none
13 + * Global values: Buffer, NodeJS, SlowBuffer, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, require, setImmediate, setInterval, setTimeout
14 +
15 +# Credits
16 +These definitions were written by Microsoft TypeScript <https://github.com/Microsoft>, DefinitelyTyped <https://github.com/DefinitelyTyped>, Parambir Singh <https://github.com/parambirs>, Christian Vaagland Tellnes <https://github.com/tellnes>, Wilco Bakker <https://github.com/WilcoBakker>, Sebastian Silbermann <https://github.com/eps1lon>, Hoàng Văn Khải <https://github.com/KSXGitHub>, Sander Koenders <https://github.com/Archcry>.
This diff could not be displayed because it is too large.
1 +{
2 + "_from": "@types/node@^7.0.31",
3 + "_id": "@types/node@7.10.2",
4 + "_inBundle": false,
5 + "_integrity": "sha512-RO4ig5taKmcrU4Rex8ojG1gpwFkjddzug9iPQSDvbewHN9vDpcFewevkaOK+KT+w1LeZnxbgOyfXwV4pxsQ4GQ==",
6 + "_location": "/@types/node",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "@types/node@^7.0.31",
12 + "name": "@types/node",
13 + "escapedName": "@types%2fnode",
14 + "scope": "@types",
15 + "rawSpec": "^7.0.31",
16 + "saveSpec": null,
17 + "fetchSpec": "^7.0.31"
18 + },
19 + "_requiredBy": [
20 + "/@line/bot-sdk",
21 + "/@types/body-parser",
22 + "/@types/connect",
23 + "/@types/file-type"
24 + ],
25 + "_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.2.tgz",
26 + "_shasum": "a98845168012d7a63a84d50e738829da43bdb0de",
27 + "_spec": "@types/node@^7.0.31",
28 + "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk",
29 + "bugs": {
30 + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
31 + },
32 + "bundleDependencies": false,
33 + "contributors": [
34 + {
35 + "name": "Microsoft TypeScript",
36 + "url": "https://github.com/Microsoft"
37 + },
38 + {
39 + "name": "DefinitelyTyped",
40 + "url": "https://github.com/DefinitelyTyped"
41 + },
42 + {
43 + "name": "Parambir Singh",
44 + "url": "https://github.com/parambirs"
45 + },
46 + {
47 + "name": "Christian Vaagland Tellnes",
48 + "url": "https://github.com/tellnes"
49 + },
50 + {
51 + "name": "Wilco Bakker",
52 + "url": "https://github.com/WilcoBakker"
53 + },
54 + {
55 + "name": "Sebastian Silbermann",
56 + "url": "https://github.com/eps1lon"
57 + },
58 + {
59 + "name": "Hoàng Văn Khải",
60 + "url": "https://github.com/KSXGitHub"
61 + },
62 + {
63 + "name": "Sander Koenders",
64 + "url": "https://github.com/Archcry"
65 + }
66 + ],
67 + "dependencies": {},
68 + "deprecated": false,
69 + "description": "TypeScript definitions for Node.js",
70 + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
71 + "license": "MIT",
72 + "main": "",
73 + "name": "@types/node",
74 + "repository": {
75 + "type": "git",
76 + "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
77 + },
78 + "scripts": {},
79 + "typeScriptVersion": "2.0",
80 + "types": "index",
81 + "typesPublisherContentHash": "55896a12ed8765c021f335913ef256ce4eb8ac2fc4b0c93611d7ce514e2906ea",
82 + "version": "7.10.2"
83 +}
1 +1.3.5 / 2018-02-28
2 +==================
3 +
4 + * deps: mime-types@~2.1.18
5 + - deps: mime-db@~1.33.0
6 +
7 +1.3.4 / 2017-08-22
8 +==================
9 +
10 + * deps: mime-types@~2.1.16
11 + - deps: mime-db@~1.29.0
12 +
13 +1.3.3 / 2016-05-02
14 +==================
15 +
16 + * deps: mime-types@~2.1.11
17 + - deps: mime-db@~1.23.0
18 + * deps: negotiator@0.6.1
19 + - perf: improve `Accept` parsing speed
20 + - perf: improve `Accept-Charset` parsing speed
21 + - perf: improve `Accept-Encoding` parsing speed
22 + - perf: improve `Accept-Language` parsing speed
23 +
24 +1.3.2 / 2016-03-08
25 +==================
26 +
27 + * deps: mime-types@~2.1.10
28 + - Fix extension of `application/dash+xml`
29 + - Update primary extension for `audio/mp4`
30 + - deps: mime-db@~1.22.0
31 +
32 +1.3.1 / 2016-01-19
33 +==================
34 +
35 + * deps: mime-types@~2.1.9
36 + - deps: mime-db@~1.21.0
37 +
38 +1.3.0 / 2015-09-29
39 +==================
40 +
41 + * deps: mime-types@~2.1.7
42 + - deps: mime-db@~1.19.0
43 + * deps: negotiator@0.6.0
44 + - Fix including type extensions in parameters in `Accept` parsing
45 + - Fix parsing `Accept` parameters with quoted equals
46 + - Fix parsing `Accept` parameters with quoted semicolons
47 + - Lazy-load modules from main entry point
48 + - perf: delay type concatenation until needed
49 + - perf: enable strict mode
50 + - perf: hoist regular expressions
51 + - perf: remove closures getting spec properties
52 + - perf: remove a closure from media type parsing
53 + - perf: remove property delete from media type parsing
54 +
55 +1.2.13 / 2015-09-06
56 +===================
57 +
58 + * deps: mime-types@~2.1.6
59 + - deps: mime-db@~1.18.0
60 +
61 +1.2.12 / 2015-07-30
62 +===================
63 +
64 + * deps: mime-types@~2.1.4
65 + - deps: mime-db@~1.16.0
66 +
67 +1.2.11 / 2015-07-16
68 +===================
69 +
70 + * deps: mime-types@~2.1.3
71 + - deps: mime-db@~1.15.0
72 +
73 +1.2.10 / 2015-07-01
74 +===================
75 +
76 + * deps: mime-types@~2.1.2
77 + - deps: mime-db@~1.14.0
78 +
79 +1.2.9 / 2015-06-08
80 +==================
81 +
82 + * deps: mime-types@~2.1.1
83 + - perf: fix deopt during mapping
84 +
85 +1.2.8 / 2015-06-07
86 +==================
87 +
88 + * deps: mime-types@~2.1.0
89 + - deps: mime-db@~1.13.0
90 + * perf: avoid argument reassignment & argument slice
91 + * perf: avoid negotiator recursive construction
92 + * perf: enable strict mode
93 + * perf: remove unnecessary bitwise operator
94 +
95 +1.2.7 / 2015-05-10
96 +==================
97 +
98 + * deps: negotiator@0.5.3
99 + - Fix media type parameter matching to be case-insensitive
100 +
101 +1.2.6 / 2015-05-07
102 +==================
103 +
104 + * deps: mime-types@~2.0.11
105 + - deps: mime-db@~1.9.1
106 + * deps: negotiator@0.5.2
107 + - Fix comparing media types with quoted values
108 + - Fix splitting media types with quoted commas
109 +
110 +1.2.5 / 2015-03-13
111 +==================
112 +
113 + * deps: mime-types@~2.0.10
114 + - deps: mime-db@~1.8.0
115 +
116 +1.2.4 / 2015-02-14
117 +==================
118 +
119 + * Support Node.js 0.6
120 + * deps: mime-types@~2.0.9
121 + - deps: mime-db@~1.7.0
122 + * deps: negotiator@0.5.1
123 + - Fix preference sorting to be stable for long acceptable lists
124 +
125 +1.2.3 / 2015-01-31
126 +==================
127 +
128 + * deps: mime-types@~2.0.8
129 + - deps: mime-db@~1.6.0
130 +
131 +1.2.2 / 2014-12-30
132 +==================
133 +
134 + * deps: mime-types@~2.0.7
135 + - deps: mime-db@~1.5.0
136 +
137 +1.2.1 / 2014-12-30
138 +==================
139 +
140 + * deps: mime-types@~2.0.5
141 + - deps: mime-db@~1.3.1
142 +
143 +1.2.0 / 2014-12-19
144 +==================
145 +
146 + * deps: negotiator@0.5.0
147 + - Fix list return order when large accepted list
148 + - Fix missing identity encoding when q=0 exists
149 + - Remove dynamic building of Negotiator class
150 +
151 +1.1.4 / 2014-12-10
152 +==================
153 +
154 + * deps: mime-types@~2.0.4
155 + - deps: mime-db@~1.3.0
156 +
157 +1.1.3 / 2014-11-09
158 +==================
159 +
160 + * deps: mime-types@~2.0.3
161 + - deps: mime-db@~1.2.0
162 +
163 +1.1.2 / 2014-10-14
164 +==================
165 +
166 + * deps: negotiator@0.4.9
167 + - Fix error when media type has invalid parameter
168 +
169 +1.1.1 / 2014-09-28
170 +==================
171 +
172 + * deps: mime-types@~2.0.2
173 + - deps: mime-db@~1.1.0
174 + * deps: negotiator@0.4.8
175 + - Fix all negotiations to be case-insensitive
176 + - Stable sort preferences of same quality according to client order
177 +
178 +1.1.0 / 2014-09-02
179 +==================
180 +
181 + * update `mime-types`
182 +
183 +1.0.7 / 2014-07-04
184 +==================
185 +
186 + * Fix wrong type returned from `type` when match after unknown extension
187 +
188 +1.0.6 / 2014-06-24
189 +==================
190 +
191 + * deps: negotiator@0.4.7
192 +
193 +1.0.5 / 2014-06-20
194 +==================
195 +
196 + * fix crash when unknown extension given
197 +
198 +1.0.4 / 2014-06-19
199 +==================
200 +
201 + * use `mime-types`
202 +
203 +1.0.3 / 2014-06-11
204 +==================
205 +
206 + * deps: negotiator@0.4.6
207 + - Order by specificity when quality is the same
208 +
209 +1.0.2 / 2014-05-29
210 +==================
211 +
212 + * Fix interpretation when header not in request
213 + * deps: pin negotiator@0.4.5
214 +
215 +1.0.1 / 2014-01-18
216 +==================
217 +
218 + * Identity encoding isn't always acceptable
219 + * deps: negotiator@~0.4.0
220 +
221 +1.0.0 / 2013-12-27
222 +==================
223 +
224 + * Genesis
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# accepts
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 +Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 +
12 +In addition to negotiator, it allows:
13 +
14 +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 + as well as `('text/html', 'application/json')`.
16 +- Allows type shorthands such as `json`.
17 +- Returns `false` when no types match
18 +- Treats non-existent headers as `*`
19 +
20 +## Installation
21 +
22 +This is a [Node.js](https://nodejs.org/en/) module available through the
23 +[npm registry](https://www.npmjs.com/). Installation is done using the
24 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 +
26 +```sh
27 +$ npm install accepts
28 +```
29 +
30 +## API
31 +
32 +<!-- eslint-disable no-unused-vars -->
33 +
34 +```js
35 +var accepts = require('accepts')
36 +```
37 +
38 +### accepts(req)
39 +
40 +Create a new `Accepts` object for the given `req`.
41 +
42 +#### .charset(charsets)
43 +
44 +Return the first accepted charset. If nothing in `charsets` is accepted,
45 +then `false` is returned.
46 +
47 +#### .charsets()
48 +
49 +Return the charsets that the request accepts, in the order of the client's
50 +preference (most preferred first).
51 +
52 +#### .encoding(encodings)
53 +
54 +Return the first accepted encoding. If nothing in `encodings` is accepted,
55 +then `false` is returned.
56 +
57 +#### .encodings()
58 +
59 +Return the encodings that the request accepts, in the order of the client's
60 +preference (most preferred first).
61 +
62 +#### .language(languages)
63 +
64 +Return the first accepted language. If nothing in `languages` is accepted,
65 +then `false` is returned.
66 +
67 +#### .languages()
68 +
69 +Return the languages that the request accepts, in the order of the client's
70 +preference (most preferred first).
71 +
72 +#### .type(types)
73 +
74 +Return the first accepted type (and it is returned as the same text as what
75 +appears in the `types` array). If nothing in `types` is accepted, then `false`
76 +is returned.
77 +
78 +The `types` array can contain full MIME types or file extensions. Any value
79 +that is not a full MIME types is passed to `require('mime-types').lookup`.
80 +
81 +#### .types()
82 +
83 +Return the types that the request accepts, in the order of the client's
84 +preference (most preferred first).
85 +
86 +## Examples
87 +
88 +### Simple type negotiation
89 +
90 +This simple example shows how to use `accepts` to return a different typed
91 +respond body based on what the client wants to accept. The server lists it's
92 +preferences in order and will get back the best match between the client and
93 +server.
94 +
95 +```js
96 +var accepts = require('accepts')
97 +var http = require('http')
98 +
99 +function app (req, res) {
100 + var accept = accepts(req)
101 +
102 + // the order of this list is significant; should be server preferred order
103 + switch (accept.type(['json', 'html'])) {
104 + case 'json':
105 + res.setHeader('Content-Type', 'application/json')
106 + res.write('{"hello":"world!"}')
107 + break
108 + case 'html':
109 + res.setHeader('Content-Type', 'text/html')
110 + res.write('<b>hello, world!</b>')
111 + break
112 + default:
113 + // the fallback is text/plain, so no need to specify it above
114 + res.setHeader('Content-Type', 'text/plain')
115 + res.write('hello, world!')
116 + break
117 + }
118 +
119 + res.end()
120 +}
121 +
122 +http.createServer(app).listen(3000)
123 +```
124 +
125 +You can test this out with the cURL program:
126 +```sh
127 +curl -I -H'Accept: text/html' http://localhost:3000/
128 +```
129 +
130 +## License
131 +
132 +[MIT](LICENSE)
133 +
134 +[npm-image]: https://img.shields.io/npm/v/accepts.svg
135 +[npm-url]: https://npmjs.org/package/accepts
136 +[node-version-image]: https://img.shields.io/node/v/accepts.svg
137 +[node-version-url]: https://nodejs.org/en/download/
138 +[travis-image]: https://img.shields.io/travis/jshttp/accepts/master.svg
139 +[travis-url]: https://travis-ci.org/jshttp/accepts
140 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts/master.svg
141 +[coveralls-url]: https://coveralls.io/r/jshttp/accepts
142 +[downloads-image]: https://img.shields.io/npm/dm/accepts.svg
143 +[downloads-url]: https://npmjs.org/package/accepts
1 +/*!
2 + * accepts
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var Negotiator = require('negotiator')
16 +var mime = require('mime-types')
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = Accepts
24 +
25 +/**
26 + * Create a new Accepts object for the given req.
27 + *
28 + * @param {object} req
29 + * @public
30 + */
31 +
32 +function Accepts (req) {
33 + if (!(this instanceof Accepts)) {
34 + return new Accepts(req)
35 + }
36 +
37 + this.headers = req.headers
38 + this.negotiator = new Negotiator(req)
39 +}
40 +
41 +/**
42 + * Check if the given `type(s)` is acceptable, returning
43 + * the best match when true, otherwise `undefined`, in which
44 + * case you should respond with 406 "Not Acceptable".
45 + *
46 + * The `type` value may be a single mime type string
47 + * such as "application/json", the extension name
48 + * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 + * or array is given the _best_ match, if any is returned.
50 + *
51 + * Examples:
52 + *
53 + * // Accept: text/html
54 + * this.types('html');
55 + * // => "html"
56 + *
57 + * // Accept: text/*, application/json
58 + * this.types('html');
59 + * // => "html"
60 + * this.types('text/html');
61 + * // => "text/html"
62 + * this.types('json', 'text');
63 + * // => "json"
64 + * this.types('application/json');
65 + * // => "application/json"
66 + *
67 + * // Accept: text/*, application/json
68 + * this.types('image/png');
69 + * this.types('png');
70 + * // => undefined
71 + *
72 + * // Accept: text/*;q=.5, application/json
73 + * this.types(['html', 'json']);
74 + * this.types('html', 'json');
75 + * // => "json"
76 + *
77 + * @param {String|Array} types...
78 + * @return {String|Array|Boolean}
79 + * @public
80 + */
81 +
82 +Accepts.prototype.type =
83 +Accepts.prototype.types = function (types_) {
84 + var types = types_
85 +
86 + // support flattened arguments
87 + if (types && !Array.isArray(types)) {
88 + types = new Array(arguments.length)
89 + for (var i = 0; i < types.length; i++) {
90 + types[i] = arguments[i]
91 + }
92 + }
93 +
94 + // no types, return all requested types
95 + if (!types || types.length === 0) {
96 + return this.negotiator.mediaTypes()
97 + }
98 +
99 + // no accept header, return first given type
100 + if (!this.headers.accept) {
101 + return types[0]
102 + }
103 +
104 + var mimes = types.map(extToMime)
105 + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 + var first = accepts[0]
107 +
108 + return first
109 + ? types[mimes.indexOf(first)]
110 + : false
111 +}
112 +
113 +/**
114 + * Return accepted encodings or best fit based on `encodings`.
115 + *
116 + * Given `Accept-Encoding: gzip, deflate`
117 + * an array sorted by quality is returned:
118 + *
119 + * ['gzip', 'deflate']
120 + *
121 + * @param {String|Array} encodings...
122 + * @return {String|Array}
123 + * @public
124 + */
125 +
126 +Accepts.prototype.encoding =
127 +Accepts.prototype.encodings = function (encodings_) {
128 + var encodings = encodings_
129 +
130 + // support flattened arguments
131 + if (encodings && !Array.isArray(encodings)) {
132 + encodings = new Array(arguments.length)
133 + for (var i = 0; i < encodings.length; i++) {
134 + encodings[i] = arguments[i]
135 + }
136 + }
137 +
138 + // no encodings, return all requested encodings
139 + if (!encodings || encodings.length === 0) {
140 + return this.negotiator.encodings()
141 + }
142 +
143 + return this.negotiator.encodings(encodings)[0] || false
144 +}
145 +
146 +/**
147 + * Return accepted charsets or best fit based on `charsets`.
148 + *
149 + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 + * an array sorted by quality is returned:
151 + *
152 + * ['utf-8', 'utf-7', 'iso-8859-1']
153 + *
154 + * @param {String|Array} charsets...
155 + * @return {String|Array}
156 + * @public
157 + */
158 +
159 +Accepts.prototype.charset =
160 +Accepts.prototype.charsets = function (charsets_) {
161 + var charsets = charsets_
162 +
163 + // support flattened arguments
164 + if (charsets && !Array.isArray(charsets)) {
165 + charsets = new Array(arguments.length)
166 + for (var i = 0; i < charsets.length; i++) {
167 + charsets[i] = arguments[i]
168 + }
169 + }
170 +
171 + // no charsets, return all requested charsets
172 + if (!charsets || charsets.length === 0) {
173 + return this.negotiator.charsets()
174 + }
175 +
176 + return this.negotiator.charsets(charsets)[0] || false
177 +}
178 +
179 +/**
180 + * Return accepted languages or best fit based on `langs`.
181 + *
182 + * Given `Accept-Language: en;q=0.8, es, pt`
183 + * an array sorted by quality is returned:
184 + *
185 + * ['es', 'pt', 'en']
186 + *
187 + * @param {String|Array} langs...
188 + * @return {Array|String}
189 + * @public
190 + */
191 +
192 +Accepts.prototype.lang =
193 +Accepts.prototype.langs =
194 +Accepts.prototype.language =
195 +Accepts.prototype.languages = function (languages_) {
196 + var languages = languages_
197 +
198 + // support flattened arguments
199 + if (languages && !Array.isArray(languages)) {
200 + languages = new Array(arguments.length)
201 + for (var i = 0; i < languages.length; i++) {
202 + languages[i] = arguments[i]
203 + }
204 + }
205 +
206 + // no languages, return all requested languages
207 + if (!languages || languages.length === 0) {
208 + return this.negotiator.languages()
209 + }
210 +
211 + return this.negotiator.languages(languages)[0] || false
212 +}
213 +
214 +/**
215 + * Convert extnames to mime.
216 + *
217 + * @param {String} type
218 + * @return {String}
219 + * @private
220 + */
221 +
222 +function extToMime (type) {
223 + return type.indexOf('/') === -1
224 + ? mime.lookup(type)
225 + : type
226 +}
227 +
228 +/**
229 + * Check if mime is valid.
230 + *
231 + * @param {String} type
232 + * @return {String}
233 + * @private
234 + */
235 +
236 +function validMime (type) {
237 + return typeof type === 'string'
238 +}
1 +{
2 + "_from": "accepts@~1.3.5",
3 + "_id": "accepts@1.3.5",
4 + "_inBundle": false,
5 + "_integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=",
6 + "_location": "/accepts",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "accepts@~1.3.5",
12 + "name": "accepts",
13 + "escapedName": "accepts",
14 + "rawSpec": "~1.3.5",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.3.5"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
22 + "_shasum": "eb777df6011723a3b14e8a72c0805c8e86746bd2",
23 + "_spec": "accepts@~1.3.5",
24 + "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\express",
25 + "bugs": {
26 + "url": "https://github.com/jshttp/accepts/issues"
27 + },
28 + "bundleDependencies": false,
29 + "contributors": [
30 + {
31 + "name": "Douglas Christopher Wilson",
32 + "email": "doug@somethingdoug.com"
33 + },
34 + {
35 + "name": "Jonathan Ong",
36 + "email": "me@jongleberry.com",
37 + "url": "http://jongleberry.com"
38 + }
39 + ],
40 + "dependencies": {
41 + "mime-types": "~2.1.18",
42 + "negotiator": "0.6.1"
43 + },
44 + "deprecated": false,
45 + "description": "Higher-level content negotiation",
46 + "devDependencies": {
47 + "eslint": "4.18.1",
48 + "eslint-config-standard": "11.0.0",
49 + "eslint-plugin-import": "2.9.0",
50 + "eslint-plugin-markdown": "1.0.0-beta.6",
51 + "eslint-plugin-node": "6.0.1",
52 + "eslint-plugin-promise": "3.6.0",
53 + "eslint-plugin-standard": "3.0.1",
54 + "istanbul": "0.4.5",
55 + "mocha": "~1.21.5"
56 + },
57 + "engines": {
58 + "node": ">= 0.6"
59 + },
60 + "files": [
61 + "LICENSE",
62 + "HISTORY.md",
63 + "index.js"
64 + ],
65 + "homepage": "https://github.com/jshttp/accepts#readme",
66 + "keywords": [
67 + "content",
68 + "negotiation",
69 + "accept",
70 + "accepts"
71 + ],
72 + "license": "MIT",
73 + "name": "accepts",
74 + "repository": {
75 + "type": "git",
76 + "url": "git+https://github.com/jshttp/accepts.git"
77 + },
78 + "scripts": {
79 + "lint": "eslint --plugin markdown --ext js,md .",
80 + "test": "mocha --reporter spec --check-leaks --bail test/",
81 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
82 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
83 + },
84 + "version": "1.3.5"
85 +}
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# Array Flatten
2 +
3 +[![NPM version][npm-image]][npm-url]
4 +[![NPM downloads][downloads-image]][downloads-url]
5 +[![Build status][travis-image]][travis-url]
6 +[![Test coverage][coveralls-image]][coveralls-url]
7 +
8 +> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
9 +
10 +## Installation
11 +
12 +```
13 +npm install array-flatten --save
14 +```
15 +
16 +## Usage
17 +
18 +```javascript
19 +var flatten = require('array-flatten')
20 +
21 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
22 +//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
23 +
24 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
25 +//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
26 +
27 +(function () {
28 + flatten(arguments) //=> [1, 2, 3]
29 +})(1, [2, 3])
30 +```
31 +
32 +## License
33 +
34 +MIT
35 +
36 +[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
37 +[npm-url]: https://npmjs.org/package/array-flatten
38 +[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
39 +[downloads-url]: https://npmjs.org/package/array-flatten
40 +[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
41 +[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
42 +[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
43 +[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
1 +'use strict'
2 +
3 +/**
4 + * Expose `arrayFlatten`.
5 + */
6 +module.exports = arrayFlatten
7 +
8 +/**
9 + * Recursive flatten function with depth.
10 + *
11 + * @param {Array} array
12 + * @param {Array} result
13 + * @param {Number} depth
14 + * @return {Array}
15 + */
16 +function flattenWithDepth (array, result, depth) {
17 + for (var i = 0; i < array.length; i++) {
18 + var value = array[i]
19 +
20 + if (depth > 0 && Array.isArray(value)) {
21 + flattenWithDepth(value, result, depth - 1)
22 + } else {
23 + result.push(value)
24 + }
25 + }
26 +
27 + return result
28 +}
29 +
30 +/**
31 + * Recursive flatten function. Omitting depth is slightly faster.
32 + *
33 + * @param {Array} array
34 + * @param {Array} result
35 + * @return {Array}
36 + */
37 +function flattenForever (array, result) {
38 + for (var i = 0; i < array.length; i++) {
39 + var value = array[i]
40 +
41 + if (Array.isArray(value)) {
42 + flattenForever(value, result)
43 + } else {
44 + result.push(value)
45 + }
46 + }
47 +
48 + return result
49 +}
50 +
51 +/**
52 + * Flatten an array, with the ability to define a depth.
53 + *
54 + * @param {Array} array
55 + * @param {Number} depth
56 + * @return {Array}
57 + */
58 +function arrayFlatten (array, depth) {
59 + if (depth == null) {
60 + return flattenForever(array, [])
61 + }
62 +
63 + return flattenWithDepth(array, [], depth)
64 +}
1 +{
2 + "_from": "array-flatten@1.1.1",
3 + "_id": "array-flatten@1.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=",
6 + "_location": "/array-flatten",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "array-flatten@1.1.1",
12 + "name": "array-flatten",
13 + "escapedName": "array-flatten",
14 + "rawSpec": "1.1.1",
15 + "saveSpec": null,
16 + "fetchSpec": "1.1.1"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "http://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
22 + "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2",
23 + "_spec": "array-flatten@1.1.1",
24 + "_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\express",
25 + "author": {
26 + "name": "Blake Embrey",
27 + "email": "hello@blakeembrey.com",
28 + "url": "http://blakeembrey.me"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/blakeembrey/array-flatten/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "Flatten an array of nested arrays into a single flat array",
36 + "devDependencies": {
37 + "istanbul": "^0.3.13",
38 + "mocha": "^2.2.4",
39 + "pre-commit": "^1.0.7",
40 + "standard": "^3.7.3"
41 + },
42 + "files": [
43 + "array-flatten.js",
44 + "LICENSE"
45 + ],
46 + "homepage": "https://github.com/blakeembrey/array-flatten",
47 + "keywords": [
48 + "array",
49 + "flatten",
50 + "arguments",
51 + "depth"
52 + ],
53 + "license": "MIT",
54 + "main": "array-flatten.js",
55 + "name": "array-flatten",
56 + "repository": {
57 + "type": "git",
58 + "url": "git://github.com/blakeembrey/array-flatten.git"
59 + },
60 + "scripts": {
61 + "test": "istanbul cover _mocha -- -R spec"
62 + },
63 + "version": "1.1.1"
64 +}
This diff is collapsed. Click to expand it.
1 +Copyright (c) 2014 Matt Zabriskie
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to deal
5 +in the Software without restriction, including without limitation the rights
6 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 +copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 +THE SOFTWARE.
This diff is collapsed. Click to expand it.
1 +# Upgrade Guide
2 +
3 +### 0.15.x -> 0.16.0
4 +
5 +#### `Promise` Type Declarations
6 +
7 +The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details.
8 +
9 +### 0.13.x -> 0.14.0
10 +
11 +#### TypeScript Definitions
12 +
13 +The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax.
14 +
15 +Please use the following `import` statement to import axios in TypeScript:
16 +
17 +```typescript
18 +import axios from 'axios';
19 +
20 +axios.get('/foo')
21 + .then(response => console.log(response))
22 + .catch(error => console.log(error));
23 +```
24 +
25 +#### `agent` Config Option
26 +
27 +The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead.
28 +
29 +```js
30 +{
31 + // Define a custom agent for HTTP
32 + httpAgent: new http.Agent({ keepAlive: true }),
33 + // Define a custom agent for HTTPS
34 + httpsAgent: new https.Agent({ keepAlive: true })
35 +}
36 +```
37 +
38 +#### `progress` Config Option
39 +
40 +The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options.
41 +
42 +```js
43 +{
44 + // Define a handler for upload progress events
45 + onUploadProgress: function (progressEvent) {
46 + // ...
47 + },
48 +
49 + // Define a handler for download progress events
50 + onDownloadProgress: function (progressEvent) {
51 + // ...
52 + }
53 +}
54 +```
55 +
56 +### 0.12.x -> 0.13.0
57 +
58 +The `0.13.0` release contains several changes to custom adapters and error handling.
59 +
60 +#### Error Handling
61 +
62 +Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response.
63 +
64 +```js
65 +axios.get('/user/12345')
66 + .catch((error) => {
67 + console.log(error.message);
68 + console.log(error.code); // Not always specified
69 + console.log(error.config); // The config that was used to make the request
70 + console.log(error.response); // Only available if response was received from the server
71 + });
72 +```
73 +
74 +#### Request Adapters
75 +
76 +This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter.
77 +
78 +1. Response transformer is now called outside of adapter.
79 +2. Request adapter returns a `Promise`.
80 +
81 +This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter.
82 +
83 +Previous code:
84 +
85 +```js
86 +function myAdapter(resolve, reject, config) {
87 + var response = {
88 + data: transformData(
89 + responseData,
90 + responseHeaders,
91 + config.transformResponse
92 + ),
93 + status: request.status,
94 + statusText: request.statusText,
95 + headers: responseHeaders
96 + };
97 + settle(resolve, reject, response);
98 +}
99 +```
100 +
101 +New code:
102 +
103 +```js
104 +function myAdapter(config) {
105 + return new Promise(function (resolve, reject) {
106 + var response = {
107 + data: responseData,
108 + status: request.status,
109 + statusText: request.statusText,
110 + headers: responseHeaders
111 + };
112 + settle(resolve, reject, response);
113 + });
114 +}
115 +```
116 +
117 +See the related commits for more details:
118 +- [Response transformers](https://github.com/mzabriskie/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
119 +- [Request adapter Promise](https://github.com/mzabriskie/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
120 +
121 +### 0.5.x -> 0.6.0
122 +
123 +The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading.
124 +
125 +#### ES6 Promise Polyfill
126 +
127 +Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it.
128 +
129 +```js
130 +require('es6-promise').polyfill();
131 +var axios = require('axios');
132 +```
133 +
134 +This will polyfill the global environment, and only needs to be done once.
135 +
136 +#### `axios.success`/`axios.error`
137 +
138 +The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/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.
139 +
140 +```js
141 +axios.get('some/url')
142 + .then(function (res) {
143 + /* ... */
144 + })
145 + .catch(function (err) {
146 + /* ... */
147 + });
148 +```
149 +
150 +#### UMD
151 +
152 +Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build.
153 +
154 +```js
155 +// AMD
156 +require(['bower_components/axios/dist/axios'], function (axios) {
157 + /* ... */
158 +});
159 +
160 +// CommonJS
161 +var axios = require('axios/dist/axios');
162 +```
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
1 +export interface AxiosTransformer {
2 + (data: any): any;
3 +}
4 +
5 +export interface AxiosAdapter {
6 + (config: AxiosRequestConfig): AxiosPromise;
7 +}
8 +
9 +export interface AxiosBasicCredentials {
10 + username: string;
11 + password: string;
12 +}
13 +
14 +export interface AxiosProxyConfig {
15 + host: string;
16 + port: number;
17 +}
18 +
19 +export interface AxiosRequestConfig {
20 + url?: string;
21 + method?: string;
22 + baseURL?: string;
23 + transformRequest?: AxiosTransformer | AxiosTransformer[];
24 + transformResponse?: AxiosTransformer | AxiosTransformer[];
25 + headers?: any;
26 + params?: any;
27 + paramsSerializer?: (params: any) => string;
28 + data?: any;
29 + timeout?: number;
30 + withCredentials?: boolean;
31 + adapter?: AxiosAdapter;
32 + auth?: AxiosBasicCredentials;
33 + responseType?: string;
34 + xsrfCookieName?: string;
35 + xsrfHeaderName?: string;
36 + onUploadProgress?: (progressEvent: any) => void;
37 + onDownloadProgress?: (progressEvent: any) => void;
38 + maxContentLength?: number;
39 + validateStatus?: (status: number) => boolean;
40 + maxRedirects?: number;
41 + httpAgent?: any;
42 + httpsAgent?: any;
43 + proxy?: AxiosProxyConfig;
44 + cancelToken?: CancelToken;
45 +}
46 +
47 +export interface AxiosResponse {
48 + data: any;
49 + status: number;
50 + statusText: string;
51 + headers: any;
52 + config: AxiosRequestConfig;
53 +}
54 +
55 +export interface AxiosError extends Error {
56 + config: AxiosRequestConfig;
57 + code?: string;
58 + response?: AxiosResponse;
59 +}
60 +
61 +export interface AxiosPromise extends Promise<AxiosResponse> {
62 +}
63 +
64 +export interface CancelStatic {
65 + new (message?: string): Cancel;
66 +}
67 +
68 +export interface Cancel {
69 + message: string;
70 +}
71 +
72 +export interface Canceler {
73 + (message?: string): void;
74 +}
75 +
76 +export interface CancelTokenStatic {
77 + new (executor: (cancel: Canceler) => void): CancelToken;
78 + source(): CancelTokenSource;
79 +}
80 +
81 +export interface CancelToken {
82 + promise: Promise<Cancel>;
83 + reason?: Cancel;
84 + throwIfRequested(): void;
85 +}
86 +
87 +export interface CancelTokenSource {
88 + token: CancelToken;
89 + cancel: Canceler;
90 +}
91 +
92 +export interface AxiosInterceptorManager<V> {
93 + use(onFulfilled: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
94 + eject(id: number): void;
95 +}
96 +
97 +export interface AxiosInstance {
98 + defaults: AxiosRequestConfig;
99 + interceptors: {
100 + request: AxiosInterceptorManager<AxiosRequestConfig>;
101 + response: AxiosInterceptorManager<AxiosResponse>;
102 + };
103 + request(config: AxiosRequestConfig): AxiosPromise;
104 + get(url: string, config?: AxiosRequestConfig): AxiosPromise;
105 + delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
106 + head(url: string, config?: AxiosRequestConfig): AxiosPromise;
107 + post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
108 + put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
109 + patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
110 +}
111 +
112 +export interface AxiosStatic extends AxiosInstance {
113 + (config: AxiosRequestConfig): AxiosPromise;
114 + (url: string, config?: AxiosRequestConfig): AxiosPromise;
115 + create(config?: AxiosRequestConfig): AxiosInstance;
116 + Cancel: CancelStatic;
117 + CancelToken: CancelTokenStatic;
118 + isCancel(value: any): boolean;
119 + all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
120 + spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
121 +}
122 +
123 +declare const Axios: AxiosStatic;
124 +
125 +export default Axios;
1 +module.exports = require('./lib/axios');
...\ No newline at end of file ...\ No newline at end of file
1 +# axios // adapters
2 +
3 +The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received.
4 +
5 +## Example
6 +
7 +```js
8 +var settle = require('./../core/settle');
9 +
10 +module.exports = function myAdapter(config) {
11 + // At this point:
12 + // - config has been merged with defaults
13 + // - request transformers have already run
14 + // - request interceptors have already run
15 +
16 + // Make the request using config provided
17 + // Upon response settle the Promise
18 +
19 + return new Promise(function(resolve, reject) {
20 +
21 + var response = {
22 + data: responseData,
23 + status: request.status,
24 + statusText: request.statusText,
25 + headers: responseHeaders,
26 + config: config,
27 + request: request
28 + };
29 +
30 + settle(resolve, reject, response);
31 +
32 + // From here:
33 + // - response transformers will run
34 + // - response interceptors will run
35 + });
36 +}
37 +```
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +var settle = require('./../core/settle');
5 +var buildURL = require('./../helpers/buildURL');
6 +var http = require('http');
7 +var https = require('https');
8 +var httpFollow = require('follow-redirects').http;
9 +var httpsFollow = require('follow-redirects').https;
10 +var url = require('url');
11 +var zlib = require('zlib');
12 +var pkg = require('./../../package.json');
13 +var createError = require('../core/createError');
14 +var enhanceError = require('../core/enhanceError');
15 +
16 +/*eslint consistent-return:0*/
17 +module.exports = function httpAdapter(config) {
18 + return new Promise(function dispatchHttpRequest(resolve, reject) {
19 + var data = config.data;
20 + var headers = config.headers;
21 + var timer;
22 + var aborted = false;
23 +
24 + // Set User-Agent (required by some servers)
25 + // Only set header if it hasn't been set in config
26 + // See https://github.com/mzabriskie/axios/issues/69
27 + if (!headers['User-Agent'] && !headers['user-agent']) {
28 + headers['User-Agent'] = 'axios/' + pkg.version;
29 + }
30 +
31 + if (data && !utils.isStream(data)) {
32 + if (Buffer.isBuffer(data)) {
33 + // Nothing to do...
34 + } else if (utils.isArrayBuffer(data)) {
35 + data = new Buffer(new Uint8Array(data));
36 + } else if (utils.isString(data)) {
37 + data = new Buffer(data, 'utf-8');
38 + } else {
39 + return reject(createError(
40 + 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
41 + config
42 + ));
43 + }
44 +
45 + // Add Content-Length header if data exists
46 + headers['Content-Length'] = data.length;
47 + }
48 +
49 + // HTTP basic authentication
50 + var auth = undefined;
51 + if (config.auth) {
52 + var username = config.auth.username || '';
53 + var password = config.auth.password || '';
54 + auth = username + ':' + password;
55 + }
56 +
57 + // Parse url
58 + var parsed = url.parse(config.url);
59 + var protocol = parsed.protocol || 'http:';
60 +
61 + if (!auth && parsed.auth) {
62 + var urlAuth = parsed.auth.split(':');
63 + var urlUsername = urlAuth[0] || '';
64 + var urlPassword = urlAuth[1] || '';
65 + auth = urlUsername + ':' + urlPassword;
66 + }
67 +
68 + if (auth) {
69 + delete headers.Authorization;
70 + }
71 +
72 + var isHttps = protocol === 'https:';
73 + var agent = isHttps ? config.httpsAgent : config.httpAgent;
74 +
75 + var options = {
76 + hostname: parsed.hostname,
77 + port: parsed.port,
78 + path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
79 + method: config.method,
80 + headers: headers,
81 + agent: agent,
82 + auth: auth
83 + };
84 +
85 + var proxy = config.proxy;
86 + if (!proxy) {
87 + var proxyEnv = protocol.slice(0, -1) + '_proxy';
88 + var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
89 + if (proxyUrl) {
90 + var parsedProxyUrl = url.parse(proxyUrl);
91 + proxy = {
92 + host: parsedProxyUrl.hostname,
93 + port: parsedProxyUrl.port
94 + };
95 +
96 + if (parsedProxyUrl.auth) {
97 + var proxyUrlAuth = parsedProxyUrl.auth.split(':');
98 + proxy.auth = {
99 + username: proxyUrlAuth[0],
100 + password: proxyUrlAuth[1]
101 + };
102 + }
103 + }
104 + }
105 +
106 + if (proxy) {
107 + options.hostname = proxy.host;
108 + options.host = proxy.host;
109 + options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
110 + options.port = proxy.port;
111 + options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path;
112 +
113 + // Basic proxy authorization
114 + if (proxy.auth) {
115 + var base64 = new Buffer(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
116 + options.headers['Proxy-Authorization'] = 'Basic ' + base64;
117 + }
118 + }
119 +
120 + var transport;
121 + if (config.maxRedirects === 0) {
122 + transport = isHttps ? https : http;
123 + } else {
124 + if (config.maxRedirects) {
125 + options.maxRedirects = config.maxRedirects;
126 + }
127 + transport = isHttps ? httpsFollow : httpFollow;
128 + }
129 +
130 + // Create the request
131 + var req = transport.request(options, function handleResponse(res) {
132 + if (aborted) return;
133 +
134 + // Response has been received so kill timer that handles request timeout
135 + clearTimeout(timer);
136 + timer = null;
137 +
138 + // uncompress the response body transparently if required
139 + var stream = res;
140 + switch (res.headers['content-encoding']) {
141 + /*eslint default-case:0*/
142 + case 'gzip':
143 + case 'compress':
144 + case 'deflate':
145 + // add the unzipper to the body stream processing pipeline
146 + stream = stream.pipe(zlib.createUnzip());
147 +
148 + // remove the content-encoding in order to not confuse downstream operations
149 + delete res.headers['content-encoding'];
150 + break;
151 + }
152 +
153 + // return the last request in case of redirects
154 + var lastRequest = res.req || req;
155 +
156 + var response = {
157 + status: res.statusCode,
158 + statusText: res.statusMessage,
159 + headers: res.headers,
160 + config: config,
161 + request: lastRequest
162 + };
163 +
164 + if (config.responseType === 'stream') {
165 + response.data = stream;
166 + settle(resolve, reject, response);
167 + } else {
168 + var responseBuffer = [];
169 + stream.on('data', function handleStreamData(chunk) {
170 + responseBuffer.push(chunk);
171 +
172 + // make sure the content length is not over the maxContentLength if specified
173 + if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
174 + reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
175 + config, null, lastRequest));
176 + }
177 + });
178 +
179 + stream.on('error', function handleStreamError(err) {
180 + if (aborted) return;
181 + reject(enhanceError(err, config, null, lastRequest));
182 + });
183 +
184 + stream.on('end', function handleStreamEnd() {
185 + var responseData = Buffer.concat(responseBuffer);
186 + if (config.responseType !== 'arraybuffer') {
187 + responseData = responseData.toString('utf8');
188 + }
189 +
190 + response.data = responseData;
191 + settle(resolve, reject, response);
192 + });
193 + }
194 + });
195 +
196 + // Handle errors
197 + req.on('error', function handleRequestError(err) {
198 + if (aborted) return;
199 + reject(enhanceError(err, config, null, req));
200 + });
201 +
202 + // Handle request timeout
203 + if (config.timeout && !timer) {
204 + timer = setTimeout(function handleRequestTimeout() {
205 + req.abort();
206 + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
207 + aborted = true;
208 + }, config.timeout);
209 + }
210 +
211 + if (config.cancelToken) {
212 + // Handle cancellation
213 + config.cancelToken.promise.then(function onCanceled(cancel) {
214 + if (aborted) {
215 + return;
216 + }
217 +
218 + req.abort();
219 + reject(cancel);
220 + aborted = true;
221 + });
222 + }
223 +
224 + // Send the request
225 + if (utils.isStream(data)) {
226 + data.pipe(req);
227 + } else {
228 + req.end(data);
229 + }
230 + });
231 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +var settle = require('./../core/settle');
5 +var buildURL = require('./../helpers/buildURL');
6 +var parseHeaders = require('./../helpers/parseHeaders');
7 +var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
8 +var createError = require('../core/createError');
9 +var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
10 +
11 +module.exports = function xhrAdapter(config) {
12 + return new Promise(function dispatchXhrRequest(resolve, reject) {
13 + var requestData = config.data;
14 + var requestHeaders = config.headers;
15 +
16 + if (utils.isFormData(requestData)) {
17 + delete requestHeaders['Content-Type']; // Let the browser set it
18 + }
19 +
20 + 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 +
38 + // HTTP basic authentication
39 + if (config.auth) {
40 + var username = config.auth.username || '';
41 + var password = config.auth.password || '';
42 + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
43 + }
44 +
45 + request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
46 +
47 + // Set the request timeout in MS
48 + request.timeout = config.timeout;
49 +
50 + // Listen for ready state
51 + request[loadEvent] = function handleLoad() {
52 + if (!request || (request.readyState !== 4 && !xDomain)) {
53 + return;
54 + }
55 +
56 + // The request errored out and we didn't get a response, this will be
57 + // handled by onerror instead
58 + // With one exception: request that using file: protocol, most browsers
59 + // will return status as 0 even though it's a successful request
60 + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
61 + return;
62 + }
63 +
64 + // Prepare the response
65 + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
66 + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
67 + var response = {
68 + data: responseData,
69 + // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
70 + status: request.status === 1223 ? 204 : request.status,
71 + statusText: request.status === 1223 ? 'No Content' : request.statusText,
72 + headers: responseHeaders,
73 + config: config,
74 + request: request
75 + };
76 +
77 + settle(resolve, reject, response);
78 +
79 + // Clean up request
80 + request = null;
81 + };
82 +
83 + // Handle low level network errors
84 + request.onerror = function handleError() {
85 + // Real errors are hidden from us by the browser
86 + // onerror should only fire if it's a network error
87 + reject(createError('Network Error', config, null, request));
88 +
89 + // Clean up request
90 + request = null;
91 + };
92 +
93 + // Handle timeout
94 + request.ontimeout = function handleTimeout() {
95 + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
96 + request));
97 +
98 + // Clean up request
99 + request = null;
100 + };
101 +
102 + // Add xsrf header
103 + // This is only done if running in a standard browser environment.
104 + // Specifically not if we're in a web worker, or react-native.
105 + if (utils.isStandardBrowserEnv()) {
106 + var cookies = require('./../helpers/cookies');
107 +
108 + // Add xsrf header
109 + var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
110 + cookies.read(config.xsrfCookieName) :
111 + undefined;
112 +
113 + if (xsrfValue) {
114 + requestHeaders[config.xsrfHeaderName] = xsrfValue;
115 + }
116 + }
117 +
118 + // Add headers to the request
119 + if ('setRequestHeader' in request) {
120 + utils.forEach(requestHeaders, function setRequestHeader(val, key) {
121 + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
122 + // Remove Content-Type if data is undefined
123 + delete requestHeaders[key];
124 + } else {
125 + // Otherwise add header to the request
126 + request.setRequestHeader(key, val);
127 + }
128 + });
129 + }
130 +
131 + // Add withCredentials to request if needed
132 + if (config.withCredentials) {
133 + request.withCredentials = true;
134 + }
135 +
136 + // Add responseType to request if needed
137 + if (config.responseType) {
138 + try {
139 + request.responseType = config.responseType;
140 + } catch (e) {
141 + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
142 + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
143 + if (config.responseType !== 'json') {
144 + throw e;
145 + }
146 + }
147 + }
148 +
149 + // Handle progress if needed
150 + if (typeof config.onDownloadProgress === 'function') {
151 + request.addEventListener('progress', config.onDownloadProgress);
152 + }
153 +
154 + // Not all browsers support upload events
155 + if (typeof config.onUploadProgress === 'function' && request.upload) {
156 + request.upload.addEventListener('progress', config.onUploadProgress);
157 + }
158 +
159 + if (config.cancelToken) {
160 + // Handle cancellation
161 + config.cancelToken.promise.then(function onCanceled(cancel) {
162 + if (!request) {
163 + return;
164 + }
165 +
166 + request.abort();
167 + reject(cancel);
168 + // Clean up request
169 + request = null;
170 + });
171 + }
172 +
173 + if (requestData === undefined) {
174 + requestData = null;
175 + }
176 +
177 + // Send the request
178 + request.send(requestData);
179 + });
180 +};
1 +'use strict';
2 +
3 +var utils = require('./utils');
4 +var bind = require('./helpers/bind');
5 +var Axios = require('./core/Axios');
6 +var defaults = require('./defaults');
7 +
8 +/**
9 + * Create an instance of Axios
10 + *
11 + * @param {Object} defaultConfig The default config for the instance
12 + * @return {Axios} A new instance of Axios
13 + */
14 +function createInstance(defaultConfig) {
15 + var context = new Axios(defaultConfig);
16 + var instance = bind(Axios.prototype.request, context);
17 +
18 + // Copy axios.prototype to instance
19 + utils.extend(instance, Axios.prototype, context);
20 +
21 + // Copy context to instance
22 + utils.extend(instance, context);
23 +
24 + return instance;
25 +}
26 +
27 +// Create the default instance to be exported
28 +var axios = createInstance(defaults);
29 +
30 +// Expose Axios class to allow class inheritance
31 +axios.Axios = Axios;
32 +
33 +// Factory for creating new instances
34 +axios.create = function create(instanceConfig) {
35 + return createInstance(utils.merge(defaults, instanceConfig));
36 +};
37 +
38 +// Expose Cancel & CancelToken
39 +axios.Cancel = require('./cancel/Cancel');
40 +axios.CancelToken = require('./cancel/CancelToken');
41 +axios.isCancel = require('./cancel/isCancel');
42 +
43 +// Expose all/spread
44 +axios.all = function all(promises) {
45 + return Promise.all(promises);
46 +};
47 +axios.spread = require('./helpers/spread');
48 +
49 +module.exports = axios;
50 +
51 +// Allow use of default import syntax in TypeScript
52 +module.exports.default = axios;
1 +'use strict';
2 +
3 +/**
4 + * A `Cancel` is an object that is thrown when an operation is canceled.
5 + *
6 + * @class
7 + * @param {string=} message The message.
8 + */
9 +function Cancel(message) {
10 + this.message = message;
11 +}
12 +
13 +Cancel.prototype.toString = function toString() {
14 + return 'Cancel' + (this.message ? ': ' + this.message : '');
15 +};
16 +
17 +Cancel.prototype.__CANCEL__ = true;
18 +
19 +module.exports = Cancel;
1 +'use strict';
2 +
3 +var Cancel = require('./Cancel');
4 +
5 +/**
6 + * A `CancelToken` is an object that can be used to request cancellation of an operation.
7 + *
8 + * @class
9 + * @param {Function} executor The executor function.
10 + */
11 +function CancelToken(executor) {
12 + if (typeof executor !== 'function') {
13 + throw new TypeError('executor must be a function.');
14 + }
15 +
16 + var resolvePromise;
17 + this.promise = new Promise(function promiseExecutor(resolve) {
18 + resolvePromise = resolve;
19 + });
20 +
21 + var token = this;
22 + executor(function cancel(message) {
23 + if (token.reason) {
24 + // Cancellation has already been requested
25 + return;
26 + }
27 +
28 + token.reason = new Cancel(message);
29 + resolvePromise(token.reason);
30 + });
31 +}
32 +
33 +/**
34 + * Throws a `Cancel` if cancellation has been requested.
35 + */
36 +CancelToken.prototype.throwIfRequested = function throwIfRequested() {
37 + if (this.reason) {
38 + throw this.reason;
39 + }
40 +};
41 +
42 +/**
43 + * Returns an object that contains a new `CancelToken` and a function that, when called,
44 + * cancels the `CancelToken`.
45 + */
46 +CancelToken.source = function source() {
47 + var cancel;
48 + var token = new CancelToken(function executor(c) {
49 + cancel = c;
50 + });
51 + return {
52 + token: token,
53 + cancel: cancel
54 + };
55 +};
56 +
57 +module.exports = CancelToken;
1 +'use strict';
2 +
3 +module.exports = function isCancel(value) {
4 + return !!(value && value.__CANCEL__);
5 +};
1 +'use strict';
2 +
3 +var defaults = require('./../defaults');
4 +var utils = require('./../utils');
5 +var InterceptorManager = require('./InterceptorManager');
6 +var dispatchRequest = require('./dispatchRequest');
7 +var isAbsoluteURL = require('./../helpers/isAbsoluteURL');
8 +var combineURLs = require('./../helpers/combineURLs');
9 +
10 +/**
11 + * Create a new instance of Axios
12 + *
13 + * @param {Object} instanceConfig The default config for the instance
14 + */
15 +function Axios(instanceConfig) {
16 + this.defaults = instanceConfig;
17 + this.interceptors = {
18 + request: new InterceptorManager(),
19 + response: new InterceptorManager()
20 + };
21 +}
22 +
23 +/**
24 + * Dispatch a request
25 + *
26 + * @param {Object} config The config specific for this request (merged with this.defaults)
27 + */
28 +Axios.prototype.request = function request(config) {
29 + /*eslint no-param-reassign:0*/
30 + // Allow for axios('example/url'[, config]) a la fetch API
31 + if (typeof config === 'string') {
32 + config = utils.merge({
33 + url: arguments[0]
34 + }, arguments[1]);
35 + }
36 +
37 + config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
38 + config.method = config.method.toLowerCase();
39 +
40 + // Support baseURL config
41 + if (config.baseURL && !isAbsoluteURL(config.url)) {
42 + config.url = combineURLs(config.baseURL, config.url);
43 + }
44 +
45 + // Hook up interceptors middleware
46 + var chain = [dispatchRequest, undefined];
47 + var promise = Promise.resolve(config);
48 +
49 + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
50 + chain.unshift(interceptor.fulfilled, interceptor.rejected);
51 + });
52 +
53 + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
54 + chain.push(interceptor.fulfilled, interceptor.rejected);
55 + });
56 +
57 + while (chain.length) {
58 + promise = promise.then(chain.shift(), chain.shift());
59 + }
60 +
61 + return promise;
62 +};
63 +
64 +// Provide aliases for supported request methods
65 +utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
66 + /*eslint func-names:0*/
67 + Axios.prototype[method] = function(url, config) {
68 + return this.request(utils.merge(config || {}, {
69 + method: method,
70 + url: url
71 + }));
72 + };
73 +});
74 +
75 +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
76 + /*eslint func-names:0*/
77 + Axios.prototype[method] = function(url, data, config) {
78 + return this.request(utils.merge(config || {}, {
79 + method: method,
80 + url: url,
81 + data: data
82 + }));
83 + };
84 +});
85 +
86 +module.exports = Axios;
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +function InterceptorManager() {
6 + this.handlers = [];
7 +}
8 +
9 +/**
10 + * Add a new interceptor to the stack
11 + *
12 + * @param {Function} fulfilled The function to handle `then` for a `Promise`
13 + * @param {Function} rejected The function to handle `reject` for a `Promise`
14 + *
15 + * @return {Number} An ID used to remove interceptor later
16 + */
17 +InterceptorManager.prototype.use = function use(fulfilled, rejected) {
18 + this.handlers.push({
19 + fulfilled: fulfilled,
20 + rejected: rejected
21 + });
22 + return this.handlers.length - 1;
23 +};
24 +
25 +/**
26 + * Remove an interceptor from the stack
27 + *
28 + * @param {Number} id The ID that was returned by `use`
29 + */
30 +InterceptorManager.prototype.eject = function eject(id) {
31 + if (this.handlers[id]) {
32 + this.handlers[id] = null;
33 + }
34 +};
35 +
36 +/**
37 + * Iterate over all the registered interceptors
38 + *
39 + * This method is particularly useful for skipping over any
40 + * interceptors that may have become `null` calling `eject`.
41 + *
42 + * @param {Function} fn The function to call for each interceptor
43 + */
44 +InterceptorManager.prototype.forEach = function forEach(fn) {
45 + utils.forEach(this.handlers, function forEachHandler(h) {
46 + if (h !== null) {
47 + fn(h);
48 + }
49 + });
50 +};
51 +
52 +module.exports = InterceptorManager;
1 +# axios // core
2 +
3 +The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
4 +
5 +- Dispatching requests
6 +- Managing interceptors
7 +- Handling config
1 +'use strict';
2 +
3 +var enhanceError = require('./enhanceError');
4 +
5 +/**
6 + * Create an Error with the specified message, config, error code, request and response.
7 + *
8 + * @param {string} message The error message.
9 + * @param {Object} config The config.
10 + * @param {string} [code] The error code (for example, 'ECONNABORTED').
11 + * @param {Object} [request] The request.
12 + * @param {Object} [response] The response.
13 + * @returns {Error} The created error.
14 + */
15 +module.exports = function createError(message, config, code, request, response) {
16 + var error = new Error(message);
17 + return enhanceError(error, config, code, request, response);
18 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +var transformData = require('./transformData');
5 +var isCancel = require('../cancel/isCancel');
6 +var defaults = require('../defaults');
7 +
8 +/**
9 + * Throws a `Cancel` if cancellation has been requested.
10 + */
11 +function throwIfCancellationRequested(config) {
12 + if (config.cancelToken) {
13 + config.cancelToken.throwIfRequested();
14 + }
15 +}
16 +
17 +/**
18 + * Dispatch a request to the server using the configured adapter.
19 + *
20 + * @param {object} config The config that is to be used for the request
21 + * @returns {Promise} The Promise to be fulfilled
22 + */
23 +module.exports = function dispatchRequest(config) {
24 + throwIfCancellationRequested(config);
25 +
26 + // Ensure headers exist
27 + config.headers = config.headers || {};
28 +
29 + // Transform request data
30 + config.data = transformData(
31 + config.data,
32 + config.headers,
33 + config.transformRequest
34 + );
35 +
36 + // Flatten headers
37 + config.headers = utils.merge(
38 + config.headers.common || {},
39 + config.headers[config.method] || {},
40 + config.headers || {}
41 + );
42 +
43 + utils.forEach(
44 + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
45 + function cleanHeaderConfig(method) {
46 + delete config.headers[method];
47 + }
48 + );
49 +
50 + var adapter = config.adapter || defaults.adapter;
51 +
52 + return adapter(config).then(function onAdapterResolution(response) {
53 + throwIfCancellationRequested(config);
54 +
55 + // Transform response data
56 + response.data = transformData(
57 + response.data,
58 + response.headers,
59 + config.transformResponse
60 + );
61 +
62 + return response;
63 + }, function onAdapterRejection(reason) {
64 + if (!isCancel(reason)) {
65 + throwIfCancellationRequested(config);
66 +
67 + // Transform response data
68 + if (reason && reason.response) {
69 + reason.response.data = transformData(
70 + reason.response.data,
71 + reason.response.headers,
72 + config.transformResponse
73 + );
74 + }
75 + }
76 +
77 + return Promise.reject(reason);
78 + });
79 +};
1 +'use strict';
2 +
3 +/**
4 + * Update an Error with the specified config, error code, and response.
5 + *
6 + * @param {Error} error The error to update.
7 + * @param {Object} config The config.
8 + * @param {string} [code] The error code (for example, 'ECONNABORTED').
9 + * @param {Object} [request] The request.
10 + * @param {Object} [response] The response.
11 + * @returns {Error} The error.
12 + */
13 +module.exports = function enhanceError(error, config, code, request, response) {
14 + error.config = config;
15 + if (code) {
16 + error.code = code;
17 + }
18 + error.request = request;
19 + error.response = response;
20 + return error;
21 +};
1 +'use strict';
2 +
3 +var createError = require('./createError');
4 +
5 +/**
6 + * Resolve or reject a Promise based on response status.
7 + *
8 + * @param {Function} resolve A function that resolves the promise.
9 + * @param {Function} reject A function that rejects the promise.
10 + * @param {object} response The response.
11 + */
12 +module.exports = function settle(resolve, reject, response) {
13 + var validateStatus = response.config.validateStatus;
14 + // Note: status is not exposed by XDomainRequest
15 + if (!response.status || !validateStatus || validateStatus(response.status)) {
16 + resolve(response);
17 + } else {
18 + reject(createError(
19 + 'Request failed with status code ' + response.status,
20 + response.config,
21 + null,
22 + response.request,
23 + response
24 + ));
25 + }
26 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +/**
6 + * Transform the data for a request or a response
7 + *
8 + * @param {Object|String} data The data to be transformed
9 + * @param {Array} headers The headers for the request or response
10 + * @param {Array|Function} fns A single function or Array of functions
11 + * @returns {*} The resulting transformed data
12 + */
13 +module.exports = function transformData(data, headers, fns) {
14 + /*eslint no-param-reassign:0*/
15 + utils.forEach(fns, function transform(fn) {
16 + data = fn(data, headers);
17 + });
18 +
19 + return data;
20 +};
1 +'use strict';
2 +
3 +var utils = require('./utils');
4 +var normalizeHeaderName = require('./helpers/normalizeHeaderName');
5 +
6 +var DEFAULT_CONTENT_TYPE = {
7 + 'Content-Type': 'application/x-www-form-urlencoded'
8 +};
9 +
10 +function setContentTypeIfUnset(headers, value) {
11 + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
12 + headers['Content-Type'] = value;
13 + }
14 +}
15 +
16 +function getDefaultAdapter() {
17 + var adapter;
18 + if (typeof XMLHttpRequest !== 'undefined') {
19 + // For browsers use XHR adapter
20 + adapter = require('./adapters/xhr');
21 + } else if (typeof process !== 'undefined') {
22 + // For node use HTTP adapter
23 + adapter = require('./adapters/http');
24 + }
25 + return adapter;
26 +}
27 +
28 +var defaults = {
29 + adapter: getDefaultAdapter(),
30 +
31 + transformRequest: [function transformRequest(data, headers) {
32 + normalizeHeaderName(headers, 'Content-Type');
33 + if (utils.isFormData(data) ||
34 + utils.isArrayBuffer(data) ||
35 + utils.isBuffer(data) ||
36 + utils.isStream(data) ||
37 + utils.isFile(data) ||
38 + utils.isBlob(data)
39 + ) {
40 + return data;
41 + }
42 + if (utils.isArrayBufferView(data)) {
43 + return data.buffer;
44 + }
45 + if (utils.isURLSearchParams(data)) {
46 + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
47 + return data.toString();
48 + }
49 + if (utils.isObject(data)) {
50 + setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
51 + return JSON.stringify(data);
52 + }
53 + return data;
54 + }],
55 +
56 + transformResponse: [function transformResponse(data) {
57 + /*eslint no-param-reassign:0*/
58 + if (typeof data === 'string') {
59 + try {
60 + data = JSON.parse(data);
61 + } catch (e) { /* Ignore */ }
62 + }
63 + return data;
64 + }],
65 +
66 + timeout: 0,
67 +
68 + xsrfCookieName: 'XSRF-TOKEN',
69 + xsrfHeaderName: 'X-XSRF-TOKEN',
70 +
71 + maxContentLength: -1,
72 +
73 + validateStatus: function validateStatus(status) {
74 + return status >= 200 && status < 300;
75 + }
76 +};
77 +
78 +defaults.headers = {
79 + common: {
80 + 'Accept': 'application/json, text/plain, */*'
81 + }
82 +};
83 +
84 +utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
85 + defaults.headers[method] = {};
86 +});
87 +
88 +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
89 + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
90 +});
91 +
92 +module.exports = defaults;
1 +# axios // helpers
2 +
3 +The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like:
4 +
5 +- Browser polyfills
6 +- Managing cookies
7 +- Parsing HTTP headers
1 +'use strict';
2 +
3 +module.exports = function bind(fn, thisArg) {
4 + return function wrap() {
5 + var args = new Array(arguments.length);
6 + for (var i = 0; i < args.length; i++) {
7 + args[i] = arguments[i];
8 + }
9 + return fn.apply(thisArg, args);
10 + };
11 +};
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;
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +function encode(val) {
6 + return encodeURIComponent(val).
7 + replace(/%40/gi, '@').
8 + replace(/%3A/gi, ':').
9 + replace(/%24/g, '$').
10 + replace(/%2C/gi, ',').
11 + replace(/%20/g, '+').
12 + replace(/%5B/gi, '[').
13 + replace(/%5D/gi, ']');
14 +}
15 +
16 +/**
17 + * Build a URL by appending params to the end
18 + *
19 + * @param {string} url The base of the url (e.g., http://www.google.com)
20 + * @param {object} [params] The params to be appended
21 + * @returns {string} The formatted url
22 + */
23 +module.exports = function buildURL(url, params, paramsSerializer) {
24 + /*eslint no-param-reassign:0*/
25 + if (!params) {
26 + return url;
27 + }
28 +
29 + var serializedParams;
30 + if (paramsSerializer) {
31 + serializedParams = paramsSerializer(params);
32 + } else if (utils.isURLSearchParams(params)) {
33 + serializedParams = params.toString();
34 + } else {
35 + var parts = [];
36 +
37 + utils.forEach(params, function serialize(val, key) {
38 + if (val === null || typeof val === 'undefined') {
39 + return;
40 + }
41 +
42 + if (utils.isArray(val)) {
43 + key = key + '[]';
44 + }
45 +
46 + if (!utils.isArray(val)) {
47 + val = [val];
48 + }
49 +
50 + utils.forEach(val, function parseValue(v) {
51 + if (utils.isDate(v)) {
52 + v = v.toISOString();
53 + } else if (utils.isObject(v)) {
54 + v = JSON.stringify(v);
55 + }
56 + parts.push(encode(key) + '=' + encode(v));
57 + });
58 + });
59 +
60 + serializedParams = parts.join('&');
61 + }
62 +
63 + if (serializedParams) {
64 + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
65 + }
66 +
67 + return url;
68 +};
1 +'use strict';
2 +
3 +/**
4 + * Creates a new URL by combining the specified URLs
5 + *
6 + * @param {string} baseURL The base URL
7 + * @param {string} relativeURL The relative URL
8 + * @returns {string} The combined URL
9 + */
10 +module.exports = function combineURLs(baseURL, relativeURL) {
11 + return relativeURL
12 + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
13 + : baseURL;
14 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +module.exports = (
6 + utils.isStandardBrowserEnv() ?
7 +
8 + // Standard browser envs support document.cookie
9 + (function standardBrowserEnv() {
10 + return {
11 + write: function write(name, value, expires, path, domain, secure) {
12 + var cookie = [];
13 + cookie.push(name + '=' + encodeURIComponent(value));
14 +
15 + if (utils.isNumber(expires)) {
16 + cookie.push('expires=' + new Date(expires).toGMTString());
17 + }
18 +
19 + if (utils.isString(path)) {
20 + cookie.push('path=' + path);
21 + }
22 +
23 + if (utils.isString(domain)) {
24 + cookie.push('domain=' + domain);
25 + }
26 +
27 + if (secure === true) {
28 + cookie.push('secure');
29 + }
30 +
31 + document.cookie = cookie.join('; ');
32 + },
33 +
34 + read: function read(name) {
35 + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36 + return (match ? decodeURIComponent(match[3]) : null);
37 + },
38 +
39 + remove: function remove(name) {
40 + this.write(name, '', Date.now() - 86400000);
41 + }
42 + };
43 + })() :
44 +
45 + // Non standard browser env (web workers, react-native) lack needed support.
46 + (function nonStandardBrowserEnv() {
47 + return {
48 + write: function write() {},
49 + read: function read() { return null; },
50 + remove: function remove() {}
51 + };
52 + })()
53 +);
1 +'use strict';
2 +
3 +/*eslint no-console:0*/
4 +
5 +/**
6 + * Supply a warning to the developer that a method they are using
7 + * has been deprecated.
8 + *
9 + * @param {string} method The name of the deprecated method
10 + * @param {string} [instead] The alternate method to use if applicable
11 + * @param {string} [docs] The documentation URL to get further details
12 + */
13 +module.exports = function deprecatedMethod(method, instead, docs) {
14 + try {
15 + console.warn(
16 + 'DEPRECATED method `' + method + '`.' +
17 + (instead ? ' Use `' + instead + '` instead.' : '') +
18 + ' This method will be removed in a future release.');
19 +
20 + if (docs) {
21 + console.warn('For more information about usage see ' + docs);
22 + }
23 + } catch (e) { /* Ignore */ }
24 +};
1 +'use strict';
2 +
3 +/**
4 + * Determines whether the specified URL is absolute
5 + *
6 + * @param {string} url The URL to test
7 + * @returns {boolean} True if the specified URL is absolute, otherwise false
8 + */
9 +module.exports = function isAbsoluteURL(url) {
10 + // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
11 + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
12 + // by any combination of letters, digits, plus, period, or hyphen.
13 + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
14 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +module.exports = (
6 + utils.isStandardBrowserEnv() ?
7 +
8 + // Standard browser envs have full support of the APIs needed to test
9 + // whether the request URL is of the same origin as current location.
10 + (function standardBrowserEnv() {
11 + var msie = /(msie|trident)/i.test(navigator.userAgent);
12 + var urlParsingNode = document.createElement('a');
13 + var originURL;
14 +
15 + /**
16 + * Parse a URL to discover it's components
17 + *
18 + * @param {String} url The URL to be parsed
19 + * @returns {Object}
20 + */
21 + function resolveURL(url) {
22 + var href = url;
23 +
24 + if (msie) {
25 + // IE needs attribute set twice to normalize properties
26 + urlParsingNode.setAttribute('href', href);
27 + href = urlParsingNode.href;
28 + }
29 +
30 + urlParsingNode.setAttribute('href', href);
31 +
32 + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33 + return {
34 + href: urlParsingNode.href,
35 + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36 + host: urlParsingNode.host,
37 + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38 + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39 + hostname: urlParsingNode.hostname,
40 + port: urlParsingNode.port,
41 + pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42 + urlParsingNode.pathname :
43 + '/' + urlParsingNode.pathname
44 + };
45 + }
46 +
47 + originURL = resolveURL(window.location.href);
48 +
49 + /**
50 + * Determine if a URL shares the same origin as the current location
51 + *
52 + * @param {String} requestURL The URL to test
53 + * @returns {boolean} True if URL shares the same origin, otherwise false
54 + */
55 + return function isURLSameOrigin(requestURL) {
56 + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57 + return (parsed.protocol === originURL.protocol &&
58 + parsed.host === originURL.host);
59 + };
60 + })() :
61 +
62 + // Non standard browser envs (web workers, react-native) lack needed support.
63 + (function nonStandardBrowserEnv() {
64 + return function isURLSameOrigin() {
65 + return true;
66 + };
67 + })()
68 +);
1 +'use strict';
2 +
3 +var utils = require('../utils');
4 +
5 +module.exports = function normalizeHeaderName(headers, normalizedName) {
6 + utils.forEach(headers, function processHeader(value, name) {
7 + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
8 + headers[normalizedName] = value;
9 + delete headers[name];
10 + }
11 + });
12 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +/**
6 + * Parse headers into an object
7 + *
8 + * ```
9 + * Date: Wed, 27 Aug 2014 08:58:49 GMT
10 + * Content-Type: application/json
11 + * Connection: keep-alive
12 + * Transfer-Encoding: chunked
13 + * ```
14 + *
15 + * @param {String} headers Headers needing to be parsed
16 + * @returns {Object} Headers parsed into an object
17 + */
18 +module.exports = function parseHeaders(headers) {
19 + var parsed = {};
20 + var key;
21 + var val;
22 + var i;
23 +
24 + if (!headers) { return parsed; }
25 +
26 + utils.forEach(headers.split('\n'), function parser(line) {
27 + i = line.indexOf(':');
28 + key = utils.trim(line.substr(0, i)).toLowerCase();
29 + val = utils.trim(line.substr(i + 1));
30 +
31 + if (key) {
32 + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
33 + }
34 + });
35 +
36 + return parsed;
37 +};
1 +'use strict';
2 +
3 +/**
4 + * Syntactic sugar for invoking a function and expanding an array for arguments.
5 + *
6 + * Common use case would be to use `Function.prototype.apply`.
7 + *
8 + * ```js
9 + * function f(x, y, z) {}
10 + * var args = [1, 2, 3];
11 + * f.apply(null, args);
12 + * ```
13 + *
14 + * With `spread` this example can be re-written.
15 + *
16 + * ```js
17 + * spread(function(x, y, z) {})([1, 2, 3]);
18 + * ```
19 + *
20 + * @param {Function} callback
21 + * @returns {Function}
22 + */
23 +module.exports = function spread(callback) {
24 + return function wrap(arr) {
25 + return callback.apply(null, arr);
26 + };
27 +};
1 +'use strict';
2 +
3 +var bind = require('./helpers/bind');
4 +var isBuffer = require('is-buffer');
5 +
6 +/*global toString:true*/
7 +
8 +// utils is a library of generic helper functions non-specific to axios
9 +
10 +var toString = Object.prototype.toString;
11 +
12 +/**
13 + * Determine if a value is an Array
14 + *
15 + * @param {Object} val The value to test
16 + * @returns {boolean} True if value is an Array, otherwise false
17 + */
18 +function isArray(val) {
19 + return toString.call(val) === '[object Array]';
20 +}
21 +
22 +/**
23 + * Determine if a value is an ArrayBuffer
24 + *
25 + * @param {Object} val The value to test
26 + * @returns {boolean} True if value is an ArrayBuffer, otherwise false
27 + */
28 +function isArrayBuffer(val) {
29 + return toString.call(val) === '[object ArrayBuffer]';
30 +}
31 +
32 +/**
33 + * Determine if a value is a FormData
34 + *
35 + * @param {Object} val The value to test
36 + * @returns {boolean} True if value is an FormData, otherwise false
37 + */
38 +function isFormData(val) {
39 + return (typeof FormData !== 'undefined') && (val instanceof FormData);
40 +}
41 +
42 +/**
43 + * Determine if a value is a view on an ArrayBuffer
44 + *
45 + * @param {Object} val The value to test
46 + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
47 + */
48 +function isArrayBufferView(val) {
49 + var result;
50 + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
51 + result = ArrayBuffer.isView(val);
52 + } else {
53 + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
54 + }
55 + return result;
56 +}
57 +
58 +/**
59 + * Determine if a value is a String
60 + *
61 + * @param {Object} val The value to test
62 + * @returns {boolean} True if value is a String, otherwise false
63 + */
64 +function isString(val) {
65 + return typeof val === 'string';
66 +}
67 +
68 +/**
69 + * Determine if a value is a Number
70 + *
71 + * @param {Object} val The value to test
72 + * @returns {boolean} True if value is a Number, otherwise false
73 + */
74 +function isNumber(val) {
75 + return typeof val === 'number';
76 +}
77 +
78 +/**
79 + * Determine if a value is undefined
80 + *
81 + * @param {Object} val The value to test
82 + * @returns {boolean} True if the value is undefined, otherwise false
83 + */
84 +function isUndefined(val) {
85 + return typeof val === 'undefined';
86 +}
87 +
88 +/**
89 + * Determine if a value is an Object
90 + *
91 + * @param {Object} val The value to test
92 + * @returns {boolean} True if value is an Object, otherwise false
93 + */
94 +function isObject(val) {
95 + return val !== null && typeof val === 'object';
96 +}
97 +
98 +/**
99 + * Determine if a value is a Date
100 + *
101 + * @param {Object} val The value to test
102 + * @returns {boolean} True if value is a Date, otherwise false
103 + */
104 +function isDate(val) {
105 + return toString.call(val) === '[object Date]';
106 +}
107 +
108 +/**
109 + * Determine if a value is a File
110 + *
111 + * @param {Object} val The value to test
112 + * @returns {boolean} True if value is a File, otherwise false
113 + */
114 +function isFile(val) {
115 + return toString.call(val) === '[object File]';
116 +}
117 +
118 +/**
119 + * Determine if a value is a Blob
120 + *
121 + * @param {Object} val The value to test
122 + * @returns {boolean} True if value is a Blob, otherwise false
123 + */
124 +function isBlob(val) {
125 + return toString.call(val) === '[object Blob]';
126 +}
127 +
128 +/**
129 + * Determine if a value is a Function
130 + *
131 + * @param {Object} val The value to test
132 + * @returns {boolean} True if value is a Function, otherwise false
133 + */
134 +function isFunction(val) {
135 + return toString.call(val) === '[object Function]';
136 +}
137 +
138 +/**
139 + * Determine if a value is a Stream
140 + *
141 + * @param {Object} val The value to test
142 + * @returns {boolean} True if value is a Stream, otherwise false
143 + */
144 +function isStream(val) {
145 + return isObject(val) && isFunction(val.pipe);
146 +}
147 +
148 +/**
149 + * Determine if a value is a URLSearchParams object
150 + *
151 + * @param {Object} val The value to test
152 + * @returns {boolean} True if value is a URLSearchParams object, otherwise false
153 + */
154 +function isURLSearchParams(val) {
155 + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
156 +}
157 +
158 +/**
159 + * Trim excess whitespace off the beginning and end of a string
160 + *
161 + * @param {String} str The String to trim
162 + * @returns {String} The String freed of excess whitespace
163 + */
164 +function trim(str) {
165 + return str.replace(/^\s*/, '').replace(/\s*$/, '');
166 +}
167 +
168 +/**
169 + * Determine if we're running in a standard browser environment
170 + *
171 + * This allows axios to run in a web worker, and react-native.
172 + * Both environments support XMLHttpRequest, but not fully standard globals.
173 + *
174 + * web workers:
175 + * typeof window -> undefined
176 + * typeof document -> undefined
177 + *
178 + * react-native:
179 + * navigator.product -> 'ReactNative'
180 + */
181 +function isStandardBrowserEnv() {
182 + if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
183 + return false;
184 + }
185 + return (
186 + typeof window !== 'undefined' &&
187 + typeof document !== 'undefined'
188 + );
189 +}
190 +
191 +/**
192 + * Iterate over an Array or an Object invoking a function for each item.
193 + *
194 + * If `obj` is an Array callback will be called passing
195 + * the value, index, and complete array for each item.
196 + *
197 + * If 'obj' is an Object callback will be called passing
198 + * the value, key, and complete object for each property.
199 + *
200 + * @param {Object|Array} obj The object to iterate
201 + * @param {Function} fn The callback to invoke for each item
202 + */
203 +function forEach(obj, fn) {
204 + // Don't bother if no value provided
205 + if (obj === null || typeof obj === 'undefined') {
206 + return;
207 + }
208 +
209 + // Force an array if not already something iterable
210 + if (typeof obj !== 'object' && !isArray(obj)) {
211 + /*eslint no-param-reassign:0*/
212 + obj = [obj];
213 + }
214 +
215 + if (isArray(obj)) {
216 + // Iterate over array values
217 + for (var i = 0, l = obj.length; i < l; i++) {
218 + fn.call(null, obj[i], i, obj);
219 + }
220 + } else {
221 + // Iterate over object keys
222 + for (var key in obj) {
223 + if (Object.prototype.hasOwnProperty.call(obj, key)) {
224 + fn.call(null, obj[key], key, obj);
225 + }
226 + }
227 + }
228 +}
229 +
230 +/**
231 + * Accepts varargs expecting each argument to be an object, then
232 + * immutably merges the properties of each object and returns result.
233 + *
234 + * When multiple objects contain the same key the later object in
235 + * the arguments list will take precedence.
236 + *
237 + * Example:
238 + *
239 + * ```js
240 + * var result = merge({foo: 123}, {foo: 456});
241 + * console.log(result.foo); // outputs 456
242 + * ```
243 + *
244 + * @param {Object} obj1 Object to merge
245 + * @returns {Object} Result of all merge properties
246 + */
247 +function merge(/* obj1, obj2, obj3, ... */) {
248 + var result = {};
249 + function assignValue(val, key) {
250 + if (typeof result[key] === 'object' && typeof val === 'object') {
251 + result[key] = merge(result[key], val);
252 + } else {
253 + result[key] = val;
254 + }
255 + }
256 +
257 + for (var i = 0, l = arguments.length; i < l; i++) {
258 + forEach(arguments[i], assignValue);
259 + }
260 + return result;
261 +}
262 +
263 +/**
264 + * Extends object a by mutably adding to it the properties of object b.
265 + *
266 + * @param {Object} a The object to be extended
267 + * @param {Object} b The object to copy properties from
268 + * @param {Object} thisArg The object to bind function to
269 + * @return {Object} The resulting value of object a
270 + */
271 +function extend(a, b, thisArg) {
272 + forEach(b, function assignValue(val, key) {
273 + if (thisArg && typeof val === 'function') {
274 + a[key] = bind(val, thisArg);
275 + } else {
276 + a[key] = val;
277 + }
278 + });
279 + return a;
280 +}
281 +
282 +module.exports = {
283 + isArray: isArray,
284 + isArrayBuffer: isArrayBuffer,
285 + isBuffer: isBuffer,
286 + isFormData: isFormData,
287 + isArrayBufferView: isArrayBufferView,
288 + isString: isString,
289 + isNumber: isNumber,
290 + isObject: isObject,
291 + isUndefined: isUndefined,
292 + isDate: isDate,
293 + isFile: isFile,
294 + isBlob: isBlob,
295 + isFunction: isFunction,
296 + isStream: isStream,
297 + isURLSearchParams: isURLSearchParams,
298 + isStandardBrowserEnv: isStandardBrowserEnv,
299 + forEach: forEach,
300 + merge: merge,
301 + extend: extend,
302 + trim: trim
303 +};
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.