UNPKG

@imigueldiaz/mongodb-labeler

Version:

A MongoDB-based labeling system for content moderation with cryptographic signing

58 lines (57 loc) 2.46 kB
/** * Validates a DID according to AT Protocol specifications * @param did - The DID to validate * @throws {AtProtocolValidationError} If the DID is invalid */ export declare function validateDid(did: string): void; /** * Validates a URI according to AT Protocol specifications * @param uri - The URI to validate * @throws {AtProtocolValidationError} If the URI is invalid */ export declare function validateUri(uri: string): void; /** * @deprecated Use validateUri instead which supports both did: and at:// URIs */ export declare function validateAtUri(uri: string): void; /** * Validates if a string is a valid CID (Content Identifier) * This validation checks the format for CIDv0 and CIDv1 (base32 and base58) * @param cidStr The CID string to validate * @throws {AtProtocolValidationError} If the CID is invalid */ export declare function validateCid(cidStr: string): void; /** * Validates a label value according to AT Protocol specifications. * The value must: * - Be a string with max 128 bytes * - Not contain whitespace * - Use only ASCII characters * - Not contain special punctuation except for '!' prefix * @param val - The label value to validate * @throws {AtProtocolValidationError} If the value is invalid */ export declare function validateVal(val: string): void; /** * Validates a timestamp string according to AT Protocol specifications. * The timestamp must be in ISO 8601 format and represent a valid date. * * @param timestamp - The timestamp string to validate * @param fieldName - The name of the field being validated ('cts' or 'exp') * @param allowExpired - Whether to allow expired timestamps * @throws {AtProtocolValidationError} If the timestamp is invalid */ export declare function validateTimestamp(timestamp: string, fieldName: 'cts' | 'exp', allowExpired?: boolean): void; /** * Validates a creation timestamp (cts) according to AT Protocol specifications. * @param cts - The creation timestamp to validate * @throws {AtProtocolValidationError} If the timestamp is invalid */ export declare function validateCts(cts: string): void; /** * Validates an expiration timestamp (exp) according to AT Protocol specifications. * @param exp - The expiration timestamp to validate * @param allowExpired - Whether to allow expired timestamps * @throws {AtProtocolValidationError} If the timestamp is invalid */ export declare function validateExp(exp: string, allowExpired?: boolean): void;