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

@appliedblockchain/silentdata-node

v0.4.0

Published

Node.js library for Silent Data

Downloads

15

Readme

Silent Data Node.js Library

Node.js library to interact with Silent Data.

Silent Data leverages hardware secure enclaves with attestation, in particular, Intel SGX in order to enable privacy-preserving retrieval and processing of off-chain data, and generation of cryptographic proofs that are verifiable in blockchain smart contracts.

Installation

npm install @appliedblockchain/silentdata-node

# or

yarn add @appliedblockchain/silentdata-node

Usage

Supported check types: balance, income, instagram and kyc.

Supported blockchains: algorand, polkadot and solana.

Supported countries for balance and income checks: CA, DE, ES, FR, GB, IE, IT, NL and US.

Start

// with ECMAScript module format:
import { silentdata } from 'silentdata'

// with CommonJS module format:
const { silentdata } = require('silentdata')

const silentdataClient = silentdata(
  {
    baseUrl: process.env.SILENTDATA_BASE_URL,
    clientId: process.env.SILENTDATA_CLIENT_ID,
    clientSecret: process.env.SILENTDATA_CLIENT_SECRET,
  }
);

Using checks defaults:

import { silentdata } from 'silentdata'

const silentdataClient = silentdata(
  {
    baseUrl: process.env.SILENTDATA_BASE_URL,
    clientId: process.env.SILENTDATA_CLIENT_ID,
    clientSecret: process.env.SILENTDATA_CLIENT_SECRET,
  },
  {
    checks: {
      redirectUrl: "https://redirect-url.com",
      webhookUrl: "https://webhook-url.com",
    },
  }
);

Checks

To override redirectUrl and webhookUrl from defaults pass new values inside data object.

Create a balance check:

import { CheckType, CheckBlockchain, CheckCountry } from 'silentdata'

const response = await silentdataClient.checks.create({
  type: CheckType.balance,
  data: {
    blockchain: CheckBlockchain.solana,
    walletAddress: "55S3CXGZnQbU6a7SMzbPvyCWg4v8CCUpJMv8tUB5zvMP",
    country: CheckCountry.gb,
    minimumBalance: 500,
  },
})
const { id, url } = response.data

Create an income check:

import { CheckType, CheckBlockchain, CheckCountry } from 'silentdata'

const response = await silentdataClient.checks.create({
  type: CheckType.income,
  data: {
    blockchain: CheckBlockchain.solana,
    walletAddress: "55S3CXGZnQbU6a7SMzbPvyCWg4v8CCUpJMv8tUB5zvMP",
    country: CheckCountry.gb,
    minimumIncome: 500,
  },
})
const { id, url } = response.data

Create an instagram check:

import { CheckType, CheckBlockchain } from 'silentdata'

const response = await silentdataClient.checks.create({
  type: CheckType.instagram,
  data: {
    blockchain: CheckBlockchain.solana,
    walletAddress: "55S3CXGZnQbU6a7SMzbPvyCWg4v8CCUpJMv8tUB5zvMP",
  },
})
const { id, url } = response.data

Create a kyc check:

import { CheckType, CheckBlockchain } from 'silentdata'

const response = await silentdataClient.checks.create({
  type: CheckType.kyc,
  data: {
    blockchain: CheckBlockchain.solana,
    walletAddress: "55S3CXGZnQbU6a7SMzbPvyCWg4v8CCUpJMv8tUB5zvMP",
  },
})
const { id, url } = response.data

Read a check by id:

import { CheckType } from 'silentdata'

const response = await silentdataClient.checks.readById({
  type: CheckType.instagram,
  id,
})
const check = response.data.check

Read checks:

import { CheckType } from 'silentdata'

const response = await silentdataClient.checks.read({
  type: CheckType.instagram,
  limit: 10,
  offset: 1,
})
const checks = response.data.checks

Delete a check by id:

import { CheckType } from 'silentdata'

const response = await silentdataClient.checks.delete({
  type: CheckType.instagram,
  id,
})
const isDeleted = response.data

Check resource:

import { CheckType } from 'silentdata'

const response = await silentdataClient.checks.readById({
  type: CheckType.instagram,
  id,
})
const check = response.data.check
const {
  id,
  date,
  signingKey,
  signature,
  rawData,
  error: { code, message },
} = check.data
const isCancelled = check.isCancelled()
const isCompleted = check.isCompleted()
const isError = check.isError()
const isPending = check.isPending()
const isInProgress = check.isInProgress()
const isCertified = check.isCertified()

Check verification:

import { VerifyCheckError, VerifyCheckErrorCode } from 'silentdata'

try {
  await check.verify()
} catch (error: VerifyCheckError) {
  if (error.code === VerifyCheckErrorCode.invalid_signature) {
    // handle invalid signature error
  }
  // handle other errors
}

Check balance certificate data:

const {
  check_hash,
  id,
  timestamp,
  initiator_pkey,
  certificate_hash,
  currency_code,
  comparison_value,
  server_timestamp,
  server_common_name,
} = balanceCheck.getCertificateDataAsJSON()

Check income certificate data:

const {
  check_hash,
  id,
  timestamp,
  initiator_pkey,
  certificate_hash,
  currency_code,
  comparison_value,
  server_timestamp,
  server_common_name,
} = incomeCheck.getCertificateDataAsJSON()

Check instagram certificate data:

const { 
  check_hash, 
  id, 
  timestamp, 
  initiator_pkey, 
  certificate_hash, 
  ig_username, 
  ig_account_type 
} = instagramCheck.getCertificateDataAsJSON()

Check kyc certificate data:

const { 
  check_hash, 
  id, 
  timestamp, 
  initiator_pkey, 
  certificate_hash, 
  check_timestamp, 
  subject_id 
} = kycCheck.getCertificateDataAsJSON()

Enclaves

Read an enclave by check signingKey:

import { CheckType } from 'silentdata'

const response = await silentdataClient.enclaves.read({
  signingKey: check.data.signingKey
});
const enclave = response.data.enclave
const {
  date,
  mrenclave,
  iasCertChain,
  iasReport,
  iasSignature,
  publicKeys
} = enclave.data
const isActive = enclave.isActive()
const isRevoked = enclave.isRevoked()
const isRetired = enclave.isRetired()
for (const { publicKey, algorithm, usage } of publicKeys) {}

Enclave verification:

import { VerifyEnclaveError, VerifyEnclaveErrorCode } from 'silentdata'

try {
  await enclave.verify()
} catch (error: VerifyEnclaveError) {
  if (error.code === VerifyEnclaveErrorCode.invalid_signature) {
    // handle invalid signature error
  }
  // handle other errors
}