Skip to content

Commit

Permalink
removed module.js from package.json
Browse files Browse the repository at this point in the history
imported Buffer everywhere so browsers don't need a polyfill
  • Loading branch information
CluEleSsUK committed Sep 21, 2023
1 parent 410e806 commit b780c90
Show file tree
Hide file tree
Showing 13 changed files with 404 additions and 6 deletions.
394 changes: 392 additions & 2 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "tlock-js",
"version": "0.6.1",
"version": "0.6.2",
"description": "A library to encrypt data that can only be decrypted in the future using drand",
"source": "src/index.ts",
"main": "index.js",
"module": "module.js",
"types": "index.d.ts",
"targets": {
"default": {
Expand Down
1 change: 1 addition & 0 deletions src/age/age-encrypt-decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {NoOpEncDec} from "./no-op-encdec"
import {readAge, writeAge} from "./age-reader-writer"
import {sliceUntil, unpaddedBase64Buffer} from "./utils"
import {createMacKey, random} from "./utils-crypto"
import {Buffer} from "buffer"

type FileKey = Uint8Array
type EncryptionWrapper = (fileKey: FileKey) => Promise<Array<Stanza>>
Expand Down
1 change: 1 addition & 0 deletions src/age/age-reader-writer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Buffer} from "buffer"
import {chunked, unpaddedBase64} from "./utils"
import {createMacKey} from "./utils-crypto"

Expand Down
1 change: 1 addition & 0 deletions src/age/armor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Buffer} from "buffer"
import {chunked} from "./utils"

const header = "-----BEGIN AGE ENCRYPTED FILE-----"
Expand Down
1 change: 1 addition & 0 deletions src/age/utils-crypto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {hkdf} from "@noble/hashes/hkdf"
import {sha256} from "@noble/hashes/sha256"
import {hmac} from "@noble/hashes/hmac"
import {Buffer} from "buffer"

export function createMacKey(fileKey: Uint8Array, macMessage: string, headerText: string): Uint8Array {
// empty string salt as per the spec!
Expand Down
2 changes: 2 additions & 0 deletions src/age/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {Buffer} from "buffer"

// as per the spec:
// RFC 4648, Section 4
// without = padding characters (sometimes referred to as "raw" or "unpadded" base64)
Expand Down
1 change: 1 addition & 0 deletions src/crypto/ibe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as bls from "@noble/bls12-381"
import {PointG1, PointG2, utils} from "@noble/bls12-381"
import {sha256} from "@noble/hashes/sha256"
import { Buffer } from "buffer"
import {bytesToNumberBE, fp12ToBytes, xor} from "./utils"

export interface Ciphertext {
Expand Down
1 change: 1 addition & 0 deletions src/crypto/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Buffer} from "buffer"
import {Fp, Fp12, Fp2} from "@noble/bls12-381"

// returns a new array with the xor of a ^ b
Expand Down
1 change: 1 addition & 0 deletions src/drand/timelock-decrypter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Stanza} from "../age/age-encrypt-decrypt"
import {PointG1, PointG2} from "@noble/bls12-381"
import {Buffer} from "buffer"
import {ChainClient, fetchBeacon, roundTime} from "drand-client"
import * as ibe from "../crypto/ibe"
import {Ciphertext, CiphertextOnG2} from "../crypto/ibe"
Expand Down
1 change: 1 addition & 0 deletions src/drand/timelock-encrypter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {PointG1, PointG2} from "@noble/bls12-381"
import {sha256} from "@noble/hashes/sha256"
import {Buffer} from "buffer"
import * as ibe from "../crypto/ibe"
import {ChainClient} from "drand-client"
import {Stanza} from "../age/age-encrypt-decrypt"
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {createTimelockEncrypter} from "./drand/timelock-encrypter"
import {decryptAge, encryptAge} from "./age/age-encrypt-decrypt"
import {decodeArmor, encodeArmor, isProbablyArmored} from "./age/armor"
import {createTimelockDecrypter} from "./drand/timelock-decrypter"
import {defaultChainInfo, defaultChainUrl, MAINNET_CHAIN_URL, TESTNET_CHAIN_INFO, TESTNET_CHAIN_URL} from "./drand/defaults"
import {defaultChainInfo, defaultChainUrl, MAINNET_CHAIN_URL, TESTNET_CHAIN_URL} from "./drand/defaults"
import {LIB_VERSION} from "./version"

export async function timelockEncrypt(
Expand Down
1 change: 0 additions & 1 deletion src/version.ts

This file was deleted.

0 comments on commit b780c90

Please sign in to comment.