Marmot-TS
    Preparing search index...

    Function parseMediaImetaTag

    • Parses an imeta tag array into a MediaAttachment.

      The MIP-04-specific fields (filename, n, v) are read directly from the raw tag entries because applesauce's getFileMetadataFromImetaTag only copies known NIP-92 fields and silently drops unknown keys. Standard NIP-92 fields (url, type/m, sha256/x, size, dimensions/dim, blurhash, thumbnail/thumb, alt, etc.) are delegated to applesauce.

      Returns null if:

      • The tag is not a valid imeta tag (first element is not "imeta")
      • The v field is absent or does not match MIP04_VERSION
      • The n (nonce) field is absent or is not exactly 24 characters (hex-encoded 12-byte nonce)
      • The filename field is absent or empty
      • The x (sha256) field is absent or is not exactly 64 characters (hex-encoded 32-byte hash)
      • The m (MIME type) field is absent or is not a valid type/subtype string

      Per the MIP-04 spec, clients MUST reject deprecated mip04-v1 tags.

      Parameters

      • tag: string[]

        A raw imeta tag array from a Nostr event (e.g. rumor.tags)

      Returns MediaAttachment | null

      A fully-typed MediaAttachment, or null if the tag is not a valid MIP-04 v2 attachment