@zhin.js/core 1.4.2 → 1.4.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/lib/built/authorization.js +27 -3
- package/package.json +2 -2
|
@@ -2,10 +2,34 @@ import { mergeAITriggerConfig, resolveSenderRoles, } from './ai-trigger.js';
|
|
|
2
2
|
import { formatCompact, getLogger } from '@zhin.js/logger';
|
|
3
3
|
const logger = getLogger('Authorization');
|
|
4
4
|
function findEndpointEntryFromConfig(config, adapter, endpointId) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// 1) top-level endpoints[] (legacy / flat format)
|
|
6
|
+
const topLevel = config.endpoints;
|
|
7
|
+
if (Array.isArray(topLevel)) {
|
|
8
|
+
const found = topLevel.find((b) => b.context === adapter && String(b.name) === endpointId);
|
|
9
|
+
if (found)
|
|
10
|
+
return found;
|
|
11
|
+
}
|
|
12
|
+
// 2) plugins.<adapter> — adapter-level master/trusted + nested endpoints[]
|
|
13
|
+
const adapterConfig = config.plugins?.[adapter];
|
|
14
|
+
if (!adapterConfig)
|
|
7
15
|
return undefined;
|
|
8
|
-
|
|
16
|
+
const nested = adapterConfig.endpoints;
|
|
17
|
+
const entry = Array.isArray(nested)
|
|
18
|
+
? nested.find((b) => String(b.name) === endpointId)
|
|
19
|
+
: undefined;
|
|
20
|
+
// Merge adapter-level master/trusted onto the matched endpoint entry
|
|
21
|
+
// so that resolveSenderRoles sees them in one place
|
|
22
|
+
const merged = {
|
|
23
|
+
context: adapter,
|
|
24
|
+
...(entry ?? { name: endpointId }),
|
|
25
|
+
};
|
|
26
|
+
if (adapterConfig.master != null && merged.master == null) {
|
|
27
|
+
merged.master = adapterConfig.master;
|
|
28
|
+
}
|
|
29
|
+
if (adapterConfig.trusted != null && merged.trusted == null) {
|
|
30
|
+
merged.trusted = adapterConfig.trusted;
|
|
31
|
+
}
|
|
32
|
+
return merged;
|
|
9
33
|
}
|
|
10
34
|
function readTriggerConfig(plugin) {
|
|
11
35
|
const root = plugin.root ?? plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Zhin机器人核心框架",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@types/qrcode": "^1.5.5",
|
|
94
94
|
"ajv": "8.18.0",
|
|
95
95
|
"typescript": "^6.0.3",
|
|
96
|
-
"@zhin.js/ai": "1.4.
|
|
96
|
+
"@zhin.js/ai": "1.4.7"
|
|
97
97
|
},
|
|
98
98
|
"repository": {
|
|
99
99
|
"type": "git",
|