Constructor
new ElvClient({contentSpaceId,fabricVersion,fabricURIs,ethereumURIs,trustAuthorityIdoptional,staticTokenoptional,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
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
contentSpaceId |
string |
ID of the content space |
||
fabricVersion |
number |
The version of the target content fabric |
||
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 |
|
staticToken |
string |
<optional> |
Static token that will be used for all authorization in place of normal auth |
|
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
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
|
- Source:
async, static FromConfigurationUrl({configUrl,regionoptional,trustAuthorityIdoptional,staticTokenoptional,noAuthoptional}) → Promise.<ElvClient>
Create a new ElvClient from the specified configuration URL
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
|
|
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 |
|
staticToken |
string |
<optional> |
Static token that will be used for all authorization in place of normal auth |
|
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
- Source:
async DecryptECIES({message}) → Promise.<(string|Object)>
Decrypt the given encrypted message with the current signer's private key
Parameters:
Name | Type | Description |
---|---|---|
message |
string |
The message to decrypt |
- Source:
async EncryptECIES({message,publicKeyoptional}) → Promise.<string>
Encrypt the given string or object with the current signer's public key
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | Object |
The string or object to encrypt |
|
publicKey |
string |
<optional> |
If specified, message will be encrypted with this public key instead of the current user's |
- Source:
GenerateWallet() → ElvWallet
Generate a new ElvWallet that is connected to the client's provider
Example
GenerateWallet(); { "provider": { "ready": "<Promise>", "_lastBlockNumber": -2, "_balances": {}, "_events": [], "_pollingInterval": 500, "_emitted": { "block": -2 }, "_fastQueryDate": 1596922821233, "connection": { "url": "https://host-34-105-49-255.testv2.contentfabric.io/eth/" }, "getCode": "<function>", "_network": { "chainId": 955203, "name": "unknown" }, "_fastBlockNumberPromise": "<Promise>", "_fastBlockNumber": 60606 }, "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
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
- 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
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
- 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 |
Examples
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io/", "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
SetNodes({ "fabricURIs": [ "https://host-34-105-49-255.testv2.contentfabric.io", "https://host-34-65-65-227.testv2.contentfabric.io" ] }); <No Return Value>
- 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:
async SetPolicyAuthorization({objectId})
Authorize the client against the specified policy.
NOTE: After authorizing, the client will only be able to access content allowed by the policy
Parameters:
Name | Type | Description |
---|---|---|
objectId |
string |
The ID of the policy object |
- 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:
SetStaticToken({token})
Set a static token for the client to use for all authorization
Parameters:
Name | Type | Description |
---|---|---|
token |
string |
The static token to use |
- Source:
ToggleLogging(enable,optionsoptional)
Enable or disable verbose logging
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enable |
boolean |
Set logging |
|
options |
Object |
<optional> |
Additional options for customizing logging
|
- Source:
async UseRegion({region}) → Promise.<Object>
Update fabric URLs to prefer the specified region.
Note: Client must have been initialized with FromConfiguration
Parameters:
Name | Type | Description |
---|---|---|
region |
string |
Preferred region - the fabric will auto-detect the best region if not specified
|
- Source: