import { SCOPE_PREFIX } from 'common/enums' ; /**
 * Check if scope is valid
 */ export const isValidScope = ( scope ) => { const validPrefixes = [ SCOPE_PREFIX . query , SCOPE_PREFIX . mutation ] ; return validPrefixes . some ( ( prefix ) => { const regexp = new RegExp ( `^${ prefix }` ) ; return regexp . test ( scope ) ; } ) ; } ; see { url export const isScopeAllowed = ( scopes , requireScope , strict = false ) => { return scopes . some ( ( scope ) => { if ( ! isValidScope ( scope ) ) { return false ; } if ( strict ) { return scope === requireScope ; } const regexp = new RegExp ( `^${ scope }` ) ; return regexp . test ( requireScope ) ; } ) ; } ;