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

cryptoforce-sdk

v1.0.5

Published

CryptoForce SDK is a TypeScript library for interacting with the Crypto Force API. It provides a convenient way to integrate your application with the CryptoForce services. Below is a guide on how to use the SDK.

Downloads

344

Readme

CryptoForce SDK

CryptoForce SDK is a TypeScript library for interacting with the Crypto Force API. It provides a convenient way to integrate your application with the CryptoForce services. Below is a guide on how to use the SDK.

Installation

Using npm:

npm install cryptoforce-sdk

Usage

importing CryptoForceProvider:

import { CryptoForceProvider } from 'cryptoforce-sdk';

Instantiate it as:

const cryptoForceProvider = new CryptoForceProvider({
  baseUrl: 'https://crypto-node.test.url/api/v1',
  tenantName: 'testTenant',
  apiKey: '48e7fbdf-65f3-4fa3-9b44-149d2d593d8d',
  // NOTE: not used for now
  // auth: {
  //  username: 'admin',
  //  password: 'admin',
  // },
  sslConfig: {
    ca: fs.readFileSync('./certificates/ca.crt'),
    cert: fs.readFileSync('./certificates/cert.crt'),
    key: fs.readFileSync('./certificates/key.crt'),
  },
});

Configuration

  • baseUrl: base URL of the CryptoForce API.
  • tenantName: tenant name.
  • apiKey: API key for authentication.
  • sslConfig: object with SSL certificate configurations.

CryptoForceProvider Clients

CryptoForceProvider includes the following clients:

  • walletApiClient: allows to interact with the CryptoForce API for wallet-related operations.
  • undeliveredCallbackApiClient: allows to resend callbacks on tenant`s callback URL
  • payoutApiClient allows to create Payment Orders
  • depositApiClient allows to revert Deposits
  • infoApiClient allows to receive information about tenant/address/deposit/payout
  • AMLApiClient allows to interact with AML System

Examples

Wallet creation

import { WalletCreateRequestDto, WalletCreateResponseDto } from 'cryptoforce-sdk';

const createWalletData: WalletCreateRequestDto = {
  client_id: 'test',
  payway: 'tron',
};
const res: WalletCreateResponseDto = await cryptoForceProvider.walletApiClient.createWallet(createWalletData);

Note: Since the operation is asynchronous, CNW will send the Wallet Creation Notification at the end of this operation to Callback URL configured for the tenant (client).

Callback DTOs are also defined and can be imported:

import { BaseCallbackDto, WalletCreateCallbackDto } from 'cryptoforce-sdk';

let callback: BaseCallbackDto<WalletCreateCallbackDto>;

Get wallet creation request status

import { GetWalletCreationStatusRequestDto, GetWalletCreationStatusResponseDto } from 'cryptoforce-sdk';

const getCreateWalletStatusData: GetWalletCreationStatusRequestDto = {
  request_id: '61da5793-0424-4ecb-8233-ba98833aacc3',
};
const res: GetWalletCreationStatusResponseDto = await cryptoForceProvider.walletApiClient.getWalletCreationStatus(getCreateWalletStatusData);

Wallet assignation

import { WalletAssignRequestDto, WalletAssignResponseDto } from 'cryptoforce-sdk';

const assignWalletData: WalletAssignRequestDto = {
  client_id: 'test',
  address: 'testAddress',
};
const res: WalletAssignResponseDto = await cryptoForceProvider.walletApiClient.assignWallet(assignWalletData);

Note: Since the operation is asynchronous, CNW will send the Wallet Assignation Notification at the end of this operation to Callback URL configured for the tenant (client).

Callback DTOs are also defined and can be imported:

import { BaseCallbackDto, WalletAssignCallbackDto } from 'cryptoforce-sdk';

let callback: BaseCallbackDto<WalletAssignCallbackDto>;

Resend Undelivered Callbacks

import { CallbackResendRequestDto, CallbackResendResponseDto } from 'cryptoforce-sdk';

const callbackResendData: CallbackResendRequestDto = {
  client_id: 'test',
  startdate: 1641902222000,
  enddate: 1641902223000,
  limit: 10,
};
const res: CallbackResendResponseDto = await cryptoForceProvider.undeliveredCallbackClient.resendCallbacks(callbackResendData);

Note: Please, check additional properties of CallbackResendRequestDto.


Verify callback signature (static function)

import { CallbackClient } from 'cryptoforce-sdk';

const res: boolean = CallbackClient.verifyCallbackSignature(payload, signature, date, apiKey);

Properties:
payload - callback payload;
signature - callback signature, usually headers['x-signature'];
date - callback date, usually headers['x-date'];
apiKey - tenant`s API Key;