From 94a3c8455d1e33e4fb5ac5523b43a7588867fe2d Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Mon, 8 Jan 2024 20:51:27 -0800 Subject: [PATCH] size-limit-policy: Exclude replaceable and epheremal kinds, drop default to 8Kb. --- src/policies/size-limit-policy.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/policies/size-limit-policy.ts b/src/policies/size-limit-policy.ts index c0ec6a1..182f4b3 100644 --- a/src/policies/size-limit-policy.ts +++ b/src/policies/size-limit-policy.ts @@ -2,27 +2,27 @@ import { Policy } from '../types.ts'; /** Policy options for `sizeLimitPolicy`. */ interface SizeLimitOptions { - /** Maximum size of the message content in bytes. Default: 12KB (12288 bytes) */ + /** Maximum size of the message content in bytes. Default: 8KB (8192 bytes) */ maxContentSize?: number; /** List of excluded event kinds */ excludeKinds?: number[]; } /** - * Reject events larger than a specified size. + * Reject events larger than a specified size. Only applies to regular events (kind is less than 10000), as all other kinds are replaceable or ephemeral anyway. * * @example * ```ts * // Reject events larger than a custom size (15KB) and exclude event kinds [1, 2]. - * sizeLimitPolicy(msg, { maxContentSize: 15000, excludeKinds: [1, 2] }); - * // Reject events larger than the default size (12KB) and exclude event kinds [3]. + * sizeLimitPolicy(msg, { maxContentSize: 15360, excludeKinds: [1, 2] }); + * // Reject events larger than the default size (8KB) and exclude event kinds [3]. * sizeLimitPolicy(msg, { excludeKinds: [3] }); * ``` */ const sizeLimitPolicy: Policy = ({ event: { id, content, kind } }, opts = {}) => { const { - excludeKinds = [3, 30078], // Exclude large events such as contact lists and app data - maxContentSize = 12 * 1024 // Default size limit is 12KB + excludeKinds = [3], // Follows aka Contact Lists (NIP-02) + maxContentSize = 8 * 1024 // Default size limit } = opts; // Convert the content into bytes and check its size