metascraper-logo-bimi
v5.56.2
Published
Metascraper logo fallback that resolves brand marks from BIMI DNS TXT records.
Maintainers
Readme
Why
BIMI is the standard behind the brand logo mailbox providers show next to an email. Domains publish it as a TXT record:
$ dig +short TXT default._bimi.microlink.io
"v=BIMI1; l=https://cdn.microlink.io/logo/logo.svg;"The specification constrains the logo to SVG Tiny P/S: vector, square, and transparent, which is exactly the shape a logo is expected to have.
The record is published in the domain's own DNS, so it is self asserted: the same level of trust as og:logo. Domains may also publish a Verified Mark Certificate under a=, where a certificate authority has attested the mark against the trademark owner, but this package does not read or validate it.
That makes it a higher quality source than a favicon, and it doesn't need the markup: a single DNS lookup, so it works even when the page is JavaScript rendered or unreachable.
Coverage is the trade-off. It's common among large brands and rare in the long tail, so pair it with metascraper-logo and metascraper-logo-favicon.
Install
$ npm install metascraper-logo-bimi --saveUsage
Rules are evaluated in the order the packages are declared, so put it first to prefer the BIMI published logo over anything found in the markup:
const metascraper = require('metascraper')([
require('metascraper-logo-bimi')(),
require('metascraper-logo')(),
require('metascraper-logo-favicon')()
])The lookup is done against the registrable domain, meaning https://blog.example.com/post resolves default._bimi.example.com.
API
metascraper-logo-bimi([options])
The record is read by bimi-url, and every option is passed to it: gotOpts, keyvOpts, resolveLogoUrl, resolveTxt, and selector are documented there.
Supplying your own resolveTxt is the common one, since node:dns resolves with no timeout by default:
const { Resolver } = require('dns').promises
const resolver = new Resolver({ timeout: 2000 })
const metascraper = require('metascraper')([
require('metascraper-logo-bimi')({
resolveTxt: hostname => resolver.resolveTxt(hostname)
})
])The same seam takes a DNS over HTTPS resolver, so the lookup leaves through the same egress as the rest of your traffic. bimi-url has that example.
createGetLogo, resolveLogoUrl and toLogoUrl are re-exported from bimi-url for use outside a metascraper rule.
License
metascraper-logo-bimi © Microlink, released under the MIT License. Authored and maintained by Microlink with help from contributors.
microlink.io · GitHub microlinkhq · X @microlinkhq
