@maiyunnet/kebab 9.1.0 → 9.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/doc/kebab-rag.md CHANGED
@@ -1355,7 +1355,7 @@ index/variables/VER.md
1355
1355
 
1356
1356
  # Variable: VER
1357
1357
 
1358
- > `const` **VER**: `"9.1.0"` = `'9.1.0'`
1358
+ > `const` **VER**: `"9.1.2"` = `'9.1.2'`
1359
1359
 
1360
1360
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1361
1361
 
@@ -10515,7 +10515,7 @@ lib/net/functions/buildCookieQuery.md
10515
10515
 
10516
10516
  > **buildCookieQuery**(`cookie`, `uri`): `string`
10517
10517
 
10518
- Defined in: [lib/net.ts:639](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L639)
10518
+ Defined in: [lib/net.ts:661](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L661)
10519
10519
 
10520
10520
  对象转换为 Cookie 拼接字符串(会自动筛掉不能发送的 cookie)
10521
10521
 
@@ -10550,7 +10550,7 @@ lib/net/functions/fetch.md
10550
10550
 
10551
10551
  > **fetch**(`input`, `init?`): `Promise`\<`Response`\>
10552
10552
 
10553
- Defined in: [lib/net.ts:133](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L133)
10553
+ Defined in: [lib/net.ts:155](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L155)
10554
10554
 
10555
10555
  发起一个完全兼容 fetch 的请求
10556
10556
 
@@ -10585,7 +10585,7 @@ lib/net/functions/filterHeaders.md
10585
10585
 
10586
10586
  > **filterHeaders**(`headers`, `res?`, `filter?`): `Record`\<`string`, `string` \| `string`[]\>
10587
10587
 
10588
- Defined in: [lib/net.ts:717](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L717)
10588
+ Defined in: [lib/net.ts:739](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L739)
10589
10589
 
10590
10590
  剔除不代理的 header,返回新的 header
10591
10591
 
@@ -10647,7 +10647,7 @@ lib/net/functions/getFormData.md
10647
10647
 
10648
10648
  > **getFormData**(): [`FormData`](../formdata/classes/FormData.md)
10649
10649
 
10650
- Defined in: [lib/net.ts:701](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L701)
10650
+ Defined in: [lib/net.ts:723](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L723)
10651
10651
 
10652
10652
  创建 FormData 对象
10653
10653
 
@@ -10690,6 +10690,43 @@ Defined in: [lib/net.ts:69](https://github.com/maiyunnet/kebab/blob/master/lib/n
10690
10690
 
10691
10691
  `Promise`\<[`Response`](../response/classes/Response.md)\>
10692
10692
 
10693
+ lib/net/functions/getResponseJson.md
10694
+ ---
10695
+
10696
+ [**Documents for @maiyunnet/kebab**](../../../index.md)
10697
+
10698
+ ***
10699
+
10700
+ [Documents for @maiyunnet/kebab](../../../index.md) / [lib/net](../index.md) / getResponseJson
10701
+
10702
+ # Function: getResponseJson()
10703
+
10704
+ > **getResponseJson**(`u`, `opt?`): `Promise`\<`any`\>
10705
+
10706
+ Defined in: [lib/net.ts:134](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L134)
10707
+
10708
+ 发起 GET 请求并解析 JSON 响应
10709
+
10710
+ ## Parameters
10711
+
10712
+ ### u
10713
+
10714
+ `string`
10715
+
10716
+ 网址
10717
+
10718
+ ### opt?
10719
+
10720
+ [`IRequestOptions`](../interfaces/IRequestOptions.md) = `{}`
10721
+
10722
+ 选项
10723
+
10724
+ ## Returns
10725
+
10726
+ `Promise`\<`any`\>
10727
+
10728
+ JSON 数据,失败时返回 null
10729
+
10693
10730
  lib/net/functions/mproxyData.md
10694
10731
  ---
10695
10732
 
@@ -10703,7 +10740,7 @@ lib/net/functions/mproxyData.md
10703
10740
 
10704
10741
  > **mproxyData**(`ctr`): `any`
10705
10742
 
10706
- Defined in: [lib/net.ts:805](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L805)
10743
+ Defined in: [lib/net.ts:827](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L827)
10707
10744
 
10708
10745
  获取 mproxy 的附加数据
10709
10746
 
@@ -10732,7 +10769,7 @@ lib/net/functions/mproxy.md
10732
10769
 
10733
10770
  > **mproxy**(`ctr`, `auth`, `opt?`): `Promise`\<`number`\>
10734
10771
 
10735
- Defined in: [lib/net.ts:753](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L753)
10772
+ Defined in: [lib/net.ts:775](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L775)
10736
10773
 
10737
10774
  正向 mproxy 代理,注意提前处理不要自动处理 post 数据,读取 get 的 url 为实际请求地址
10738
10775
  get: url, auth
@@ -10926,7 +10963,7 @@ lib/net/functions/request.md
10926
10963
 
10927
10964
  > **request**(`u`, `data?`, `opt?`): `Promise`\<[`Response`](../response/classes/Response.md)\>
10928
10965
 
10929
- Defined in: [lib/net.ts:283](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L283)
10966
+ Defined in: [lib/net.ts:305](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L305)
10930
10967
 
10931
10968
  发起一个请求
10932
10969
 
@@ -10963,7 +11000,7 @@ lib/net/functions/resetCookieSession.md
10963
11000
 
10964
11001
  > **resetCookieSession**(`cookie`): `void`
10965
11002
 
10966
- Defined in: [lib/net.ts:689](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L689)
11003
+ Defined in: [lib/net.ts:711](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L711)
10967
11004
 
10968
11005
  模拟重启浏览器后的状态
10969
11006
 
@@ -10992,7 +11029,7 @@ lib/net/functions/rproxy.md
10992
11029
 
10993
11030
  > **rproxy**(`ctr`, `route`, `opt?`): `Promise`\<`boolean`\>
10994
11031
 
10995
- Defined in: [lib/net.ts:823](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L823)
11032
+ Defined in: [lib/net.ts:845](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L845)
10996
11033
 
10997
11034
  反向代理,注意提前处理不要自动处理 post 数据,将本服务器的某个路由反代到其他网址
10998
11035
 
@@ -11033,7 +11070,7 @@ lib/net/functions/setCookie.md
11033
11070
 
11034
11071
  > **setCookie**(`cookie`, `name`, `value`, `domain`, `opt?`): `void`
11035
11072
 
11036
- Defined in: [lib/net.ts:477](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L477)
11073
+ Defined in: [lib/net.ts:499](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L499)
11037
11074
 
11038
11075
  对 cookie 对象进行操作
11039
11076
 
@@ -11117,6 +11154,7 @@ lib/net/index.md
11117
11154
  - [get](functions/get.md)
11118
11155
  - [getCa](functions/getCa.md)
11119
11156
  - [getFormData](functions/getFormData.md)
11157
+ - [getResponseJson](functions/getResponseJson.md)
11120
11158
  - [mproxy](functions/mproxy.md)
11121
11159
  - [mproxyData](functions/mproxyData.md)
11122
11160
  - [open](functions/open.md)
@@ -11139,7 +11177,7 @@ lib/net/interfaces/ICookie.md
11139
11177
 
11140
11178
  # Interface: ICookie
11141
11179
 
11142
- Defined in: [lib/net.ts:954](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L954)
11180
+ Defined in: [lib/net.ts:976](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L976)
11143
11181
 
11144
11182
  Net Cookie 对象
11145
11183
 
@@ -11149,7 +11187,7 @@ Net Cookie 对象
11149
11187
 
11150
11188
  > **domain**: `string`
11151
11189
 
11152
- Defined in: [lib/net.ts:960](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L960)
11190
+ Defined in: [lib/net.ts:982](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L982)
11153
11191
 
11154
11192
  ***
11155
11193
 
@@ -11157,7 +11195,7 @@ Defined in: [lib/net.ts:960](https://github.com/maiyunnet/kebab/blob/master/lib/
11157
11195
 
11158
11196
  > **exp**: `number`
11159
11197
 
11160
- Defined in: [lib/net.ts:958](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L958)
11198
+ Defined in: [lib/net.ts:980](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L980)
11161
11199
 
11162
11200
  有效期秒级时间戳
11163
11201
 
@@ -11167,7 +11205,7 @@ Defined in: [lib/net.ts:958](https://github.com/maiyunnet/kebab/blob/master/lib/
11167
11205
 
11168
11206
  > **httponly**: `boolean`
11169
11207
 
11170
- Defined in: [lib/net.ts:962](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L962)
11208
+ Defined in: [lib/net.ts:984](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L984)
11171
11209
 
11172
11210
  ***
11173
11211
 
@@ -11175,7 +11213,7 @@ Defined in: [lib/net.ts:962](https://github.com/maiyunnet/kebab/blob/master/lib/
11175
11213
 
11176
11214
  > **name**: `string`
11177
11215
 
11178
- Defined in: [lib/net.ts:955](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L955)
11216
+ Defined in: [lib/net.ts:977](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L977)
11179
11217
 
11180
11218
  ***
11181
11219
 
@@ -11183,7 +11221,7 @@ Defined in: [lib/net.ts:955](https://github.com/maiyunnet/kebab/blob/master/lib/
11183
11221
 
11184
11222
  > **path**: `string`
11185
11223
 
11186
- Defined in: [lib/net.ts:959](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L959)
11224
+ Defined in: [lib/net.ts:981](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L981)
11187
11225
 
11188
11226
  ***
11189
11227
 
@@ -11191,7 +11229,7 @@ Defined in: [lib/net.ts:959](https://github.com/maiyunnet/kebab/blob/master/lib/
11191
11229
 
11192
11230
  > **secure**: `boolean`
11193
11231
 
11194
- Defined in: [lib/net.ts:961](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L961)
11232
+ Defined in: [lib/net.ts:983](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L983)
11195
11233
 
11196
11234
  ***
11197
11235
 
@@ -11199,7 +11237,7 @@ Defined in: [lib/net.ts:961](https://github.com/maiyunnet/kebab/blob/master/lib/
11199
11237
 
11200
11238
  > **value**: `string`
11201
11239
 
11202
- Defined in: [lib/net.ts:956](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L956)
11240
+ Defined in: [lib/net.ts:978](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L978)
11203
11241
 
11204
11242
  lib/net/interfaces/IMproxyOptions.md
11205
11243
  ---
@@ -11212,7 +11250,7 @@ lib/net/interfaces/IMproxyOptions.md
11212
11250
 
11213
11251
  # Interface: IMproxyOptions
11214
11252
 
11215
- Defined in: [lib/net.ts:907](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L907)
11253
+ Defined in: [lib/net.ts:929](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L929)
11216
11254
 
11217
11255
  正向代理请求的传入参数选项
11218
11256
 
@@ -11222,7 +11260,7 @@ Defined in: [lib/net.ts:907](https://github.com/maiyunnet/kebab/blob/master/lib/
11222
11260
 
11223
11261
  > `optional` **filter?**: (`h`) => `boolean`
11224
11262
 
11225
- Defined in: [lib/net.ts:916](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L916)
11263
+ Defined in: [lib/net.ts:938](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L938)
11226
11264
 
11227
11265
  过滤 header,返回 true 则留下
11228
11266
 
@@ -11242,7 +11280,7 @@ Defined in: [lib/net.ts:916](https://github.com/maiyunnet/kebab/blob/master/lib/
11242
11280
 
11243
11281
  > `optional` **follow?**: `number`
11244
11282
 
11245
- Defined in: [lib/net.ts:910](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L910)
11283
+ Defined in: [lib/net.ts:932](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L932)
11246
11284
 
11247
11285
  ***
11248
11286
 
@@ -11250,7 +11288,7 @@ Defined in: [lib/net.ts:910](https://github.com/maiyunnet/kebab/blob/master/lib/
11250
11288
 
11251
11289
  > `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
11252
11290
 
11253
- Defined in: [lib/net.ts:914](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L914)
11291
+ Defined in: [lib/net.ts:936](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L936)
11254
11292
 
11255
11293
  ***
11256
11294
 
@@ -11258,7 +11296,7 @@ Defined in: [lib/net.ts:914](https://github.com/maiyunnet/kebab/blob/master/lib/
11258
11296
 
11259
11297
  > `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
11260
11298
 
11261
- Defined in: [lib/net.ts:912](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L912)
11299
+ Defined in: [lib/net.ts:934](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L934)
11262
11300
 
11263
11301
  自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
11264
11302
 
@@ -11268,7 +11306,7 @@ Defined in: [lib/net.ts:912](https://github.com/maiyunnet/kebab/blob/master/lib/
11268
11306
 
11269
11307
  > `optional` **local?**: `string`
11270
11308
 
11271
- Defined in: [lib/net.ts:913](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L913)
11309
+ Defined in: [lib/net.ts:935](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L935)
11272
11310
 
11273
11311
  ***
11274
11312
 
@@ -11276,7 +11314,7 @@ Defined in: [lib/net.ts:913](https://github.com/maiyunnet/kebab/blob/master/lib/
11276
11314
 
11277
11315
  > `optional` **reuse?**: `string`
11278
11316
 
11279
- Defined in: [lib/net.ts:918](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L918)
11317
+ Defined in: [lib/net.ts:940](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L940)
11280
11318
 
11281
11319
  默认为 default
11282
11320
 
@@ -11286,7 +11324,7 @@ Defined in: [lib/net.ts:918](https://github.com/maiyunnet/kebab/blob/master/lib/
11286
11324
 
11287
11325
  > `optional` **timeout?**: `number`
11288
11326
 
11289
- Defined in: [lib/net.ts:909](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L909)
11327
+ Defined in: [lib/net.ts:931](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L931)
11290
11328
 
11291
11329
  秒数
11292
11330
 
@@ -11301,7 +11339,7 @@ lib/net/interfaces/IRequestOptions.md
11301
11339
 
11302
11340
  # Interface: IRequestOptions
11303
11341
 
11304
- Defined in: [lib/net.ts:876](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L876)
11342
+ Defined in: [lib/net.ts:898](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L898)
11305
11343
 
11306
11344
  请求的传入参数选项
11307
11345
 
@@ -11311,7 +11349,7 @@ Defined in: [lib/net.ts:876](https://github.com/maiyunnet/kebab/blob/master/lib/
11311
11349
 
11312
11350
  > `optional` **cookie?**: `Record`\<`string`, [`ICookie`](ICookie.md)\>
11313
11351
 
11314
- Defined in: [lib/net.ts:901](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L901)
11352
+ Defined in: [lib/net.ts:923](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L923)
11315
11353
 
11316
11354
  cookie 托管对象
11317
11355
 
@@ -11321,7 +11359,7 @@ cookie 托管对象
11321
11359
 
11322
11360
  > `optional` **follow?**: `number`
11323
11361
 
11324
- Defined in: [lib/net.ts:882](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L882)
11362
+ Defined in: [lib/net.ts:904](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L904)
11325
11363
 
11326
11364
  追踪 location 次数,0 为不追踪,默认为 0
11327
11365
 
@@ -11331,7 +11369,7 @@ Defined in: [lib/net.ts:882](https://github.com/maiyunnet/kebab/blob/master/lib/
11331
11369
 
11332
11370
  > `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
11333
11371
 
11334
- Defined in: [lib/net.ts:887](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L887)
11372
+ Defined in: [lib/net.ts:909](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L909)
11335
11373
 
11336
11374
  ***
11337
11375
 
@@ -11339,7 +11377,7 @@ Defined in: [lib/net.ts:887](https://github.com/maiyunnet/kebab/blob/master/lib/
11339
11377
 
11340
11378
  > `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
11341
11379
 
11342
- Defined in: [lib/net.ts:884](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L884)
11380
+ Defined in: [lib/net.ts:906](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L906)
11343
11381
 
11344
11382
  自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
11345
11383
 
@@ -11349,7 +11387,7 @@ Defined in: [lib/net.ts:884](https://github.com/maiyunnet/kebab/blob/master/lib/
11349
11387
 
11350
11388
  > `optional` **keep?**: `boolean`
11351
11389
 
11352
- Defined in: [lib/net.ts:897](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L897)
11390
+ Defined in: [lib/net.ts:919](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L919)
11353
11391
 
11354
11392
  连接是否保持长连接(即是否允许复用),默认为 true
11355
11393
 
@@ -11359,7 +11397,7 @@ Defined in: [lib/net.ts:897](https://github.com/maiyunnet/kebab/blob/master/lib/
11359
11397
 
11360
11398
  > `optional` **local?**: `string`
11361
11399
 
11362
- Defined in: [lib/net.ts:886](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L886)
11400
+ Defined in: [lib/net.ts:908](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L908)
11363
11401
 
11364
11402
  ***
11365
11403
 
@@ -11367,7 +11405,7 @@ Defined in: [lib/net.ts:886](https://github.com/maiyunnet/kebab/blob/master/lib/
11367
11405
 
11368
11406
  > `optional` **log?**: `boolean`
11369
11407
 
11370
- Defined in: [lib/net.ts:903](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L903)
11408
+ Defined in: [lib/net.ts:925](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L925)
11371
11409
 
11372
11410
  若有异常写入文件日志,默认为 true
11373
11411
 
@@ -11377,7 +11415,7 @@ Defined in: [lib/net.ts:903](https://github.com/maiyunnet/kebab/blob/master/lib/
11377
11415
 
11378
11416
  > `optional` **method?**: `"GET"` \| `"POST"` \| `"PUT"` \| `"DELETE"` \| `"OPTIONS"`
11379
11417
 
11380
- Defined in: [lib/net.ts:877](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L877)
11418
+ Defined in: [lib/net.ts:899](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L899)
11381
11419
 
11382
11420
  ***
11383
11421
 
@@ -11385,7 +11423,7 @@ Defined in: [lib/net.ts:877](https://github.com/maiyunnet/kebab/blob/master/lib/
11385
11423
 
11386
11424
  > `optional` **mproxy?**: `object`
11387
11425
 
11388
- Defined in: [lib/net.ts:889](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L889)
11426
+ Defined in: [lib/net.ts:911](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L911)
11389
11427
 
11390
11428
  正向 mproxy 代理,url 如 https://xxx/abc
11391
11429
 
@@ -11413,7 +11451,7 @@ Defined in: [lib/net.ts:889](https://github.com/maiyunnet/kebab/blob/master/lib/
11413
11451
 
11414
11452
  > `optional` **reuse?**: `string`
11415
11453
 
11416
- Defined in: [lib/net.ts:899](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L899)
11454
+ Defined in: [lib/net.ts:921](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L921)
11417
11455
 
11418
11456
  复用池名,默认为 default
11419
11457
 
@@ -11423,7 +11461,7 @@ Defined in: [lib/net.ts:899](https://github.com/maiyunnet/kebab/blob/master/lib/
11423
11461
 
11424
11462
  > `optional` **save?**: `string`
11425
11463
 
11426
- Defined in: [lib/net.ts:885](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L885)
11464
+ Defined in: [lib/net.ts:907](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L907)
11427
11465
 
11428
11466
  ***
11429
11467
 
@@ -11431,7 +11469,7 @@ Defined in: [lib/net.ts:885](https://github.com/maiyunnet/kebab/blob/master/lib/
11431
11469
 
11432
11470
  > `optional` **timeout?**: `number`
11433
11471
 
11434
- Defined in: [lib/net.ts:880](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L880)
11472
+ Defined in: [lib/net.ts:902](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L902)
11435
11473
 
11436
11474
  秒数
11437
11475
 
@@ -11441,7 +11479,7 @@ Defined in: [lib/net.ts:880](https://github.com/maiyunnet/kebab/blob/master/lib/
11441
11479
 
11442
11480
  > `optional` **type?**: `"form"` \| `"json"`
11443
11481
 
11444
- Defined in: [lib/net.ts:878](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L878)
11482
+ Defined in: [lib/net.ts:900](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L900)
11445
11483
 
11446
11484
  lib/net/interfaces/IRproxyOptions.md
11447
11485
  ---
@@ -11454,7 +11492,7 @@ lib/net/interfaces/IRproxyOptions.md
11454
11492
 
11455
11493
  # Interface: IRproxyOptions
11456
11494
 
11457
- Defined in: [lib/net.ts:922](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L922)
11495
+ Defined in: [lib/net.ts:944](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L944)
11458
11496
 
11459
11497
  反向代理请求的传入参数选项
11460
11498
 
@@ -11464,7 +11502,7 @@ Defined in: [lib/net.ts:922](https://github.com/maiyunnet/kebab/blob/master/lib/
11464
11502
 
11465
11503
  > `optional` **filter?**: (`h`) => `boolean`
11466
11504
 
11467
- Defined in: [lib/net.ts:931](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L931)
11505
+ Defined in: [lib/net.ts:953](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L953)
11468
11506
 
11469
11507
  过滤 header,返回 true 则留下
11470
11508
 
@@ -11484,7 +11522,7 @@ Defined in: [lib/net.ts:931](https://github.com/maiyunnet/kebab/blob/master/lib/
11484
11522
 
11485
11523
  > `optional` **follow?**: `number`
11486
11524
 
11487
- Defined in: [lib/net.ts:925](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L925)
11525
+ Defined in: [lib/net.ts:947](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L947)
11488
11526
 
11489
11527
  ***
11490
11528
 
@@ -11492,7 +11530,7 @@ Defined in: [lib/net.ts:925](https://github.com/maiyunnet/kebab/blob/master/lib/
11492
11530
 
11493
11531
  > `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
11494
11532
 
11495
- Defined in: [lib/net.ts:929](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L929)
11533
+ Defined in: [lib/net.ts:951](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L951)
11496
11534
 
11497
11535
  ***
11498
11536
 
@@ -11500,7 +11538,7 @@ Defined in: [lib/net.ts:929](https://github.com/maiyunnet/kebab/blob/master/lib/
11500
11538
 
11501
11539
  > `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
11502
11540
 
11503
- Defined in: [lib/net.ts:927](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L927)
11541
+ Defined in: [lib/net.ts:949](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L949)
11504
11542
 
11505
11543
  自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
11506
11544
 
@@ -11510,7 +11548,7 @@ Defined in: [lib/net.ts:927](https://github.com/maiyunnet/kebab/blob/master/lib/
11510
11548
 
11511
11549
  > `optional` **local?**: `string`
11512
11550
 
11513
- Defined in: [lib/net.ts:928](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L928)
11551
+ Defined in: [lib/net.ts:950](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L950)
11514
11552
 
11515
11553
  ***
11516
11554
 
@@ -11518,7 +11556,7 @@ Defined in: [lib/net.ts:928](https://github.com/maiyunnet/kebab/blob/master/lib/
11518
11556
 
11519
11557
  > `optional` **mproxy?**: `object`
11520
11558
 
11521
- Defined in: [lib/net.ts:933](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L933)
11559
+ Defined in: [lib/net.ts:955](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L955)
11522
11560
 
11523
11561
  正向 mproxy 代理,url 如 https://xxx/abc
11524
11562
 
@@ -11546,7 +11584,7 @@ Defined in: [lib/net.ts:933](https://github.com/maiyunnet/kebab/blob/master/lib/
11546
11584
 
11547
11585
  > `optional` **reuse?**: `string`
11548
11586
 
11549
- Defined in: [lib/net.ts:941](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L941)
11587
+ Defined in: [lib/net.ts:963](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L963)
11550
11588
 
11551
11589
  默认为 default
11552
11590
 
@@ -11556,7 +11594,7 @@ Defined in: [lib/net.ts:941](https://github.com/maiyunnet/kebab/blob/master/lib/
11556
11594
 
11557
11595
  > `optional` **timeout?**: `number`
11558
11596
 
11559
- Defined in: [lib/net.ts:924](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L924)
11597
+ Defined in: [lib/net.ts:946](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L946)
11560
11598
 
11561
11599
  秒数
11562
11600
 
@@ -12017,7 +12055,7 @@ lib/net/type-aliases/THttpHeaders.md
12017
12055
 
12018
12056
  > **THttpHeaders** = `http.IncomingHttpHeaders` & `object`
12019
12057
 
12020
- Defined in: [lib/net.ts:946](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L946)
12058
+ Defined in: [lib/net.ts:968](https://github.com/maiyunnet/kebab/blob/master/lib/net.ts#L968)
12021
12059
 
12022
12060
  http headers
12023
12061
 
@@ -13049,7 +13087,7 @@ Defined in: [lib/session.ts:39](https://github.com/maiyunnet/kebab/blob/master/l
13049
13087
 
13050
13088
  > **getName**(): `string`
13051
13089
 
13052
- Defined in: [lib/session.ts:207](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L207)
13090
+ Defined in: [lib/session.ts:212](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L212)
13053
13091
 
13054
13092
  获取当前的 cookie 的 name 值
13055
13093
 
@@ -13063,7 +13101,7 @@ Defined in: [lib/session.ts:207](https://github.com/maiyunnet/kebab/blob/master/
13063
13101
 
13064
13102
  > **getToken**(): `string`
13065
13103
 
13066
- Defined in: [lib/session.ts:200](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L200)
13104
+ Defined in: [lib/session.ts:205](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L205)
13067
13105
 
13068
13106
  获取当前的 token 值
13069
13107
 
@@ -13119,7 +13157,7 @@ false 表示系统错误
13119
13157
 
13120
13158
  > **update**(): `Promise`\<`void`\>
13121
13159
 
13122
- Defined in: [lib/session.ts:214](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L214)
13160
+ Defined in: [lib/session.ts:219](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L219)
13123
13161
 
13124
13162
  页面整体结束时,要写入到 Kv 或 数据库
13125
13163
 
@@ -20199,7 +20237,7 @@ Defined in: [sys/ctr.ts:120](https://github.com/maiyunnet/kebab/blob/master/sys/
20199
20237
 
20200
20238
  Defined in: [sys/ctr.ts:132](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L132)
20201
20239
 
20202
- 获取当前过期时间
20240
+ 获取当前过期时间(毫秒)
20203
20241
 
20204
20242
  ##### Returns
20205
20243
 
@@ -20211,7 +20249,7 @@ Defined in: [sys/ctr.ts:132](https://github.com/maiyunnet/kebab/blob/master/sys/
20211
20249
 
20212
20250
  Defined in: [sys/ctr.ts:139](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L139)
20213
20251
 
20214
- 设置当前过期时间
20252
+ 设置当前过期时间(毫秒)
20215
20253
 
20216
20254
  ##### Parameters
20217
20255
 
@@ -20319,7 +20357,7 @@ Defined in: [sys/ctr.ts:746](https://github.com/maiyunnet/kebab/blob/master/sys/
20319
20357
 
20320
20358
  > `protected` **\_cross**(`opt?`): `boolean`
20321
20359
 
20322
- Defined in: [sys/ctr.ts:960](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L960)
20360
+ Defined in: [sys/ctr.ts:975](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L975)
20323
20361
 
20324
20362
  开启跨域请求
20325
20363
 
@@ -20401,7 +20439,7 @@ Defined in: [sys/ctr.ts:757](https://github.com/maiyunnet/kebab/blob/master/sys/
20401
20439
 
20402
20440
  > `protected` **\_end**(): `void`
20403
20441
 
20404
- Defined in: [sys/ctr.ts:1068](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1068)
20442
+ Defined in: [sys/ctr.ts:1083](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1083)
20405
20443
 
20406
20444
  主动关闭当前 socket 连接
20407
20445
 
@@ -20443,7 +20481,7 @@ Defined in: [sys/ctr.ts:781](https://github.com/maiyunnet/kebab/blob/master/sys/
20443
20481
 
20444
20482
  > `protected` **\_getLocale**(): `string`
20445
20483
 
20446
- Defined in: [sys/ctr.ts:951](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L951)
20484
+ Defined in: [sys/ctr.ts:966](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L966)
20447
20485
 
20448
20486
  获取当前语言名
20449
20487
 
@@ -20457,7 +20495,7 @@ Defined in: [sys/ctr.ts:951](https://github.com/maiyunnet/kebab/blob/master/sys/
20457
20495
 
20458
20496
  > `protected` **\_getLocaleJsonString**(): `string`
20459
20497
 
20460
- Defined in: [sys/ctr.ts:939](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L939)
20498
+ Defined in: [sys/ctr.ts:954](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L954)
20461
20499
 
20462
20500
  根据当前后台语言包设置情况获取 JSON 字符串传输到前台
20463
20501
 
@@ -20509,7 +20547,7 @@ Defined in: [sys/ctr.ts:315](https://github.com/maiyunnet/kebab/blob/master/sys/
20509
20547
 
20510
20548
  > `protected` **\_handleFormData**(`events?`, `limits?`): `Promise`\<`boolean`\>
20511
20549
 
20512
- Defined in: [sys/ctr.ts:1077](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1077)
20550
+ Defined in: [sys/ctr.ts:1092](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1092)
20513
20551
 
20514
20552
  获取 formdata 的信息
20515
20553
 
@@ -20557,7 +20595,7 @@ Defined in: [sys/ctr.ts:1077](https://github.com/maiyunnet/kebab/blob/master/sys
20557
20595
 
20558
20596
  > **\_l**(`key`, `data?`): `string`
20559
20597
 
20560
- Defined in: [sys/ctr.ts:1003](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1003)
20598
+ Defined in: [sys/ctr.ts:1018](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1018)
20561
20599
 
20562
20600
  获取语言包值
20563
20601
 
@@ -20583,7 +20621,7 @@ Defined in: [sys/ctr.ts:1003](https://github.com/maiyunnet/kebab/blob/master/sys
20583
20621
 
20584
20622
  > `protected` **\_loadData**(`path`): `Promise`\<`Record`\<`string`, `string`\> \| `null`\>
20585
20623
 
20586
- Defined in: [sys/ctr.ts:842](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L842)
20624
+ Defined in: [sys/ctr.ts:857](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L857)
20587
20625
 
20588
20626
  获取 data 数据
20589
20627
 
@@ -20605,7 +20643,7 @@ Defined in: [sys/ctr.ts:842](https://github.com/maiyunnet/kebab/blob/master/sys/
20605
20643
 
20606
20644
  > `protected` **\_loadLocale**(`loc`, `pkg?`): `Promise`\<`boolean`\>
20607
20645
 
20608
- Defined in: [sys/ctr.ts:890](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L890)
20646
+ Defined in: [sys/ctr.ts:905](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L905)
20609
20647
 
20610
20648
  设定语言并加载语言包
20611
20649
 
@@ -20726,7 +20764,7 @@ Defined in: [sys/ctr.ts:332](https://github.com/maiyunnet/kebab/blob/master/sys/
20726
20764
 
20727
20765
  > `protected` **\_location**(`location`): `false`
20728
20766
 
20729
- Defined in: [sys/ctr.ts:860](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L860)
20767
+ Defined in: [sys/ctr.ts:875](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L875)
20730
20768
 
20731
20769
  跳转(302临时跳转),支持相对本项目根路径的路径或绝对路径
20732
20770
 
@@ -20748,7 +20786,7 @@ Defined in: [sys/ctr.ts:860](https://github.com/maiyunnet/kebab/blob/master/sys/
20748
20786
 
20749
20787
  > `protected` **\_ping**(`data?`): `boolean`
20750
20788
 
20751
- Defined in: [sys/ctr.ts:1053](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1053)
20789
+ Defined in: [sys/ctr.ts:1068](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1068)
20752
20790
 
20753
20791
  发送 socket ping
20754
20792
 
@@ -20770,7 +20808,7 @@ Defined in: [sys/ctr.ts:1053](https://github.com/maiyunnet/kebab/blob/master/sys
20770
20808
 
20771
20809
  > `protected` **\_pong**(`data?`): `boolean`
20772
20810
 
20773
- Defined in: [sys/ctr.ts:1061](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1061)
20811
+ Defined in: [sys/ctr.ts:1076](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1076)
20774
20812
 
20775
20813
  发送 socket pong
20776
20814
 
@@ -20792,7 +20830,7 @@ Defined in: [sys/ctr.ts:1061](https://github.com/maiyunnet/kebab/blob/master/sys
20792
20830
 
20793
20831
  > `protected` **\_startSession**(`link`, `auth?`, `opt?`): `Promise`\<`boolean`\>
20794
20832
 
20795
- Defined in: [sys/ctr.ts:874](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L874)
20833
+ Defined in: [sys/ctr.ts:889](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L889)
20796
20834
 
20797
20835
  开启 Session
20798
20836
 
@@ -20826,7 +20864,7 @@ Kv 或 Db 实例
20826
20864
 
20827
20865
  > `protected` **\_writeBinary**(`data`): `boolean`
20828
20866
 
20829
- Defined in: [sys/ctr.ts:1045](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1045)
20867
+ Defined in: [sys/ctr.ts:1060](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1060)
20830
20868
 
20831
20869
  发送 socket 二进制
20832
20870
 
@@ -20848,7 +20886,7 @@ Defined in: [sys/ctr.ts:1045](https://github.com/maiyunnet/kebab/blob/master/sys
20848
20886
 
20849
20887
  > `protected` **\_writeResult**(`data`): `boolean`
20850
20888
 
20851
- Defined in: [sys/ctr.ts:1037](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1037)
20889
+ Defined in: [sys/ctr.ts:1052](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1052)
20852
20890
 
20853
20891
  发送结果对象文本
20854
20892
 
@@ -20870,7 +20908,7 @@ Defined in: [sys/ctr.ts:1037](https://github.com/maiyunnet/kebab/blob/master/sys
20870
20908
 
20871
20909
  > `protected` **\_writeText**(`data`): `boolean`
20872
20910
 
20873
- Defined in: [sys/ctr.ts:1029](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1029)
20911
+ Defined in: [sys/ctr.ts:1044](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1044)
20874
20912
 
20875
20913
  发送 socket 文本
20876
20914
 
@@ -20890,15 +20928,15 @@ Defined in: [sys/ctr.ts:1029](https://github.com/maiyunnet/kebab/blob/master/sys
20890
20928
 
20891
20929
  ### getAuthorization()
20892
20930
 
20893
- > **getAuthorization**(): `false` \| \{ `pwd`: `string`; `user`: `string`; \}
20931
+ > **getAuthorization**(): `false` \| \{ `pwd`: `string`; `type`: `"basic"`; `user`: `string`; \} \| \{ `token`: `string`; `type`: `"bearer"`; \}
20894
20932
 
20895
20933
  Defined in: [sys/ctr.ts:809](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L809)
20896
20934
 
20897
- 通过 header 或 _auth 获取 Basic Auth 鉴权信息
20935
+ 通过 header 或 _auth 获取鉴权信息,支持 Basic Auth 和 Bearer Token
20898
20936
 
20899
20937
  #### Returns
20900
20938
 
20901
- `false` \| \{ `pwd`: `string`; `user`: `string`; \}
20939
+ `false` \| \{ `pwd`: `string`; `type`: `"basic"`; `user`: `string`; \} \| \{ `token`: `string`; `type`: `"bearer"`; \}
20902
20940
 
20903
20941
  ***
20904
20942
 
@@ -23890,7 +23928,7 @@ sys/route/functions/getFormData.md
23890
23928
 
23891
23929
  > **getFormData**(`req`, `events?`, `limits?`): `Promise`\<`false` \| \{ `files`: `Record`\<`string`, [`IPostFile`](../../../index/interfaces/IPostFile.md) \| [`IPostFile`](../../../index/interfaces/IPostFile.md)[]\>; `post`: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\>; \}\>
23892
23930
 
23893
- Defined in: [sys/route.ts:933](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L933)
23931
+ Defined in: [sys/route.ts:962](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L962)
23894
23932
 
23895
23933
  获取 formdata 的 post
23896
23934
 
@@ -23957,7 +23995,7 @@ sys/route/functions/getPost.md
23957
23995
 
23958
23996
  > **getPost**(`req`): `Promise`\<\{ `input`: `string`; `post`: `Record`\<`string`, `any`\>; `raw`: `Record`\<`string`, `any`\>; \}\>
23959
23997
 
23960
- Defined in: [sys/route.ts:866](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L866)
23998
+ Defined in: [sys/route.ts:876](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L876)
23961
23999
 
23962
24000
  获取 post 对象(通常已自动获取),如果是文件上传(formdata)的情况则不获取
23963
24001
 
@@ -24073,7 +24111,7 @@ sys/route/functions/unlinkUploadFiles.md
24073
24111
 
24074
24112
  > **unlinkUploadFiles**(`cctr`): `Promise`\<`void`\>
24075
24113
 
24076
- Defined in: [sys/route.ts:825](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L825)
24114
+ Defined in: [sys/route.ts:835](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L835)
24077
24115
 
24078
24116
  删除本次请求所有已上传的临时文件
24079
24117
 
@@ -24102,7 +24140,7 @@ sys/route/functions/waitCtr.md
24102
24140
 
24103
24141
  > **waitCtr**(`cctr`): `Promise`\<`void`\>
24104
24142
 
24105
- Defined in: [sys/route.ts:845](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L845)
24143
+ Defined in: [sys/route.ts:855](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L855)
24106
24144
 
24107
24145
  等待异步任务结束,并删除临时文件,如果结束后还有事务没关闭,则会在本函数中打印控制台并且写入 log 文件
24108
24146
  此时其实已经给客户端返回了,此处等待不消耗客户端的等待时间
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.1.0";
8
+ export declare const VER = "9.1.2";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.1.0';
9
+ export const VER = '9.1.2';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/net.d.ts CHANGED
@@ -47,6 +47,13 @@ export declare function postJson(u: string, data: kebab.Json[] | Record<string,
47
47
  * @returns JSON 数据,失败时返回 null
48
48
  */
49
49
  export declare function postJsonResponseJson(u: string, data: kebab.Json[] | Record<string, kebab.Json>, opt?: IRequestOptions): Promise<kebab.Json | null>;
50
+ /**
51
+ * --- 发起 GET 请求并解析 JSON 响应 ---
52
+ * @param u 网址
53
+ * @param opt 选项
54
+ * @returns JSON 数据,失败时返回 null
55
+ */
56
+ export declare function getResponseJson(u: string, opt?: IRequestOptions): Promise<kebab.Json | null>;
50
57
  /**
51
58
  * --- 发起一个完全兼容 fetch 的请求 ---
52
59
  * @param input 请求的 URL 或 Request 对象
package/lib/net.js CHANGED
@@ -97,6 +97,24 @@ export async function postJsonResponseJson(u, data, opt = {}) {
97
97
  }
98
98
  return json;
99
99
  }
100
+ /**
101
+ * --- 发起 GET 请求并解析 JSON 响应 ---
102
+ * @param u 网址
103
+ * @param opt 选项
104
+ * @returns JSON 数据,失败时返回 null
105
+ */
106
+ export async function getResponseJson(u, opt = {}) {
107
+ const res = await request(u, undefined, opt);
108
+ const rtn = await res.getContent();
109
+ if (!rtn) {
110
+ return null;
111
+ }
112
+ const json = lText.parseJson(rtn.toString());
113
+ if (!json) {
114
+ return null;
115
+ }
116
+ return json;
117
+ }
100
118
  /**
101
119
  * --- 发起一个完全兼容 fetch 的请求 ---
102
120
  * @param input 请求的 URL 或 Request 对象
package/lib/session.js CHANGED
@@ -56,7 +56,12 @@ export class Session {
56
56
  }
57
57
  else if (auth) {
58
58
  const a = ctr.getAuthorization();
59
- if (a && typeof a !== 'string' && (a.user === 'token')) {
59
+ if (a && a.type === 'bearer') {
60
+ // --- Authorization: Bearer <token> ---
61
+ this._token = a.token;
62
+ }
63
+ else if (a && a.type === 'basic' && a.user === 'token') {
64
+ // --- Authorization: Basic base64(token:<token>),兼容旧模式 ---
60
65
  this._token = a.pwd;
61
66
  }
62
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.1.0",
3
+ "version": "9.1.2",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/ctr.d.ts CHANGED
@@ -58,10 +58,10 @@ export declare class Ctr {
58
58
  'timeout': number;
59
59
  'callback': () => void;
60
60
  };
61
- /** --- 获取当前过期时间 --- */
61
+ /** --- 获取当前过期时间(毫秒) --- */
62
62
  get timeout(): number;
63
63
  /**
64
- * --- 设置当前过期时间 ---
64
+ * --- 设置当前过期时间(毫秒) ---
65
65
  */
66
66
  set timeout(num: number);
67
67
  /** --- 一些需要等待的事项的记录(异步任务、事务) --- */
@@ -231,14 +231,18 @@ export declare class Ctr {
231
231
  * --- 根据用户 ua 获取当前用户的设备类型 ---
232
232
  */
233
233
  protected _device(): 'android' | 'windows' | 'linux' | 'macintosh' | 'ipad' | 'unknown';
234
- /** --- auth 对象,user, pwd --- */
234
+ /** --- auth 对象 --- */
235
235
  private _authorization;
236
236
  /**
237
- * --- 通过 header 或 _auth 获取 Basic Auth 鉴权信息 ---
237
+ * --- 通过 header 或 _auth 获取鉴权信息,支持 Basic Auth Bearer Token ---
238
238
  */
239
239
  getAuthorization(): {
240
+ 'type': 'basic';
240
241
  'user': string;
241
242
  'pwd': string;
243
+ } | {
244
+ 'type': 'bearer';
245
+ 'token': string;
242
246
  } | false;
243
247
  /**
244
248
  * --- 获取 data 数据 ---
package/sys/ctr.js CHANGED
@@ -78,12 +78,12 @@ export class Ctr {
78
78
  }
79
79
  /** --- timeout 的 timer --- */
80
80
  _timer;
81
- /** --- 获取当前过期时间 --- */
81
+ /** --- 获取当前过期时间(毫秒) --- */
82
82
  get timeout() {
83
83
  return this._timer?.timeout ?? 30_000;
84
84
  }
85
85
  /**
86
- * --- 设置当前过期时间 ---
86
+ * --- 设置当前过期时间(毫秒) ---
87
87
  */
88
88
  set timeout(num) {
89
89
  if (!this._timer) {
@@ -642,10 +642,10 @@ export class Ctr {
642
642
  }
643
643
  return 'unknown';
644
644
  }
645
- /** --- auth 对象,user, pwd --- */
645
+ /** --- auth 对象 --- */
646
646
  _authorization = null;
647
647
  /**
648
- * --- 通过 header 或 _auth 获取 Basic Auth 鉴权信息 ---
648
+ * --- 通过 header 或 _auth 获取鉴权信息,支持 Basic Auth Bearer Token ---
649
649
  */
650
650
  getAuthorization() {
651
651
  if (this._authorization !== null) {
@@ -664,15 +664,28 @@ export class Ctr {
664
664
  if (typeof auth !== 'string') {
665
665
  return false;
666
666
  }
667
- let authArr = auth.split(' ');
668
- if (authArr[1] === undefined) {
667
+ const spaceIdx = auth.indexOf(' ');
668
+ if (spaceIdx === -1) {
669
669
  return false;
670
670
  }
671
- if (!(auth = lCrypto.base64Decode(authArr[1]))) {
671
+ const scheme = auth.slice(0, spaceIdx).toLowerCase();
672
+ const credential = auth.slice(spaceIdx + 1).trim();
673
+ if (!credential) {
672
674
  return false;
673
675
  }
674
- authArr = auth.split(':');
675
- this._authorization = { 'user': authArr[0], 'pwd': authArr[1] ?? '' };
676
+ if (scheme === 'bearer') {
677
+ this._authorization = { 'type': 'bearer', 'token': credential };
678
+ return this._authorization;
679
+ }
680
+ // --- Basic Auth: base64(user:pwd) ---
681
+ const decoded = lCrypto.base64Decode(credential);
682
+ if (!decoded) {
683
+ return false;
684
+ }
685
+ const colonIdx = decoded.indexOf(':');
686
+ const user = colonIdx === -1 ? decoded : decoded.slice(0, colonIdx);
687
+ const pwd = colonIdx === -1 ? '' : decoded.slice(colonIdx + 1);
688
+ this._authorization = { 'type': 'basic', 'user': user, 'pwd': pwd };
676
689
  return this._authorization;
677
690
  }
678
691
  /**
package/sys/route.js CHANGED
@@ -227,8 +227,18 @@ export async function run(data) {
227
227
  if (data.req.headers['cookie']) {
228
228
  const hcookies = data.req.headers['cookie'].split(';');
229
229
  for (const cookie of hcookies) {
230
- const co = cookie.split('=');
231
- cookies[co[0].trim()] = decodeURIComponent(co[1]);
230
+ const eqIndex = cookie.indexOf('=');
231
+ if (eqIndex === -1) {
232
+ continue;
233
+ }
234
+ const key = cookie.slice(0, eqIndex).trim();
235
+ const rawVal = cookie.slice(eqIndex + 1);
236
+ try {
237
+ cookies[key] = decodeURIComponent(rawVal);
238
+ }
239
+ catch {
240
+ cookies[key] = rawVal;
241
+ }
232
242
  }
233
243
  }
234
244
  // --- 处理 headers ---
@@ -818,11 +828,30 @@ export function getPost(req) {
818
828
  return;
819
829
  }
820
830
  // --- json 或普通 post ---
831
+ /** --- POST body 最大允许 50 MB,防止攻击者发送超大请求体耗尽内存 --- */
832
+ const maxPostSize = 50 * 1024 * 1024;
821
833
  let buffer = Buffer.from('');
834
+ let overflow = false;
822
835
  req.on('data', function (chunk) {
836
+ if (overflow) {
837
+ return;
838
+ }
839
+ if (buffer.length + chunk.length > maxPostSize) {
840
+ overflow = true;
841
+ buffer = Buffer.from('');
842
+ return;
843
+ }
823
844
  buffer = Buffer.concat([buffer, chunk], buffer.length + chunk.length);
824
845
  });
825
846
  req.on('end', function () {
847
+ if (overflow) {
848
+ resolve({
849
+ 'input': '',
850
+ 'raw': {},
851
+ 'post': {},
852
+ });
853
+ return;
854
+ }
826
855
  const s = buffer.toString();
827
856
  if (!s) {
828
857
  resolve({
@@ -90,6 +90,9 @@ export default class extends sCtr.Ctr {
90
90
  netFilterheaders(): string;
91
91
  netFetch(): Promise<string | boolean>;
92
92
  netFetch1(): any[];
93
+ netGetResponseJson(): Promise<string>;
94
+ getResponseJson1(): any[];
95
+ getResponseJson2(): any[];
93
96
  scan(): Promise<kebab.Json>;
94
97
  scan1(): Promise<kebab.Json>;
95
98
  scan2(): Promise<kebab.Json>;
@@ -185,6 +185,7 @@ export default class extends sCtr.Ctr {
185
185
  `<br><a href="${this._config.const.urlBase}test/net-mproxy">View "test/net-mproxy"</a>`,
186
186
  `<br><a href="${this._config.const.urlBase}test/net-filterheaders">View "test/net-filterheaders"</a>`,
187
187
  `<br><a href="${this._config.const.urlBase}test/net-fetch">View "test/net-fetch"</a>`,
188
+ `<br><a href="${this._config.const.urlBase}test/net-get-response-json">View "test/net-get-response-json"</a>`,
188
189
  '<br><br><b>Scan:</b>',
189
190
  `<br><br><a href="${this._config.const.urlBase}test/scan?s=db">View "test/scan?s=db"</a>`,
190
191
  `<br><a href="${this._config.const.urlBase}test/scan?s=kv">View "test/scan?s=kv"</a>`,
@@ -2306,6 +2307,29 @@ error: <pre>${JSON.stringify(res.error, null, 4)}</pre>`);
2306
2307
  'post': this._post,
2307
2308
  }];
2308
2309
  }
2310
+ async netGetResponseJson() {
2311
+ const echo = [];
2312
+ const json = await lNet.getResponseJson(this._internalUrl + 'test/get-response-json1');
2313
+ echo.push(`<pre>const json = await lNet.getResponseJson('${this._internalUrl}test/get-response-json1');</pre>
2314
+ result: <pre>${lText.htmlescape(JSON.stringify(json, null, 4))}</pre>`);
2315
+ const json2 = await lNet.getResponseJson(this._internalUrl + 'test/get-response-json2');
2316
+ echo.push(`<pre>const json2 = await lNet.getResponseJson('${this._internalUrl}test/get-response-json2');</pre>
2317
+ result: <pre>${lText.htmlescape(JSON.stringify(json2, null, 4))}</pre>`);
2318
+ return echo.join('') + '<br><br>' + this._getEnd();
2319
+ }
2320
+ getResponseJson1() {
2321
+ return [1, {
2322
+ 'data': 'This is test data from getResponseJson1',
2323
+ 'timestamp': lTime.stamp()
2324
+ }];
2325
+ }
2326
+ getResponseJson2() {
2327
+ return [1, {
2328
+ 'name': 'Kebab Framework',
2329
+ 'version': kebab.VER,
2330
+ 'features': ['GET request with JSON parsing', 'Automatic JSON parsing', 'Simple and clean API']
2331
+ }];
2332
+ }
2309
2333
  async scan() {
2310
2334
  const link = await this._scanLink();
2311
2335
  if (!link) {