Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@triviumcapital/trivium-ts-sdk

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@triviumcapital/trivium-ts-sdk

Typescript Axios Client SDK for trivium APIs

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Typescript Axios Client SDK for trivium

SDK Development Documentation

To use SDK:

import { Configuration, UserApi, CashApi, FixedDepositApi, TransactionsApi } from '@triviumcapital/trivium-ts-sdk';

const TriviumService = (() => {

  const triviumUrl = 'https://staging.api.triviumcapital.tech';

  const configuration = new Configuration({
    apiKey: '<your-api-key>',
    accessToken: '<your-api-secret>'
  });

  const userApi = new UserApi(configuration, triviumUrl);

  const cashApi = new CashApi(configuration, triviumUrl);

  const fixedDepositApi = new FixedDepositApi(configuration, triviumUrl);

  const transactionsApi = new TransactionsApi(configuration, triviumUrl);

  return {
    userApi,
    cashApi,
    fixedDepositApi,
    transactionsApi
  };
})();

const companyDetails = ...

const user = await TriviumService.userApi.postApiV1User(companyDetails); // creates trivium user and returns user id

Example server to verify callback requests from Trivium:

import express from "express";
import { verifyTriviumCallbackRequest } from "@triviumcapital/trivium-ts-sdk/security";

const app = express();
app.use(
  express.json({
    limit: "5mb",
    verify: (req, res, buf) => {
      req.rawBody = buf.toString();
    },
  })
);
const port = 3000;

const publicKey = "<public key retrieved from Trivium API>";

app.put("/webhook", (req, res) => {
  const { rawBody } = req;
  const timestamp = req.header("Trivium-Timestamp");
  const signature = req.header("Trivium-Signature");

  const isVerified = verifyTriviumCallbackRequest(
    signature,
    rawBody,
    timestamp,
    publicKey
  );

  console.log(`timestamp: ${timestamp}`);
  console.log(`signature: ${signature}`);
  console.log(`body: ${rawBody}`);
  console.log(`isVerified: ${isVerified}`);

  if (isVerified) {
    res.sendStatus(200);
  } else {
    res.sendStatus(500);
  }
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});

Keywords

FAQs

Package last updated on 24 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc