Showing
360 changed files
with
68 additions
and
4727 deletions
1 | -<<<<<<< HEAD | ||
2 | # Troll.gg | 1 | # Troll.gg |
3 | 2 | ||
4 | ![N|Solid](https://ifh.cc/g/PAs6FB.png) | 3 | ![N|Solid](https://ifh.cc/g/PAs6FB.png) |
5 | 4 | ||
6 | 5 | ||
7 | -Troll.gg는 검색한 유저의 최근 플레이를 분석하고 에이스 스코어를 계산하여 트롤, 에이스 플레이어의 기준을 알려줍니다. | ||
8 | - | ||
9 | - | ||
10 | - | ||
11 | - | ||
12 | - | ||
13 | -# 구현 | ||
14 | - | ||
15 | - - UI는 C# WINFORM을 사용하여 EXE 파일로 사용자가 실행할 수 있게 만들었습니다. | ||
16 | - ![N|Solid](https://ifh.cc/g/UOfb1W.png) | ||
17 | 6 | ||
7 | +# 접속 | ||
8 | +- aws 서버가 3~10분마다 끊기는 현상이 발생하여 이 주소로 배포합니다. | ||
9 | +- http://74becbd3c1ed.ngrok.io | ||
18 | 10 | ||
19 | 11 | ||
12 | +Troll.gg는 검색한 유저의 최근 플레이를 분석하고 에이스 스코어를 계산하여 트롤, 에이스 플레이어의 기준을 알려줍니다. | ||
13 | + ![N|Solid](https://ifh.cc/g/BptisC.jpg) | ||
20 | 14 | ||
21 | 15 | ||
22 | - - 데이터는 Riot Developer에서 11월 11에 신청하였으나 아직 승인이 나오지 않아 임시 API 코드를 갱신하면서 개발중입니다. | 16 | +# 공통 요구사항 |
23 | - ![N|Solid](https://ifh.cc/g/8l2qhc.png) | 17 | +- MySQL |
24 | - | 18 | +- Python |
25 | - | 19 | +- NodeJS |
26 | - | ||
27 | -- API를 이용해 데이터를 받아와 가공하고 처리하는 과정은 PYTHON을 이용하여 처리하고 있습니다. | ||
28 | - | ||
29 | - | ||
30 | 20 | ||
21 | +# 개발 도구 | ||
22 | +- Visual Studio Code | ||
23 | +- WebStorm | ||
31 | 24 | ||
32 | -# 사용한 API 목록 | 25 | +# 사용한 API |
33 | - /lol/match/v4/matchlists/by-account/{encryptedAccountId} | 26 | - /lol/match/v4/matchlists/by-account/{encryptedAccountId} |
34 | - /lol/summoner/v4/summoners/by-name/{summonerName} | 27 | - /lol/summoner/v4/summoners/by-name/{summonerName} |
35 | - /lol/match/v4/matches/{matchId} | 28 | - /lol/match/v4/matches/{matchId} |
36 | - | 29 | +# |
37 | - | 30 | +# |
38 | 31 | ||
39 | # 개발기간 | 32 | # 개발기간 |
40 | 33 | ||
... | @@ -47,39 +40,52 @@ Troll.gg는 검색한 유저의 최근 플레이를 분석하고 에이스 스 | ... | @@ -47,39 +40,52 @@ Troll.gg는 검색한 유저의 최근 플레이를 분석하고 에이스 스 |
47 | | 2020-11-30 | UI개발 마무리 | | 40 | | 2020-11-30 | UI개발 마무리 | |
48 | | 2020-12-01 | MySQL DB 생성 및 테이블 생성 | | 41 | | 2020-12-01 | MySQL DB 생성 및 테이블 생성 | |
49 | | 2020-12-02 | UI-PYTHON 코드 연동 시작 | | 42 | | 2020-12-02 | UI-PYTHON 코드 연동 시작 | |
50 | - | 43 | +| 2020-12-04 | UI 변경 NodeJs express로 개발 | |
51 | - | 44 | +| 2020-12-06 | Python code & UI 연동 | |
52 | -### 개발 도구 및 언어 | 45 | +| 2020-12-10 | 테스트 및 프로젝트 종료| |
53 | -* [C#] - WINFORM 이용 UI디자인 | 46 | +| 2020-12-11 | 배포용 코드로 수정| |
54 | -* [PYTHON] - API 데이터 처리 | ||
55 | -* [Visual Studio Code] - Python-C# 연동 테스트 코드 작성 | ||
56 | -* [Visual Studio 2019] - C# UI 디자인 코드 작성 | ||
57 | -* [IDLE] - Python 코드 작성 | ||
58 | - | ||
59 | - | ||
60 | -### Branch | ||
61 | -- 개발초기 생성한 first branch는 테스트 코드를 올리기위한 branch로 현재 삭제상태 | ||
62 | -- Master Branch에 모든 작업 폴더 push | ||
63 | - | ||
64 | - | ||
65 | -### 진행 상태 | ||
66 | -현재 UI와 Python 코드를 연동하는 과정입니다. | ||
67 | -여유가 있으면 DB에 데이터를 보내고 받아오는 과정까지 추가할 예정입니다. | ||
68 | - | ||
69 | - | ||
70 | -======= | ||
71 | -# lol_op_rating | ||
72 | -#2020-11-15 | ||
73 | -lol api 연동하여 대용량 데이터를 받아 처리하는 과정을 테스트하였습니다. | ||
74 | -유저의 데이터를 대용량으로 가져와 처리하는 과정에서 오픈 API 로 제공하는 rating제한보다 | ||
75 | -많이 요청하여 오류가 생겼습니다. 해당 문제처리를 위해 DB를 사용하여 CSV파일로 만들어 처리해보겠습니다. | ||
76 | # | 47 | # |
77 | # | 48 | # |
78 | -#2020-11-30 | 49 | + |
79 | -MySQL DB 생성하였습니다. | 50 | +# DB 초기화(MySQL DB을 사용하여 배포과정이 복잡해져 업로드 코드는 DB코드를 삭제하였습니다) |
80 | -사용자 UI 디자인 시작하여 중간과정까지 코드 업로드하였습니다. | 51 | +- 다음 SQL문을 실행해 데이터 베이스 테이블 초기화 |
81 | -# | 52 | +- 'lol' 부분은 스키마 이름으로 아래 TABLE 생성 전 원하는 스키마 이름으로 만들고 'lol' 대신 만든 스키마 이름을 입력 |
82 | -# | 53 | +```sql |
83 | -#2020-12-01 | 54 | +CREATE TABLE `lol`.`user_info` ( |
84 | -UI 디자인 완료하였습니다. | 55 | + `name` VARCHAR(45) NOT NULL, |
85 | ->>>>>>> f59092d21e02cb4f5ce17a4fe17843ebd99e0a61 | 56 | + `level` INT NULL, |
57 | + `tier` VARCHAR(45) NULL, | ||
58 | + PRIMARY KEY (`name`)); | ||
59 | +CREATE TABLE `lol`.`match_info` ( | ||
60 | + `name` VARCHAR(45) NOT NULL, | ||
61 | + `country` VARCHAR(45) NULL, | ||
62 | + `season` INT NULL, | ||
63 | + PRIMARY KEY (`name`)); | ||
64 | +CREATE TABLE `lol`.`game_info` ( | ||
65 | + `name` VARCHAR(45) NOT NULL, | ||
66 | + `kill_cs` FLOAT NULL, | ||
67 | + `view_score` FLOAT NULL, | ||
68 | + `cs` FLOAT NULL, | ||
69 | + `death` FLOAT NULL, | ||
70 | + `assist` FLOAT NULL, | ||
71 | + PRIMARY KEY (`name`)); | ||
72 | +CREATE TABLE `lol`.`analysis_info` ( | ||
73 | + `name` VARCHAR(45) NOT NULL, | ||
74 | + `opscore` FLOAT NULL, | ||
75 | + PRIMARY KEY (`name`)); | ||
76 | +``` | ||
77 | + | ||
78 | +# 실행방법 | ||
79 | +- Riot Developer에 접속하여 API 발급(임시 API는 즉시 발급가능) | ||
80 | +- 발급받은 API를 Python코드의 APIKEY="~~~~"에 입력 | ||
81 | +- Python의 DB 명령문들에 있는 "trollgg" 스키마 이름과 "?" 패스워드를 본인의 스키마, MySQL 패스워드에 맞게 변경 | ||
82 | +- 위 파이썬 코드변경 후 WebStorm으로 trollgg 파일 프로젝트를 open(폴더) | ||
83 | +``` | ||
84 | +$ npm install | ||
85 | +$ npm start | ||
86 | +``` | ||
87 | +- localhost:3001에 접속 | ||
88 | + | ||
89 | +# 주의사항 | ||
90 | +- 없는 유저를 검색할 경우 오류가 발생할 수 있다. | ||
91 | +- 현재 Python 코드에 입력된 API는 임시키로 매일 갱신하거나 영구키를 발급 받아 사용해야한다. | ... | ... |
1 | import requests | 1 | import requests |
2 | from urllib import parse | 2 | from urllib import parse |
3 | -import pymysql | ||
4 | import sys, json | 3 | import sys, json |
5 | import base64 | 4 | import base64 |
6 | 5 | ||
7 | -def select(user_name): | ||
8 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll") | ||
9 | - check=0 | ||
10 | - try: | ||
11 | - with conn.cursor() as curs: | ||
12 | - sql = "select name from user_info" | ||
13 | - curs.execute(sql) | ||
14 | - rs = curs.fetchall() | ||
15 | - for row in rs: | ||
16 | - if user_name in row: | ||
17 | - check=1 | ||
18 | - finally: | ||
19 | - conn.close() | ||
20 | - return check | ||
21 | -def read_level(user_name): | ||
22 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
23 | - try: | ||
24 | - with conn.cursor() as curs: | ||
25 | - sql ="select level from user_info where name=%s" | ||
26 | - curs.execute(sql,[user_name,]) | ||
27 | - for rs in curs.fetchall(): | ||
28 | - temp=rs[0] | ||
29 | - finally: | ||
30 | - conn.close() | ||
31 | - return temp | ||
32 | -def read_tier(user_name): | ||
33 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
34 | - try: | ||
35 | - with conn.cursor() as curs: | ||
36 | - sql ="select tier from user_info where name=%s" | ||
37 | - curs.execute(sql,[user_name,]) | ||
38 | - for rs in curs.fetchall(): | ||
39 | - temp=rs[0] | ||
40 | - finally: | ||
41 | - conn.close() | ||
42 | - return temp | ||
43 | -def read_score(user_name): | ||
44 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
45 | - try: | ||
46 | - with conn.cursor() as curs: | ||
47 | - sql ="select opscore from analysis_info where name=%s" | ||
48 | - curs.execute(sql,[user_name,]) | ||
49 | - for rs in curs.fetchall(): | ||
50 | - temp=rs[0] | ||
51 | - finally: | ||
52 | - conn.close() | ||
53 | - return temp | ||
54 | -def read_game(user_name): | ||
55 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
56 | - try: | ||
57 | - with conn.cursor() as curs: | ||
58 | - curs.execute("select * from game_info where name=%s",[user_name,]) | ||
59 | - for rs in curs.fetchall(): | ||
60 | - temp=rs | ||
61 | 6 | ||
62 | - finally: | 7 | +APIKEY = "RGAPI-686e045c-f10b-40f4-967b-c38d1f08f602" |
63 | - conn.close() | ||
64 | - lst=list(temp) | ||
65 | - return lst[1],lst[2],lst[3],lst[4],lst[5] | ||
66 | -def read_kill(user_name): | ||
67 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
68 | - try: | ||
69 | - with conn.cursor() as curs: | ||
70 | - curs.execute("select kill_cs from game_info where name=%s",[user_name,]) | ||
71 | - for rs in curs.fetchall(): | ||
72 | - temp=rs[0] | ||
73 | - | ||
74 | - finally: | ||
75 | - conn.close() | ||
76 | - return temp | ||
77 | -def read_view(user_name): | ||
78 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
79 | - try: | ||
80 | - with conn.cursor() as curs: | ||
81 | - curs.execute("select view_score from game_info where name=%s",[user_name,]) | ||
82 | - for rs in curs.fetchall(): | ||
83 | - temp=rs[0] | ||
84 | - | ||
85 | - finally: | ||
86 | - conn.close() | ||
87 | - return temp | ||
88 | -def read_cs(user_name): | ||
89 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
90 | - try: | ||
91 | - with conn.cursor() as curs: | ||
92 | - curs.execute("select cs from game_info where name=%s",[user_name,]) | ||
93 | - for rs in curs.fetchall(): | ||
94 | - temp=rs[0] | ||
95 | - | ||
96 | - finally: | ||
97 | - conn.close() | ||
98 | - return temp | ||
99 | -def read_as(user_name): | ||
100 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
101 | - try: | ||
102 | - with conn.cursor() as curs: | ||
103 | - curs.execute("select assist from game_info where name=%s",[user_name,]) | ||
104 | - for rs in curs.fetchall(): | ||
105 | - temp=rs[0] | ||
106 | - | ||
107 | - finally: | ||
108 | - conn.close() | ||
109 | - return temp | ||
110 | -def read_death(user_name): | ||
111 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
112 | - try: | ||
113 | - with conn.cursor() as curs: | ||
114 | - curs.execute("select death from game_info where name=%s",[user_name,]) | ||
115 | - for rs in curs.fetchall(): | ||
116 | - temp=rs[0] | ||
117 | - | ||
118 | - finally: | ||
119 | - conn.close() | ||
120 | - return temp | ||
121 | -def read_season(user_name): | ||
122 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
123 | - try: | ||
124 | - with conn.cursor() as curs: | ||
125 | - curs.execute("select season from match_info where name=%s",[user_name,]) | ||
126 | - for i in curs.fetchall(): | ||
127 | - temp=i[0] | ||
128 | - break | ||
129 | - finally: | ||
130 | - conn.close() | ||
131 | - return temp | ||
132 | -def read_country(user_name): | ||
133 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
134 | - try: | ||
135 | - with conn.cursor() as curs: | ||
136 | - curs.execute("select country from match_info where name=%s",[user_name,]) | ||
137 | - | ||
138 | - for i in curs.fetchall(): | ||
139 | - temp=i[0] | ||
140 | - break | ||
141 | - finally: | ||
142 | - conn.close() | ||
143 | - return temp | ||
144 | - | ||
145 | - | ||
146 | -def insert_game_table(name, kill,death,ass,cs,view): | ||
147 | - if select(name)==1: | ||
148 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
149 | - try: | ||
150 | - with conn.cursor() as curs: | ||
151 | - sql = 'UPDATE game_info SET kill_cs=%s,death=%s,assist=%s,cs=%s,view_score=%s WHERE name=%s' | ||
152 | - curs.execute(sql, (kill,death,ass,cs,view,name)) | ||
153 | - conn.commit() | ||
154 | - finally: | ||
155 | - conn.close() | ||
156 | - else: | ||
157 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
158 | - try: | ||
159 | - with conn.cursor() as curs: | ||
160 | - sql = 'insert into game_info values(%s, %s,%s,%s,%s,%s)' | ||
161 | - curs.execute(sql, (name, kill,view,cs,death,ass)) | ||
162 | - conn.commit() | ||
163 | - finally: | ||
164 | - conn.close() | ||
165 | -def insert_match_table(name,country,season): | ||
166 | - if select(name)==1: | ||
167 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
168 | - try: | ||
169 | - with conn.cursor() as curs: | ||
170 | - sql = 'UPDATE match_info SET country=%s,season=%s WHERE name=%s' | ||
171 | - curs.execute(sql,(country,season,name)) | ||
172 | - conn.commit() | ||
173 | - finally: | ||
174 | - conn.close() | ||
175 | - else: | ||
176 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
177 | - try: | ||
178 | - with conn.cursor() as curs: | ||
179 | - sql = 'insert into match_info values(%s, %s,%s)' | ||
180 | - curs.execute(sql, (name, country,season)) | ||
181 | - conn.commit() | ||
182 | - finally: | ||
183 | - conn.close() | ||
184 | -def insert_score_table(name,score): | ||
185 | - if select(name)==1: | ||
186 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
187 | - try: | ||
188 | - with conn.cursor() as curs: | ||
189 | - sql = 'UPDATE analysis_info SET opscore=%s WHERE name=%s' | ||
190 | - curs.execute(sql,(score,name)) | ||
191 | - conn.commit() | ||
192 | - finally: | ||
193 | - conn.close() | ||
194 | - else: | ||
195 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
196 | - try: | ||
197 | - with conn.cursor() as curs: | ||
198 | - sql = 'insert into analysis_info values(%s, %s)' | ||
199 | - curs.execute(sql, (name, score)) | ||
200 | - conn.commit() | ||
201 | - finally: | ||
202 | - conn.close() | ||
203 | -def insert_user_table(name,level,tier): | ||
204 | - if select(name)==1: | ||
205 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
206 | - try: | ||
207 | - with conn.cursor() as curs: | ||
208 | - sql = 'UPDATE user_info SET level=%s,tier=%s WHERE name=%s' | ||
209 | - curs.execute(sql,(level,tier,name)) | ||
210 | - conn.commit() | ||
211 | - finally: | ||
212 | - conn.close() | ||
213 | - else: | ||
214 | - conn = pymysql.connect(host='localhost', user='root', password="?", db="project_troll", charset='utf8') | ||
215 | - try: | ||
216 | - with conn.cursor() as curs: | ||
217 | - sql = 'insert into user_info values(%s, %s,%s)' | ||
218 | - curs.execute(sql, (name, level,tier)) | ||
219 | - conn.commit() | ||
220 | - finally: | ||
221 | - conn.close() | ||
222 | -APIKEY = "RGAPI-57786682-f258-4eb0-a7c3-b4ecd15e575f" | ||
223 | headers = { | 8 | headers = { |
224 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", | 9 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", |
225 | "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", | 10 | "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", |
... | @@ -247,7 +32,7 @@ def user_tier(name): | ... | @@ -247,7 +32,7 @@ def user_tier(name): |
247 | API="https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+user_id | 32 | API="https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+user_id |
248 | getAPI=requests.get(API, headers=headers) | 33 | getAPI=requests.get(API, headers=headers) |
249 | apidata=getAPI.json() | 34 | apidata=getAPI.json() |
250 | - insert_user_table(name,level,apidata[0]["tier"]) | 35 | + #insert_user_table(name,level,apidata[0]["tier"]) |
251 | return apidata[0]["tier"] | 36 | return apidata[0]["tier"] |
252 | def game_id(name,num): | 37 | def game_id(name,num): |
253 | API="https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + name | 38 | API="https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + name |
... | @@ -268,7 +53,7 @@ def season_country(name): | ... | @@ -268,7 +53,7 @@ def season_country(name): |
268 | getAPI=requests.get(API, headers=headers) | 53 | getAPI=requests.get(API, headers=headers) |
269 | LOL_API_DATA=getAPI.json()['matches'] | 54 | LOL_API_DATA=getAPI.json()['matches'] |
270 | #str값리턴 | 55 | #str값리턴 |
271 | - insert_match_table(name,LOL_API_DATA[0].get("platformId"),LOL_API_DATA[0].get("season")) | 56 | + #insert_match_table(name,LOL_API_DATA[0].get("platformId"),LOL_API_DATA[0].get("season")) |
272 | return LOL_API_DATA[0].get("platformId"),LOL_API_DATA[0].get("season") | 57 | return LOL_API_DATA[0].get("platformId"),LOL_API_DATA[0].get("season") |
273 | def opscore(name): | 58 | def opscore(name): |
274 | API="https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + name | 59 | API="https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + name |
... | @@ -339,8 +124,8 @@ def all_info(name): | ... | @@ -339,8 +124,8 @@ def all_info(name): |
339 | vision=vision+LOL_API_DATA["participants"][checkpoint]["stats"]["visionScore"] | 124 | vision=vision+LOL_API_DATA["participants"][checkpoint]["stats"]["visionScore"] |
340 | time=time+LOL_API_DATA["gameDuration"] | 125 | time=time+LOL_API_DATA["gameDuration"] |
341 | score=round((kill*3+ass*2)/(death*3),2)+round((cs/(time/60)*0.2),2)+round(vision*0.05,2) | 126 | score=round((kill*3+ass*2)/(death*3),2)+round((cs/(time/60)*0.2),2)+round(vision*0.05,2) |
342 | - insert_game_table(name, round(kill/10,2),round(death/10,2),round(ass/10,2),round(cs/(time/60),2),round(vision/10,2)) | 127 | + #insert_game_table(name, round(kill/10,2),round(death/10,2),round(ass/10,2),round(cs/(time/60),2),round(vision/10,2)) |
343 | - insert_score_table(name,score) | 128 | + #insert_score_table(name,score) |
344 | a=user_tier(name) | 129 | a=user_tier(name) |
345 | if(a=='BRONZE'): | 130 | if(a=='BRONZE'): |
346 | b=0 | 131 | b=0 | ... | ... |
... | @@ -12,7 +12,7 @@ var http = require('http'); | ... | @@ -12,7 +12,7 @@ var http = require('http'); |
12 | * Get port from environment and store in Express. | 12 | * Get port from environment and store in Express. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | -var port = normalizePort(process.env.PORT || '3000'); | 15 | +var port = normalizePort(process.env.PORT || '3001'); |
16 | app.set('port', port); | 16 | app.set('port', port); |
17 | 17 | ||
18 | /** | 18 | /** | ... | ... |
trollgg/node_modules/.bin/mime
deleted
100644 → 0
1 | -#!/bin/sh | ||
2 | -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | ||
3 | - | ||
4 | -case `uname` in | ||
5 | - *CYGWIN*|*MINGW*|*MSYS*) 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 |
trollgg/node_modules/.bin/mime.cmd
deleted
100644 → 0
1 | -@ECHO off | ||
2 | -SETLOCAL | ||
3 | -CALL :find_dp0 | ||
4 | - | ||
5 | -IF EXIST "%dp0%\node.exe" ( | ||
6 | - SET "_prog=%dp0%\node.exe" | ||
7 | -) ELSE ( | ||
8 | - SET "_prog=node" | ||
9 | - SET PATHEXT=%PATHEXT:;.JS;=;% | ||
10 | -) | ||
11 | - | ||
12 | -"%_prog%" "%dp0%\..\mime\cli.js" %* | ||
13 | -ENDLOCAL | ||
14 | -EXIT /b %errorlevel% | ||
15 | -:find_dp0 | ||
16 | -SET dp0=%~dp0 | ||
17 | -EXIT /b |
trollgg/node_modules/.bin/mime.ps1
deleted
100644 → 0
1 | -#!/usr/bin/env pwsh | ||
2 | -$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent | ||
3 | - | ||
4 | -$exe="" | ||
5 | -if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { | ||
6 | - # Fix case when both the Windows and Linux builds of Node | ||
7 | - # are installed in the same directory | ||
8 | - $exe=".exe" | ||
9 | -} | ||
10 | -$ret=0 | ||
11 | -if (Test-Path "$basedir/node$exe") { | ||
12 | - & "$basedir/node$exe" "$basedir/../mime/cli.js" $args | ||
13 | - $ret=$LASTEXITCODE | ||
14 | -} else { | ||
15 | - & "node$exe" "$basedir/../mime/cli.js" $args | ||
16 | - $ret=$LASTEXITCODE | ||
17 | -} | ||
18 | -exit $ret |
1 | -1.3.7 / 2019-04-29 | ||
2 | -================== | ||
3 | - | ||
4 | - * deps: negotiator@0.6.2 | ||
5 | - - Fix sorting charset, encoding, and language with extra parameters | ||
6 | - | ||
7 | -1.3.6 / 2019-04-28 | ||
8 | -================== | ||
9 | - | ||
10 | - * deps: mime-types@~2.1.24 | ||
11 | - - deps: mime-db@~1.40.0 | ||
12 | - | ||
13 | -1.3.5 / 2018-02-28 | ||
14 | -================== | ||
15 | - | ||
16 | - * deps: mime-types@~2.1.18 | ||
17 | - - deps: mime-db@~1.33.0 | ||
18 | - | ||
19 | -1.3.4 / 2017-08-22 | ||
20 | -================== | ||
21 | - | ||
22 | - * deps: mime-types@~2.1.16 | ||
23 | - - deps: mime-db@~1.29.0 | ||
24 | - | ||
25 | -1.3.3 / 2016-05-02 | ||
26 | -================== | ||
27 | - | ||
28 | - * deps: mime-types@~2.1.11 | ||
29 | - - deps: mime-db@~1.23.0 | ||
30 | - * deps: negotiator@0.6.1 | ||
31 | - - perf: improve `Accept` parsing speed | ||
32 | - - perf: improve `Accept-Charset` parsing speed | ||
33 | - - perf: improve `Accept-Encoding` parsing speed | ||
34 | - - perf: improve `Accept-Language` parsing speed | ||
35 | - | ||
36 | -1.3.2 / 2016-03-08 | ||
37 | -================== | ||
38 | - | ||
39 | - * deps: mime-types@~2.1.10 | ||
40 | - - Fix extension of `application/dash+xml` | ||
41 | - - Update primary extension for `audio/mp4` | ||
42 | - - deps: mime-db@~1.22.0 | ||
43 | - | ||
44 | -1.3.1 / 2016-01-19 | ||
45 | -================== | ||
46 | - | ||
47 | - * deps: mime-types@~2.1.9 | ||
48 | - - deps: mime-db@~1.21.0 | ||
49 | - | ||
50 | -1.3.0 / 2015-09-29 | ||
51 | -================== | ||
52 | - | ||
53 | - * deps: mime-types@~2.1.7 | ||
54 | - - deps: mime-db@~1.19.0 | ||
55 | - * deps: negotiator@0.6.0 | ||
56 | - - Fix including type extensions in parameters in `Accept` parsing | ||
57 | - - Fix parsing `Accept` parameters with quoted equals | ||
58 | - - Fix parsing `Accept` parameters with quoted semicolons | ||
59 | - - Lazy-load modules from main entry point | ||
60 | - - perf: delay type concatenation until needed | ||
61 | - - perf: enable strict mode | ||
62 | - - perf: hoist regular expressions | ||
63 | - - perf: remove closures getting spec properties | ||
64 | - - perf: remove a closure from media type parsing | ||
65 | - - perf: remove property delete from media type parsing | ||
66 | - | ||
67 | -1.2.13 / 2015-09-06 | ||
68 | -=================== | ||
69 | - | ||
70 | - * deps: mime-types@~2.1.6 | ||
71 | - - deps: mime-db@~1.18.0 | ||
72 | - | ||
73 | -1.2.12 / 2015-07-30 | ||
74 | -=================== | ||
75 | - | ||
76 | - * deps: mime-types@~2.1.4 | ||
77 | - - deps: mime-db@~1.16.0 | ||
78 | - | ||
79 | -1.2.11 / 2015-07-16 | ||
80 | -=================== | ||
81 | - | ||
82 | - * deps: mime-types@~2.1.3 | ||
83 | - - deps: mime-db@~1.15.0 | ||
84 | - | ||
85 | -1.2.10 / 2015-07-01 | ||
86 | -=================== | ||
87 | - | ||
88 | - * deps: mime-types@~2.1.2 | ||
89 | - - deps: mime-db@~1.14.0 | ||
90 | - | ||
91 | -1.2.9 / 2015-06-08 | ||
92 | -================== | ||
93 | - | ||
94 | - * deps: mime-types@~2.1.1 | ||
95 | - - perf: fix deopt during mapping | ||
96 | - | ||
97 | -1.2.8 / 2015-06-07 | ||
98 | -================== | ||
99 | - | ||
100 | - * deps: mime-types@~2.1.0 | ||
101 | - - deps: mime-db@~1.13.0 | ||
102 | - * perf: avoid argument reassignment & argument slice | ||
103 | - * perf: avoid negotiator recursive construction | ||
104 | - * perf: enable strict mode | ||
105 | - * perf: remove unnecessary bitwise operator | ||
106 | - | ||
107 | -1.2.7 / 2015-05-10 | ||
108 | -================== | ||
109 | - | ||
110 | - * deps: negotiator@0.5.3 | ||
111 | - - Fix media type parameter matching to be case-insensitive | ||
112 | - | ||
113 | -1.2.6 / 2015-05-07 | ||
114 | -================== | ||
115 | - | ||
116 | - * deps: mime-types@~2.0.11 | ||
117 | - - deps: mime-db@~1.9.1 | ||
118 | - * deps: negotiator@0.5.2 | ||
119 | - - Fix comparing media types with quoted values | ||
120 | - - Fix splitting media types with quoted commas | ||
121 | - | ||
122 | -1.2.5 / 2015-03-13 | ||
123 | -================== | ||
124 | - | ||
125 | - * deps: mime-types@~2.0.10 | ||
126 | - - deps: mime-db@~1.8.0 | ||
127 | - | ||
128 | -1.2.4 / 2015-02-14 | ||
129 | -================== | ||
130 | - | ||
131 | - * Support Node.js 0.6 | ||
132 | - * deps: mime-types@~2.0.9 | ||
133 | - - deps: mime-db@~1.7.0 | ||
134 | - * deps: negotiator@0.5.1 | ||
135 | - - Fix preference sorting to be stable for long acceptable lists | ||
136 | - | ||
137 | -1.2.3 / 2015-01-31 | ||
138 | -================== | ||
139 | - | ||
140 | - * deps: mime-types@~2.0.8 | ||
141 | - - deps: mime-db@~1.6.0 | ||
142 | - | ||
143 | -1.2.2 / 2014-12-30 | ||
144 | -================== | ||
145 | - | ||
146 | - * deps: mime-types@~2.0.7 | ||
147 | - - deps: mime-db@~1.5.0 | ||
148 | - | ||
149 | -1.2.1 / 2014-12-30 | ||
150 | -================== | ||
151 | - | ||
152 | - * deps: mime-types@~2.0.5 | ||
153 | - - deps: mime-db@~1.3.1 | ||
154 | - | ||
155 | -1.2.0 / 2014-12-19 | ||
156 | -================== | ||
157 | - | ||
158 | - * deps: negotiator@0.5.0 | ||
159 | - - Fix list return order when large accepted list | ||
160 | - - Fix missing identity encoding when q=0 exists | ||
161 | - - Remove dynamic building of Negotiator class | ||
162 | - | ||
163 | -1.1.4 / 2014-12-10 | ||
164 | -================== | ||
165 | - | ||
166 | - * deps: mime-types@~2.0.4 | ||
167 | - - deps: mime-db@~1.3.0 | ||
168 | - | ||
169 | -1.1.3 / 2014-11-09 | ||
170 | -================== | ||
171 | - | ||
172 | - * deps: mime-types@~2.0.3 | ||
173 | - - deps: mime-db@~1.2.0 | ||
174 | - | ||
175 | -1.1.2 / 2014-10-14 | ||
176 | -================== | ||
177 | - | ||
178 | - * deps: negotiator@0.4.9 | ||
179 | - - Fix error when media type has invalid parameter | ||
180 | - | ||
181 | -1.1.1 / 2014-09-28 | ||
182 | -================== | ||
183 | - | ||
184 | - * deps: mime-types@~2.0.2 | ||
185 | - - deps: mime-db@~1.1.0 | ||
186 | - * deps: negotiator@0.4.8 | ||
187 | - - Fix all negotiations to be case-insensitive | ||
188 | - - Stable sort preferences of same quality according to client order | ||
189 | - | ||
190 | -1.1.0 / 2014-09-02 | ||
191 | -================== | ||
192 | - | ||
193 | - * update `mime-types` | ||
194 | - | ||
195 | -1.0.7 / 2014-07-04 | ||
196 | -================== | ||
197 | - | ||
198 | - * Fix wrong type returned from `type` when match after unknown extension | ||
199 | - | ||
200 | -1.0.6 / 2014-06-24 | ||
201 | -================== | ||
202 | - | ||
203 | - * deps: negotiator@0.4.7 | ||
204 | - | ||
205 | -1.0.5 / 2014-06-20 | ||
206 | -================== | ||
207 | - | ||
208 | - * fix crash when unknown extension given | ||
209 | - | ||
210 | -1.0.4 / 2014-06-19 | ||
211 | -================== | ||
212 | - | ||
213 | - * use `mime-types` | ||
214 | - | ||
215 | -1.0.3 / 2014-06-11 | ||
216 | -================== | ||
217 | - | ||
218 | - * deps: negotiator@0.4.6 | ||
219 | - - Order by specificity when quality is the same | ||
220 | - | ||
221 | -1.0.2 / 2014-05-29 | ||
222 | -================== | ||
223 | - | ||
224 | - * Fix interpretation when header not in request | ||
225 | - * deps: pin negotiator@0.4.5 | ||
226 | - | ||
227 | -1.0.1 / 2014-01-18 | ||
228 | -================== | ||
229 | - | ||
230 | - * Identity encoding isn't always acceptable | ||
231 | - * deps: negotiator@~0.4.0 | ||
232 | - | ||
233 | -1.0.0 / 2013-12-27 | ||
234 | -================== | ||
235 | - | ||
236 | - * Genesis |
trollgg/node_modules/accepts/LICENSE
deleted
100644 → 0
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-version-image]][npm-url] | ||
4 | -[![NPM Downloads][npm-downloads-image]][npm-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 | -[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master | ||
135 | -[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master | ||
136 | -[node-version-image]: https://badgen.net/npm/node/accepts | ||
137 | -[node-version-url]: https://nodejs.org/en/download | ||
138 | -[npm-downloads-image]: https://badgen.net/npm/dm/accepts | ||
139 | -[npm-url]: https://npmjs.org/package/accepts | ||
140 | -[npm-version-image]: https://badgen.net/npm/v/accepts | ||
141 | -[travis-image]: https://badgen.net/travis/jshttp/accepts/master | ||
142 | -[travis-url]: https://travis-ci.org/jshttp/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 | - "_args": [ | ||
3 | - [ | ||
4 | - "accepts@1.3.7", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "accepts@1.3.7", | ||
9 | - "_id": "accepts@1.3.7", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", | ||
12 | - "_location": "/accepts", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "accepts@1.3.7", | ||
18 | - "name": "accepts", | ||
19 | - "escapedName": "accepts", | ||
20 | - "rawSpec": "1.3.7", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "1.3.7" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/express" | ||
26 | - ], | ||
27 | - "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", | ||
28 | - "_spec": "1.3.7", | ||
29 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
30 | - "bugs": { | ||
31 | - "url": "https://github.com/jshttp/accepts/issues" | ||
32 | - }, | ||
33 | - "contributors": [ | ||
34 | - { | ||
35 | - "name": "Douglas Christopher Wilson", | ||
36 | - "email": "doug@somethingdoug.com" | ||
37 | - }, | ||
38 | - { | ||
39 | - "name": "Jonathan Ong", | ||
40 | - "email": "me@jongleberry.com", | ||
41 | - "url": "http://jongleberry.com" | ||
42 | - } | ||
43 | - ], | ||
44 | - "dependencies": { | ||
45 | - "mime-types": "~2.1.24", | ||
46 | - "negotiator": "0.6.2" | ||
47 | - }, | ||
48 | - "description": "Higher-level content negotiation", | ||
49 | - "devDependencies": { | ||
50 | - "deep-equal": "1.0.1", | ||
51 | - "eslint": "5.16.0", | ||
52 | - "eslint-config-standard": "12.0.0", | ||
53 | - "eslint-plugin-import": "2.17.2", | ||
54 | - "eslint-plugin-markdown": "1.0.0", | ||
55 | - "eslint-plugin-node": "8.0.1", | ||
56 | - "eslint-plugin-promise": "4.1.1", | ||
57 | - "eslint-plugin-standard": "4.0.0", | ||
58 | - "mocha": "6.1.4", | ||
59 | - "nyc": "14.0.0" | ||
60 | - }, | ||
61 | - "engines": { | ||
62 | - "node": ">= 0.6" | ||
63 | - }, | ||
64 | - "files": [ | ||
65 | - "LICENSE", | ||
66 | - "HISTORY.md", | ||
67 | - "index.js" | ||
68 | - ], | ||
69 | - "homepage": "https://github.com/jshttp/accepts#readme", | ||
70 | - "keywords": [ | ||
71 | - "content", | ||
72 | - "negotiation", | ||
73 | - "accept", | ||
74 | - "accepts" | ||
75 | - ], | ||
76 | - "license": "MIT", | ||
77 | - "name": "accepts", | ||
78 | - "repository": { | ||
79 | - "type": "git", | ||
80 | - "url": "git+https://github.com/jshttp/accepts.git" | ||
81 | - }, | ||
82 | - "scripts": { | ||
83 | - "lint": "eslint --plugin markdown --ext js,md .", | ||
84 | - "test": "mocha --reporter spec --check-leaks --bail test/", | ||
85 | - "test-cov": "nyc --reporter=html --reporter=text npm test", | ||
86 | - "test-travis": "nyc --reporter=text npm test" | ||
87 | - }, | ||
88 | - "version": "1.3.7" | ||
89 | -} |
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 | - "_args": [ | ||
3 | - [ | ||
4 | - "array-flatten@1.1.1", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "array-flatten@1.1.1", | ||
9 | - "_id": "array-flatten@1.1.1", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", | ||
12 | - "_location": "/array-flatten", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "array-flatten@1.1.1", | ||
18 | - "name": "array-flatten", | ||
19 | - "escapedName": "array-flatten", | ||
20 | - "rawSpec": "1.1.1", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "1.1.1" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/express" | ||
26 | - ], | ||
27 | - "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", | ||
28 | - "_spec": "1.1.1", | ||
29 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
30 | - "author": { | ||
31 | - "name": "Blake Embrey", | ||
32 | - "email": "hello@blakeembrey.com", | ||
33 | - "url": "http://blakeembrey.me" | ||
34 | - }, | ||
35 | - "bugs": { | ||
36 | - "url": "https://github.com/blakeembrey/array-flatten/issues" | ||
37 | - }, | ||
38 | - "description": "Flatten an array of nested arrays into a single flat array", | ||
39 | - "devDependencies": { | ||
40 | - "istanbul": "^0.3.13", | ||
41 | - "mocha": "^2.2.4", | ||
42 | - "pre-commit": "^1.0.7", | ||
43 | - "standard": "^3.7.3" | ||
44 | - }, | ||
45 | - "files": [ | ||
46 | - "array-flatten.js", | ||
47 | - "LICENSE" | ||
48 | - ], | ||
49 | - "homepage": "https://github.com/blakeembrey/array-flatten", | ||
50 | - "keywords": [ | ||
51 | - "array", | ||
52 | - "flatten", | ||
53 | - "arguments", | ||
54 | - "depth" | ||
55 | - ], | ||
56 | - "license": "MIT", | ||
57 | - "main": "array-flatten.js", | ||
58 | - "name": "array-flatten", | ||
59 | - "repository": { | ||
60 | - "type": "git", | ||
61 | - "url": "git://github.com/blakeembrey/array-flatten.git" | ||
62 | - }, | ||
63 | - "scripts": { | ||
64 | - "test": "istanbul cover _mocha -- -R spec" | ||
65 | - }, | ||
66 | - "version": "1.1.1" | ||
67 | -} |
1 | -2.0.1 / 2018-09-19 | ||
2 | -================== | ||
3 | - | ||
4 | - * deps: safe-buffer@5.1.2 | ||
5 | - | ||
6 | -2.0.0 / 2017-09-12 | ||
7 | -================== | ||
8 | - | ||
9 | - * Drop support for Node.js below 0.8 | ||
10 | - * Remove `auth(ctx)` signature -- pass in header or `auth(ctx.req)` | ||
11 | - * Use `safe-buffer` for improved Buffer API | ||
12 | - | ||
13 | -1.1.0 / 2016-11-18 | ||
14 | -================== | ||
15 | - | ||
16 | - * Add `auth.parse` for low-level string parsing | ||
17 | - | ||
18 | -1.0.4 / 2016-05-10 | ||
19 | -================== | ||
20 | - | ||
21 | - * Improve error message when `req` argument is not an object | ||
22 | - * Improve error message when `req` missing `headers` property | ||
23 | - | ||
24 | -1.0.3 / 2015-07-01 | ||
25 | -================== | ||
26 | - | ||
27 | - * Fix regression accepting a Koa context | ||
28 | - | ||
29 | -1.0.2 / 2015-06-12 | ||
30 | -================== | ||
31 | - | ||
32 | - * Improve error message when `req` argument missing | ||
33 | - * perf: enable strict mode | ||
34 | - * perf: hoist regular expression | ||
35 | - * perf: parse with regular expressions | ||
36 | - * perf: remove argument reassignment | ||
37 | - | ||
38 | -1.0.1 / 2015-05-04 | ||
39 | -================== | ||
40 | - | ||
41 | - * Update readme | ||
42 | - | ||
43 | -1.0.0 / 2014-07-01 | ||
44 | -================== | ||
45 | - | ||
46 | - * Support empty password | ||
47 | - * Support empty username | ||
48 | - | ||
49 | -0.0.1 / 2013-11-30 | ||
50 | -================== | ||
51 | - | ||
52 | - * Initial release |
1 | -(The MIT License) | ||
2 | - | ||
3 | -Copyright (c) 2013 TJ Holowaychuk | ||
4 | -Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> | ||
5 | -Copyright (c) 2015-2016 Douglas Christopher Wilson <doug@somethingdoug.com> | ||
6 | - | ||
7 | -Permission is hereby granted, free of charge, to any person obtaining | ||
8 | -a copy of this software and associated documentation files (the | ||
9 | -'Software'), to deal in the Software without restriction, including | ||
10 | -without limitation the rights to use, copy, modify, merge, publish, | ||
11 | -distribute, sublicense, and/or sell copies of the Software, and to | ||
12 | -permit persons to whom the Software is furnished to do so, subject to | ||
13 | -the following conditions: | ||
14 | - | ||
15 | -The above copyright notice and this permission notice shall be | ||
16 | -included in all copies or substantial portions of the Software. | ||
17 | - | ||
18 | -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
19 | -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
20 | -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
21 | -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
22 | -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
23 | -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
24 | -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
1 | -# basic-auth | ||
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 | -Generic basic auth Authorization header field parser for whatever. | ||
10 | - | ||
11 | -## Installation | ||
12 | - | ||
13 | -This is a [Node.js](https://nodejs.org/en/) module available through the | ||
14 | -[npm registry](https://www.npmjs.com/). Installation is done using the | ||
15 | -[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): | ||
16 | - | ||
17 | -``` | ||
18 | -$ npm install basic-auth | ||
19 | -``` | ||
20 | - | ||
21 | -## API | ||
22 | - | ||
23 | -<!-- eslint-disable no-unused-vars --> | ||
24 | - | ||
25 | -```js | ||
26 | -var auth = require('basic-auth') | ||
27 | -``` | ||
28 | - | ||
29 | -### auth(req) | ||
30 | - | ||
31 | -Get the basic auth credentials from the given request. The `Authorization` | ||
32 | -header is parsed and if the header is invalid, `undefined` is returned, | ||
33 | -otherwise an object with `name` and `pass` properties. | ||
34 | - | ||
35 | -### auth.parse(string) | ||
36 | - | ||
37 | -Parse a basic auth authorization header string. This will return an object | ||
38 | -with `name` and `pass` properties, or `undefined` if the string is invalid. | ||
39 | - | ||
40 | -## Example | ||
41 | - | ||
42 | -Pass a Node.js request object to the module export. If parsing fails | ||
43 | -`undefined` is returned, otherwise an object with `.name` and `.pass`. | ||
44 | - | ||
45 | -<!-- eslint-disable no-unused-vars, no-undef --> | ||
46 | - | ||
47 | -```js | ||
48 | -var auth = require('basic-auth') | ||
49 | -var user = auth(req) | ||
50 | -// => { name: 'something', pass: 'whatever' } | ||
51 | -``` | ||
52 | - | ||
53 | -A header string from any other location can also be parsed with | ||
54 | -`auth.parse`, for example a `Proxy-Authorization` header: | ||
55 | - | ||
56 | -<!-- eslint-disable no-unused-vars, no-undef --> | ||
57 | - | ||
58 | -```js | ||
59 | -var auth = require('basic-auth') | ||
60 | -var user = auth.parse(req.getHeader('Proxy-Authorization')) | ||
61 | -``` | ||
62 | - | ||
63 | -### With vanilla node.js http server | ||
64 | - | ||
65 | -```js | ||
66 | -var http = require('http') | ||
67 | -var auth = require('basic-auth') | ||
68 | -var compare = require('tsscmp') | ||
69 | - | ||
70 | -// Create server | ||
71 | -var server = http.createServer(function (req, res) { | ||
72 | - var credentials = auth(req) | ||
73 | - | ||
74 | - // Check credentials | ||
75 | - // The "check" function will typically be against your user store | ||
76 | - if (!credentials || !check(credentials.name, credentials.pass)) { | ||
77 | - res.statusCode = 401 | ||
78 | - res.setHeader('WWW-Authenticate', 'Basic realm="example"') | ||
79 | - res.end('Access denied') | ||
80 | - } else { | ||
81 | - res.end('Access granted') | ||
82 | - } | ||
83 | -}) | ||
84 | - | ||
85 | -// Basic function to validate credentials for example | ||
86 | -function check (name, pass) { | ||
87 | - var valid = true | ||
88 | - | ||
89 | - // Simple method to prevent short-circut and use timing-safe compare | ||
90 | - valid = compare(name, 'john') && valid | ||
91 | - valid = compare(pass, 'secret') && valid | ||
92 | - | ||
93 | - return valid | ||
94 | -} | ||
95 | - | ||
96 | -// Listen | ||
97 | -server.listen(3000) | ||
98 | -``` | ||
99 | - | ||
100 | -# License | ||
101 | - | ||
102 | -[MIT](LICENSE) | ||
103 | - | ||
104 | -[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/basic-auth/master | ||
105 | -[coveralls-url]: https://coveralls.io/r/jshttp/basic-auth?branch=master | ||
106 | -[downloads-image]: https://badgen.net/npm/dm/basic-auth | ||
107 | -[downloads-url]: https://npmjs.org/package/basic-auth | ||
108 | -[node-version-image]: https://badgen.net/npm/node/basic-auth | ||
109 | -[node-version-url]: https://nodejs.org/en/download | ||
110 | -[npm-image]: https://badgen.net/npm/v/basic-auth | ||
111 | -[npm-url]: https://npmjs.org/package/basic-auth | ||
112 | -[travis-image]: https://badgen.net/travis/jshttp/basic-auth/master | ||
113 | -[travis-url]: https://travis-ci.org/jshttp/basic-auth |
1 | -/*! | ||
2 | - * basic-auth | ||
3 | - * Copyright(c) 2013 TJ Holowaychuk | ||
4 | - * Copyright(c) 2014 Jonathan Ong | ||
5 | - * Copyright(c) 2015-2016 Douglas Christopher Wilson | ||
6 | - * MIT Licensed | ||
7 | - */ | ||
8 | - | ||
9 | -'use strict' | ||
10 | - | ||
11 | -/** | ||
12 | - * Module dependencies. | ||
13 | - * @private | ||
14 | - */ | ||
15 | - | ||
16 | -var Buffer = require('safe-buffer').Buffer | ||
17 | - | ||
18 | -/** | ||
19 | - * Module exports. | ||
20 | - * @public | ||
21 | - */ | ||
22 | - | ||
23 | -module.exports = auth | ||
24 | -module.exports.parse = parse | ||
25 | - | ||
26 | -/** | ||
27 | - * RegExp for basic auth credentials | ||
28 | - * | ||
29 | - * credentials = auth-scheme 1*SP token68 | ||
30 | - * auth-scheme = "Basic" ; case insensitive | ||
31 | - * token68 = 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"=" | ||
32 | - * @private | ||
33 | - */ | ||
34 | - | ||
35 | -var CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/ | ||
36 | - | ||
37 | -/** | ||
38 | - * RegExp for basic auth user/pass | ||
39 | - * | ||
40 | - * user-pass = userid ":" password | ||
41 | - * userid = *<TEXT excluding ":"> | ||
42 | - * password = *TEXT | ||
43 | - * @private | ||
44 | - */ | ||
45 | - | ||
46 | -var USER_PASS_REGEXP = /^([^:]*):(.*)$/ | ||
47 | - | ||
48 | -/** | ||
49 | - * Parse the Authorization header field of a request. | ||
50 | - * | ||
51 | - * @param {object} req | ||
52 | - * @return {object} with .name and .pass | ||
53 | - * @public | ||
54 | - */ | ||
55 | - | ||
56 | -function auth (req) { | ||
57 | - if (!req) { | ||
58 | - throw new TypeError('argument req is required') | ||
59 | - } | ||
60 | - | ||
61 | - if (typeof req !== 'object') { | ||
62 | - throw new TypeError('argument req is required to be an object') | ||
63 | - } | ||
64 | - | ||
65 | - // get header | ||
66 | - var header = getAuthorization(req) | ||
67 | - | ||
68 | - // parse header | ||
69 | - return parse(header) | ||
70 | -} | ||
71 | - | ||
72 | -/** | ||
73 | - * Decode base64 string. | ||
74 | - * @private | ||
75 | - */ | ||
76 | - | ||
77 | -function decodeBase64 (str) { | ||
78 | - return Buffer.from(str, 'base64').toString() | ||
79 | -} | ||
80 | - | ||
81 | -/** | ||
82 | - * Get the Authorization header from request object. | ||
83 | - * @private | ||
84 | - */ | ||
85 | - | ||
86 | -function getAuthorization (req) { | ||
87 | - if (!req.headers || typeof req.headers !== 'object') { | ||
88 | - throw new TypeError('argument req is required to have headers property') | ||
89 | - } | ||
90 | - | ||
91 | - return req.headers.authorization | ||
92 | -} | ||
93 | - | ||
94 | -/** | ||
95 | - * Parse basic auth to object. | ||
96 | - * | ||
97 | - * @param {string} string | ||
98 | - * @return {object} | ||
99 | - * @public | ||
100 | - */ | ||
101 | - | ||
102 | -function parse (string) { | ||
103 | - if (typeof string !== 'string') { | ||
104 | - return undefined | ||
105 | - } | ||
106 | - | ||
107 | - // parse header | ||
108 | - var match = CREDENTIALS_REGEXP.exec(string) | ||
109 | - | ||
110 | - if (!match) { | ||
111 | - return undefined | ||
112 | - } | ||
113 | - | ||
114 | - // decode user pass | ||
115 | - var userPass = USER_PASS_REGEXP.exec(decodeBase64(match[1])) | ||
116 | - | ||
117 | - if (!userPass) { | ||
118 | - return undefined | ||
119 | - } | ||
120 | - | ||
121 | - // return credentials object | ||
122 | - return new Credentials(userPass[1], userPass[2]) | ||
123 | -} | ||
124 | - | ||
125 | -/** | ||
126 | - * Object to represent user credentials. | ||
127 | - * @private | ||
128 | - */ | ||
129 | - | ||
130 | -function Credentials (name, pass) { | ||
131 | - this.name = name | ||
132 | - this.pass = pass | ||
133 | -} |
1 | -{ | ||
2 | - "_args": [ | ||
3 | - [ | ||
4 | - "basic-auth@2.0.1", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "basic-auth@2.0.1", | ||
9 | - "_id": "basic-auth@2.0.1", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", | ||
12 | - "_location": "/basic-auth", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "basic-auth@2.0.1", | ||
18 | - "name": "basic-auth", | ||
19 | - "escapedName": "basic-auth", | ||
20 | - "rawSpec": "2.0.1", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "2.0.1" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/morgan" | ||
26 | - ], | ||
27 | - "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", | ||
28 | - "_spec": "2.0.1", | ||
29 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
30 | - "bugs": { | ||
31 | - "url": "https://github.com/jshttp/basic-auth/issues" | ||
32 | - }, | ||
33 | - "dependencies": { | ||
34 | - "safe-buffer": "5.1.2" | ||
35 | - }, | ||
36 | - "description": "node.js basic auth parser", | ||
37 | - "devDependencies": { | ||
38 | - "eslint": "5.6.0", | ||
39 | - "eslint-config-standard": "12.0.0", | ||
40 | - "eslint-plugin-import": "2.14.0", | ||
41 | - "eslint-plugin-markdown": "1.0.0-beta.6", | ||
42 | - "eslint-plugin-node": "7.0.1", | ||
43 | - "eslint-plugin-promise": "4.0.1", | ||
44 | - "eslint-plugin-standard": "4.0.0", | ||
45 | - "istanbul": "0.4.5", | ||
46 | - "mocha": "5.2.0" | ||
47 | - }, | ||
48 | - "engines": { | ||
49 | - "node": ">= 0.8" | ||
50 | - }, | ||
51 | - "files": [ | ||
52 | - "HISTORY.md", | ||
53 | - "LICENSE", | ||
54 | - "index.js" | ||
55 | - ], | ||
56 | - "homepage": "https://github.com/jshttp/basic-auth#readme", | ||
57 | - "keywords": [ | ||
58 | - "basic", | ||
59 | - "auth", | ||
60 | - "authorization", | ||
61 | - "basicauth" | ||
62 | - ], | ||
63 | - "license": "MIT", | ||
64 | - "name": "basic-auth", | ||
65 | - "repository": { | ||
66 | - "type": "git", | ||
67 | - "url": "git+https://github.com/jshttp/basic-auth.git" | ||
68 | - }, | ||
69 | - "scripts": { | ||
70 | - "lint": "eslint --plugin markdown --ext js,md .", | ||
71 | - "test": "mocha --check-leaks --reporter spec --bail", | ||
72 | - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", | ||
73 | - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" | ||
74 | - }, | ||
75 | - "version": "2.0.1" | ||
76 | -} |
This diff is collapsed. Click to expand it.
1 | -(The MIT License) | ||
2 | - | ||
3 | -Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> | ||
4 | -Copyright (c) 2014-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. |
This diff is collapsed. Click to expand it.
1 | -/*! | ||
2 | - * body-parser | ||
3 | - * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
4 | - * MIT Licensed | ||
5 | - */ | ||
6 | - | ||
7 | -'use strict' | ||
8 | - | ||
9 | -/** | ||
10 | - * Module dependencies. | ||
11 | - * @private | ||
12 | - */ | ||
13 | - | ||
14 | -var deprecate = require('depd')('body-parser') | ||
15 | - | ||
16 | -/** | ||
17 | - * Cache of loaded parsers. | ||
18 | - * @private | ||
19 | - */ | ||
20 | - | ||
21 | -var parsers = Object.create(null) | ||
22 | - | ||
23 | -/** | ||
24 | - * @typedef Parsers | ||
25 | - * @type {function} | ||
26 | - * @property {function} json | ||
27 | - * @property {function} raw | ||
28 | - * @property {function} text | ||
29 | - * @property {function} urlencoded | ||
30 | - */ | ||
31 | - | ||
32 | -/** | ||
33 | - * Module exports. | ||
34 | - * @type {Parsers} | ||
35 | - */ | ||
36 | - | ||
37 | -exports = module.exports = deprecate.function(bodyParser, | ||
38 | - 'bodyParser: use individual json/urlencoded middlewares') | ||
39 | - | ||
40 | -/** | ||
41 | - * JSON parser. | ||
42 | - * @public | ||
43 | - */ | ||
44 | - | ||
45 | -Object.defineProperty(exports, 'json', { | ||
46 | - configurable: true, | ||
47 | - enumerable: true, | ||
48 | - get: createParserGetter('json') | ||
49 | -}) | ||
50 | - | ||
51 | -/** | ||
52 | - * Raw parser. | ||
53 | - * @public | ||
54 | - */ | ||
55 | - | ||
56 | -Object.defineProperty(exports, 'raw', { | ||
57 | - configurable: true, | ||
58 | - enumerable: true, | ||
59 | - get: createParserGetter('raw') | ||
60 | -}) | ||
61 | - | ||
62 | -/** | ||
63 | - * Text parser. | ||
64 | - * @public | ||
65 | - */ | ||
66 | - | ||
67 | -Object.defineProperty(exports, 'text', { | ||
68 | - configurable: true, | ||
69 | - enumerable: true, | ||
70 | - get: createParserGetter('text') | ||
71 | -}) | ||
72 | - | ||
73 | -/** | ||
74 | - * URL-encoded parser. | ||
75 | - * @public | ||
76 | - */ | ||
77 | - | ||
78 | -Object.defineProperty(exports, 'urlencoded', { | ||
79 | - configurable: true, | ||
80 | - enumerable: true, | ||
81 | - get: createParserGetter('urlencoded') | ||
82 | -}) | ||
83 | - | ||
84 | -/** | ||
85 | - * Create a middleware to parse json and urlencoded bodies. | ||
86 | - * | ||
87 | - * @param {object} [options] | ||
88 | - * @return {function} | ||
89 | - * @deprecated | ||
90 | - * @public | ||
91 | - */ | ||
92 | - | ||
93 | -function bodyParser (options) { | ||
94 | - var opts = {} | ||
95 | - | ||
96 | - // exclude type option | ||
97 | - if (options) { | ||
98 | - for (var prop in options) { | ||
99 | - if (prop !== 'type') { | ||
100 | - opts[prop] = options[prop] | ||
101 | - } | ||
102 | - } | ||
103 | - } | ||
104 | - | ||
105 | - var _urlencoded = exports.urlencoded(opts) | ||
106 | - var _json = exports.json(opts) | ||
107 | - | ||
108 | - return function bodyParser (req, res, next) { | ||
109 | - _json(req, res, function (err) { | ||
110 | - if (err) return next(err) | ||
111 | - _urlencoded(req, res, next) | ||
112 | - }) | ||
113 | - } | ||
114 | -} | ||
115 | - | ||
116 | -/** | ||
117 | - * Create a getter for loading a parser. | ||
118 | - * @private | ||
119 | - */ | ||
120 | - | ||
121 | -function createParserGetter (name) { | ||
122 | - return function get () { | ||
123 | - return loadParser(name) | ||
124 | - } | ||
125 | -} | ||
126 | - | ||
127 | -/** | ||
128 | - * Load a parser module. | ||
129 | - * @private | ||
130 | - */ | ||
131 | - | ||
132 | -function loadParser (parserName) { | ||
133 | - var parser = parsers[parserName] | ||
134 | - | ||
135 | - if (parser !== undefined) { | ||
136 | - return parser | ||
137 | - } | ||
138 | - | ||
139 | - // this uses a switch for static require analysis | ||
140 | - switch (parserName) { | ||
141 | - case 'json': | ||
142 | - parser = require('./lib/types/json') | ||
143 | - break | ||
144 | - case 'raw': | ||
145 | - parser = require('./lib/types/raw') | ||
146 | - break | ||
147 | - case 'text': | ||
148 | - parser = require('./lib/types/text') | ||
149 | - break | ||
150 | - case 'urlencoded': | ||
151 | - parser = require('./lib/types/urlencoded') | ||
152 | - break | ||
153 | - } | ||
154 | - | ||
155 | - // store to prevent invoking require() | ||
156 | - return (parsers[parserName] = parser) | ||
157 | -} |
1 | -/*! | ||
2 | - * body-parser | ||
3 | - * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
4 | - * MIT Licensed | ||
5 | - */ | ||
6 | - | ||
7 | -'use strict' | ||
8 | - | ||
9 | -/** | ||
10 | - * Module dependencies. | ||
11 | - * @private | ||
12 | - */ | ||
13 | - | ||
14 | -var createError = require('http-errors') | ||
15 | -var getBody = require('raw-body') | ||
16 | -var iconv = require('iconv-lite') | ||
17 | -var onFinished = require('on-finished') | ||
18 | -var zlib = require('zlib') | ||
19 | - | ||
20 | -/** | ||
21 | - * Module exports. | ||
22 | - */ | ||
23 | - | ||
24 | -module.exports = read | ||
25 | - | ||
26 | -/** | ||
27 | - * Read a request into a buffer and parse. | ||
28 | - * | ||
29 | - * @param {object} req | ||
30 | - * @param {object} res | ||
31 | - * @param {function} next | ||
32 | - * @param {function} parse | ||
33 | - * @param {function} debug | ||
34 | - * @param {object} options | ||
35 | - * @private | ||
36 | - */ | ||
37 | - | ||
38 | -function read (req, res, next, parse, debug, options) { | ||
39 | - var length | ||
40 | - var opts = options | ||
41 | - var stream | ||
42 | - | ||
43 | - // flag as parsed | ||
44 | - req._body = true | ||
45 | - | ||
46 | - // read options | ||
47 | - var encoding = opts.encoding !== null | ||
48 | - ? opts.encoding | ||
49 | - : null | ||
50 | - var verify = opts.verify | ||
51 | - | ||
52 | - try { | ||
53 | - // get the content stream | ||
54 | - stream = contentstream(req, debug, opts.inflate) | ||
55 | - length = stream.length | ||
56 | - stream.length = undefined | ||
57 | - } catch (err) { | ||
58 | - return next(err) | ||
59 | - } | ||
60 | - | ||
61 | - // set raw-body options | ||
62 | - opts.length = length | ||
63 | - opts.encoding = verify | ||
64 | - ? null | ||
65 | - : encoding | ||
66 | - | ||
67 | - // assert charset is supported | ||
68 | - if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) { | ||
69 | - return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', { | ||
70 | - charset: encoding.toLowerCase(), | ||
71 | - type: 'charset.unsupported' | ||
72 | - })) | ||
73 | - } | ||
74 | - | ||
75 | - // read body | ||
76 | - debug('read body') | ||
77 | - getBody(stream, opts, function (error, body) { | ||
78 | - if (error) { | ||
79 | - var _error | ||
80 | - | ||
81 | - if (error.type === 'encoding.unsupported') { | ||
82 | - // echo back charset | ||
83 | - _error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', { | ||
84 | - charset: encoding.toLowerCase(), | ||
85 | - type: 'charset.unsupported' | ||
86 | - }) | ||
87 | - } else { | ||
88 | - // set status code on error | ||
89 | - _error = createError(400, error) | ||
90 | - } | ||
91 | - | ||
92 | - // read off entire request | ||
93 | - stream.resume() | ||
94 | - onFinished(req, function onfinished () { | ||
95 | - next(createError(400, _error)) | ||
96 | - }) | ||
97 | - return | ||
98 | - } | ||
99 | - | ||
100 | - // verify | ||
101 | - if (verify) { | ||
102 | - try { | ||
103 | - debug('verify body') | ||
104 | - verify(req, res, body, encoding) | ||
105 | - } catch (err) { | ||
106 | - next(createError(403, err, { | ||
107 | - body: body, | ||
108 | - type: err.type || 'entity.verify.failed' | ||
109 | - })) | ||
110 | - return | ||
111 | - } | ||
112 | - } | ||
113 | - | ||
114 | - // parse | ||
115 | - var str = body | ||
116 | - try { | ||
117 | - debug('parse body') | ||
118 | - str = typeof body !== 'string' && encoding !== null | ||
119 | - ? iconv.decode(body, encoding) | ||
120 | - : body | ||
121 | - req.body = parse(str) | ||
122 | - } catch (err) { | ||
123 | - next(createError(400, err, { | ||
124 | - body: str, | ||
125 | - type: err.type || 'entity.parse.failed' | ||
126 | - })) | ||
127 | - return | ||
128 | - } | ||
129 | - | ||
130 | - next() | ||
131 | - }) | ||
132 | -} | ||
133 | - | ||
134 | -/** | ||
135 | - * Get the content stream of the request. | ||
136 | - * | ||
137 | - * @param {object} req | ||
138 | - * @param {function} debug | ||
139 | - * @param {boolean} [inflate=true] | ||
140 | - * @return {object} | ||
141 | - * @api private | ||
142 | - */ | ||
143 | - | ||
144 | -function contentstream (req, debug, inflate) { | ||
145 | - var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase() | ||
146 | - var length = req.headers['content-length'] | ||
147 | - var stream | ||
148 | - | ||
149 | - debug('content-encoding "%s"', encoding) | ||
150 | - | ||
151 | - if (inflate === false && encoding !== 'identity') { | ||
152 | - throw createError(415, 'content encoding unsupported', { | ||
153 | - encoding: encoding, | ||
154 | - type: 'encoding.unsupported' | ||
155 | - }) | ||
156 | - } | ||
157 | - | ||
158 | - switch (encoding) { | ||
159 | - case 'deflate': | ||
160 | - stream = zlib.createInflate() | ||
161 | - debug('inflate body') | ||
162 | - req.pipe(stream) | ||
163 | - break | ||
164 | - case 'gzip': | ||
165 | - stream = zlib.createGunzip() | ||
166 | - debug('gunzip body') | ||
167 | - req.pipe(stream) | ||
168 | - break | ||
169 | - case 'identity': | ||
170 | - stream = req | ||
171 | - stream.length = length | ||
172 | - break | ||
173 | - default: | ||
174 | - throw createError(415, 'unsupported content encoding "' + encoding + '"', { | ||
175 | - encoding: encoding, | ||
176 | - type: 'encoding.unsupported' | ||
177 | - }) | ||
178 | - } | ||
179 | - | ||
180 | - return stream | ||
181 | -} |
1 | -/*! | ||
2 | - * body-parser | ||
3 | - * Copyright(c) 2014 Jonathan Ong | ||
4 | - * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
5 | - * MIT Licensed | ||
6 | - */ | ||
7 | - | ||
8 | -'use strict' | ||
9 | - | ||
10 | -/** | ||
11 | - * Module dependencies. | ||
12 | - * @private | ||
13 | - */ | ||
14 | - | ||
15 | -var bytes = require('bytes') | ||
16 | -var contentType = require('content-type') | ||
17 | -var createError = require('http-errors') | ||
18 | -var debug = require('debug')('body-parser:json') | ||
19 | -var read = require('../read') | ||
20 | -var typeis = require('type-is') | ||
21 | - | ||
22 | -/** | ||
23 | - * Module exports. | ||
24 | - */ | ||
25 | - | ||
26 | -module.exports = json | ||
27 | - | ||
28 | -/** | ||
29 | - * RegExp to match the first non-space in a string. | ||
30 | - * | ||
31 | - * Allowed whitespace is defined in RFC 7159: | ||
32 | - * | ||
33 | - * ws = *( | ||
34 | - * %x20 / ; Space | ||
35 | - * %x09 / ; Horizontal tab | ||
36 | - * %x0A / ; Line feed or New line | ||
37 | - * %x0D ) ; Carriage return | ||
38 | - */ | ||
39 | - | ||
40 | -var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*(.)/ // eslint-disable-line no-control-regex | ||
41 | - | ||
42 | -/** | ||
43 | - * Create a middleware to parse JSON bodies. | ||
44 | - * | ||
45 | - * @param {object} [options] | ||
46 | - * @return {function} | ||
47 | - * @public | ||
48 | - */ | ||
49 | - | ||
50 | -function json (options) { | ||
51 | - var opts = options || {} | ||
52 | - | ||
53 | - var limit = typeof opts.limit !== 'number' | ||
54 | - ? bytes.parse(opts.limit || '100kb') | ||
55 | - : opts.limit | ||
56 | - var inflate = opts.inflate !== false | ||
57 | - var reviver = opts.reviver | ||
58 | - var strict = opts.strict !== false | ||
59 | - var type = opts.type || 'application/json' | ||
60 | - var verify = opts.verify || false | ||
61 | - | ||
62 | - if (verify !== false && typeof verify !== 'function') { | ||
63 | - throw new TypeError('option verify must be function') | ||
64 | - } | ||
65 | - | ||
66 | - // create the appropriate type checking function | ||
67 | - var shouldParse = typeof type !== 'function' | ||
68 | - ? typeChecker(type) | ||
69 | - : type | ||
70 | - | ||
71 | - function parse (body) { | ||
72 | - if (body.length === 0) { | ||
73 | - // special-case empty json body, as it's a common client-side mistake | ||
74 | - // TODO: maybe make this configurable or part of "strict" option | ||
75 | - return {} | ||
76 | - } | ||
77 | - | ||
78 | - if (strict) { | ||
79 | - var first = firstchar(body) | ||
80 | - | ||
81 | - if (first !== '{' && first !== '[') { | ||
82 | - debug('strict violation') | ||
83 | - throw createStrictSyntaxError(body, first) | ||
84 | - } | ||
85 | - } | ||
86 | - | ||
87 | - try { | ||
88 | - debug('parse json') | ||
89 | - return JSON.parse(body, reviver) | ||
90 | - } catch (e) { | ||
91 | - throw normalizeJsonSyntaxError(e, { | ||
92 | - message: e.message, | ||
93 | - stack: e.stack | ||
94 | - }) | ||
95 | - } | ||
96 | - } | ||
97 | - | ||
98 | - return function jsonParser (req, res, next) { | ||
99 | - if (req._body) { | ||
100 | - debug('body already parsed') | ||
101 | - next() | ||
102 | - return | ||
103 | - } | ||
104 | - | ||
105 | - req.body = req.body || {} | ||
106 | - | ||
107 | - // skip requests without bodies | ||
108 | - if (!typeis.hasBody(req)) { | ||
109 | - debug('skip empty body') | ||
110 | - next() | ||
111 | - return | ||
112 | - } | ||
113 | - | ||
114 | - debug('content-type %j', req.headers['content-type']) | ||
115 | - | ||
116 | - // determine if request should be parsed | ||
117 | - if (!shouldParse(req)) { | ||
118 | - debug('skip parsing') | ||
119 | - next() | ||
120 | - return | ||
121 | - } | ||
122 | - | ||
123 | - // assert charset per RFC 7159 sec 8.1 | ||
124 | - var charset = getCharset(req) || 'utf-8' | ||
125 | - if (charset.substr(0, 4) !== 'utf-') { | ||
126 | - debug('invalid charset') | ||
127 | - next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { | ||
128 | - charset: charset, | ||
129 | - type: 'charset.unsupported' | ||
130 | - })) | ||
131 | - return | ||
132 | - } | ||
133 | - | ||
134 | - // read | ||
135 | - read(req, res, next, parse, debug, { | ||
136 | - encoding: charset, | ||
137 | - inflate: inflate, | ||
138 | - limit: limit, | ||
139 | - verify: verify | ||
140 | - }) | ||
141 | - } | ||
142 | -} | ||
143 | - | ||
144 | -/** | ||
145 | - * Create strict violation syntax error matching native error. | ||
146 | - * | ||
147 | - * @param {string} str | ||
148 | - * @param {string} char | ||
149 | - * @return {Error} | ||
150 | - * @private | ||
151 | - */ | ||
152 | - | ||
153 | -function createStrictSyntaxError (str, char) { | ||
154 | - var index = str.indexOf(char) | ||
155 | - var partial = str.substring(0, index) + '#' | ||
156 | - | ||
157 | - try { | ||
158 | - JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation') | ||
159 | - } catch (e) { | ||
160 | - return normalizeJsonSyntaxError(e, { | ||
161 | - message: e.message.replace('#', char), | ||
162 | - stack: e.stack | ||
163 | - }) | ||
164 | - } | ||
165 | -} | ||
166 | - | ||
167 | -/** | ||
168 | - * Get the first non-whitespace character in a string. | ||
169 | - * | ||
170 | - * @param {string} str | ||
171 | - * @return {function} | ||
172 | - * @private | ||
173 | - */ | ||
174 | - | ||
175 | -function firstchar (str) { | ||
176 | - return FIRST_CHAR_REGEXP.exec(str)[1] | ||
177 | -} | ||
178 | - | ||
179 | -/** | ||
180 | - * Get the charset of a request. | ||
181 | - * | ||
182 | - * @param {object} req | ||
183 | - * @api private | ||
184 | - */ | ||
185 | - | ||
186 | -function getCharset (req) { | ||
187 | - try { | ||
188 | - return (contentType.parse(req).parameters.charset || '').toLowerCase() | ||
189 | - } catch (e) { | ||
190 | - return undefined | ||
191 | - } | ||
192 | -} | ||
193 | - | ||
194 | -/** | ||
195 | - * Normalize a SyntaxError for JSON.parse. | ||
196 | - * | ||
197 | - * @param {SyntaxError} error | ||
198 | - * @param {object} obj | ||
199 | - * @return {SyntaxError} | ||
200 | - */ | ||
201 | - | ||
202 | -function normalizeJsonSyntaxError (error, obj) { | ||
203 | - var keys = Object.getOwnPropertyNames(error) | ||
204 | - | ||
205 | - for (var i = 0; i < keys.length; i++) { | ||
206 | - var key = keys[i] | ||
207 | - if (key !== 'stack' && key !== 'message') { | ||
208 | - delete error[key] | ||
209 | - } | ||
210 | - } | ||
211 | - | ||
212 | - // replace stack before message for Node.js 0.10 and below | ||
213 | - error.stack = obj.stack.replace(error.message, obj.message) | ||
214 | - error.message = obj.message | ||
215 | - | ||
216 | - return error | ||
217 | -} | ||
218 | - | ||
219 | -/** | ||
220 | - * Get the simple type checker. | ||
221 | - * | ||
222 | - * @param {string} type | ||
223 | - * @return {function} | ||
224 | - */ | ||
225 | - | ||
226 | -function typeChecker (type) { | ||
227 | - return function checkType (req) { | ||
228 | - return Boolean(typeis(req, type)) | ||
229 | - } | ||
230 | -} |
1 | -/*! | ||
2 | - * body-parser | ||
3 | - * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
4 | - * MIT Licensed | ||
5 | - */ | ||
6 | - | ||
7 | -'use strict' | ||
8 | - | ||
9 | -/** | ||
10 | - * Module dependencies. | ||
11 | - */ | ||
12 | - | ||
13 | -var bytes = require('bytes') | ||
14 | -var debug = require('debug')('body-parser:raw') | ||
15 | -var read = require('../read') | ||
16 | -var typeis = require('type-is') | ||
17 | - | ||
18 | -/** | ||
19 | - * Module exports. | ||
20 | - */ | ||
21 | - | ||
22 | -module.exports = raw | ||
23 | - | ||
24 | -/** | ||
25 | - * Create a middleware to parse raw bodies. | ||
26 | - * | ||
27 | - * @param {object} [options] | ||
28 | - * @return {function} | ||
29 | - * @api public | ||
30 | - */ | ||
31 | - | ||
32 | -function raw (options) { | ||
33 | - var opts = options || {} | ||
34 | - | ||
35 | - var inflate = opts.inflate !== false | ||
36 | - var limit = typeof opts.limit !== 'number' | ||
37 | - ? bytes.parse(opts.limit || '100kb') | ||
38 | - : opts.limit | ||
39 | - var type = opts.type || 'application/octet-stream' | ||
40 | - var verify = opts.verify || false | ||
41 | - | ||
42 | - if (verify !== false && typeof verify !== 'function') { | ||
43 | - throw new TypeError('option verify must be function') | ||
44 | - } | ||
45 | - | ||
46 | - // create the appropriate type checking function | ||
47 | - var shouldParse = typeof type !== 'function' | ||
48 | - ? typeChecker(type) | ||
49 | - : type | ||
50 | - | ||
51 | - function parse (buf) { | ||
52 | - return buf | ||
53 | - } | ||
54 | - | ||
55 | - return function rawParser (req, res, next) { | ||
56 | - if (req._body) { | ||
57 | - debug('body already parsed') | ||
58 | - next() | ||
59 | - return | ||
60 | - } | ||
61 | - | ||
62 | - req.body = req.body || {} | ||
63 | - | ||
64 | - // skip requests without bodies | ||
65 | - if (!typeis.hasBody(req)) { | ||
66 | - debug('skip empty body') | ||
67 | - next() | ||
68 | - return | ||
69 | - } | ||
70 | - | ||
71 | - debug('content-type %j', req.headers['content-type']) | ||
72 | - | ||
73 | - // determine if request should be parsed | ||
74 | - if (!shouldParse(req)) { | ||
75 | - debug('skip parsing') | ||
76 | - next() | ||
77 | - return | ||
78 | - } | ||
79 | - | ||
80 | - // read | ||
81 | - read(req, res, next, parse, debug, { | ||
82 | - encoding: null, | ||
83 | - inflate: inflate, | ||
84 | - limit: limit, | ||
85 | - verify: verify | ||
86 | - }) | ||
87 | - } | ||
88 | -} | ||
89 | - | ||
90 | -/** | ||
91 | - * Get the simple type checker. | ||
92 | - * | ||
93 | - * @param {string} type | ||
94 | - * @return {function} | ||
95 | - */ | ||
96 | - | ||
97 | -function typeChecker (type) { | ||
98 | - return function checkType (req) { | ||
99 | - return Boolean(typeis(req, type)) | ||
100 | - } | ||
101 | -} |
1 | -/*! | ||
2 | - * body-parser | ||
3 | - * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
4 | - * MIT Licensed | ||
5 | - */ | ||
6 | - | ||
7 | -'use strict' | ||
8 | - | ||
9 | -/** | ||
10 | - * Module dependencies. | ||
11 | - */ | ||
12 | - | ||
13 | -var bytes = require('bytes') | ||
14 | -var contentType = require('content-type') | ||
15 | -var debug = require('debug')('body-parser:text') | ||
16 | -var read = require('../read') | ||
17 | -var typeis = require('type-is') | ||
18 | - | ||
19 | -/** | ||
20 | - * Module exports. | ||
21 | - */ | ||
22 | - | ||
23 | -module.exports = text | ||
24 | - | ||
25 | -/** | ||
26 | - * Create a middleware to parse text bodies. | ||
27 | - * | ||
28 | - * @param {object} [options] | ||
29 | - * @return {function} | ||
30 | - * @api public | ||
31 | - */ | ||
32 | - | ||
33 | -function text (options) { | ||
34 | - var opts = options || {} | ||
35 | - | ||
36 | - var defaultCharset = opts.defaultCharset || 'utf-8' | ||
37 | - var inflate = opts.inflate !== false | ||
38 | - var limit = typeof opts.limit !== 'number' | ||
39 | - ? bytes.parse(opts.limit || '100kb') | ||
40 | - : opts.limit | ||
41 | - var type = opts.type || 'text/plain' | ||
42 | - var verify = opts.verify || false | ||
43 | - | ||
44 | - if (verify !== false && typeof verify !== 'function') { | ||
45 | - throw new TypeError('option verify must be function') | ||
46 | - } | ||
47 | - | ||
48 | - // create the appropriate type checking function | ||
49 | - var shouldParse = typeof type !== 'function' | ||
50 | - ? typeChecker(type) | ||
51 | - : type | ||
52 | - | ||
53 | - function parse (buf) { | ||
54 | - return buf | ||
55 | - } | ||
56 | - | ||
57 | - return function textParser (req, res, next) { | ||
58 | - if (req._body) { | ||
59 | - debug('body already parsed') | ||
60 | - next() | ||
61 | - return | ||
62 | - } | ||
63 | - | ||
64 | - req.body = req.body || {} | ||
65 | - | ||
66 | - // skip requests without bodies | ||
67 | - if (!typeis.hasBody(req)) { | ||
68 | - debug('skip empty body') | ||
69 | - next() | ||
70 | - return | ||
71 | - } | ||
72 | - | ||
73 | - debug('content-type %j', req.headers['content-type']) | ||
74 | - | ||
75 | - // determine if request should be parsed | ||
76 | - if (!shouldParse(req)) { | ||
77 | - debug('skip parsing') | ||
78 | - next() | ||
79 | - return | ||
80 | - } | ||
81 | - | ||
82 | - // get charset | ||
83 | - var charset = getCharset(req) || defaultCharset | ||
84 | - | ||
85 | - // read | ||
86 | - read(req, res, next, parse, debug, { | ||
87 | - encoding: charset, | ||
88 | - inflate: inflate, | ||
89 | - limit: limit, | ||
90 | - verify: verify | ||
91 | - }) | ||
92 | - } | ||
93 | -} | ||
94 | - | ||
95 | -/** | ||
96 | - * Get the charset of a request. | ||
97 | - * | ||
98 | - * @param {object} req | ||
99 | - * @api private | ||
100 | - */ | ||
101 | - | ||
102 | -function getCharset (req) { | ||
103 | - try { | ||
104 | - return (contentType.parse(req).parameters.charset || '').toLowerCase() | ||
105 | - } catch (e) { | ||
106 | - return undefined | ||
107 | - } | ||
108 | -} | ||
109 | - | ||
110 | -/** | ||
111 | - * Get the simple type checker. | ||
112 | - * | ||
113 | - * @param {string} type | ||
114 | - * @return {function} | ||
115 | - */ | ||
116 | - | ||
117 | -function typeChecker (type) { | ||
118 | - return function checkType (req) { | ||
119 | - return Boolean(typeis(req, type)) | ||
120 | - } | ||
121 | -} |
1 | -/*! | ||
2 | - * body-parser | ||
3 | - * Copyright(c) 2014 Jonathan Ong | ||
4 | - * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
5 | - * MIT Licensed | ||
6 | - */ | ||
7 | - | ||
8 | -'use strict' | ||
9 | - | ||
10 | -/** | ||
11 | - * Module dependencies. | ||
12 | - * @private | ||
13 | - */ | ||
14 | - | ||
15 | -var bytes = require('bytes') | ||
16 | -var contentType = require('content-type') | ||
17 | -var createError = require('http-errors') | ||
18 | -var debug = require('debug')('body-parser:urlencoded') | ||
19 | -var deprecate = require('depd')('body-parser') | ||
20 | -var read = require('../read') | ||
21 | -var typeis = require('type-is') | ||
22 | - | ||
23 | -/** | ||
24 | - * Module exports. | ||
25 | - */ | ||
26 | - | ||
27 | -module.exports = urlencoded | ||
28 | - | ||
29 | -/** | ||
30 | - * Cache of parser modules. | ||
31 | - */ | ||
32 | - | ||
33 | -var parsers = Object.create(null) | ||
34 | - | ||
35 | -/** | ||
36 | - * Create a middleware to parse urlencoded bodies. | ||
37 | - * | ||
38 | - * @param {object} [options] | ||
39 | - * @return {function} | ||
40 | - * @public | ||
41 | - */ | ||
42 | - | ||
43 | -function urlencoded (options) { | ||
44 | - var opts = options || {} | ||
45 | - | ||
46 | - // notice because option default will flip in next major | ||
47 | - if (opts.extended === undefined) { | ||
48 | - deprecate('undefined extended: provide extended option') | ||
49 | - } | ||
50 | - | ||
51 | - var extended = opts.extended !== false | ||
52 | - var inflate = opts.inflate !== false | ||
53 | - var limit = typeof opts.limit !== 'number' | ||
54 | - ? bytes.parse(opts.limit || '100kb') | ||
55 | - : opts.limit | ||
56 | - var type = opts.type || 'application/x-www-form-urlencoded' | ||
57 | - var verify = opts.verify || false | ||
58 | - | ||
59 | - if (verify !== false && typeof verify !== 'function') { | ||
60 | - throw new TypeError('option verify must be function') | ||
61 | - } | ||
62 | - | ||
63 | - // create the appropriate query parser | ||
64 | - var queryparse = extended | ||
65 | - ? extendedparser(opts) | ||
66 | - : simpleparser(opts) | ||
67 | - | ||
68 | - // create the appropriate type checking function | ||
69 | - var shouldParse = typeof type !== 'function' | ||
70 | - ? typeChecker(type) | ||
71 | - : type | ||
72 | - | ||
73 | - function parse (body) { | ||
74 | - return body.length | ||
75 | - ? queryparse(body) | ||
76 | - : {} | ||
77 | - } | ||
78 | - | ||
79 | - return function urlencodedParser (req, res, next) { | ||
80 | - if (req._body) { | ||
81 | - debug('body already parsed') | ||
82 | - next() | ||
83 | - return | ||
84 | - } | ||
85 | - | ||
86 | - req.body = req.body || {} | ||
87 | - | ||
88 | - // skip requests without bodies | ||
89 | - if (!typeis.hasBody(req)) { | ||
90 | - debug('skip empty body') | ||
91 | - next() | ||
92 | - return | ||
93 | - } | ||
94 | - | ||
95 | - debug('content-type %j', req.headers['content-type']) | ||
96 | - | ||
97 | - // determine if request should be parsed | ||
98 | - if (!shouldParse(req)) { | ||
99 | - debug('skip parsing') | ||
100 | - next() | ||
101 | - return | ||
102 | - } | ||
103 | - | ||
104 | - // assert charset | ||
105 | - var charset = getCharset(req) || 'utf-8' | ||
106 | - if (charset !== 'utf-8') { | ||
107 | - debug('invalid charset') | ||
108 | - next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { | ||
109 | - charset: charset, | ||
110 | - type: 'charset.unsupported' | ||
111 | - })) | ||
112 | - return | ||
113 | - } | ||
114 | - | ||
115 | - // read | ||
116 | - read(req, res, next, parse, debug, { | ||
117 | - debug: debug, | ||
118 | - encoding: charset, | ||
119 | - inflate: inflate, | ||
120 | - limit: limit, | ||
121 | - verify: verify | ||
122 | - }) | ||
123 | - } | ||
124 | -} | ||
125 | - | ||
126 | -/** | ||
127 | - * Get the extended query parser. | ||
128 | - * | ||
129 | - * @param {object} options | ||
130 | - */ | ||
131 | - | ||
132 | -function extendedparser (options) { | ||
133 | - var parameterLimit = options.parameterLimit !== undefined | ||
134 | - ? options.parameterLimit | ||
135 | - : 1000 | ||
136 | - var parse = parser('qs') | ||
137 | - | ||
138 | - if (isNaN(parameterLimit) || parameterLimit < 1) { | ||
139 | - throw new TypeError('option parameterLimit must be a positive number') | ||
140 | - } | ||
141 | - | ||
142 | - if (isFinite(parameterLimit)) { | ||
143 | - parameterLimit = parameterLimit | 0 | ||
144 | - } | ||
145 | - | ||
146 | - return function queryparse (body) { | ||
147 | - var paramCount = parameterCount(body, parameterLimit) | ||
148 | - | ||
149 | - if (paramCount === undefined) { | ||
150 | - debug('too many parameters') | ||
151 | - throw createError(413, 'too many parameters', { | ||
152 | - type: 'parameters.too.many' | ||
153 | - }) | ||
154 | - } | ||
155 | - | ||
156 | - var arrayLimit = Math.max(100, paramCount) | ||
157 | - | ||
158 | - debug('parse extended urlencoding') | ||
159 | - return parse(body, { | ||
160 | - allowPrototypes: true, | ||
161 | - arrayLimit: arrayLimit, | ||
162 | - depth: Infinity, | ||
163 | - parameterLimit: parameterLimit | ||
164 | - }) | ||
165 | - } | ||
166 | -} | ||
167 | - | ||
168 | -/** | ||
169 | - * Get the charset of a request. | ||
170 | - * | ||
171 | - * @param {object} req | ||
172 | - * @api private | ||
173 | - */ | ||
174 | - | ||
175 | -function getCharset (req) { | ||
176 | - try { | ||
177 | - return (contentType.parse(req).parameters.charset || '').toLowerCase() | ||
178 | - } catch (e) { | ||
179 | - return undefined | ||
180 | - } | ||
181 | -} | ||
182 | - | ||
183 | -/** | ||
184 | - * Count the number of parameters, stopping once limit reached | ||
185 | - * | ||
186 | - * @param {string} body | ||
187 | - * @param {number} limit | ||
188 | - * @api private | ||
189 | - */ | ||
190 | - | ||
191 | -function parameterCount (body, limit) { | ||
192 | - var count = 0 | ||
193 | - var index = 0 | ||
194 | - | ||
195 | - while ((index = body.indexOf('&', index)) !== -1) { | ||
196 | - count++ | ||
197 | - index++ | ||
198 | - | ||
199 | - if (count === limit) { | ||
200 | - return undefined | ||
201 | - } | ||
202 | - } | ||
203 | - | ||
204 | - return count | ||
205 | -} | ||
206 | - | ||
207 | -/** | ||
208 | - * Get parser for module name dynamically. | ||
209 | - * | ||
210 | - * @param {string} name | ||
211 | - * @return {function} | ||
212 | - * @api private | ||
213 | - */ | ||
214 | - | ||
215 | -function parser (name) { | ||
216 | - var mod = parsers[name] | ||
217 | - | ||
218 | - if (mod !== undefined) { | ||
219 | - return mod.parse | ||
220 | - } | ||
221 | - | ||
222 | - // this uses a switch for static require analysis | ||
223 | - switch (name) { | ||
224 | - case 'qs': | ||
225 | - mod = require('qs') | ||
226 | - break | ||
227 | - case 'querystring': | ||
228 | - mod = require('querystring') | ||
229 | - break | ||
230 | - } | ||
231 | - | ||
232 | - // store to prevent invoking require() | ||
233 | - parsers[name] = mod | ||
234 | - | ||
235 | - return mod.parse | ||
236 | -} | ||
237 | - | ||
238 | -/** | ||
239 | - * Get the simple query parser. | ||
240 | - * | ||
241 | - * @param {object} options | ||
242 | - */ | ||
243 | - | ||
244 | -function simpleparser (options) { | ||
245 | - var parameterLimit = options.parameterLimit !== undefined | ||
246 | - ? options.parameterLimit | ||
247 | - : 1000 | ||
248 | - var parse = parser('querystring') | ||
249 | - | ||
250 | - if (isNaN(parameterLimit) || parameterLimit < 1) { | ||
251 | - throw new TypeError('option parameterLimit must be a positive number') | ||
252 | - } | ||
253 | - | ||
254 | - if (isFinite(parameterLimit)) { | ||
255 | - parameterLimit = parameterLimit | 0 | ||
256 | - } | ||
257 | - | ||
258 | - return function queryparse (body) { | ||
259 | - var paramCount = parameterCount(body, parameterLimit) | ||
260 | - | ||
261 | - if (paramCount === undefined) { | ||
262 | - debug('too many parameters') | ||
263 | - throw createError(413, 'too many parameters', { | ||
264 | - type: 'parameters.too.many' | ||
265 | - }) | ||
266 | - } | ||
267 | - | ||
268 | - debug('parse urlencoding') | ||
269 | - return parse(body, undefined, undefined, {maxKeys: parameterLimit}) | ||
270 | - } | ||
271 | -} | ||
272 | - | ||
273 | -/** | ||
274 | - * Get the simple type checker. | ||
275 | - * | ||
276 | - * @param {string} type | ||
277 | - * @return {function} | ||
278 | - */ | ||
279 | - | ||
280 | -function typeChecker (type) { | ||
281 | - return function checkType (req) { | ||
282 | - return Boolean(typeis(req, type)) | ||
283 | - } | ||
284 | -} |
1 | -{ | ||
2 | - "_args": [ | ||
3 | - [ | ||
4 | - "body-parser@1.18.3", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "body-parser@1.18.3", | ||
9 | - "_id": "body-parser@1.18.3", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", | ||
12 | - "_location": "/body-parser", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "body-parser@1.18.3", | ||
18 | - "name": "body-parser", | ||
19 | - "escapedName": "body-parser", | ||
20 | - "rawSpec": "1.18.3", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "1.18.3" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/express" | ||
26 | - ], | ||
27 | - "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", | ||
28 | - "_spec": "1.18.3", | ||
29 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
30 | - "bugs": { | ||
31 | - "url": "https://github.com/expressjs/body-parser/issues" | ||
32 | - }, | ||
33 | - "contributors": [ | ||
34 | - { | ||
35 | - "name": "Douglas Christopher Wilson", | ||
36 | - "email": "doug@somethingdoug.com" | ||
37 | - }, | ||
38 | - { | ||
39 | - "name": "Jonathan Ong", | ||
40 | - "email": "me@jongleberry.com", | ||
41 | - "url": "http://jongleberry.com" | ||
42 | - } | ||
43 | - ], | ||
44 | - "dependencies": { | ||
45 | - "bytes": "3.0.0", | ||
46 | - "content-type": "~1.0.4", | ||
47 | - "debug": "2.6.9", | ||
48 | - "depd": "~1.1.2", | ||
49 | - "http-errors": "~1.6.3", | ||
50 | - "iconv-lite": "0.4.23", | ||
51 | - "on-finished": "~2.3.0", | ||
52 | - "qs": "6.5.2", | ||
53 | - "raw-body": "2.3.3", | ||
54 | - "type-is": "~1.6.16" | ||
55 | - }, | ||
56 | - "description": "Node.js body parsing middleware", | ||
57 | - "devDependencies": { | ||
58 | - "eslint": "4.19.1", | ||
59 | - "eslint-config-standard": "11.0.0", | ||
60 | - "eslint-plugin-import": "2.11.0", | ||
61 | - "eslint-plugin-markdown": "1.0.0-beta.6", | ||
62 | - "eslint-plugin-node": "6.0.1", | ||
63 | - "eslint-plugin-promise": "3.7.0", | ||
64 | - "eslint-plugin-standard": "3.1.0", | ||
65 | - "istanbul": "0.4.5", | ||
66 | - "methods": "1.1.2", | ||
67 | - "mocha": "2.5.3", | ||
68 | - "safe-buffer": "5.1.2", | ||
69 | - "supertest": "1.1.0" | ||
70 | - }, | ||
71 | - "engines": { | ||
72 | - "node": ">= 0.8" | ||
73 | - }, | ||
74 | - "files": [ | ||
75 | - "lib/", | ||
76 | - "LICENSE", | ||
77 | - "HISTORY.md", | ||
78 | - "index.js" | ||
79 | - ], | ||
80 | - "homepage": "https://github.com/expressjs/body-parser#readme", | ||
81 | - "license": "MIT", | ||
82 | - "name": "body-parser", | ||
83 | - "repository": { | ||
84 | - "type": "git", | ||
85 | - "url": "git+https://github.com/expressjs/body-parser.git" | ||
86 | - }, | ||
87 | - "scripts": { | ||
88 | - "lint": "eslint --plugin markdown --ext js,md .", | ||
89 | - "test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/", | ||
90 | - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/", | ||
91 | - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/" | ||
92 | - }, | ||
93 | - "version": "1.18.3" | ||
94 | -} |
1 | -3.0.0 / 2017-08-31 | ||
2 | -================== | ||
3 | - | ||
4 | - * Change "kB" to "KB" in format output | ||
5 | - * Remove support for Node.js 0.6 | ||
6 | - * Remove support for ComponentJS | ||
7 | - | ||
8 | -2.5.0 / 2017-03-24 | ||
9 | -================== | ||
10 | - | ||
11 | - * Add option "unit" | ||
12 | - | ||
13 | -2.4.0 / 2016-06-01 | ||
14 | -================== | ||
15 | - | ||
16 | - * Add option "unitSeparator" | ||
17 | - | ||
18 | -2.3.0 / 2016-02-15 | ||
19 | -================== | ||
20 | - | ||
21 | - * Drop partial bytes on all parsed units | ||
22 | - * Fix non-finite numbers to `.format` to return `null` | ||
23 | - * Fix parsing byte string that looks like hex | ||
24 | - * perf: hoist regular expressions | ||
25 | - | ||
26 | -2.2.0 / 2015-11-13 | ||
27 | -================== | ||
28 | - | ||
29 | - * add option "decimalPlaces" | ||
30 | - * add option "fixedDecimals" | ||
31 | - | ||
32 | -2.1.0 / 2015-05-21 | ||
33 | -================== | ||
34 | - | ||
35 | - * add `.format` export | ||
36 | - * add `.parse` export | ||
37 | - | ||
38 | -2.0.2 / 2015-05-20 | ||
39 | -================== | ||
40 | - | ||
41 | - * remove map recreation | ||
42 | - * remove unnecessary object construction | ||
43 | - | ||
44 | -2.0.1 / 2015-05-07 | ||
45 | -================== | ||
46 | - | ||
47 | - * fix browserify require | ||
48 | - * remove node.extend dependency | ||
49 | - | ||
50 | -2.0.0 / 2015-04-12 | ||
51 | -================== | ||
52 | - | ||
53 | - * add option "case" | ||
54 | - * add option "thousandsSeparator" | ||
55 | - * return "null" on invalid parse input | ||
56 | - * support proper round-trip: bytes(bytes(num)) === num | ||
57 | - * units no longer case sensitive when parsing | ||
58 | - | ||
59 | -1.0.0 / 2014-05-05 | ||
60 | -================== | ||
61 | - | ||
62 | - * add negative support. fixes #6 | ||
63 | - | ||
64 | -0.3.0 / 2014-03-19 | ||
65 | -================== | ||
66 | - | ||
67 | - * added terabyte support | ||
68 | - | ||
69 | -0.2.1 / 2013-04-01 | ||
70 | -================== | ||
71 | - | ||
72 | - * add .component | ||
73 | - | ||
74 | -0.2.0 / 2012-10-28 | ||
75 | -================== | ||
76 | - | ||
77 | - * bytes(200).should.eql('200b') | ||
78 | - | ||
79 | -0.1.0 / 2012-07-04 | ||
80 | -================== | ||
81 | - | ||
82 | - * add bytes to string conversion [yields] |
trollgg/node_modules/bytes/LICENSE
deleted
100644 → 0
1 | -(The MIT License) | ||
2 | - | ||
3 | -Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca> | ||
4 | -Copyright (c) 2015 Jed Watson <jed.watson@me.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. |
trollgg/node_modules/bytes/Readme.md
deleted
100644 → 0
1 | -# Bytes utility | ||
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 | -Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa. | ||
9 | - | ||
10 | -## Installation | ||
11 | - | ||
12 | -This is a [Node.js](https://nodejs.org/en/) module available through the | ||
13 | -[npm registry](https://www.npmjs.com/). Installation is done using the | ||
14 | -[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): | ||
15 | - | ||
16 | -```bash | ||
17 | -$ npm install bytes | ||
18 | -``` | ||
19 | - | ||
20 | -## Usage | ||
21 | - | ||
22 | -```js | ||
23 | -var bytes = require('bytes'); | ||
24 | -``` | ||
25 | - | ||
26 | -#### bytes.format(number value, [options]): string|null | ||
27 | - | ||
28 | -Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is | ||
29 | - rounded. | ||
30 | - | ||
31 | -**Arguments** | ||
32 | - | ||
33 | -| Name | Type | Description | | ||
34 | -|---------|----------|--------------------| | ||
35 | -| value | `number` | Value in bytes | | ||
36 | -| options | `Object` | Conversion options | | ||
37 | - | ||
38 | -**Options** | ||
39 | - | ||
40 | -| Property | Type | Description | | ||
41 | -|-------------------|--------|-----------------------------------------------------------------------------------------| | ||
42 | -| decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. | | ||
43 | -| fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` | | ||
44 | -| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `.`... Default value to `''`. | | ||
45 | -| unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). | | ||
46 | -| unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. | | ||
47 | - | ||
48 | -**Returns** | ||
49 | - | ||
50 | -| Name | Type | Description | | ||
51 | -|---------|------------------|-------------------------------------------------| | ||
52 | -| results | `string`|`null` | Return null upon error. String value otherwise. | | ||
53 | - | ||
54 | -**Example** | ||
55 | - | ||
56 | -```js | ||
57 | -bytes(1024); | ||
58 | -// output: '1KB' | ||
59 | - | ||
60 | -bytes(1000); | ||
61 | -// output: '1000B' | ||
62 | - | ||
63 | -bytes(1000, {thousandsSeparator: ' '}); | ||
64 | -// output: '1 000B' | ||
65 | - | ||
66 | -bytes(1024 * 1.7, {decimalPlaces: 0}); | ||
67 | -// output: '2KB' | ||
68 | - | ||
69 | -bytes(1024, {unitSeparator: ' '}); | ||
70 | -// output: '1 KB' | ||
71 | - | ||
72 | -``` | ||
73 | - | ||
74 | -#### bytes.parse(string|number value): number|null | ||
75 | - | ||
76 | -Parse the string value into an integer in bytes. If no unit is given, or `value` | ||
77 | -is a number, it is assumed the value is in bytes. | ||
78 | - | ||
79 | -Supported units and abbreviations are as follows and are case-insensitive: | ||
80 | - | ||
81 | - * `b` for bytes | ||
82 | - * `kb` for kilobytes | ||
83 | - * `mb` for megabytes | ||
84 | - * `gb` for gigabytes | ||
85 | - * `tb` for terabytes | ||
86 | - | ||
87 | -The units are in powers of two, not ten. This means 1kb = 1024b according to this parser. | ||
88 | - | ||
89 | -**Arguments** | ||
90 | - | ||
91 | -| Name | Type | Description | | ||
92 | -|---------------|--------|--------------------| | ||
93 | -| value | `string`|`number` | String to parse, or number in bytes. | | ||
94 | - | ||
95 | -**Returns** | ||
96 | - | ||
97 | -| Name | Type | Description | | ||
98 | -|---------|-------------|-------------------------| | ||
99 | -| results | `number`|`null` | Return null upon error. Value in bytes otherwise. | | ||
100 | - | ||
101 | -**Example** | ||
102 | - | ||
103 | -```js | ||
104 | -bytes('1KB'); | ||
105 | -// output: 1024 | ||
106 | - | ||
107 | -bytes('1024'); | ||
108 | -// output: 1024 | ||
109 | - | ||
110 | -bytes(1024); | ||
111 | -// output: 1024 | ||
112 | -``` | ||
113 | - | ||
114 | -## License | ||
115 | - | ||
116 | -[MIT](LICENSE) | ||
117 | - | ||
118 | -[downloads-image]: https://img.shields.io/npm/dm/bytes.svg | ||
119 | -[downloads-url]: https://npmjs.org/package/bytes | ||
120 | -[npm-image]: https://img.shields.io/npm/v/bytes.svg | ||
121 | -[npm-url]: https://npmjs.org/package/bytes | ||
122 | -[travis-image]: https://img.shields.io/travis/visionmedia/bytes.js/master.svg | ||
123 | -[travis-url]: https://travis-ci.org/visionmedia/bytes.js | ||
124 | -[coveralls-image]: https://img.shields.io/coveralls/visionmedia/bytes.js/master.svg | ||
125 | -[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master |
trollgg/node_modules/bytes/index.js
deleted
100644 → 0
1 | -/*! | ||
2 | - * bytes | ||
3 | - * Copyright(c) 2012-2014 TJ Holowaychuk | ||
4 | - * Copyright(c) 2015 Jed Watson | ||
5 | - * MIT Licensed | ||
6 | - */ | ||
7 | - | ||
8 | -'use strict'; | ||
9 | - | ||
10 | -/** | ||
11 | - * Module exports. | ||
12 | - * @public | ||
13 | - */ | ||
14 | - | ||
15 | -module.exports = bytes; | ||
16 | -module.exports.format = format; | ||
17 | -module.exports.parse = parse; | ||
18 | - | ||
19 | -/** | ||
20 | - * Module variables. | ||
21 | - * @private | ||
22 | - */ | ||
23 | - | ||
24 | -var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g; | ||
25 | - | ||
26 | -var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/; | ||
27 | - | ||
28 | -var map = { | ||
29 | - b: 1, | ||
30 | - kb: 1 << 10, | ||
31 | - mb: 1 << 20, | ||
32 | - gb: 1 << 30, | ||
33 | - tb: ((1 << 30) * 1024) | ||
34 | -}; | ||
35 | - | ||
36 | -var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb)$/i; | ||
37 | - | ||
38 | -/** | ||
39 | - * Convert the given value in bytes into a string or parse to string to an integer in bytes. | ||
40 | - * | ||
41 | - * @param {string|number} value | ||
42 | - * @param {{ | ||
43 | - * case: [string], | ||
44 | - * decimalPlaces: [number] | ||
45 | - * fixedDecimals: [boolean] | ||
46 | - * thousandsSeparator: [string] | ||
47 | - * unitSeparator: [string] | ||
48 | - * }} [options] bytes options. | ||
49 | - * | ||
50 | - * @returns {string|number|null} | ||
51 | - */ | ||
52 | - | ||
53 | -function bytes(value, options) { | ||
54 | - if (typeof value === 'string') { | ||
55 | - return parse(value); | ||
56 | - } | ||
57 | - | ||
58 | - if (typeof value === 'number') { | ||
59 | - return format(value, options); | ||
60 | - } | ||
61 | - | ||
62 | - return null; | ||
63 | -} | ||
64 | - | ||
65 | -/** | ||
66 | - * Format the given value in bytes into a string. | ||
67 | - * | ||
68 | - * If the value is negative, it is kept as such. If it is a float, | ||
69 | - * it is rounded. | ||
70 | - * | ||
71 | - * @param {number} value | ||
72 | - * @param {object} [options] | ||
73 | - * @param {number} [options.decimalPlaces=2] | ||
74 | - * @param {number} [options.fixedDecimals=false] | ||
75 | - * @param {string} [options.thousandsSeparator=] | ||
76 | - * @param {string} [options.unit=] | ||
77 | - * @param {string} [options.unitSeparator=] | ||
78 | - * | ||
79 | - * @returns {string|null} | ||
80 | - * @public | ||
81 | - */ | ||
82 | - | ||
83 | -function format(value, options) { | ||
84 | - if (!Number.isFinite(value)) { | ||
85 | - return null; | ||
86 | - } | ||
87 | - | ||
88 | - var mag = Math.abs(value); | ||
89 | - var thousandsSeparator = (options && options.thousandsSeparator) || ''; | ||
90 | - var unitSeparator = (options && options.unitSeparator) || ''; | ||
91 | - var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2; | ||
92 | - var fixedDecimals = Boolean(options && options.fixedDecimals); | ||
93 | - var unit = (options && options.unit) || ''; | ||
94 | - | ||
95 | - if (!unit || !map[unit.toLowerCase()]) { | ||
96 | - if (mag >= map.tb) { | ||
97 | - unit = 'TB'; | ||
98 | - } else if (mag >= map.gb) { | ||
99 | - unit = 'GB'; | ||
100 | - } else if (mag >= map.mb) { | ||
101 | - unit = 'MB'; | ||
102 | - } else if (mag >= map.kb) { | ||
103 | - unit = 'KB'; | ||
104 | - } else { | ||
105 | - unit = 'B'; | ||
106 | - } | ||
107 | - } | ||
108 | - | ||
109 | - var val = value / map[unit.toLowerCase()]; | ||
110 | - var str = val.toFixed(decimalPlaces); | ||
111 | - | ||
112 | - if (!fixedDecimals) { | ||
113 | - str = str.replace(formatDecimalsRegExp, '$1'); | ||
114 | - } | ||
115 | - | ||
116 | - if (thousandsSeparator) { | ||
117 | - str = str.replace(formatThousandsRegExp, thousandsSeparator); | ||
118 | - } | ||
119 | - | ||
120 | - return str + unitSeparator + unit; | ||
121 | -} | ||
122 | - | ||
123 | -/** | ||
124 | - * Parse the string value into an integer in bytes. | ||
125 | - * | ||
126 | - * If no unit is given, it is assumed the value is in bytes. | ||
127 | - * | ||
128 | - * @param {number|string} val | ||
129 | - * | ||
130 | - * @returns {number|null} | ||
131 | - * @public | ||
132 | - */ | ||
133 | - | ||
134 | -function parse(val) { | ||
135 | - if (typeof val === 'number' && !isNaN(val)) { | ||
136 | - return val; | ||
137 | - } | ||
138 | - | ||
139 | - if (typeof val !== 'string') { | ||
140 | - return null; | ||
141 | - } | ||
142 | - | ||
143 | - // Test if the string passed is valid | ||
144 | - var results = parseRegExp.exec(val); | ||
145 | - var floatValue; | ||
146 | - var unit = 'b'; | ||
147 | - | ||
148 | - if (!results) { | ||
149 | - // Nothing could be extracted from the given string | ||
150 | - floatValue = parseInt(val, 10); | ||
151 | - unit = 'b' | ||
152 | - } else { | ||
153 | - // Retrieve the value and the unit | ||
154 | - floatValue = parseFloat(results[1]); | ||
155 | - unit = results[4].toLowerCase(); | ||
156 | - } | ||
157 | - | ||
158 | - return Math.floor(map[unit] * floatValue); | ||
159 | -} |
1 | -{ | ||
2 | - "_args": [ | ||
3 | - [ | ||
4 | - "bytes@3.0.0", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "bytes@3.0.0", | ||
9 | - "_id": "bytes@3.0.0", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", | ||
12 | - "_location": "/bytes", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "bytes@3.0.0", | ||
18 | - "name": "bytes", | ||
19 | - "escapedName": "bytes", | ||
20 | - "rawSpec": "3.0.0", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "3.0.0" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/body-parser", | ||
26 | - "/raw-body" | ||
27 | - ], | ||
28 | - "_resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", | ||
29 | - "_spec": "3.0.0", | ||
30 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
31 | - "author": { | ||
32 | - "name": "TJ Holowaychuk", | ||
33 | - "email": "tj@vision-media.ca", | ||
34 | - "url": "http://tjholowaychuk.com" | ||
35 | - }, | ||
36 | - "bugs": { | ||
37 | - "url": "https://github.com/visionmedia/bytes.js/issues" | ||
38 | - }, | ||
39 | - "contributors": [ | ||
40 | - { | ||
41 | - "name": "Jed Watson", | ||
42 | - "email": "jed.watson@me.com" | ||
43 | - }, | ||
44 | - { | ||
45 | - "name": "Théo FIDRY", | ||
46 | - "email": "theo.fidry@gmail.com" | ||
47 | - } | ||
48 | - ], | ||
49 | - "description": "Utility to parse a string bytes to bytes and vice-versa", | ||
50 | - "devDependencies": { | ||
51 | - "mocha": "2.5.3", | ||
52 | - "nyc": "10.3.2" | ||
53 | - }, | ||
54 | - "engines": { | ||
55 | - "node": ">= 0.8" | ||
56 | - }, | ||
57 | - "files": [ | ||
58 | - "History.md", | ||
59 | - "LICENSE", | ||
60 | - "Readme.md", | ||
61 | - "index.js" | ||
62 | - ], | ||
63 | - "homepage": "https://github.com/visionmedia/bytes.js#readme", | ||
64 | - "keywords": [ | ||
65 | - "byte", | ||
66 | - "bytes", | ||
67 | - "utility", | ||
68 | - "parse", | ||
69 | - "parser", | ||
70 | - "convert", | ||
71 | - "converter" | ||
72 | - ], | ||
73 | - "license": "MIT", | ||
74 | - "name": "bytes", | ||
75 | - "repository": { | ||
76 | - "type": "git", | ||
77 | - "url": "git+https://github.com/visionmedia/bytes.js.git" | ||
78 | - }, | ||
79 | - "scripts": { | ||
80 | - "test": "mocha --check-leaks --reporter spec", | ||
81 | - "test-ci": "nyc --reporter=text npm test", | ||
82 | - "test-cov": "nyc --reporter=html --reporter=text npm test" | ||
83 | - }, | ||
84 | - "version": "3.0.0" | ||
85 | -} |
1 | -0.5.2 / 2016-12-08 | ||
2 | -================== | ||
3 | - | ||
4 | - * Fix `parse` to accept any linear whitespace character | ||
5 | - | ||
6 | -0.5.1 / 2016-01-17 | ||
7 | -================== | ||
8 | - | ||
9 | - * perf: enable strict mode | ||
10 | - | ||
11 | -0.5.0 / 2014-10-11 | ||
12 | -================== | ||
13 | - | ||
14 | - * Add `parse` function | ||
15 | - | ||
16 | -0.4.0 / 2014-09-21 | ||
17 | -================== | ||
18 | - | ||
19 | - * Expand non-Unicode `filename` to the full ISO-8859-1 charset | ||
20 | - | ||
21 | -0.3.0 / 2014-09-20 | ||
22 | -================== | ||
23 | - | ||
24 | - * Add `fallback` option | ||
25 | - * Add `type` option | ||
26 | - | ||
27 | -0.2.0 / 2014-09-19 | ||
28 | -================== | ||
29 | - | ||
30 | - * Reduce ambiguity of file names with hex escape in buggy browsers | ||
31 | - | ||
32 | -0.1.2 / 2014-09-19 | ||
33 | -================== | ||
34 | - | ||
35 | - * Fix periodic invalid Unicode filename header | ||
36 | - | ||
37 | -0.1.1 / 2014-09-19 | ||
38 | -================== | ||
39 | - | ||
40 | - * Fix invalid characters appearing in `filename*` parameter | ||
41 | - | ||
42 | -0.1.0 / 2014-09-18 | ||
43 | -================== | ||
44 | - | ||
45 | - * Make the `filename` argument optional | ||
46 | - | ||
47 | -0.0.0 / 2014-09-18 | ||
48 | -================== | ||
49 | - | ||
50 | - * Initial release |
1 | -(The MIT License) | ||
2 | - | ||
3 | -Copyright (c) 2014 Douglas Christopher Wilson | ||
4 | - | ||
5 | -Permission is hereby granted, free of charge, to any person obtaining | ||
6 | -a copy of this software and associated documentation files (the | ||
7 | -'Software'), to deal in the Software without restriction, including | ||
8 | -without limitation the rights to use, copy, modify, merge, publish, | ||
9 | -distribute, sublicense, and/or sell copies of the Software, and to | ||
10 | -permit persons to whom the Software is furnished to do so, subject to | ||
11 | -the following conditions: | ||
12 | - | ||
13 | -The above copyright notice and this permission notice shall be | ||
14 | -included in all copies or substantial portions of the Software. | ||
15 | - | ||
16 | -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
17 | -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
18 | -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
19 | -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
20 | -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
21 | -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
22 | -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
1 | -# content-disposition | ||
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 | -Create and parse HTTP `Content-Disposition` header | ||
10 | - | ||
11 | -## Installation | ||
12 | - | ||
13 | -```sh | ||
14 | -$ npm install content-disposition | ||
15 | -``` | ||
16 | - | ||
17 | -## API | ||
18 | - | ||
19 | -```js | ||
20 | -var contentDisposition = require('content-disposition') | ||
21 | -``` | ||
22 | - | ||
23 | -### contentDisposition(filename, options) | ||
24 | - | ||
25 | -Create an attachment `Content-Disposition` header value using the given file name, | ||
26 | -if supplied. The `filename` is optional and if no file name is desired, but you | ||
27 | -want to specify `options`, set `filename` to `undefined`. | ||
28 | - | ||
29 | -```js | ||
30 | -res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf')) | ||
31 | -``` | ||
32 | - | ||
33 | -**note** HTTP headers are of the ISO-8859-1 character set. If you are writing this | ||
34 | -header through a means different from `setHeader` in Node.js, you'll want to specify | ||
35 | -the `'binary'` encoding in Node.js. | ||
36 | - | ||
37 | -#### Options | ||
38 | - | ||
39 | -`contentDisposition` accepts these properties in the options object. | ||
40 | - | ||
41 | -##### fallback | ||
42 | - | ||
43 | -If the `filename` option is outside ISO-8859-1, then the file name is actually | ||
44 | -stored in a supplemental field for clients that support Unicode file names and | ||
45 | -a ISO-8859-1 version of the file name is automatically generated. | ||
46 | - | ||
47 | -This specifies the ISO-8859-1 file name to override the automatic generation or | ||
48 | -disables the generation all together, defaults to `true`. | ||
49 | - | ||
50 | - - A string will specify the ISO-8859-1 file name to use in place of automatic | ||
51 | - generation. | ||
52 | - - `false` will disable including a ISO-8859-1 file name and only include the | ||
53 | - Unicode version (unless the file name is already ISO-8859-1). | ||
54 | - - `true` will enable automatic generation if the file name is outside ISO-8859-1. | ||
55 | - | ||
56 | -If the `filename` option is ISO-8859-1 and this option is specified and has a | ||
57 | -different value, then the `filename` option is encoded in the extended field | ||
58 | -and this set as the fallback field, even though they are both ISO-8859-1. | ||
59 | - | ||
60 | -##### type | ||
61 | - | ||
62 | -Specifies the disposition type, defaults to `"attachment"`. This can also be | ||
63 | -`"inline"`, or any other value (all values except inline are treated like | ||
64 | -`attachment`, but can convey additional information if both parties agree to | ||
65 | -it). The type is normalized to lower-case. | ||
66 | - | ||
67 | -### contentDisposition.parse(string) | ||
68 | - | ||
69 | -```js | ||
70 | -var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'); | ||
71 | -``` | ||
72 | - | ||
73 | -Parse a `Content-Disposition` header string. This automatically handles extended | ||
74 | -("Unicode") parameters by decoding them and providing them under the standard | ||
75 | -parameter name. This will return an object with the following properties (examples | ||
76 | -are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`): | ||
77 | - | ||
78 | - - `type`: The disposition type (always lower case). Example: `'attachment'` | ||
79 | - | ||
80 | - - `parameters`: An object of the parameters in the disposition (name of parameter | ||
81 | - always lower case and extended versions replace non-extended versions). Example: | ||
82 | - `{filename: "€ rates.txt"}` | ||
83 | - | ||
84 | -## Examples | ||
85 | - | ||
86 | -### Send a file for download | ||
87 | - | ||
88 | -```js | ||
89 | -var contentDisposition = require('content-disposition') | ||
90 | -var destroy = require('destroy') | ||
91 | -var http = require('http') | ||
92 | -var onFinished = require('on-finished') | ||
93 | - | ||
94 | -var filePath = '/path/to/public/plans.pdf' | ||
95 | - | ||
96 | -http.createServer(function onRequest(req, res) { | ||
97 | - // set headers | ||
98 | - res.setHeader('Content-Type', 'application/pdf') | ||
99 | - res.setHeader('Content-Disposition', contentDisposition(filePath)) | ||
100 | - | ||
101 | - // send file | ||
102 | - var stream = fs.createReadStream(filePath) | ||
103 | - stream.pipe(res) | ||
104 | - onFinished(res, function (err) { | ||
105 | - destroy(stream) | ||
106 | - }) | ||
107 | -}) | ||
108 | -``` | ||
109 | - | ||
110 | -## Testing | ||
111 | - | ||
112 | -```sh | ||
113 | -$ npm test | ||
114 | -``` | ||
115 | - | ||
116 | -## References | ||
117 | - | ||
118 | -- [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616] | ||
119 | -- [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987] | ||
120 | -- [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266] | ||
121 | -- [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231] | ||
122 | - | ||
123 | -[rfc-2616]: https://tools.ietf.org/html/rfc2616 | ||
124 | -[rfc-5987]: https://tools.ietf.org/html/rfc5987 | ||
125 | -[rfc-6266]: https://tools.ietf.org/html/rfc6266 | ||
126 | -[tc-2231]: http://greenbytes.de/tech/tc2231/ | ||
127 | - | ||
128 | -## License | ||
129 | - | ||
130 | -[MIT](LICENSE) | ||
131 | - | ||
132 | -[npm-image]: https://img.shields.io/npm/v/content-disposition.svg?style=flat | ||
133 | -[npm-url]: https://npmjs.org/package/content-disposition | ||
134 | -[node-version-image]: https://img.shields.io/node/v/content-disposition.svg?style=flat | ||
135 | -[node-version-url]: https://nodejs.org/en/download | ||
136 | -[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg?style=flat | ||
137 | -[travis-url]: https://travis-ci.org/jshttp/content-disposition | ||
138 | -[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg?style=flat | ||
139 | -[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master | ||
140 | -[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg?style=flat | ||
141 | -[downloads-url]: https://npmjs.org/package/content-disposition |
This diff is collapsed. Click to expand it.
1 | -{ | ||
2 | - "_args": [ | ||
3 | - [ | ||
4 | - "content-disposition@0.5.2", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "content-disposition@0.5.2", | ||
9 | - "_id": "content-disposition@0.5.2", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=", | ||
12 | - "_location": "/content-disposition", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "content-disposition@0.5.2", | ||
18 | - "name": "content-disposition", | ||
19 | - "escapedName": "content-disposition", | ||
20 | - "rawSpec": "0.5.2", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "0.5.2" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/express" | ||
26 | - ], | ||
27 | - "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", | ||
28 | - "_spec": "0.5.2", | ||
29 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
30 | - "bugs": { | ||
31 | - "url": "https://github.com/jshttp/content-disposition/issues" | ||
32 | - }, | ||
33 | - "contributors": [ | ||
34 | - { | ||
35 | - "name": "Douglas Christopher Wilson", | ||
36 | - "email": "doug@somethingdoug.com" | ||
37 | - } | ||
38 | - ], | ||
39 | - "description": "Create and parse Content-Disposition header", | ||
40 | - "devDependencies": { | ||
41 | - "eslint": "3.11.1", | ||
42 | - "eslint-config-standard": "6.2.1", | ||
43 | - "eslint-plugin-promise": "3.3.0", | ||
44 | - "eslint-plugin-standard": "2.0.1", | ||
45 | - "istanbul": "0.4.5", | ||
46 | - "mocha": "1.21.5" | ||
47 | - }, | ||
48 | - "engines": { | ||
49 | - "node": ">= 0.6" | ||
50 | - }, | ||
51 | - "files": [ | ||
52 | - "LICENSE", | ||
53 | - "HISTORY.md", | ||
54 | - "README.md", | ||
55 | - "index.js" | ||
56 | - ], | ||
57 | - "homepage": "https://github.com/jshttp/content-disposition#readme", | ||
58 | - "keywords": [ | ||
59 | - "content-disposition", | ||
60 | - "http", | ||
61 | - "rfc6266", | ||
62 | - "res" | ||
63 | - ], | ||
64 | - "license": "MIT", | ||
65 | - "name": "content-disposition", | ||
66 | - "repository": { | ||
67 | - "type": "git", | ||
68 | - "url": "git+https://github.com/jshttp/content-disposition.git" | ||
69 | - }, | ||
70 | - "scripts": { | ||
71 | - "lint": "eslint .", | ||
72 | - "test": "mocha --reporter spec --bail --check-leaks test/", | ||
73 | - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", | ||
74 | - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" | ||
75 | - }, | ||
76 | - "version": "0.5.2" | ||
77 | -} |
1 | -1.0.4 / 2017-09-11 | ||
2 | -================== | ||
3 | - | ||
4 | - * perf: skip parameter parsing when no parameters | ||
5 | - | ||
6 | -1.0.3 / 2017-09-10 | ||
7 | -================== | ||
8 | - | ||
9 | - * perf: remove argument reassignment | ||
10 | - | ||
11 | -1.0.2 / 2016-05-09 | ||
12 | -================== | ||
13 | - | ||
14 | - * perf: enable strict mode | ||
15 | - | ||
16 | -1.0.1 / 2015-02-13 | ||
17 | -================== | ||
18 | - | ||
19 | - * Improve missing `Content-Type` header error message | ||
20 | - | ||
21 | -1.0.0 / 2015-02-01 | ||
22 | -================== | ||
23 | - | ||
24 | - * Initial implementation, derived from `media-typer@0.3.0` |
1 | -(The MIT License) | ||
2 | - | ||
3 | -Copyright (c) 2015 Douglas Christopher Wilson | ||
4 | - | ||
5 | -Permission is hereby granted, free of charge, to any person obtaining | ||
6 | -a copy of this software and associated documentation files (the | ||
7 | -'Software'), to deal in the Software without restriction, including | ||
8 | -without limitation the rights to use, copy, modify, merge, publish, | ||
9 | -distribute, sublicense, and/or sell copies of the Software, and to | ||
10 | -permit persons to whom the Software is furnished to do so, subject to | ||
11 | -the following conditions: | ||
12 | - | ||
13 | -The above copyright notice and this permission notice shall be | ||
14 | -included in all copies or substantial portions of the Software. | ||
15 | - | ||
16 | -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
17 | -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
18 | -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
19 | -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
20 | -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
21 | -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
22 | -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
1 | -# content-type | ||
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 | -Create and parse HTTP Content-Type header according to RFC 7231 | ||
10 | - | ||
11 | -## Installation | ||
12 | - | ||
13 | -```sh | ||
14 | -$ npm install content-type | ||
15 | -``` | ||
16 | - | ||
17 | -## API | ||
18 | - | ||
19 | -```js | ||
20 | -var contentType = require('content-type') | ||
21 | -``` | ||
22 | - | ||
23 | -### contentType.parse(string) | ||
24 | - | ||
25 | -```js | ||
26 | -var obj = contentType.parse('image/svg+xml; charset=utf-8') | ||
27 | -``` | ||
28 | - | ||
29 | -Parse a content type string. This will return an object with the following | ||
30 | -properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): | ||
31 | - | ||
32 | - - `type`: The media type (the type and subtype, always lower case). | ||
33 | - Example: `'image/svg+xml'` | ||
34 | - | ||
35 | - - `parameters`: An object of the parameters in the media type (name of parameter | ||
36 | - always lower case). Example: `{charset: 'utf-8'}` | ||
37 | - | ||
38 | -Throws a `TypeError` if the string is missing or invalid. | ||
39 | - | ||
40 | -### contentType.parse(req) | ||
41 | - | ||
42 | -```js | ||
43 | -var obj = contentType.parse(req) | ||
44 | -``` | ||
45 | - | ||
46 | -Parse the `content-type` header from the given `req`. Short-cut for | ||
47 | -`contentType.parse(req.headers['content-type'])`. | ||
48 | - | ||
49 | -Throws a `TypeError` if the `Content-Type` header is missing or invalid. | ||
50 | - | ||
51 | -### contentType.parse(res) | ||
52 | - | ||
53 | -```js | ||
54 | -var obj = contentType.parse(res) | ||
55 | -``` | ||
56 | - | ||
57 | -Parse the `content-type` header set on the given `res`. Short-cut for | ||
58 | -`contentType.parse(res.getHeader('content-type'))`. | ||
59 | - | ||
60 | -Throws a `TypeError` if the `Content-Type` header is missing or invalid. | ||
61 | - | ||
62 | -### contentType.format(obj) | ||
63 | - | ||
64 | -```js | ||
65 | -var str = contentType.format({type: 'image/svg+xml'}) | ||
66 | -``` | ||
67 | - | ||
68 | -Format an object into a content type string. This will return a string of the | ||
69 | -content type for the given object with the following properties (examples are | ||
70 | -shown that produce the string `'image/svg+xml; charset=utf-8'`): | ||
71 | - | ||
72 | - - `type`: The media type (will be lower-cased). Example: `'image/svg+xml'` | ||
73 | - | ||
74 | - - `parameters`: An object of the parameters in the media type (name of the | ||
75 | - parameter will be lower-cased). Example: `{charset: 'utf-8'}` | ||
76 | - | ||
77 | -Throws a `TypeError` if the object contains an invalid type or parameter names. | ||
78 | - | ||
79 | -## License | ||
80 | - | ||
81 | -[MIT](LICENSE) | ||
82 | - | ||
83 | -[npm-image]: https://img.shields.io/npm/v/content-type.svg | ||
84 | -[npm-url]: https://npmjs.org/package/content-type | ||
85 | -[node-version-image]: https://img.shields.io/node/v/content-type.svg | ||
86 | -[node-version-url]: http://nodejs.org/download/ | ||
87 | -[travis-image]: https://img.shields.io/travis/jshttp/content-type/master.svg | ||
88 | -[travis-url]: https://travis-ci.org/jshttp/content-type | ||
89 | -[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-type/master.svg | ||
90 | -[coveralls-url]: https://coveralls.io/r/jshttp/content-type | ||
91 | -[downloads-image]: https://img.shields.io/npm/dm/content-type.svg | ||
92 | -[downloads-url]: https://npmjs.org/package/content-type |
1 | -/*! | ||
2 | - * content-type | ||
3 | - * Copyright(c) 2015 Douglas Christopher Wilson | ||
4 | - * MIT Licensed | ||
5 | - */ | ||
6 | - | ||
7 | -'use strict' | ||
8 | - | ||
9 | -/** | ||
10 | - * RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1 | ||
11 | - * | ||
12 | - * parameter = token "=" ( token / quoted-string ) | ||
13 | - * token = 1*tchar | ||
14 | - * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" | ||
15 | - * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" | ||
16 | - * / DIGIT / ALPHA | ||
17 | - * ; any VCHAR, except delimiters | ||
18 | - * quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE | ||
19 | - * qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text | ||
20 | - * obs-text = %x80-FF | ||
21 | - * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) | ||
22 | - */ | ||
23 | -var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g | ||
24 | -var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/ | ||
25 | -var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/ | ||
26 | - | ||
27 | -/** | ||
28 | - * RegExp to match quoted-pair in RFC 7230 sec 3.2.6 | ||
29 | - * | ||
30 | - * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) | ||
31 | - * obs-text = %x80-FF | ||
32 | - */ | ||
33 | -var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g | ||
34 | - | ||
35 | -/** | ||
36 | - * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6 | ||
37 | - */ | ||
38 | -var QUOTE_REGEXP = /([\\"])/g | ||
39 | - | ||
40 | -/** | ||
41 | - * RegExp to match type in RFC 7231 sec 3.1.1.1 | ||
42 | - * | ||
43 | - * media-type = type "/" subtype | ||
44 | - * type = token | ||
45 | - * subtype = token | ||
46 | - */ | ||
47 | -var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/ | ||
48 | - | ||
49 | -/** | ||
50 | - * Module exports. | ||
51 | - * @public | ||
52 | - */ | ||
53 | - | ||
54 | -exports.format = format | ||
55 | -exports.parse = parse | ||
56 | - | ||
57 | -/** | ||
58 | - * Format object to media type. | ||
59 | - * | ||
60 | - * @param {object} obj | ||
61 | - * @return {string} | ||
62 | - * @public | ||
63 | - */ | ||
64 | - | ||
65 | -function format (obj) { | ||
66 | - if (!obj || typeof obj !== 'object') { | ||
67 | - throw new TypeError('argument obj is required') | ||
68 | - } | ||
69 | - | ||
70 | - var parameters = obj.parameters | ||
71 | - var type = obj.type | ||
72 | - | ||
73 | - if (!type || !TYPE_REGEXP.test(type)) { | ||
74 | - throw new TypeError('invalid type') | ||
75 | - } | ||
76 | - | ||
77 | - var string = type | ||
78 | - | ||
79 | - // append parameters | ||
80 | - if (parameters && typeof parameters === 'object') { | ||
81 | - var param | ||
82 | - var params = Object.keys(parameters).sort() | ||
83 | - | ||
84 | - for (var i = 0; i < params.length; i++) { | ||
85 | - param = params[i] | ||
86 | - | ||
87 | - if (!TOKEN_REGEXP.test(param)) { | ||
88 | - throw new TypeError('invalid parameter name') | ||
89 | - } | ||
90 | - | ||
91 | - string += '; ' + param + '=' + qstring(parameters[param]) | ||
92 | - } | ||
93 | - } | ||
94 | - | ||
95 | - return string | ||
96 | -} | ||
97 | - | ||
98 | -/** | ||
99 | - * Parse media type to object. | ||
100 | - * | ||
101 | - * @param {string|object} string | ||
102 | - * @return {Object} | ||
103 | - * @public | ||
104 | - */ | ||
105 | - | ||
106 | -function parse (string) { | ||
107 | - if (!string) { | ||
108 | - throw new TypeError('argument string is required') | ||
109 | - } | ||
110 | - | ||
111 | - // support req/res-like objects as argument | ||
112 | - var header = typeof string === 'object' | ||
113 | - ? getcontenttype(string) | ||
114 | - : string | ||
115 | - | ||
116 | - if (typeof header !== 'string') { | ||
117 | - throw new TypeError('argument string is required to be a string') | ||
118 | - } | ||
119 | - | ||
120 | - var index = header.indexOf(';') | ||
121 | - var type = index !== -1 | ||
122 | - ? header.substr(0, index).trim() | ||
123 | - : header.trim() | ||
124 | - | ||
125 | - if (!TYPE_REGEXP.test(type)) { | ||
126 | - throw new TypeError('invalid media type') | ||
127 | - } | ||
128 | - | ||
129 | - var obj = new ContentType(type.toLowerCase()) | ||
130 | - | ||
131 | - // parse parameters | ||
132 | - if (index !== -1) { | ||
133 | - var key | ||
134 | - var match | ||
135 | - var value | ||
136 | - | ||
137 | - PARAM_REGEXP.lastIndex = index | ||
138 | - | ||
139 | - while ((match = PARAM_REGEXP.exec(header))) { | ||
140 | - if (match.index !== index) { | ||
141 | - throw new TypeError('invalid parameter format') | ||
142 | - } | ||
143 | - | ||
144 | - index += match[0].length | ||
145 | - key = match[1].toLowerCase() | ||
146 | - value = match[2] | ||
147 | - | ||
148 | - if (value[0] === '"') { | ||
149 | - // remove quotes and escapes | ||
150 | - value = value | ||
151 | - .substr(1, value.length - 2) | ||
152 | - .replace(QESC_REGEXP, '$1') | ||
153 | - } | ||
154 | - | ||
155 | - obj.parameters[key] = value | ||
156 | - } | ||
157 | - | ||
158 | - if (index !== header.length) { | ||
159 | - throw new TypeError('invalid parameter format') | ||
160 | - } | ||
161 | - } | ||
162 | - | ||
163 | - return obj | ||
164 | -} | ||
165 | - | ||
166 | -/** | ||
167 | - * Get content-type from req/res objects. | ||
168 | - * | ||
169 | - * @param {object} | ||
170 | - * @return {Object} | ||
171 | - * @private | ||
172 | - */ | ||
173 | - | ||
174 | -function getcontenttype (obj) { | ||
175 | - var header | ||
176 | - | ||
177 | - if (typeof obj.getHeader === 'function') { | ||
178 | - // res-like | ||
179 | - header = obj.getHeader('content-type') | ||
180 | - } else if (typeof obj.headers === 'object') { | ||
181 | - // req-like | ||
182 | - header = obj.headers && obj.headers['content-type'] | ||
183 | - } | ||
184 | - | ||
185 | - if (typeof header !== 'string') { | ||
186 | - throw new TypeError('content-type header is missing from object') | ||
187 | - } | ||
188 | - | ||
189 | - return header | ||
190 | -} | ||
191 | - | ||
192 | -/** | ||
193 | - * Quote a string if necessary. | ||
194 | - * | ||
195 | - * @param {string} val | ||
196 | - * @return {string} | ||
197 | - * @private | ||
198 | - */ | ||
199 | - | ||
200 | -function qstring (val) { | ||
201 | - var str = String(val) | ||
202 | - | ||
203 | - // no need to quote tokens | ||
204 | - if (TOKEN_REGEXP.test(str)) { | ||
205 | - return str | ||
206 | - } | ||
207 | - | ||
208 | - if (str.length > 0 && !TEXT_REGEXP.test(str)) { | ||
209 | - throw new TypeError('invalid parameter value') | ||
210 | - } | ||
211 | - | ||
212 | - return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"' | ||
213 | -} | ||
214 | - | ||
215 | -/** | ||
216 | - * Class to represent a content type. | ||
217 | - * @private | ||
218 | - */ | ||
219 | -function ContentType (type) { | ||
220 | - this.parameters = Object.create(null) | ||
221 | - this.type = type | ||
222 | -} |
1 | -{ | ||
2 | - "_args": [ | ||
3 | - [ | ||
4 | - "content-type@1.0.4", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "content-type@1.0.4", | ||
9 | - "_id": "content-type@1.0.4", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", | ||
12 | - "_location": "/content-type", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "content-type@1.0.4", | ||
18 | - "name": "content-type", | ||
19 | - "escapedName": "content-type", | ||
20 | - "rawSpec": "1.0.4", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "1.0.4" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/body-parser", | ||
26 | - "/express" | ||
27 | - ], | ||
28 | - "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", | ||
29 | - "_spec": "1.0.4", | ||
30 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
31 | - "author": { | ||
32 | - "name": "Douglas Christopher Wilson", | ||
33 | - "email": "doug@somethingdoug.com" | ||
34 | - }, | ||
35 | - "bugs": { | ||
36 | - "url": "https://github.com/jshttp/content-type/issues" | ||
37 | - }, | ||
38 | - "description": "Create and parse HTTP Content-Type header", | ||
39 | - "devDependencies": { | ||
40 | - "eslint": "3.19.0", | ||
41 | - "eslint-config-standard": "10.2.1", | ||
42 | - "eslint-plugin-import": "2.7.0", | ||
43 | - "eslint-plugin-node": "5.1.1", | ||
44 | - "eslint-plugin-promise": "3.5.0", | ||
45 | - "eslint-plugin-standard": "3.0.1", | ||
46 | - "istanbul": "0.4.5", | ||
47 | - "mocha": "~1.21.5" | ||
48 | - }, | ||
49 | - "engines": { | ||
50 | - "node": ">= 0.6" | ||
51 | - }, | ||
52 | - "files": [ | ||
53 | - "LICENSE", | ||
54 | - "HISTORY.md", | ||
55 | - "README.md", | ||
56 | - "index.js" | ||
57 | - ], | ||
58 | - "homepage": "https://github.com/jshttp/content-type#readme", | ||
59 | - "keywords": [ | ||
60 | - "content-type", | ||
61 | - "http", | ||
62 | - "req", | ||
63 | - "res", | ||
64 | - "rfc7231" | ||
65 | - ], | ||
66 | - "license": "MIT", | ||
67 | - "name": "content-type", | ||
68 | - "repository": { | ||
69 | - "type": "git", | ||
70 | - "url": "git+https://github.com/jshttp/content-type.git" | ||
71 | - }, | ||
72 | - "scripts": { | ||
73 | - "lint": "eslint .", | ||
74 | - "test": "mocha --reporter spec --check-leaks --bail test/", | ||
75 | - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", | ||
76 | - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" | ||
77 | - }, | ||
78 | - "version": "1.0.4" | ||
79 | -} |
1 | -1.4.5 / 2020-03-14 | ||
2 | -================== | ||
3 | - | ||
4 | - * deps: cookie@0.4.0 | ||
5 | - | ||
6 | -1.4.4 / 2019-02-12 | ||
7 | -================== | ||
8 | - | ||
9 | - * perf: normalize `secret` argument only once | ||
10 | - | ||
11 | -1.4.3 / 2016-05-26 | ||
12 | -================== | ||
13 | - | ||
14 | - * deps: cookie@0.3.1 | ||
15 | - - perf: use for loop in parse | ||
16 | - | ||
17 | -1.4.2 / 2016-05-20 | ||
18 | -================== | ||
19 | - | ||
20 | - * deps: cookie@0.2.4 | ||
21 | - - perf: enable strict mode | ||
22 | - - perf: use for loop in parse | ||
23 | - - perf: use string concatenation for serialization | ||
24 | - | ||
25 | -1.4.1 / 2016-01-11 | ||
26 | -================== | ||
27 | - | ||
28 | - * deps: cookie@0.2.3 | ||
29 | - * perf: enable strict mode | ||
30 | - | ||
31 | -1.4.0 / 2015-09-18 | ||
32 | -================== | ||
33 | - | ||
34 | - * Accept array of secrets in addition to a single secret | ||
35 | - * Fix `JSONCookie` to return `undefined` for non-string arguments | ||
36 | - * Fix `signedCookie` to return `undefined` for non-string arguments | ||
37 | - * deps: cookie@0.2.2 | ||
38 | - | ||
39 | -1.3.5 / 2015-05-19 | ||
40 | -================== | ||
41 | - | ||
42 | - * deps: cookie@0.1.3 | ||
43 | - - Slight optimizations | ||
44 | - | ||
45 | -1.3.4 / 2015-02-15 | ||
46 | -================== | ||
47 | - | ||
48 | - * deps: cookie-signature@1.0.6 | ||
49 | - | ||
50 | -1.3.3 / 2014-09-05 | ||
51 | -================== | ||
52 | - | ||
53 | - * deps: cookie-signature@1.0.5 | ||
54 | - | ||
55 | -1.3.2 / 2014-06-26 | ||
56 | -================== | ||
57 | - | ||
58 | - * deps: cookie-signature@1.0.4 | ||
59 | - - fix for timing attacks | ||
60 | - | ||
61 | -1.3.1 / 2014-06-17 | ||
62 | -================== | ||
63 | - | ||
64 | - * actually export `signedCookie` | ||
65 | - | ||
66 | -1.3.0 / 2014-06-17 | ||
67 | -================== | ||
68 | - | ||
69 | - * add `signedCookie` export for single cookie unsigning | ||
70 | - | ||
71 | -1.2.0 / 2014-06-17 | ||
72 | -================== | ||
73 | - | ||
74 | - * export parsing functions | ||
75 | - * `req.cookies` and `req.signedCookies` are now plain objects | ||
76 | - * slightly faster parsing of many cookies | ||
77 | - | ||
78 | -1.1.0 / 2014-05-12 | ||
79 | -================== | ||
80 | - | ||
81 | - * Support for NodeJS version 0.8 | ||
82 | - * deps: cookie@0.1.2 | ||
83 | - - Fix for maxAge == 0 | ||
84 | - - made compat with expires field | ||
85 | - - tweak maxAge NaN error message | ||
86 | - | ||
87 | -1.0.1 / 2014-02-20 | ||
88 | -================== | ||
89 | - | ||
90 | - * add missing dependencies | ||
91 | - | ||
92 | -1.0.0 / 2014-02-15 | ||
93 | -================== | ||
94 | - | ||
95 | - * Genesis from `connect` |
1 | -(The MIT License) | ||
2 | - | ||
3 | -Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> | ||
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 | -# cookie-parser | ||
2 | - | ||
3 | -[![NPM Version][npm-version-image]][npm-url] | ||
4 | -[![NPM Downloads][npm-downloads-image]][npm-url] | ||
5 | -[![Build Status][travis-image]][travis-url] | ||
6 | -[![Test Coverage][coveralls-image]][coveralls-url] | ||
7 | - | ||
8 | -Parse `Cookie` header and populate `req.cookies` with an object keyed by the | ||
9 | -cookie names. Optionally you may enable signed cookie support by passing a | ||
10 | -`secret` string, which assigns `req.secret` so it may be used by other | ||
11 | -middleware. | ||
12 | - | ||
13 | -## Installation | ||
14 | - | ||
15 | -```sh | ||
16 | -$ npm install cookie-parser | ||
17 | -``` | ||
18 | - | ||
19 | -## API | ||
20 | - | ||
21 | -```js | ||
22 | -var express = require('express') | ||
23 | -var cookieParser = require('cookie-parser') | ||
24 | - | ||
25 | -var app = express() | ||
26 | -app.use(cookieParser()) | ||
27 | -``` | ||
28 | - | ||
29 | -### cookieParser(secret, options) | ||
30 | - | ||
31 | -- `secret` a string or array used for signing cookies. This is optional and if | ||
32 | - not specified, will not parse signed cookies. If a string is provided, this | ||
33 | - is used as the secret. If an array is provided, an attempt will be made to | ||
34 | - unsign the cookie with each secret in order. | ||
35 | -- `options` an object that is passed to `cookie.parse` as the second option. Se | ||
36 | - [cookie](https://www.npmjs.org/package/cookie) for more information. | ||
37 | - - `decode` a function to decode the value of the cookie | ||
38 | - | ||
39 | -### cookieParser.JSONCookie(str) | ||
40 | - | ||
41 | -Parse a cookie value as a JSON cookie. This will return the parsed JSON value | ||
42 | -if it was a JSON cookie, otherwise, it will return the passed value. | ||
43 | - | ||
44 | -### cookieParser.JSONCookies(cookies) | ||
45 | - | ||
46 | -Given an object, this will iterate over the keys and call `JSONCookie` on each | ||
47 | -value, replacing the original value with the parsed value. This returns the | ||
48 | -same object that was passed in. | ||
49 | - | ||
50 | -### cookieParser.signedCookie(str, secret) | ||
51 | - | ||
52 | -Parse a cookie value as a signed cookie. This will return the parsed unsigned | ||
53 | -value if it was a signed cookie and the signature was valid. If the value was | ||
54 | -not signed, the original value is returned. If the value was signed but the | ||
55 | -signature could not be validated, `false` is returned. | ||
56 | - | ||
57 | -The `secret` argument can be an array or string. If a string is provided, this | ||
58 | -is used as the secret. If an array is provided, an attempt will be made to | ||
59 | -unsign the cookie with each secret in order. | ||
60 | - | ||
61 | -### cookieParser.signedCookies(cookies, secret) | ||
62 | - | ||
63 | -Given an object, this will iterate over the keys and check if any value is a | ||
64 | -signed cookie. If it is a signed cookie and the signature is valid, the key | ||
65 | -will be deleted from the object and added to the new object that is returned. | ||
66 | - | ||
67 | -The `secret` argument can be an array or string. If a string is provided, this | ||
68 | -is used as the secret. If an array is provided, an attempt will be made to | ||
69 | -unsign the cookie with each secret in order. | ||
70 | - | ||
71 | -## Example | ||
72 | - | ||
73 | -```js | ||
74 | -var express = require('express') | ||
75 | -var cookieParser = require('cookie-parser') | ||
76 | - | ||
77 | -var app = express() | ||
78 | -app.use(cookieParser()) | ||
79 | - | ||
80 | -app.get('/', function (req, res) { | ||
81 | - // Cookies that have not been signed | ||
82 | - console.log('Cookies: ', req.cookies) | ||
83 | - | ||
84 | - // Cookies that have been signed | ||
85 | - console.log('Signed Cookies: ', req.signedCookies) | ||
86 | -}) | ||
87 | - | ||
88 | -app.listen(8080) | ||
89 | - | ||
90 | -// curl command that sends an HTTP request with two cookies | ||
91 | -// curl http://127.0.0.1:8080 --cookie "Cho=Kim;Greet=Hello" | ||
92 | -``` | ||
93 | - | ||
94 | -### [MIT Licensed](LICENSE) | ||
95 | - | ||
96 | -[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/cookie-parser/master | ||
97 | -[coveralls-url]: https://coveralls.io/r/expressjs/cookie-parser?branch=master | ||
98 | -[npm-downloads-image]: https://badgen.net/npm/dm/cookie-parser | ||
99 | -[npm-url]: https://npmjs.org/package/cookie-parser | ||
100 | -[npm-version-image]: https://badgen.net/npm/v/cookie-parser | ||
101 | -[travis-image]: https://badgen.net/travis/expressjs/cookie-parser/master | ||
102 | -[travis-url]: https://travis-ci.org/expressjs/cookie-parser |
1 | -/*! | ||
2 | - * cookie-parser | ||
3 | - * Copyright(c) 2014 TJ Holowaychuk | ||
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 cookie = require('cookie') | ||
16 | -var signature = require('cookie-signature') | ||
17 | - | ||
18 | -/** | ||
19 | - * Module exports. | ||
20 | - * @public | ||
21 | - */ | ||
22 | - | ||
23 | -module.exports = cookieParser | ||
24 | -module.exports.JSONCookie = JSONCookie | ||
25 | -module.exports.JSONCookies = JSONCookies | ||
26 | -module.exports.signedCookie = signedCookie | ||
27 | -module.exports.signedCookies = signedCookies | ||
28 | - | ||
29 | -/** | ||
30 | - * Parse Cookie header and populate `req.cookies` | ||
31 | - * with an object keyed by the cookie names. | ||
32 | - * | ||
33 | - * @param {string|array} [secret] A string (or array of strings) representing cookie signing secret(s). | ||
34 | - * @param {Object} [options] | ||
35 | - * @return {Function} | ||
36 | - * @public | ||
37 | - */ | ||
38 | - | ||
39 | -function cookieParser (secret, options) { | ||
40 | - var secrets = !secret || Array.isArray(secret) | ||
41 | - ? (secret || []) | ||
42 | - : [secret] | ||
43 | - | ||
44 | - return function cookieParser (req, res, next) { | ||
45 | - if (req.cookies) { | ||
46 | - return next() | ||
47 | - } | ||
48 | - | ||
49 | - var cookies = req.headers.cookie | ||
50 | - | ||
51 | - req.secret = secrets[0] | ||
52 | - req.cookies = Object.create(null) | ||
53 | - req.signedCookies = Object.create(null) | ||
54 | - | ||
55 | - // no cookies | ||
56 | - if (!cookies) { | ||
57 | - return next() | ||
58 | - } | ||
59 | - | ||
60 | - req.cookies = cookie.parse(cookies, options) | ||
61 | - | ||
62 | - // parse signed cookies | ||
63 | - if (secrets.length !== 0) { | ||
64 | - req.signedCookies = signedCookies(req.cookies, secrets) | ||
65 | - req.signedCookies = JSONCookies(req.signedCookies) | ||
66 | - } | ||
67 | - | ||
68 | - // parse JSON cookies | ||
69 | - req.cookies = JSONCookies(req.cookies) | ||
70 | - | ||
71 | - next() | ||
72 | - } | ||
73 | -} | ||
74 | - | ||
75 | -/** | ||
76 | - * Parse JSON cookie string. | ||
77 | - * | ||
78 | - * @param {String} str | ||
79 | - * @return {Object} Parsed object or undefined if not json cookie | ||
80 | - * @public | ||
81 | - */ | ||
82 | - | ||
83 | -function JSONCookie (str) { | ||
84 | - if (typeof str !== 'string' || str.substr(0, 2) !== 'j:') { | ||
85 | - return undefined | ||
86 | - } | ||
87 | - | ||
88 | - try { | ||
89 | - return JSON.parse(str.slice(2)) | ||
90 | - } catch (err) { | ||
91 | - return undefined | ||
92 | - } | ||
93 | -} | ||
94 | - | ||
95 | -/** | ||
96 | - * Parse JSON cookies. | ||
97 | - * | ||
98 | - * @param {Object} obj | ||
99 | - * @return {Object} | ||
100 | - * @public | ||
101 | - */ | ||
102 | - | ||
103 | -function JSONCookies (obj) { | ||
104 | - var cookies = Object.keys(obj) | ||
105 | - var key | ||
106 | - var val | ||
107 | - | ||
108 | - for (var i = 0; i < cookies.length; i++) { | ||
109 | - key = cookies[i] | ||
110 | - val = JSONCookie(obj[key]) | ||
111 | - | ||
112 | - if (val) { | ||
113 | - obj[key] = val | ||
114 | - } | ||
115 | - } | ||
116 | - | ||
117 | - return obj | ||
118 | -} | ||
119 | - | ||
120 | -/** | ||
121 | - * Parse a signed cookie string, return the decoded value. | ||
122 | - * | ||
123 | - * @param {String} str signed cookie string | ||
124 | - * @param {string|array} secret | ||
125 | - * @return {String} decoded value | ||
126 | - * @public | ||
127 | - */ | ||
128 | - | ||
129 | -function signedCookie (str, secret) { | ||
130 | - if (typeof str !== 'string') { | ||
131 | - return undefined | ||
132 | - } | ||
133 | - | ||
134 | - if (str.substr(0, 2) !== 's:') { | ||
135 | - return str | ||
136 | - } | ||
137 | - | ||
138 | - var secrets = !secret || Array.isArray(secret) | ||
139 | - ? (secret || []) | ||
140 | - : [secret] | ||
141 | - | ||
142 | - for (var i = 0; i < secrets.length; i++) { | ||
143 | - var val = signature.unsign(str.slice(2), secrets[i]) | ||
144 | - | ||
145 | - if (val !== false) { | ||
146 | - return val | ||
147 | - } | ||
148 | - } | ||
149 | - | ||
150 | - return false | ||
151 | -} | ||
152 | - | ||
153 | -/** | ||
154 | - * Parse signed cookies, returning an object containing the decoded key/value | ||
155 | - * pairs, while removing the signed key from obj. | ||
156 | - * | ||
157 | - * @param {Object} obj | ||
158 | - * @param {string|array} secret | ||
159 | - * @return {Object} | ||
160 | - * @public | ||
161 | - */ | ||
162 | - | ||
163 | -function signedCookies (obj, secret) { | ||
164 | - var cookies = Object.keys(obj) | ||
165 | - var dec | ||
166 | - var key | ||
167 | - var ret = Object.create(null) | ||
168 | - var val | ||
169 | - | ||
170 | - for (var i = 0; i < cookies.length; i++) { | ||
171 | - key = cookies[i] | ||
172 | - val = obj[key] | ||
173 | - dec = signedCookie(val, secret) | ||
174 | - | ||
175 | - if (val !== dec) { | ||
176 | - ret[key] = dec | ||
177 | - delete obj[key] | ||
178 | - } | ||
179 | - } | ||
180 | - | ||
181 | - return ret | ||
182 | -} |
1 | -{ | ||
2 | - "_args": [ | ||
3 | - [ | ||
4 | - "cookie-parser@1.4.5", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "cookie-parser@1.4.5", | ||
9 | - "_id": "cookie-parser@1.4.5", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha512-f13bPUj/gG/5mDr+xLmSxxDsB9DQiTIfhJS/sqjrmfAWiAN+x2O4i/XguTL9yDZ+/IFDanJ+5x7hC4CXT9Tdzw==", | ||
12 | - "_location": "/cookie-parser", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "cookie-parser@1.4.5", | ||
18 | - "name": "cookie-parser", | ||
19 | - "escapedName": "cookie-parser", | ||
20 | - "rawSpec": "1.4.5", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "1.4.5" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/" | ||
26 | - ], | ||
27 | - "_resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.5.tgz", | ||
28 | - "_spec": "1.4.5", | ||
29 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
30 | - "author": { | ||
31 | - "name": "TJ Holowaychuk", | ||
32 | - "email": "tj@vision-media.ca", | ||
33 | - "url": "http://tjholowaychuk.com" | ||
34 | - }, | ||
35 | - "bugs": { | ||
36 | - "url": "https://github.com/expressjs/cookie-parser/issues" | ||
37 | - }, | ||
38 | - "contributors": [ | ||
39 | - { | ||
40 | - "name": "Douglas Christopher Wilson", | ||
41 | - "email": "doug@somethingdoug.com" | ||
42 | - } | ||
43 | - ], | ||
44 | - "dependencies": { | ||
45 | - "cookie": "0.4.0", | ||
46 | - "cookie-signature": "1.0.6" | ||
47 | - }, | ||
48 | - "description": "Parse HTTP request cookies", | ||
49 | - "devDependencies": { | ||
50 | - "eslint": "6.8.0", | ||
51 | - "eslint-config-standard": "14.1.0", | ||
52 | - "eslint-plugin-import": "2.20.1", | ||
53 | - "eslint-plugin-markdown": "1.0.2", | ||
54 | - "eslint-plugin-node": "11.0.0", | ||
55 | - "eslint-plugin-promise": "4.2.1", | ||
56 | - "eslint-plugin-standard": "4.0.1", | ||
57 | - "istanbul": "0.4.5", | ||
58 | - "mocha": "7.1.0", | ||
59 | - "supertest": "4.0.2" | ||
60 | - }, | ||
61 | - "engines": { | ||
62 | - "node": ">= 0.8.0" | ||
63 | - }, | ||
64 | - "files": [ | ||
65 | - "LICENSE", | ||
66 | - "HISTORY.md", | ||
67 | - "index.js" | ||
68 | - ], | ||
69 | - "homepage": "https://github.com/expressjs/cookie-parser#readme", | ||
70 | - "keywords": [ | ||
71 | - "cookie", | ||
72 | - "middleware" | ||
73 | - ], | ||
74 | - "license": "MIT", | ||
75 | - "name": "cookie-parser", | ||
76 | - "repository": { | ||
77 | - "type": "git", | ||
78 | - "url": "git+https://github.com/expressjs/cookie-parser.git" | ||
79 | - }, | ||
80 | - "scripts": { | ||
81 | - "lint": "eslint --plugin markdown --ext js,md .", | ||
82 | - "test": "mocha --reporter spec --bail --check-leaks test/", | ||
83 | - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", | ||
84 | - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" | ||
85 | - }, | ||
86 | - "version": "1.4.5" | ||
87 | -} |
1 | -1.0.6 / 2015-02-03 | ||
2 | -================== | ||
3 | - | ||
4 | -* use `npm test` instead of `make test` to run tests | ||
5 | -* clearer assertion messages when checking input | ||
6 | - | ||
7 | - | ||
8 | -1.0.5 / 2014-09-05 | ||
9 | -================== | ||
10 | - | ||
11 | -* add license to package.json | ||
12 | - | ||
13 | -1.0.4 / 2014-06-25 | ||
14 | -================== | ||
15 | - | ||
16 | - * corrected avoidance of timing attacks (thanks @tenbits!) | ||
17 | - | ||
18 | -1.0.3 / 2014-01-28 | ||
19 | -================== | ||
20 | - | ||
21 | - * [incorrect] fix for timing attacks | ||
22 | - | ||
23 | -1.0.2 / 2014-01-28 | ||
24 | -================== | ||
25 | - | ||
26 | - * fix missing repository warning | ||
27 | - * fix typo in test | ||
28 | - | ||
29 | -1.0.1 / 2013-04-15 | ||
30 | -================== | ||
31 | - | ||
32 | - * Revert "Changed underlying HMAC algo. to sha512." | ||
33 | - * Revert "Fix for timing attacks on MAC verification." | ||
34 | - | ||
35 | -0.0.1 / 2010-01-03 | ||
36 | -================== | ||
37 | - | ||
38 | - * Initial release |
1 | - | ||
2 | -# cookie-signature | ||
3 | - | ||
4 | - Sign and unsign cookies. | ||
5 | - | ||
6 | -## Example | ||
7 | - | ||
8 | -```js | ||
9 | -var cookie = require('cookie-signature'); | ||
10 | - | ||
11 | -var val = cookie.sign('hello', 'tobiiscool'); | ||
12 | -val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI'); | ||
13 | - | ||
14 | -var val = cookie.sign('hello', 'tobiiscool'); | ||
15 | -cookie.unsign(val, 'tobiiscool').should.equal('hello'); | ||
16 | -cookie.unsign(val, 'luna').should.be.false; | ||
17 | -``` | ||
18 | - | ||
19 | -## License | ||
20 | - | ||
21 | -(The MIT License) | ||
22 | - | ||
23 | -Copyright (c) 2012 LearnBoost <tj@learnboost.com> | ||
24 | - | ||
25 | -Permission is hereby granted, free of charge, to any person obtaining | ||
26 | -a copy of this software and associated documentation files (the | ||
27 | -'Software'), to deal in the Software without restriction, including | ||
28 | -without limitation the rights to use, copy, modify, merge, publish, | ||
29 | -distribute, sublicense, and/or sell copies of the Software, and to | ||
30 | -permit persons to whom the Software is furnished to do so, subject to | ||
31 | -the following conditions: | ||
32 | - | ||
33 | -The above copyright notice and this permission notice shall be | ||
34 | -included in all copies or substantial portions of the Software. | ||
35 | - | ||
36 | -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
37 | -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
38 | -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
39 | -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
40 | -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
41 | -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
42 | -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -/** | ||
2 | - * Module dependencies. | ||
3 | - */ | ||
4 | - | ||
5 | -var crypto = require('crypto'); | ||
6 | - | ||
7 | -/** | ||
8 | - * Sign the given `val` with `secret`. | ||
9 | - * | ||
10 | - * @param {String} val | ||
11 | - * @param {String} secret | ||
12 | - * @return {String} | ||
13 | - * @api private | ||
14 | - */ | ||
15 | - | ||
16 | -exports.sign = function(val, secret){ | ||
17 | - if ('string' != typeof val) throw new TypeError("Cookie value must be provided as a string."); | ||
18 | - if ('string' != typeof secret) throw new TypeError("Secret string must be provided."); | ||
19 | - return val + '.' + crypto | ||
20 | - .createHmac('sha256', secret) | ||
21 | - .update(val) | ||
22 | - .digest('base64') | ||
23 | - .replace(/\=+$/, ''); | ||
24 | -}; | ||
25 | - | ||
26 | -/** | ||
27 | - * Unsign and decode the given `val` with `secret`, | ||
28 | - * returning `false` if the signature is invalid. | ||
29 | - * | ||
30 | - * @param {String} val | ||
31 | - * @param {String} secret | ||
32 | - * @return {String|Boolean} | ||
33 | - * @api private | ||
34 | - */ | ||
35 | - | ||
36 | -exports.unsign = function(val, secret){ | ||
37 | - if ('string' != typeof val) throw new TypeError("Signed cookie string must be provided."); | ||
38 | - if ('string' != typeof secret) throw new TypeError("Secret string must be provided."); | ||
39 | - var str = val.slice(0, val.lastIndexOf('.')) | ||
40 | - , mac = exports.sign(str, secret); | ||
41 | - | ||
42 | - return sha1(mac) == sha1(val) ? str : false; | ||
43 | -}; | ||
44 | - | ||
45 | -/** | ||
46 | - * Private | ||
47 | - */ | ||
48 | - | ||
49 | -function sha1(str){ | ||
50 | - return crypto.createHash('sha1').update(str).digest('hex'); | ||
51 | -} |
1 | -{ | ||
2 | - "_args": [ | ||
3 | - [ | ||
4 | - "cookie-signature@1.0.6", | ||
5 | - "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho" | ||
6 | - ] | ||
7 | - ], | ||
8 | - "_from": "cookie-signature@1.0.6", | ||
9 | - "_id": "cookie-signature@1.0.6", | ||
10 | - "_inBundle": false, | ||
11 | - "_integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", | ||
12 | - "_location": "/cookie-signature", | ||
13 | - "_phantomChildren": {}, | ||
14 | - "_requested": { | ||
15 | - "type": "version", | ||
16 | - "registry": true, | ||
17 | - "raw": "cookie-signature@1.0.6", | ||
18 | - "name": "cookie-signature", | ||
19 | - "escapedName": "cookie-signature", | ||
20 | - "rawSpec": "1.0.6", | ||
21 | - "saveSpec": null, | ||
22 | - "fetchSpec": "1.0.6" | ||
23 | - }, | ||
24 | - "_requiredBy": [ | ||
25 | - "/cookie-parser", | ||
26 | - "/express" | ||
27 | - ], | ||
28 | - "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", | ||
29 | - "_spec": "1.0.6", | ||
30 | - "_where": "C:\\Users\\ksh970\\Downloads\\sunho_final\\sunho", | ||
31 | - "author": { | ||
32 | - "name": "TJ Holowaychuk", | ||
33 | - "email": "tj@learnboost.com" | ||
34 | - }, | ||
35 | - "bugs": { | ||
36 | - "url": "https://github.com/visionmedia/node-cookie-signature/issues" | ||
37 | - }, | ||
38 | - "dependencies": {}, | ||
39 | - "description": "Sign and unsign cookies", | ||
40 | - "devDependencies": { | ||
41 | - "mocha": "*", | ||
42 | - "should": "*" | ||
43 | - }, | ||
44 | - "homepage": "https://github.com/visionmedia/node-cookie-signature#readme", | ||
45 | - "keywords": [ | ||
46 | - "cookie", | ||
47 | - "sign", | ||
48 | - "unsign" | ||
49 | - ], | ||
50 | - "license": "MIT", | ||
51 | - "main": "index", | ||
52 | - "name": "cookie-signature", | ||
53 | - "repository": { | ||
54 | - "type": "git", | ||
55 | - "url": "git+https://github.com/visionmedia/node-cookie-signature.git" | ||
56 | - }, | ||
57 | - "scripts": { | ||
58 | - "test": "mocha --require should --reporter spec" | ||
59 | - }, | ||
60 | - "version": "1.0.6" | ||
61 | -} |
This diff is collapsed. Click to expand it.
trollgg/node_modules/cookie/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/cookie/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/debug/.eslintrc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/debug/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/debug/Makefile
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/debug/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/debug/node.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/depd/History.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/depd/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/depd/Readme.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/depd/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/destroy/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/ejs/Jakefile
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ejs/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ejs/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ejs/ejs.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ejs/ejs.min.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ejs/lib/ejs.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/etag/HISTORY.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/etag/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/etag/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/etag/index.js
deleted
100644 → 0
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.
trollgg/node_modules/express/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/fresh/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/fresh/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/fresh/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/methods/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/mime-db/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/mime-db/db.json
deleted
100644 → 0
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.
trollgg/node_modules/mime/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/mime/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/mime/cli.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/mime/mime.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/mime/types.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/morgan/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/morgan/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/ms/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ms/license.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ms/package.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/ms/readme.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/.eslintrc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/CHANGELOG.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/dist/qs.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/lib/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/lib/parse.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/lib/utils.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/qs/package.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/send/HISTORY.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/send/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/send/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/send/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/type-is/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/unpipe/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/unpipe/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
trollgg/node_modules/vary/HISTORY.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/vary/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/vary/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
trollgg/node_modules/vary/index.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment