@veil-cash/sdk 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.cjs +35 -8
- package/dist/index.cjs +35 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/compat.ts +23 -0
- package/src/ffjavascript.d.ts +13 -8
- package/src/keypair.ts +1 -1
- package/src/utils.ts +1 -1
package/package.json
CHANGED
package/src/compat.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CJS/ESM interop for legacy dependencies that only ship CommonJS.
|
|
3
|
+
*
|
|
4
|
+
* eth-sig-util sets __esModule: true but has no default export — only named
|
|
5
|
+
* exports. circomlib uses module.exports = { poseidon, ... }.
|
|
6
|
+
*
|
|
7
|
+
* Using namespace imports (import * as X) works reliably across both tsup's
|
|
8
|
+
* CJS and ESM outputs, and browser bundlers (webpack/vite) handle them correctly.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as _ethSigUtil from 'eth-sig-util';
|
|
12
|
+
import * as _circomlib from 'circomlib';
|
|
13
|
+
|
|
14
|
+
function resolveInterop<T>(mod: T): T {
|
|
15
|
+
if (mod && typeof mod === 'object' && 'default' in (mod as object)) {
|
|
16
|
+
const defaultVal = (mod as unknown as { default: T }).default;
|
|
17
|
+
if (defaultVal != null) return defaultVal;
|
|
18
|
+
}
|
|
19
|
+
return mod;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const ethSigUtil = resolveInterop(_ethSigUtil);
|
|
23
|
+
export const circomlib = resolveInterop(_circomlib);
|
package/src/ffjavascript.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ declare module 'ffjavascript' {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
declare module 'circomlib' {
|
|
9
|
+
export const poseidon: (items: Array<bigint | string | number>) => { toString: () => string };
|
|
9
10
|
const circomlib: {
|
|
10
|
-
poseidon:
|
|
11
|
+
poseidon: typeof poseidon;
|
|
11
12
|
};
|
|
12
13
|
export default circomlib;
|
|
13
14
|
}
|
|
@@ -15,14 +16,18 @@ declare module 'circomlib' {
|
|
|
15
16
|
declare module 'eth-sig-util' {
|
|
16
17
|
import type { EncryptedMessage } from './types.js';
|
|
17
18
|
|
|
19
|
+
export function getEncryptionPublicKey(privateKey: string): string;
|
|
20
|
+
export function encrypt(
|
|
21
|
+
receiverPublicKey: string,
|
|
22
|
+
msgParams: { data: string },
|
|
23
|
+
version: 'x25519-xsalsa20-poly1305'
|
|
24
|
+
): EncryptedMessage;
|
|
25
|
+
export function decrypt(encryptedData: EncryptedMessage, receiverPrivateKey: string): string;
|
|
26
|
+
|
|
18
27
|
const ethSigUtil: {
|
|
19
|
-
getEncryptionPublicKey:
|
|
20
|
-
encrypt:
|
|
21
|
-
|
|
22
|
-
msgParams: { data: string },
|
|
23
|
-
version: 'x25519-xsalsa20-poly1305'
|
|
24
|
-
) => EncryptedMessage;
|
|
25
|
-
decrypt: (encryptedData: EncryptedMessage, receiverPrivateKey: string) => string;
|
|
28
|
+
getEncryptionPublicKey: typeof getEncryptionPublicKey;
|
|
29
|
+
encrypt: typeof encrypt;
|
|
30
|
+
decrypt: typeof decrypt;
|
|
26
31
|
};
|
|
27
32
|
export default ethSigUtil;
|
|
28
33
|
}
|
package/src/keypair.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { ethers } from 'ethers';
|
|
7
7
|
import { Buffer } from 'buffer';
|
|
8
8
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
9
|
-
import ethSigUtil from '
|
|
9
|
+
import { ethSigUtil } from './compat.js';
|
|
10
10
|
import { poseidonHash, toFixedHex } from './utils.js';
|
|
11
11
|
import type { EncryptedMessage } from './types.js';
|
|
12
12
|
|