mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 23:53:50 +08:00
feat: add unified IM access policies
This commit is contained in:
parent
075d2713c1
commit
840e5aa857
89 changed files with 5573 additions and 1676 deletions
17
plugin-src/host/channels/shared/access-policy-rpc.mjs
Normal file
17
plugin-src/host/channels/shared/access-policy-rpc.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { validateAccessPolicy } from '../../../../src/channels/shared/access-policy.mjs';
|
||||
|
||||
export const SET_ACCESS_POLICY_ENDPOINT = 'bot.access-policy.set';
|
||||
|
||||
export function validAccessPolicyPayload(payload) {
|
||||
try {
|
||||
if (!payload || typeof payload !== 'object' || Array.isArray(payload)
|
||||
|| Reflect.ownKeys(payload).length !== 2
|
||||
|| !Object.hasOwn(payload, 'botId') || !Object.hasOwn(payload, 'policy')
|
||||
|| typeof payload.botId !== 'string'
|
||||
|| !/^[A-Za-z0-9_-]{1,128}$/.test(payload.botId)) return false;
|
||||
validateAccessPolicy(payload.policy);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue