Class

Server

Federation.Server(serverURL, domain, optsopt) → {void}

Federation.Server handles a network connection to a federation server instance and exposes an interface for requests to that instance.

Constructor

# new Server(serverURL, domain, optsopt) → {void}

Parameters:
Name Type Attributes Description
serverURL string

The federation server URL (ex. https://acme.com/federation).

domain string

Domain this server represents

opts Api.Options <optional>

Options object

View Source lib/federation/server.js, line 36

void

Members

# private domain

Domain this server represents.

View Source lib/minimal/federation/server.d.ts, line 16

# private serverURL

The federation server URL (ex. https://acme.com/federation).

View Source lib/minimal/federation/server.d.ts, line 11

# private timeout

Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue.

View Source lib/minimal/federation/server.d.ts, line 21

Methods

# resolveAccountId(accountId) → {Promise.<module:Federation.Api.Record>}

Given an account ID, get their federation record if the user was found

Parameters:
Name Type Description
accountId string

Account ID (ex. GBYNR2QJXLBCBTRN44MRORCMI4YO7FZPFBCNOKTOBCAAFC7KC3LNPRYS)

See:

View Source lib/minimal/federation/server.d.ts, line 96

Will throw an error if the federation server returns an invalid memo value.

Will throw an error if the federation server's response exceeds the allowed maximum size.

Will throw an error if the server query fails with an improper response.

A promise that resolves to the federation record

Promise.<module:Federation.Api.Record>

# resolveAddress(address) → {Promise.<module:Federation.Api.Record>}

Get the federation record if the user was found for a given Stellar address

Parameters:
Name Type Description
address string

Stellar address (ex. bob*stellar.org). If FederationServer was instantiated with domain param only username (ex. bob) can be passed.

See:

View Source lib/minimal/federation/server.d.ts, line 85

Will throw an error if the federated address does not contain a domain, or if the server object was not instantiated with a domain parameter

A promise that resolves to the federation record

Promise.<module:Federation.Api.Record>

# resolveTransactionId(transactionId) → {Promise.<module:Federation.Api.Record>}

Given a transactionId, get the federation record if the sender of the transaction was found

Parameters:
Name Type Description
transactionId string

Transaction ID (ex. 3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889)

See:

View Source lib/minimal/federation/server.d.ts, line 107

Will throw an error if the federation server returns an invalid memo value.

Will throw an error if the federation server's response exceeds the allowed maximum size.

Will throw an error if the server query fails with an improper response.

A promise that resolves to the federation record

Promise.<module:Federation.Api.Record>

# static createForDomain(domain, optsopt) → {Promise.<module:Federation.Api.Record>}

Creates a FederationServer instance based on information from stellar.toml file for a given domain.

If stellar.toml file does not exist for a given domain or it does not contain information about a federation server Promise will reject.

Parameters:
Name Type Attributes Description
domain string

Domain to get federation server for

opts module:Federation.Api.Options <optional>

Options object

See:

View Source lib/minimal/federation/server.d.ts, line 76

Will throw an error if the domain's stellar.toml file does not contain a federation server field.

A promise that resolves to the federation record

Promise.<module:Federation.Api.Record>
Example
StellarSdk.FederationServer.createForDomain('acme.com')
  .then(federationServer => {
    // federationServer.resolveAddress('bob').then(...)
  })
  .catch(error => {
    // stellar.toml does not exist or it does not contain information about federation server.
  });

# static resolve(value, optsopt) → {Promise.<module:Federation.Api.Record>}

A helper method for handling user inputs that contain destination value. It accepts two types of values:

  • For Stellar address (ex. bob*stellar.org) it splits Stellar address and then tries to find information about federation server in stellar.toml file for a given domain. It returns a Promise which resolves if federation server exists and user has been found and rejects in all other cases.
  • For Account ID (ex. GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS) it returns a Promise which resolves if Account ID is valid and rejects in all other cases. Please note that this method does not check if the account actually exists in a ledger.
Parameters:
Name Type Attributes Description
value string

Stellar Address (ex. bob*stellar.org)

opts object <optional>

Options object

See:

View Source lib/minimal/federation/server.d.ts, line 51

Will throw an error if the provided account ID is not a valid Ed25519 public key.

A promise that resolves to the federation record

Promise.<module:Federation.Api.Record>
Example
StellarSdk.FederationServer.resolve('bob*stellar.org')
 .then(federationRecord => {
   // {
   //   account_id: 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS',
   //   memo_type: 'id',
   //   memo: 100
   // }
 });