@paymanai/payman-ask-sdk 4.0.2 → 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.js
CHANGED
|
@@ -157,11 +157,17 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
157
157
|
requiredAnyPermissions: ["vault:author", "vault:publish"]
|
|
158
158
|
}
|
|
159
159
|
];
|
|
160
|
+
function hasCommandPermission(granted, requiredPermission) {
|
|
161
|
+
if (granted.has("*") || granted.has(requiredPermission)) return true;
|
|
162
|
+
if (!requiredPermission.includes(".")) return false;
|
|
163
|
+
const wildcard = requiredPermission.substring(0, requiredPermission.lastIndexOf(".")) + ".*";
|
|
164
|
+
return granted.has(wildcard);
|
|
165
|
+
}
|
|
160
166
|
function filterSlashCommands(commands, permissions) {
|
|
161
167
|
const granted = new Set(permissions ?? []);
|
|
162
168
|
return commands.filter((command) => {
|
|
163
169
|
const required = command.requiredAnyPermissions ?? [];
|
|
164
|
-
return required.length === 0 || required.some((permission) => granted
|
|
170
|
+
return required.length === 0 || required.some((permission) => hasCommandPermission(granted, permission));
|
|
165
171
|
});
|
|
166
172
|
}
|
|
167
173
|
function parseSlashCommand(content) {
|