$ npm i @trustology/trustvault-nodejs-sdk
The SDK wraps the TrustVault GraphQL interface and gives you easy access to core functionalities within the API.
The API can be configured against sandbox (ETH ropsten, BTC testnet3) or production environments.
If you use the SDK with an external instruction key the SDK provides callbacks for you to sign the correct data.
The SDK includes helper methods to ensure you data integrity including validating policy template, publicKey provenance, HMAC webhook payload and digests. It also includes an AWS KMS wrapper class for data signing.
The SDK requires an API key, please contact Trustology to get one.
See TrustVault Node.js SDK in github
The function that will be called with the data that needs to be signed.
AwsKmsKeyStore class ensures that the correct key from the correct curve is used for signing. It has a method
sign which is an implementation of the signCallback.
You will need to ensure that your code has the relevant AWS permissions to access your KMS key.
Retrieve the list of subWallets associated with the API key. Use this method to get the
subWalletId of the wallet you wish to create transactions from or get the
walletId where the subWallets belongs to.
const subWallets = await trustVault.getSubWallets();
Send a bitcoin transaction to TrustVault
const requestId = await trustVault.sendBitcoin(fromSubWalletId, toAddress, amount, speed, signCallback);
Send an ethereum transaction to TrustVault
const requestId = await trustVault.sendEthereum(fromAddress, toAddress, amount, asset, speed, currency, signCallback)
Change the external public instruction key of a wallet
const requestId = await trustVault.replacePublicKeyInDefaultSchedule(walletId, publicKey, signCallback);
Validate the webhook, sign and submit the signature to TrustVault
TrustVault.validateWebhookSignature(req.body, "<YOUR_WEBHOOK_SECRET>", req.headers["X-Sha2-Signature"]);
NOTE: validateWebhookSignature is a static method
Create a new bitcoin address for the given subWalletId
const address = await trustVault.createBitcoinAddress(subWalletId)
Retrieve the request item associated with the given requestId. Use this method to query the status of your request.
const request = await trustVault.getRequest(requestId)
|AWAITING_SIGNATURES||the request is still awaiting signatures enough signature before it can be processed|
|SIGNED||the request has received enough signatures to be processed|
|SUBMITTED||the transaction request has been processed and submitted to the network|
|CONFIRMED||the transaction request has been confirmed by the network (1+ confirmation)|
|PROCESSED||the request has been successfully processed|
|USER_CANCELLED||the request has been cancelled by the user|
|ERROR||an error occurred when processing the request|