@paymanai/payman-ask-sdk 4.0.1 → 4.0.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/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -131,11 +131,17 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
131
131
|
requiredAnyPermissions: ["vault:author", "vault:publish"]
|
|
132
132
|
}
|
|
133
133
|
];
|
|
134
|
+
function hasCommandPermission(granted, requiredPermission) {
|
|
135
|
+
if (granted.has("*") || granted.has(requiredPermission)) return true;
|
|
136
|
+
if (!requiredPermission.includes(".")) return false;
|
|
137
|
+
const wildcard = requiredPermission.substring(0, requiredPermission.lastIndexOf(".")) + ".*";
|
|
138
|
+
return granted.has(wildcard);
|
|
139
|
+
}
|
|
134
140
|
function filterSlashCommands(commands, permissions) {
|
|
135
141
|
const granted = new Set(permissions ?? []);
|
|
136
142
|
return commands.filter((command) => {
|
|
137
143
|
const required = command.requiredAnyPermissions ?? [];
|
|
138
|
-
return required.length === 0 || required.some((permission) => granted
|
|
144
|
+
return required.length === 0 || required.some((permission) => hasCommandPermission(granted, permission));
|
|
139
145
|
});
|
|
140
146
|
}
|
|
141
147
|
function parseSlashCommand(content) {
|