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

react-native-recovery-kit

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-recovery-kit

MPC based recovery kit

  • 1.0.12
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-native-recovery-kit

Overview

Use this library to securely spilt the private key in 3 different parts. Can upload one shard to users google drive using google drive access token. Second key can be uploaded to Enterprise AWS S3 bucket. The third key is returned back.

A. Installation

Create a .npmrc file in the root directory or where the package.json stays and paste the following code and use the auth_token given by silence laboratories.

//registry.npmjs.org/:_authToken=<auth_token>

Then, run the following command in terminal

yarn add @silencelaboratories/react-native-recovery-kit react-native-randombytes

This is using react-native-randombytes as a peer-dependencies, yarn will link dependencies better then npm

B. Recovery Kit Setup and Sync

During integration of the Silent Shard Recovery SDK, you are requested to setup cloud accesses and permissions for storage management. The following two steps are mandatory before usage of the recovery Kit.

  • Setup google sign in and access token for users google drive.
  • Setup AWS S3 bucket.

C. Configure

Before using the functions directly, we have to configure. This is not compulsory but a recommended way to use the library. You can use the configure by passing the following parameters:

RecoveryKit.configure({
      drive: {
            googleAccessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
            driveFileName: 'FILE NAME FOR DRIVE',
            driveFolderName: 'FOLDER NAME FOR DRIVE',
      },
      AWS: {
            accessKeyId: 'xxxxxxxxxxxxxxxxx',
            secretAccesskey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
            signatureVersion: 'v4',
            bucket: 'xxxxxxxxxxx',
            fileName: 'FILE NAME FOR AWS'
      },
      numberOfShares: n,
      threshold: k,
})
  • drive parameters (line 2) : This will take 3 values.

    • googleAccessToken (line 3) : This will take a valid google access token with the scope of editing the drive. The scope needed here is https://www.googleapis.com/auth/drive.file . Learn more about google scopes here
    • driveFileName (line 4) : This will take a name which you want to be used when creating a file in users google drive. This is optional and by default the value is SLBackupSecret . Do not add .txt at the end of the file name.
    • driveFolderName (line 5) : This will take a name which you want to be used when creating a folder in users google drive. This is optional and by default the value is SLBackup .
  • AWS parameters (line 7): This will take 5 values. This parameter is optional and only needed when AWS S3 bucket is setup. To setup the AWS S3 bucked follow this guide.

    • accessKeyId (line 8): This is AWS accessKeyId
    • secretAccesskey (line 9): This is AWS secretAccesskey
    • signatureVersion (line 10): This we have to use the value v4
    • bucket (line 11): This will take the bucket name
    • fileName (line 12): This is an optional argument, you can give any name to the file uploaded to AWS. By default the AWS file name will be .txt which will look something like this 118xxxxxxxxxxxxxx7291.txt
  • numberOfShares (line 14): number of shares you want to create include one uploaded to drive and AWS, (default value is 3)

  • threshold (line 15): number of shards needed for recovery. (default value is 2)

D. Functions (With Configure)

1. Recovery.upload

Pass the private key (hex string) and the library will use the configured data. Function will split the private key in to n shards (numberOfShares). One will be uploaded to Google Drive using google access token, one will be uploaded to AWS which is configured. On success the function will return and array of remaining shards.

await RecoveryKit.upload({
    privateKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',  //hex string
});
2. RecoveryKit.recovery

Call the recovery function to recover the private key. For recovery at least threshold number of shards (k shards) are needed. If AWS is setup then this will use drive shard and AWS shard and need k-2 recovery shards. Function will return the original private key.

await RecoveryKit.recovery({
    recoveryShards: [
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        ...,
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    ] // at least threshold number of shards including drive and AWS shard
});

Functions (Without Configure)

If not using configured then also go through the configuration once as we will pass the same parameters in functions.

1.RecoveryKit.upload

Pass the configuration parameters with the private key (hex string). Function will split the private key in to n shards (numberOfShares). One will be uploaded to Google Drive using google access token, one will be uploaded to AWS which is configured. On success the function will return and array of remaining shards.

await RecoveryKit.upload({
    drive: {
        googleAccessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        driveFileName: 'FILE NAME FOR DRIVE',
        driveFolderName: 'FOLDER NAME FOR DRIVE',
    },
    AWS: {
        accessKeyId: 'xxxxxxxxxx',
        secretAccesskey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        signatureVersion: 'v4',
        bucket: 'xxxxxxxxxxx',
        fileName: 'FILE NAME FOR AWS'
},
    numberOfShares: n,
    threshold: k,
    privateKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', //hex string
});
2. RecoveryKit.recovery

Pass the configuration parameters with the recoveryShard. Call the recovery function to recover the private key. For recovery at least threshold number of shards (k shards) are needed. If AWS is setup then this will use drive shard and AWS shard and need k-2 recovery shards. Function will return the original private key.

await RecoveryKit.recovery({
    drive: {
        googleAccessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        driveFileName: 'FILE NAME FOR DRIVE',
        driveFolderName: 'FOLDER NAME FOR DRIVE',
    },
    AWS: {
        accessKeyId: 'xxxxxxxxxx',
        secretAccesskey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        signatureVersion: 'v4',
        bucket: 'xxxxxxxxxxx',
        fileName: 'FILE NAME FOR AWS'
},
    recoveryShards: [
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        ...
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    ], //at least threshold number of shards including drive and AWS shard
});

Keywords

FAQs

Package last updated on 16 Dec 2022

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