Skip to content

Commit 143dee2

Browse files
authored
fix: expose crypto implementations (#614)
* fix: expose crypto implementations * chore: fix lint
1 parent 44aa97b commit 143dee2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
".": {
3434
"types": "./dist/src/index.d.ts",
3535
"import": "./dist/src/index.js"
36+
},
37+
"./crypto": {
38+
"types": "./dist/src/crypto/index.d.ts",
39+
"import": "./dist/src/crypto/index.js"
3640
}
3741
},
3842
"release": {

src/crypto/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const asImpl = new ChaCha20Poly1305(ctx)
1212
const CHACHA_POLY1305 = 'chacha20-poly1305'
1313
const PKCS8_PREFIX = Buffer.from([0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e, 0x04, 0x22, 0x04, 0x20])
1414
const X25519_PREFIX = Buffer.from([0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e, 0x03, 0x21, 0x00])
15-
const nodeCrypto: Pick<ICryptoInterface, 'hashSHA256' | 'chaCha20Poly1305Encrypt' | 'chaCha20Poly1305Decrypt'> = {
15+
16+
export { pureJsCrypto }
17+
18+
export const nodeCrypto: Pick<ICryptoInterface, 'hashSHA256' | 'chaCha20Poly1305Encrypt' | 'chaCha20Poly1305Decrypt'> = {
1619
hashSHA256 (data) {
1720
const hash = crypto.createHash('sha256')
1821

@@ -104,7 +107,7 @@ const nodeCrypto: Pick<ICryptoInterface, 'hashSHA256' | 'chaCha20Poly1305Encrypt
104107
}
105108
}
106109

107-
const asCrypto: Pick<ICryptoInterface, 'hashSHA256' | 'chaCha20Poly1305Encrypt' | 'chaCha20Poly1305Decrypt'> = {
110+
export const asCrypto: Pick<ICryptoInterface, 'hashSHA256' | 'chaCha20Poly1305Encrypt' | 'chaCha20Poly1305Decrypt'> = {
108111
hashSHA256 (data) {
109112
return digest(data.subarray())
110113
},

0 commit comments

Comments
 (0)