import type { Filter } from "../modules/DirectoryAbstractService/Filter.ta.mjs"; import type { FilterItem } from "../modules/DirectoryAbstractService/FilterItem.ta.mjs"; import type { AttributeValueAssertion } from "../modules/InformationFramework/AttributeValueAssertion.ta.mjs"; import type { AttributeType } from "../modules/InformationFramework/AttributeType.ta.mjs"; import type { AttributeValue } from "../modules/InformationFramework/AttributeValue.ta.mjs"; import type { AttributeTypeAssertion } from "../modules/InformationFramework/AttributeTypeAssertion.ta.mjs"; import type { MatchingRuleAssertion } from "../modules/DirectoryAbstractService/MatchingRuleAssertion.ta.mjs"; import { Attribute } from "../modules/InformationFramework/Attribute.ta.mjs"; import type { EntryInformation } from "../modules/DirectoryAbstractService/EntryInformation.ta.mjs"; import type { FilterItem_substrings } from "../modules/DirectoryAbstractService/FilterItem-substrings.ta.mjs"; import type { ASN1Element, OBJECT_IDENTIFIER } from "@wildboar/asn1"; import type EqualityMatcher from "../types/EqualityMatcher.mjs"; import type OrderingMatcher from "../types/OrderingMatcher.mjs"; import type SubstringsMatcher from "../types/SubstringsMatcher.mjs"; import type ApproxMatcher from "../types/ApproxMatcher.mjs"; import type ContextMatcher from "../types/ContextMatcher.mjs"; import type { Context } from "../modules/InformationFramework/Context.ta.mjs"; import { RequestAttribute } from "../modules/ServiceAdministration/RequestAttribute.ta.mjs"; interface MatchedValue { type: AttributeType; value: ASN1Element; contexts?: Context[]; } interface MatchedEntryInfo extends MatchedValue { entryIndex: number; } export interface EvaluateFilterReturn { matched: boolean | undefined; matchedValues?: MatchedEntryInfo[]; contributingEntries: Set; } export interface EvaluateFilterSettings { /** * A function that accepts an attribute type and returns a function * that can perform an equality comparison on an asserted value against an * attribute value. * * @readonly * @property */ readonly getEqualityMatcher: (attributeType: OBJECT_IDENTIFIER) => EqualityMatcher | undefined; /** * A function that accepts an attribute type and returns a function * that can perform a ordering matching on an asserted value against an * attribute value. * * @readonly * @property */ readonly getOrderingMatcher: (attributeType: OBJECT_IDENTIFIER) => OrderingMatcher | undefined; /** * A function that accepts an attribute type and returns a function * that can perform a substrings matching on an asserted value against an * attribute value. * * @readonly * @property */ readonly getSubstringsMatcher: (attributeType: OBJECT_IDENTIFIER) => SubstringsMatcher | undefined; /** * A function that accepts an attribute type and returns a function * that can perform an approximate matching on an asserted value against an * attribute value. */ readonly getApproximateMatcher: (attributeType: OBJECT_IDENTIFIER) => ApproxMatcher | undefined; /** * A function that takes a context type object identifier and returns a * function that can perform a context matching with an asserted context * value and the actual context value. * * @readonly * @property */ readonly getContextMatcher: (contextType: OBJECT_IDENTIFIER) => ContextMatcher | undefined; /** * A function that takes a context type object identifier and returns a * `boolean` that corresponds to the `&absentMatch` field of the context * type definition. * * @readonly * @property */ readonly determineAbsentMatch: (contextType: OBJECT_IDENTIFIER) => boolean; /** * A function that takes a matching rule object identifier and an attribute * type object identifier and returns `true` if the attribute type is * compatible with the identified matching rule and `false` if it is not. * * @readonly * @property */ readonly isMatchingRuleCompatibleWithAttributeType: (mr: OBJECT_IDENTIFIER, at: OBJECT_IDENTIFIER) => boolean; /** * A function that accepts two attribute types, one for an attribute * and one for a potential parent attribute type. This function returns a * `boolean` indicating whether the attribute type is a subtype of `parent`. * * WARNING: This MUST also return `true` if the types are equal. * * @readonly * @property */ readonly isAttributeSubtype: (attributeType: OBJECT_IDENTIFIER, parentType: OBJECT_IDENTIFIER) => boolean; /** * A function that accepts an attribute type and returns an array of object * identifiers of all attribute types that are friends. If the * `dontMatchFriends` option is used, this should always return an empty * array. * * @readonly * @property */ readonly getFriends?: (attributeType: OBJECT_IDENTIFIER) => OBJECT_IDENTIFIER[]; /** * A function that accepts an attribute description and optionally an * attribute value. If only an attribute type is supplied, this function * returns a `boolean` indicating whether the user is permitted to filter * on that attribute type. If the attribute value is supplied as well, this * function returns a `boolean` indicating whether the user is permitted to * filter on that attribute type and value. * * @readonly * @property */ readonly permittedToMatch: (attributeType: OBJECT_IDENTIFIER, value?: AttributeValue) => boolean; /** * Referenced in ITU Recommendation X.511, Section 7.8.2.g, this option * determines whether the filter should return UNDEFINED or throw an error * if none of the matching rules specified in a `FilterItem.extensibleMatch` * can be understood or if none are compatible with the specified attribute * type. * * @readonly * @property */ readonly performExactly?: boolean; /** * Referenced in ITU Recommendation X.511, Section 11.2.2, this option * determines whether the filter should only return values that contributed * to a match for attribute types that contributed to the match. * (Unrelated attribute types or attribute types that did not match are not * affected by this option.) * * Within this implementation, this option matters for performance: it * determines whether this function bails out as soon as it finds a match * for a given filter item. If this option is set, every attribute type of * interest is evaluated so that the complete list of matched values can be * returned. * * @readonly * @property */ readonly matchedValuesOnly?: boolean; /** * Referenced in ITU Recommendation X.511, Section 11.2.2, this option * determines whether the filter should include values from the * distinguished name. * * @readonly * @property */ readonly dnAttribute?: boolean; /** * Referenced in ITU Recommendation X.501 (2019), Section 16.10.2, this is * an index of request attribute profiles by the string-form object * identifier of the attribute type. This is primarily used for its * `defaultValues` property, which fills in values for attribute types if * not present in the entry. * * @readonly * @property */ readonly requestAttributes?: Map; } export declare function getAttributesFromEntry(entry: EntryInformation, dnAttributes?: boolean): Attribute[]; export declare function evaluateEquality(ava: AttributeValueAssertion, entry: EntryInformation, options: EvaluateFilterSettings): MatchedValue[] | boolean | undefined; export declare function evaluateApprox(ava: AttributeValueAssertion, entry: EntryInformation, options: EvaluateFilterSettings): MatchedValue[] | boolean | undefined; export declare function evaluateOrdering(gte: boolean, ava: AttributeValueAssertion, entry: EntryInformation, options: EvaluateFilterSettings): MatchedValue[] | boolean | undefined; export declare function evaluateSubstring(sub: FilterItem_substrings, entry: EntryInformation, options: EvaluateFilterSettings): MatchedValue[] | boolean | undefined; export declare function evaluateAttributePresence(attributeType: AttributeType, entry: EntryInformation, options: EvaluateFilterSettings): boolean; export declare function evaluateMatchingRuleAssertion(mra: MatchingRuleAssertion, entry: EntryInformation, options: EvaluateFilterSettings): MatchedValue[] | boolean | undefined; export declare function evaluateAttributeTypeAssertion(ata: AttributeTypeAssertion, entry: EntryInformation, options: EvaluateFilterSettings): boolean | undefined; export declare function evaluateFilterItem(filterItem: FilterItem, entry: EntryInformation, options: EvaluateFilterSettings): MatchedValue[] | boolean | undefined; /** * @summary Implementation of X.500 filtering * @description * * This function filters a group of directory entries that are supposed to * represent a subset of the members of a compound entry, or the non-compound * entry alone. If multiple entries are supplied, all of their attributes are * treated as though they were all merged into a single "pseudo-entry" before * matching. In other words, this function will treat all of the entries as a * single entry (but still keeps them separate for the sake of tracking which * of them supplied matching values and hence "contributed" to the match, per * ITU Recommendation X.511 (2016), Section 7.13). * * This function returns `true` if the sum of all attributes of the supplied * entries match the filter, `false` if they do not, or `undefined` if it could * not be determined. It may also return an array of `MatchedValue`, each of * which is an attribute type, value, contexts (if present), and the index of * the entry from the array of supplied entries that supplied that matching * value. If this array is empty, it means that there was no match; an empty * array should be treated like a `false` result. * * Features: * * - Attribute subtyping * - `nullMatch` * - `performExactly` * - `matchedValuesOnly` * - `dnAttributes` * - Family contribution tracking * * Though this implementation does not explicitly include support for the * `dontMatchFriends` and `noSubtypesMatch` service control options, these can * be trivially implemented through the use of the parameters. * `dontMatchFriends` can be implemented by simply not including friend * attributes in the entry (these can be added after filtering to complete the * entry, if needed). `noSubtypesMatch` can be implemented by supplying an * `options.isAttributeSubtype()` function that only returns `true` if both * object identifiers are equal. * * NOTE: ITU Recommendation X.511, Section 7.8.2.{b,c,d} does not specify to consider contexts. * * @param {Filter} filter The filter against which the entry is to be evaluated. * @param {EntryInformation[]} family The entries of the family that is to be evaluated by the filter. * @param {Object} options An options object containing. Despite the name, this * parameter, and most of its properties, are required. * @param {Set} contributingEntries The contributing entries. Do not supply this * argument. Just leave this `undefined`. * @returns `true` if the entry matches the filter, `false` if it does not, or * `undefined` if it cannot be determined whether the entry matches or not. * An array of matched values may be returned, containing the values that * matched and the indices of the entries from which the matches came, if this * array is empty, it means there was no match. * @function */ export declare function evaluateFilter(filter: Filter, family: EntryInformation[], options: EvaluateFilterSettings, contributingEntries?: Set): EvaluateFilterReturn; export default evaluateFilter; //# sourceMappingURL=evaluateFilter.d.mts.map