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

dekey-v2-wallet-core

v0.3.31

Published

Currently (2023.11.23) this package... - is written in Javascript - uses KMS for encryption and decryption - responsible for proceeding the creation/recover of wallets - responsible for storing users' private data to the private area

Downloads

27

Readme

Dekey v2 wallet core

Currently (2023.11.23) this package...

  • is written in Javascript
  • uses KMS for encryption and decryption
  • responsible for proceeding the creation/recover of wallets
  • responsible for storing users' private data to the private area

Installation

# using npm
$ npm i dekey-v2-wallet-core

# using yarn
$ yarn add dekey-v2-wallet-core

Usage

  • YOU MUST LOGIN TO GOOGLE FIRST in order to get an access token and an ID token.

  • Also, you must use Dekey v2 OAuth client for Google login.

Getting the keyshare of the user

// Example of using getKeyshare()

import { Dekey, createDekeyInstance, IDekeyConfig, DekeyOutput } from 'dekey-v2-wallet-core';

const DEKEY_CONFIG: IDekeyConfig = {
  aws: {
    kmsKeyId: import.meta.env.VITE_AWS_KMS_KEY_ID,
    region: import.meta.env.VITE_AWS_REGION,
    identityPoolId: import.meta.env.VITE_AWS_COGNITO_IDENTITY_POOL_ID,
    userPoolId: import.meta.env.VITE_AWS_COGNITO_USER_POOL_ID,
    tokenProvider: import.meta.env.VITE_AWS_TOKEN_PROVIDER,
    credentialProvider: import.meta.env.VITE_AWS_CREDENTIAL_PROVIDER,
    roleArn: import.meta.env.VITE_AWS_ROLE_ARN,
    cognitoSyncDataset: import.meta.env.VITE_AWS_COGNITO_SYNC_DATASET,
  },
  aesSource: '',
  workerFileBasePath,
  appServer: {
    appServerAddressProtocol: import.meta.env.VITE_APP_SERVER_ADDRESS_PROTOCOL,
    appServerAddress: import.meta.env.VITE_APP_SERVER_ADDRESS,
  },
  mpc: {
    enableMPCTLS: import.meta.env.VITE_APP_MPC_TLS,
  }
};

const idToken = 'fhB7d...nql', // Google ID token
const accessToken = '9ejsk...fhk', // Google access token

const payloadOfIdToken = JSON.parse(atob(idToken.split('.')[1]));

// Different user is logged in so the data on local stroage is needed to be cleared.
if (userId !== getUserIdFromLocal()) {
  // Different user is logged in so the data on local stroage is needed to be cleared.
  clearLocalData();
}

// If there is a wallet address stored in Local storage already
const walletAddress = getWalletAddressFromLocal();
if (walletAddress) {
  return {
    walletAddress
  };
}

const dekey = Dekey.createDekeyInstance(dekeyConfig);

const result = await dekey.getKeyshare({
  idToken,
  accessToken,
  setProcess: (completed) => {
    console.log(completed)
  } // this is optional
})

const { sid: walletAddress } = result;
return {
  walletAddress
};
  • This method will proceed KG/RG and store the keyshare backup and the private key. It also saves the keyshare(=pvenc) on the browser local storage.

  • workerFileBasePath must point where mpc_worker.mjs is located.

Calling sign API

import { Dekey } from 'dekey-v2-wallet-core';

const dekey = Dekey.createDekeyInstance(dekeyConfig);
const { r, s, vsource } = await dekey.sign(
  messageHash,
  setProcess: (completed) => {
    console.log(completed)
  }
)