@maiyunnet/kebab 9.29.1 → 9.29.3
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/abox/session-login.js +4 -1
- package/doc/kebab-rag.md +46 -22
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/session/login.d.ts +4 -2
- package/lib/session/login.js +1 -1
- package/lib/ws.js +7 -1
- package/package.json +1 -1
package/abox/session-login.js
CHANGED
|
@@ -51,6 +51,7 @@ if op == 'create' then
|
|
|
51
51
|
end
|
|
52
52
|
local r = cjson.decode(data)
|
|
53
53
|
r.timeAdd = tonumber(redis.call('TIME')[1])
|
|
54
|
+
r.timeLast = r.timeAdd
|
|
54
55
|
r.index = idx
|
|
55
56
|
redis.call('SET', record(hash), cjson.encode(r))
|
|
56
57
|
expiry(hash, r, ttl)
|
|
@@ -66,6 +67,8 @@ if op == 'get' then
|
|
|
66
67
|
end
|
|
67
68
|
if me.uid ~= ARGV[3] then return nil end
|
|
68
69
|
if op == 'touch' then
|
|
70
|
+
me.timeLast = tonumber(redis.call('TIME')[1])
|
|
71
|
+
redis.call('SET', record(hash), cjson.encode(me))
|
|
69
72
|
expiry(hash, me, tonumber(ARGV[4]))
|
|
70
73
|
return 1
|
|
71
74
|
end
|
|
@@ -114,7 +117,7 @@ function uidValid(uid) {
|
|
|
114
117
|
}
|
|
115
118
|
function record(value) {
|
|
116
119
|
const row = value;
|
|
117
|
-
return { ...row, data: JSON.parse(row.data) };
|
|
120
|
+
return { ...row, timeAdd: row.timeAdd ?? 0, timeLast: row.timeLast ?? 0, data: JSON.parse(row.data) };
|
|
118
121
|
}
|
|
119
122
|
function parse(value) {
|
|
120
123
|
if (value === null || value === false)
|
package/doc/kebab-rag.md
CHANGED
|
@@ -1913,7 +1913,7 @@ index/variables/VER.md
|
|
|
1913
1913
|
|
|
1914
1914
|
# Variable: VER
|
|
1915
1915
|
|
|
1916
|
-
> `const` **VER**: `"9.29.
|
|
1916
|
+
> `const` **VER**: `"9.29.3"` = `'9.29.3'`
|
|
1917
1917
|
|
|
1918
1918
|
Defined in: [index.ts:8](https://github.com/maiyunnet/kebab/blob/master/index.ts#L8)
|
|
1919
1919
|
|
|
@@ -124434,7 +124434,7 @@ lib/session/login/classes/Login.md
|
|
|
124434
124434
|
|
|
124435
124435
|
# Class: Login
|
|
124436
124436
|
|
|
124437
|
-
Defined in: [lib/session/login.ts:
|
|
124437
|
+
Defined in: [lib/session/login.ts:65](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L65)
|
|
124438
124438
|
|
|
124439
124439
|
管理一个账号在多个客户端的登录授权
|
|
124440
124440
|
基于单节点 Redis;不会修改 Session 数据或 Cookie。业务每次请求须验证账号、权限和授权版本。
|
|
@@ -124446,7 +124446,7 @@ Defined in: [lib/session/login.ts:63](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124446
124446
|
|
|
124447
124447
|
> **new Login**(`kv`, `ctrToken`, `options?`): `Login`
|
|
124448
124448
|
|
|
124449
|
-
Defined in: [lib/session/login.ts:
|
|
124449
|
+
Defined in: [lib/session/login.ts:79](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L79)
|
|
124450
124450
|
|
|
124451
124451
|
创建可复用的登录管理器
|
|
124452
124452
|
|
|
@@ -124480,7 +124480,7 @@ Defined in: [lib/session/login.ts:77](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124480
124480
|
|
|
124481
124481
|
> **create**(`identity`, `options?`): `Promise`\<`false` \| [`ILoginRecord`](../interfaces/ILoginRecord.md)\>
|
|
124482
124482
|
|
|
124483
|
-
Defined in: [lib/session/login.ts:
|
|
124483
|
+
Defined in: [lib/session/login.ts:99](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L99)
|
|
124484
124484
|
|
|
124485
124485
|
创建登录授权并替换同一凭据原来绑定的身份
|
|
124486
124486
|
每次创建生成新 UID,包括同一账号在同一 Session 重复登录;旧 UID 随即失效。
|
|
@@ -124512,7 +124512,7 @@ single 开启时,同账号同作用域以最后执行成功的创建为准;
|
|
|
124512
124512
|
|
|
124513
124513
|
> **get**(): `Promise`\<`false` \| [`ILoginRecord`](../interfaces/ILoginRecord.md) \| `null`\>
|
|
124514
124514
|
|
|
124515
|
-
Defined in: [lib/session/login.ts:
|
|
124515
|
+
Defined in: [lib/session/login.ts:107](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L107)
|
|
124516
124516
|
|
|
124517
124517
|
读取凭据当前绑定的登录授权,不延长有效期
|
|
124518
124518
|
|
|
@@ -124528,7 +124528,7 @@ Defined in: [lib/session/login.ts:105](https://github.com/maiyunnet/kebab/blob/m
|
|
|
124528
124528
|
|
|
124529
124529
|
> **list**(`uid`): `Promise`\<`false` \| [`IListLogin`](../interfaces/IListLogin.md)[] \| `null`\>
|
|
124530
124530
|
|
|
124531
|
-
Defined in: [lib/session/login.ts:
|
|
124531
|
+
Defined in: [lib/session/login.ts:135](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L135)
|
|
124532
124532
|
|
|
124533
124533
|
列出当前账号、作用域及授权版本一致的有效登录
|
|
124534
124534
|
返回登录附加信息,业务响应前须筛选可展示字段;适合交互式账号的登录列表,不用于全站会话统计。
|
|
@@ -124553,7 +124553,7 @@ get 返回的当前登录 UID
|
|
|
124553
124553
|
|
|
124554
124554
|
> **remove**(`uid`): `Promise`\<`boolean` \| `null`\>
|
|
124555
124555
|
|
|
124556
|
-
Defined in: [lib/session/login.ts:
|
|
124556
|
+
Defined in: [lib/session/login.ts:125](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L125)
|
|
124557
124557
|
|
|
124558
124558
|
退出凭据仍绑定的指定登录,保留 Session 本身
|
|
124559
124559
|
|
|
@@ -124577,7 +124577,7 @@ true 已退出,null 已失效或被替换,false 输入无效或存储失败
|
|
|
124577
124577
|
|
|
124578
124578
|
> **revoke**(`uid`, `target?`): `Promise`\<`boolean` \| `null`\>
|
|
124579
124579
|
|
|
124580
|
-
Defined in: [lib/session/login.ts:
|
|
124580
|
+
Defined in: [lib/session/login.ts:146](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L146)
|
|
124581
124581
|
|
|
124582
124582
|
清退当前账号和作用域内的指定登录或其他全部登录
|
|
124583
124583
|
清退覆盖所有授权版本;可指定当前登录,不能撤销其他账号或作用域的登录。
|
|
@@ -124608,9 +124608,9 @@ true 已清退,null 当前或目标登录失效,false 输入无效或存储
|
|
|
124608
124608
|
|
|
124609
124609
|
> **touch**(`uid`): `Promise`\<`boolean` \| `null`\>
|
|
124610
124610
|
|
|
124611
|
-
Defined in: [lib/session/login.ts:
|
|
124611
|
+
Defined in: [lib/session/login.ts:116](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L116)
|
|
124612
124612
|
|
|
124613
|
-
|
|
124613
|
+
更新仍与本次请求读取的登录 UID 匹配的授权访问时间,并延长有效期
|
|
124614
124614
|
|
|
124615
124615
|
#### Parameters
|
|
124616
124616
|
|
|
@@ -124664,7 +124664,7 @@ lib/session/login/interfaces/IListLogin.md
|
|
|
124664
124664
|
|
|
124665
124665
|
# Interface: IListLogin
|
|
124666
124666
|
|
|
124667
|
-
Defined in: [lib/session/login.ts:
|
|
124667
|
+
Defined in: [lib/session/login.ts:39](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L39)
|
|
124668
124668
|
|
|
124669
124669
|
登录列表中的记录
|
|
124670
124670
|
|
|
@@ -124678,7 +124678,7 @@ Defined in: [lib/session/login.ts:37](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124678
124678
|
|
|
124679
124679
|
> **current**: `boolean`
|
|
124680
124680
|
|
|
124681
|
-
Defined in: [lib/session/login.ts:
|
|
124681
|
+
Defined in: [lib/session/login.ts:41](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L41)
|
|
124682
124682
|
|
|
124683
124683
|
是否为当前登录
|
|
124684
124684
|
|
|
@@ -124688,7 +124688,7 @@ Defined in: [lib/session/login.ts:39](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124688
124688
|
|
|
124689
124689
|
> **data**: `Record`\<`string`, [`LoginValue`](../type-aliases/LoginValue.md)\>
|
|
124690
124690
|
|
|
124691
|
-
Defined in: [lib/session/login.ts:
|
|
124691
|
+
Defined in: [lib/session/login.ts:35](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L35)
|
|
124692
124692
|
|
|
124693
124693
|
登录时保存的附加信息
|
|
124694
124694
|
|
|
@@ -124732,7 +124732,7 @@ Defined in: [lib/session/login.ts:25](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124732
124732
|
|
|
124733
124733
|
Defined in: [lib/session/login.ts:31](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L31)
|
|
124734
124734
|
|
|
124735
|
-
登录时间,Redis 服务端 UTC Unix
|
|
124735
|
+
登录时间,Redis 服务端 UTC Unix 秒,0 表示未记录
|
|
124736
124736
|
|
|
124737
124737
|
#### Inherited from
|
|
124738
124738
|
|
|
@@ -124740,6 +124740,20 @@ Defined in: [lib/session/login.ts:31](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124740
124740
|
|
|
124741
124741
|
***
|
|
124742
124742
|
|
|
124743
|
+
### timeLast
|
|
124744
|
+
|
|
124745
|
+
> **timeLast**: `number`
|
|
124746
|
+
|
|
124747
|
+
Defined in: [lib/session/login.ts:33](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L33)
|
|
124748
|
+
|
|
124749
|
+
最后访问时间,创建及成功 touch 时更新;Redis 服务端 UTC Unix 秒,0 表示未记录
|
|
124750
|
+
|
|
124751
|
+
#### Inherited from
|
|
124752
|
+
|
|
124753
|
+
[`ILoginRecord`](ILoginRecord.md).[`timeLast`](ILoginRecord.md#timelast)
|
|
124754
|
+
|
|
124755
|
+
***
|
|
124756
|
+
|
|
124743
124757
|
### uid
|
|
124744
124758
|
|
|
124745
124759
|
> **uid**: `string`
|
|
@@ -124777,7 +124791,7 @@ lib/session/login/interfaces/ILoginCreateOptions.md
|
|
|
124777
124791
|
|
|
124778
124792
|
# Interface: ILoginCreateOptions
|
|
124779
124793
|
|
|
124780
|
-
Defined in: [lib/session/login.ts:
|
|
124794
|
+
Defined in: [lib/session/login.ts:45](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L45)
|
|
124781
124795
|
|
|
124782
124796
|
创建登录时的选项
|
|
124783
124797
|
|
|
@@ -124787,7 +124801,7 @@ Defined in: [lib/session/login.ts:43](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124787
124801
|
|
|
124788
124802
|
> `optional` **single?**: `boolean`
|
|
124789
124803
|
|
|
124790
|
-
Defined in: [lib/session/login.ts:
|
|
124804
|
+
Defined in: [lib/session/login.ts:47](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L47)
|
|
124791
124805
|
|
|
124792
124806
|
清退同账号、同作用域的其他登录(包含旧版本),默认 false;与创建原子执行
|
|
124793
124807
|
|
|
@@ -124857,7 +124871,7 @@ lib/session/login/interfaces/ILoginOptions.md
|
|
|
124857
124871
|
|
|
124858
124872
|
# Interface: ILoginOptions
|
|
124859
124873
|
|
|
124860
|
-
Defined in: [lib/session/login.ts:
|
|
124874
|
+
Defined in: [lib/session/login.ts:51](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L51)
|
|
124861
124875
|
|
|
124862
124876
|
Redis 登录管理选项
|
|
124863
124877
|
|
|
@@ -124867,7 +124881,7 @@ Redis 登录管理选项
|
|
|
124867
124881
|
|
|
124868
124882
|
> `optional` **name?**: `string`
|
|
124869
124883
|
|
|
124870
|
-
Defined in: [lib/session/login.ts:
|
|
124884
|
+
Defined in: [lib/session/login.ts:53](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L53)
|
|
124871
124885
|
|
|
124872
124886
|
Session 名称;传 token 时必填,传控制器时使用已初始化 Session 的实际名称
|
|
124873
124887
|
|
|
@@ -124877,7 +124891,7 @@ Session 名称;传 token 时必填,传控制器时使用已初始化 Session
|
|
|
124877
124891
|
|
|
124878
124892
|
> `optional` **pre?**: `string`
|
|
124879
124893
|
|
|
124880
|
-
Defined in: [lib/session/login.ts:
|
|
124894
|
+
Defined in: [lib/session/login.ts:55](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L55)
|
|
124881
124895
|
|
|
124882
124896
|
Session 名称之后的键名前缀,默认 login:;可进一步隔离授权用途
|
|
124883
124897
|
|
|
@@ -124887,7 +124901,7 @@ Session 名称之后的键名前缀,默认 login:;可进一步隔离授权
|
|
|
124887
124901
|
|
|
124888
124902
|
> `optional` **ttl?**: `number`
|
|
124889
124903
|
|
|
124890
|
-
Defined in: [lib/session/login.ts:
|
|
124904
|
+
Defined in: [lib/session/login.ts:57](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L57)
|
|
124891
124905
|
|
|
124892
124906
|
有效期秒数,默认 172800;整数 0~2147483647,0 表示永久;与业务 Session 有效期一致
|
|
124893
124907
|
|
|
@@ -124916,7 +124930,7 @@ Defined in: [lib/session/login.ts:21](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124916
124930
|
|
|
124917
124931
|
> **data**: `Record`\<`string`, [`LoginValue`](../type-aliases/LoginValue.md)\>
|
|
124918
124932
|
|
|
124919
|
-
Defined in: [lib/session/login.ts:
|
|
124933
|
+
Defined in: [lib/session/login.ts:35](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L35)
|
|
124920
124934
|
|
|
124921
124935
|
登录时保存的附加信息
|
|
124922
124936
|
|
|
@@ -124948,7 +124962,17 @@ Defined in: [lib/session/login.ts:25](https://github.com/maiyunnet/kebab/blob/ma
|
|
|
124948
124962
|
|
|
124949
124963
|
Defined in: [lib/session/login.ts:31](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L31)
|
|
124950
124964
|
|
|
124951
|
-
登录时间,Redis 服务端 UTC Unix
|
|
124965
|
+
登录时间,Redis 服务端 UTC Unix 秒,0 表示未记录
|
|
124966
|
+
|
|
124967
|
+
***
|
|
124968
|
+
|
|
124969
|
+
### timeLast
|
|
124970
|
+
|
|
124971
|
+
> **timeLast**: `number`
|
|
124972
|
+
|
|
124973
|
+
Defined in: [lib/session/login.ts:33](https://github.com/maiyunnet/kebab/blob/master/lib/session/login.ts#L33)
|
|
124974
|
+
|
|
124975
|
+
最后访问时间,创建及成功 touch 时更新;Redis 服务端 UTC Unix 秒,0 表示未记录
|
|
124952
124976
|
|
|
124953
124977
|
***
|
|
124954
124978
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
5
5
|
*/
|
|
6
6
|
/** --- 当前系统版本号 --- */
|
|
7
|
-
export const VER = '9.29.
|
|
7
|
+
export const VER = '9.29.3';
|
|
8
8
|
// --- 服务端用的路径 ---
|
|
9
9
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
10
10
|
/** --- /xxx/xxx --- */
|
package/lib/session/login.d.ts
CHANGED
|
@@ -25,8 +25,10 @@ export interface ILoginRecord {
|
|
|
25
25
|
'scope': string;
|
|
26
26
|
/** --- 业务授权版本,框架不查询业务数据验证此值 --- */
|
|
27
27
|
'version': string;
|
|
28
|
-
/** --- 登录时间,Redis 服务端 UTC Unix
|
|
28
|
+
/** --- 登录时间,Redis 服务端 UTC Unix 秒,0 表示未记录 --- */
|
|
29
29
|
'timeAdd': number;
|
|
30
|
+
/** --- 最后访问时间,创建及成功 touch 时更新;Redis 服务端 UTC Unix 秒,0 表示未记录 --- */
|
|
31
|
+
'timeLast': number;
|
|
30
32
|
/** --- 登录时保存的附加信息 --- */
|
|
31
33
|
'data': Record<string, LoginValue>;
|
|
32
34
|
}
|
|
@@ -81,7 +83,7 @@ export declare class Login {
|
|
|
81
83
|
*/
|
|
82
84
|
get(): Promise<ILoginRecord | null | false>;
|
|
83
85
|
/**
|
|
84
|
-
* ---
|
|
86
|
+
* --- 更新仍与本次请求读取的登录 UID 匹配的授权访问时间,并延长有效期 ---
|
|
85
87
|
* @param uid get 返回的登录 UID
|
|
86
88
|
* @returns true 成功,null 已失效或被替换,false 输入无效或存储失败
|
|
87
89
|
*/
|
package/lib/session/login.js
CHANGED
package/lib/ws.js
CHANGED
|
@@ -844,6 +844,11 @@ export async function rsocket(ctr, host, port) {
|
|
|
844
844
|
const ws = ctr.getPrototype('_socket');
|
|
845
845
|
/** --- 对端真实 tcp socket --- */
|
|
846
846
|
const socket = new net.Socket();
|
|
847
|
+
ws.on('error', (error) => {
|
|
848
|
+
lCore.log(ctr, `[WS][RSOCKET][SOURCE ERROR] ${host}:${port}: ${lText.stringifyError(error)}`, '-error');
|
|
849
|
+
}).on('timeout', () => {
|
|
850
|
+
lCore.log(ctr, `[WS][RSOCKET][SOURCE TIMEOUT] ${host}:${port}`, '-error');
|
|
851
|
+
});
|
|
847
852
|
socket.connect(port, host, () => {
|
|
848
853
|
socket.setKeepAlive(true);
|
|
849
854
|
// --- 连接成功 ---
|
|
@@ -882,7 +887,8 @@ export async function rsocket(ctr, host, port) {
|
|
|
882
887
|
ws.end();
|
|
883
888
|
resolve(true);
|
|
884
889
|
});
|
|
885
|
-
}).on('error', () => {
|
|
890
|
+
}).on('error', (error) => {
|
|
891
|
+
lCore.log(ctr, `[WS][RSOCKET][TARGET ERROR] ${host}:${port}: ${lText.stringifyError(error)}`, '-error');
|
|
886
892
|
resolve(false);
|
|
887
893
|
});
|
|
888
894
|
});
|