export function isScopeSufficient()

in src/smartScopeHelper.ts [112:142]


export function isScopeSufficient(
    scope: string,
    scopeRule: ScopeRule,
    reqOperation: TypeOperation | SystemOperation,
    isUserScopeAllowedForSystemExport: boolean,
    reqResourceType?: string,
    bulkDataAuth?: BulkDataAuth,
): boolean {
    try {
        const smartScope = convertScopeToSmartScope(scope);
        if (bulkDataAuth) {
            return isSmartScopeSufficientForBulkDataAccess(
                bulkDataAuth,
                smartScope,
                scopeRule,
                isUserScopeAllowedForSystemExport,
            );
        }
        const validOperations: (TypeOperation | SystemOperation)[] = getValidOperationsForScope(
            smartScope,
            scopeRule,
            reqOperation,
            reqResourceType,
        );
        return validOperations.includes(reqOperation);
    } catch (e) {
        // Caused by trying to convert non-SmartScope to SmartScope, for example converting non-SMART scope 'openid'
    }

    return false;
}