Skip to content

Commit

Permalink
Merge pull request #5 from privy-io/node-support
Browse files Browse the repository at this point in the history
Support for older node versions
  • Loading branch information
benjreinhart committed May 29, 2023
2 parents 6b172a5 + e5c2160 commit 9183a96
Show file tree
Hide file tree
Showing 13 changed files with 1,234 additions and 2,806 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.DS_Store
lib/
node_modules/
*.gitignored.*
.env
/*.d.ts
/*.js
/*.js.map
/esm/*.d.ts
/esm/*.js
/esm/*.js.map
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Simple, independently audited, zero-dependency TypeScript implementation of [Sha

Uses GF(2^8). Works on `Uint8Array` objects. Implementation inspired by [hashicorp/vault](https://github.com/hashicorp/vault/tree/main/shamir).

Both Node and browser environments are supported.

Made with ❤️ by [Privy](https://privy.io).

## Security considerations
Expand All @@ -18,12 +20,6 @@ There are a couple of considerations for proper use of this library.
2. This library is not responsible for verifying the result of share reconstruction. Incorrect or corrupted shares will produce an incorrect value. Thus, it is the responsibility of users of this library to verify the integrity of the reconstructed secret.
3. Secrets should ideally be uniformly distributed at random. If this is not the case, it is recommended to first encrypt the value and split the encryption key.

## Compatibility

Currently works in the browser and most recent versions of node (>= 17). The only reason for poor node support right now is the use of `crypto.getRandomValues()` from the Webcrypto spec. This exists in recent versions of node but not older ones.

There are future plans to make this work well in all node versions.

## Usage

We can `split` a secret into shares and later `combine` the shares to reconstruct the secret.
Expand Down
9 changes: 9 additions & 0 deletions esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "module",
"browser": {
"node:crypto": false
},
"node": {
"./csprng": "./esm/csprng.node.js"
}
}
4 changes: 0 additions & 4 deletions jest.config.js

This file was deleted.

Loading

0 comments on commit 9183a96

Please sign in to comment.