npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

matrix-resolve

v1.0.1

Published

Find matrix server with a domain name

Downloads

5

Readme

matrix-resolve

Find matrix server with a domain name

Synopsis

import { matrixResolve } from 'matrix-resolve'

const baseUrl = await matrixResolve('mydomain.com')

or using Object interface:

import { MatrixResolve } from 'matrix-resolve'

const matrixResolve = new MatrixResolve({
  // optional cache
  cache: 'toad-cache',
  cacheSize: 100,
  cacheTtl: 300,
})

const baseUrl = await matrixResolve.resolve('mydomain.com')

Description

matrix-resolve permits to find the base URL of a Matrix "server name". Following the specification it tries to resolve the url in the following order:

  1. If the hostname is an IP literal, then it builds base URL using that IP address together with the given port number, or 8448 if no port is given.

  2. If the hostname is not an IP literal, and the server name includes an explicit port, it builds base URL using this hostname and the given port

  3. Tries a request to https://<hostname>/.well-known/matrix/server to get a delegated hostname (value of m.serverfield). If success:

    1. If delegated hostname is an IP literal, it builds base URL using that IP together with the delegated port or 8448 if no port is provided
    2. If delegated hostname is not an IP literal and delegated port is present, it builds base URL using that name with the delegated port
    3. Else follow the next points but using delegated hostname instead of hostname
  4. Tries to found a DNS SRV record using _matrix-fed._tcp.<hostname>, if succeed, it build URL using name and port given by the SRV entry. Returns an array if more than one entry is found, sorted by priority

  5. [Deprecated] Try to found a DNS SRV record using _matrix._tcp.<hostname>, if succeed, it build URL using name and port given by the SRV entry Returns an array if more than one entry is found, sorted by priority

  6. Verifies that hostname exists in DNS and builds URL using hostname and port 8448

Object interface

You can use either the simple interface or the Object one. With the Object interface, you can add a cache (only toad-cache is supported for now).

The constructor take an optional object argument. Constructor argument keys:

  • cache: cache type. For now, only toad-cache is accepted
  • cacheSize: the max number of responses to store. Default: 500
  • cacheTtl: the time-to-live in seconds. Default: 600

Copyright and license

Copyright (c) 2023-present Linagora https://linagora.com

License: GNU AFFERO GENERAL PUBLIC LICENSE