ElvClient

See the Modules section on the sidebar for details about methods related to interacting with the Fabric.

Constructor

new ElvClient({
contentSpaceId,
fabricURIs,
ethereumURIs,
trustAuthorityIdoptional,
noCacheoptional,
noAuthoptional
})
ElvClient

Create a new ElvClient

NOTE: It is highly recommended to use ElvClient.FromConfiguration to automatically import the client settings from the fabric

Returns: New ElvClient connected to the specified content fabric and blockchain
Parameters:
Name Type Attributes Default Description
contentSpaceId string

ID of the content space

fabricURIs Array.<string>

A list of full URIs to content fabric nodes

ethereumURIs Array.<string>

A list of full URIs to ethereum nodes

trustAuthorityId string <optional>

(OAuth) The ID of the trust authority to use for OAuth authentication

noCache boolean <optional>
false

If enabled, blockchain transactions will not be cached

noAuth boolean <optional>
false

If enabled, blockchain authorization will not be performed

Source:

Methods

async, static Configuration({
configUrl,
kmsUrls,
regionoptional
})
→ Promise.<Object>

Retrieve content space info and preferred fabric and blockchain URLs from the fabric

Returns: Object containing content space ID and fabric and ethereum URLs
Parameters:
Name Type Attributes Description
configUrl string

Full URL to the config endpoint

kmsUrls Array.<string>

List of KMS urls to use for OAuth authentication

region string <optional>

Preferred region - the fabric will auto-detect the best region if not specified

  • Available regions: na-west-north, na-west-south, na-east, eu-west, eu-east, as-east, au-east
Source:

async, static FromConfigurationUrl({
configUrl,
regionoptional,
trustAuthorityIdoptional,
noAuthoptional
})
→ Promise.<ElvClient>

Create a new ElvClient from the specified configuration URL

Returns: New ElvClient connected to the specified content fabric and blockchain
Parameters:
Name Type Attributes Default Description
configUrl string

Full URL to the config endpoint

region string <optional>

Preferred region - the fabric will auto-detect the best region if not specified

  • Available regions: na-west-north, na-west-south, na-east, eu-west, eu-east, as-east, au-east
trustAuthorityId string <optional>

(OAuth) The ID of the trust authority to use for OAuth authentication * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached

noAuth boolean <optional>
false

If enabled, blockchain authorization will not be performed

Source:

ClearCache()

Clear saved access and state channel tokens

Source:

ClearSigner()

Remove the signer from this client

Source:

CurrentAccountAddress() → string

Get the account address of the current signer

Returns: The address of the current signer
Source:

async DecryptECIES(message) → Promise.<(string|Object)>

Decrypt the given encrypted message with the current signer's private key

Returns: The decrypted string or object
Parameters:
Name Type Description
message string

The message to decrypt

Source:

async EncryptECIES(message) → Promise.<string>

Encrypt the given string or object with the current signer's public key

Returns: The encrypted message
Parameters:
Name Type Description
message string | Object

The string or object to encrypt

Source:

GenerateWallet()ElvWallet

Generate a new ElvWallet that is connected to the client's provider

Returns: ElvWallet instance with this client's provider
Example
 GenerateWallet();


{
  "provider": {
    "ready": "<Promise>",
    "_lastBlockNumber": -2,
    "_balances": {},
    "_events": [],
    "_pollingInterval": 500,
    "_emitted": {
      "block": -2
    },
    "_fastQueryDate": 1592591603671,
    "connection": {
      "url": "https://host-35-233-145-232.test.contentfabric.io/eth/"
    },
    "getCode": "<function>",
    "_network": {
      "chainId": 955210,
      "name": "unknown"
    },
    "_fastBlockNumberPromise": "<Promise>",
    "_fastBlockNumber": 904161
  },
  "signers": {}
}
Source:

async NodeId({region}) → Promise.<string>

Retrieve the node ID reported by the fabric for the specified region

Note: Client must have been initialized with FromConfiguration

Returns: The node ID reported by the fabric
Parameters:
Name Type Description
region string

Region from which to retrieve the node ID

Source:

Nodes() → Promise.<Object>

Retrieve the fabric and ethereum nodes currently used by the client, in preference order

Returns: An object containing the lists of fabric and ethereum urls in use by the client
Source:

Request(
url,
formatoptional,
methodoptional,
bodyoptional,
headersoptional
)
→ Promise.<*>

Request the specified URL with the given method and body, and return the result in the specified format

Returns: Response in the specified format
Parameters:
Name Type Attributes Default Description
url string

URL to request

format string <optional>
"json"

Format of response

method string <optional>
"GET"

Request method

body object <optional>

Request body

headers object <optional>

Request headers

Source:

async ResetRegion() → Promise.<Object>

Reset fabric URLs to prefer the best region auto-detected by the fabric.

Note: Client must have been initialized with FromConfiguration

Returns: An object containing the updated fabric and ethereum URLs in order of preference
Source:

SetNodes({
fabricURIsoptional,
ethereumURIsoptional
})

Set the client to use the specified fabric and ethereum nodes, in preference order

Parameters:
Name Type Attributes Description
fabricURIs Array.<string> <optional>

A list of URLs for the fabric, in preference order

ethereumURIs Array.<string> <optional>

A list of URLs for the blockchain, in preference order

Source:

async SetOauthToken(token)

Set the OAuth token for use in state channel calls

Parameters:
Name Type Description
token string

The OAuth ID token

Source:

SetSigner({signer})

Set the signer for this client to use for blockchain transactions

Parameters:
Name Type Description
signer object

The ethers.js signer object

Source:

async SetSignerFromOauthToken(token)

Set the signer for this client via OAuth token. The client will exchange the given token for the user's private key using the KMS specified in the configuration.

NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl)

Parameters:
Name Type Description
token string

The OAuth ID

Source:

async SetSignerFromWeb3Provider({provider})

Set the signer for this client to use for blockchain transactions from an existing web3 provider. Useful for integrating with MetaMask

Parameters:
Name Type Description
provider object

The web3 provider object

Source:

ToggleLogging(enable)

Enable or disable verbose logging

Parameters:
Name Type Description
enable boolean

Set logging

Source:

async UseRegion({region}) → Promise.<Object>

Update fabric URLs to prefer the specified region.

Note: Client must have been initialized with FromConfiguration

Returns: An object containing the updated fabric and ethereum URLs in order of preference
Parameters:
Name Type Description
region string

Preferred region - the fabric will auto-detect the best region if not specified

  • Available regions: na-west-north, na-west-south, na-east, eu-west, eu-east, as-east, au-east
Source: