Skip to content

Commit

Permalink
WebCrypto Shim
Browse files Browse the repository at this point in the history
  • Loading branch information
Akamig committed Oct 30, 2023
1 parent 0210fa0 commit 83309ad
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 33 deletions.
26 changes: 9 additions & 17 deletions @planetarium/tx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,21 @@
"main": "./dist/index.js",
"imports": {
"#crypto": {
"node": "./src/webcrypto/crypto.ts",
"default": "./src/webcrypto/cryptoNode.ts"
}
"node": "./src/crypto/node.ts",
"default": "./src/crypto/browser.ts"
},
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./webcrypto/crypto": {
"types": "./src/webcrypto/crypto.d.ts",
"node": {
"import": "./src/webcrypto/cryptoNode.js",
"default": "./src/webcrypto/cryptoNode.cjs"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"import": "./src/webcrypto/crypto.js",
"default": "./src/webcrypto/crypto.cjs"
"browser": "./dist/index.browser.mjs",
"default": "./dist/index.js"
}
},
"browser": {
"./webcrypto/crypto": "./webcrypto/crypto.js",
"node:crypto": false

},
"types": "./dist/index.d.ts",
"files": [
Expand Down
1 change: 1 addition & 0 deletions @planetarium/tx/src/assets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { encode, RecordValue, RecordView, Value } from "@planetarium/bencodex";
import { Address, encodeAddressSet } from "./address.js";
import { crypto } from "#crypto";

export interface Currency {
ticker: string;
Expand Down
1 change: 1 addition & 0 deletions @planetarium/tx/src/crypto/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const crypto = window.crypto;
2 changes: 2 additions & 0 deletions @planetarium/tx/src/crypto/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Crypto } from "@peculiar/webcrypto";
export const crypto = new Crypto();
1 change: 1 addition & 0 deletions @planetarium/tx/src/tx/signed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BencodexDictionary, Dictionary, encode } from "@planetarium/bencodex";
import { Account, Address, Signature } from "@planetarium/account";
import { crypto } from "#crypto";
import { type UnsignedTx, encodeUnsignedTx } from "./unsigned.js";
import { bytesEqual } from "../bytes.js";

Expand Down
7 changes: 0 additions & 7 deletions @planetarium/tx/src/webcrypto/crypto.ts

This file was deleted.

9 changes: 0 additions & 9 deletions @planetarium/tx/src/webcrypto/cryptoNode.ts

This file was deleted.

0 comments on commit 83309ad

Please sign in to comment.