Skip to content

Commit 7e191c9

Browse files
committed
fix: exports
1 parent b5f6c93 commit 7e191c9

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

js/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
"type": "module",
66
"exports": {
77
".": {
8-
"import": "./lib/index.js"
8+
"types": "./lib/index.d.ts",
9+
"default": "./lib/index.js"
910
},
1011
"./snarkjs": {
11-
"import": "./lib/snarkjs/operator.js"
12+
"types": "./lib/snarkjs/operator.d.ts",
13+
"default": "./lib/snarkjs/operator.js"
1214
},
1315
"./gnark": {
14-
"import": "./lib/gnark/index.js"
16+
"types": "./lib/gnark/index.d.ts",
17+
"default": "./lib/gnark/index.js"
1518
},
1619
"./expander": {
20+
"types": "./lib/expander/operator.d.ts",
1721
"import": "./lib/expander/operator.js"
1822
}
1923
},

js/readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ For `expander`: No additional dependencies needed
2121
### Generating & Verifying Proofs
2222

2323
```ts
24-
import { generateProof, verifyProof, makeSnarkJsZkOperator } from '@reclaimprotocol/zk-symmetric-crypto'
24+
import { generateProof, verifyProof } from '@reclaimprotocol/zk-symmetric-crypto'
25+
import { makeSnarkJsZkOperator } from '@reclaimprotocol/zk-symmetric-crypto/snarkjs'
2526
import { createCipheriv, randomBytes } from 'crypto'
2627

2728
async function main() {

js/src/file-fetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export function makeLocalFileFetch(
5353
// import here to avoid loading fs in
5454
// a browser env
5555
const { readFile } = await import('fs/promises')
56-
const { join, resolve, dirname } = await import('path')
57-
const __dirname = resolve(dirname(''))
56+
const { join, dirname } = await import('path')
57+
const __dirname = dirname(import.meta.url.replace('file://', ''))
5858
const fullPath = join(__dirname, path)
5959
const buff = await readFile(fullPath)
6060
return buff

js/src/gnark/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './operator.ts'
2+
export * from './toprf.ts'

js/src/gnark/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Base64 } from 'js-base64'
22
import type { EncryptionAlgorithm, FileFetch, Logger, ZKProofInput, ZKProofInputOPRF, ZKProofPublicSignals, ZKProofPublicSignalsOPRF, ZKTOPRFResponsePublicSignals } from '../types.ts'
33

4-
const BIN_PATH = './bin/gnark'
4+
const BIN_PATH = '../../bin/gnark'
55

66
let globalGnarkLib: ReturnType<typeof loadGnarkLib> | undefined
77

@@ -33,9 +33,9 @@ async function loadGnarkLib(): Promise<GnarkLib> {
3333
throw new Error('Koffi not available, cannot use gnark')
3434
}
3535

36-
const { join, dirname, resolve } = await import('path')
36+
const { join, dirname } = await import('path')
3737

38-
const __dirname = resolve(dirname(''))
38+
const __dirname = dirname(import.meta.url.replace('file://', ''))
3939
const { default: koffi } = koffiMod
4040
koffi.reset() //otherwise tests will fail
4141

js/src/tests/benchmark.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { randomBytes } from 'crypto'
22
import { Bench } from 'tinybench'
3-
import { CONFIG } from '../config'
4-
import { EncryptionAlgorithm, PrivateInput, PublicInput, ZKOperator } from '../types'
5-
import { generateZkWitness } from '../zk'
6-
import { encryptData, ZK_CONFIG_MAP, ZK_CONFIGS } from './utils'
3+
import { CONFIG } from '../config.ts'
4+
import type { EncryptionAlgorithm, PrivateInput, PublicInput, ZKOperator } from '../types.ts'
5+
import { generateZkWitness } from '../zk.ts'
6+
import { encryptData, ZK_CONFIG_MAP, ZK_CONFIGS } from './utils.ts'
77

88
const ALL_ALGOS: EncryptionAlgorithm[] = [
99
'chacha20',

0 commit comments

Comments
 (0)