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

@mojaloop/pathfinder-query-client

v5.3.0

Published

Library for querying PathFinder DNS records.

Downloads

3

Readme

pathfinder-query-client

A library used to query PathFinder by E.164 telephone number and retrieve records provisioned for that number.

Installation

You must have setup connection to the @leveloneproject npm repo on JFrog in order to install.

npm install @mojaloop/pathfinder-query-client

Usage

const Query = require('@mojaloop/pathfinder-query-client')

const phoneNumber = '+15714344668'

const client = Query.createClient({ address: '156.154.59.228' })

client.request(phoneNumber)
  .then(response => {
    console.log('RESPONSE MESSAGE')
    console.log(response)
  })
  .catch(err => {
    console.log('ERROR')
    console.log(err)
  })

API

Class: Client

This class represents a client to query PathFinder.

createClient(options)

  • options {Object}
    • address {String} The hostname or IP address of the PathFinder server. Defaults to 'localhost'.
    • port {Number} The port of the PathFinder server. Defaults to 53.
    • type {String} The connection type to use when connecting to PathFinder ('udp'). Defaults to 'udp'.
    • timeout {Number} The timeout used when querying PathFinder, in milliseconds. Defaults to 5000.
    • enumSuffix {String} The suffix to append to the ENUM query sent to PathFinder. Defaults to 'e164enum.net'.

Creates a new query client.

This method can also throw a variety of Error types that should be handled.

  • InvalidConnectionTypeError Thrown if the type parameter is not 'udp'.

client.request(phoneNumber)

  • phoneNumber {String} The E.164 formatted phone number to query. The + sign at the beginning of the number is optional.
  • Returns: {Array}

Returns an array of Result objects.

This method can also throw a variety of Error types that should be handled.

  • RequestTimeoutError Thrown if the request is not completed within the timeout value used when creating the client.
  • QueryFormatError Thrown if the query format is not recognized by PathFinder. Corresponds to an rcode value of 1 in the DNS response header.
  • ServerFailError Thrown if unable to process the query due to a problem with PathFinder server. Corresponds to an rcode value of 2 in the DNS response header.
  • InvalidPhoneFormatError Thrown if the telephone number being requested is not in a valid E.164 format.
  • InvalidPhoneNumberError Thrown if the telephone number is not valid as determined by PathFinder. Corresponds to an rcode value of 3 in the DNS response header.
  • UnauthorizedError Thrown if the source IP is not authorized to access PathFinder. Corresponds to an rcode value of 5 in the DNS response header.
  • UnhandledRcodeError Thrown if the rcode returned from PathFinder is not recognized by this client.

Class: Result

This class represents a result returned from PathFinder for a query.

New instances of Result are returned from Client.request(). The new keyword is not to be used to create Result instances.

result.tn

  • {String}

The E.164 phone number that was queried.

result.query

  • {String}

The query that was sent to PathFinder for this result.

result.records

  • {Array}
    • {Object}
      • order {Number} A request from the holder of the telephone number that specifies the order in which records must be processed when multiple records are returned for the same TN. Lower values have priority.
      • preference {Number} A suggestion from the holder of the TN that one record is better to use than another when multiple NAPTR records show the same value for order. Lower values have priority.
      • ttl {Number} The time interval in seconds that the record may be stored or cached.
      • service {String} A character string that specifies the resolution protocol and resolution service(s) that will be available if the rewrite specified by the regexp fields is applied.
      • regexp {Object} An object containing the rewrite rule. It is applied to the original query string to construct the domain name.
        • pattern {RegExp} The pattern to apply to the E.164 phone number. Example: '+15551234567'.replace(regex.pattern, replace)
        • replace {String} The replacement string to use when using the pattern against the E.164 phone number.
      • replacement {String} Another field that may be used for the rewrite rule. An empty string indicates there is no other rewrite rule.

An array of records that were returned for the query.