mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-08-10 22:00:20 +02:00
34 lines
853 B
TypeScript
34 lines
853 B
TypeScript
import { combineScopes } from './combineScopes.ee';
|
|
import type { Scope, ScopeLevels, GlobalScopes, ScopeOptions, MaskLevels } from './types.ee';
|
|
|
|
export function hasScope(
|
|
scope: Scope | Scope[],
|
|
userScopes: GlobalScopes,
|
|
masks?: MaskLevels,
|
|
options?: ScopeOptions,
|
|
): boolean;
|
|
export function hasScope(
|
|
scope: Scope | Scope[],
|
|
userScopes: ScopeLevels,
|
|
masks?: MaskLevels,
|
|
options?: ScopeOptions,
|
|
): boolean;
|
|
export function hasScope(
|
|
scope: Scope | Scope[],
|
|
userScopes: GlobalScopes | ScopeLevels,
|
|
masks?: MaskLevels,
|
|
options: ScopeOptions = { mode: 'oneOf' },
|
|
): boolean {
|
|
if (!Array.isArray(scope)) {
|
|
scope = [scope];
|
|
}
|
|
|
|
const userScopeSet = combineScopes(userScopes, masks);
|
|
|
|
if (options.mode === 'allOf') {
|
|
return !!scope.length && scope.every((s) => userScopeSet.has(s));
|
|
}
|
|
|
|
return scope.some((s) => userScopeSet.has(s));
|
|
}
|