Skip to content

Commit

Permalink
fix: almost working rollup bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianbormann committed Dec 7, 2022
1 parent ce86eab commit b36ed5a
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 15 deletions.
7 changes: 6 additions & 1 deletion .babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"presets": ["@babel/preset-typescript"]
"targets": ">0.5%",
"assumptions": {
"noDocumentAll": true,
"noClassCalls": true
},
"presets": ["@babel/preset-env"]
}
12 changes: 6 additions & 6 deletions meerkat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import nacl, { randomBytes } from 'tweetnacl';
import nacl from 'tweetnacl';
import type { SignKeyPair, BoxKeyPair } from 'tweetnacl';
import bs58check from 'bs58check';
import { Buffer } from 'buffer';
Expand All @@ -17,7 +17,7 @@ export default class Meerkat extends EventEmitter {
webTorrent: any;
seed: string;
torrent: any;
torrentCreated: boolean;
torrentCreated: boolean = false;
keyPair: SignKeyPair;
keyPairEncrypt: BoxKeyPair;
publicKey: string;
Expand All @@ -43,7 +43,7 @@ export default class Meerkat extends EventEmitter {
'wss://spacetradersapi-chatbox.herokuapp.com:443/announce',
'ws://tracker.files.fm:7072/announce',
];
this.seed = seed || this.encodeseed(randomBytes(32));
this.seed = seed || this.encodeseed(nacl.randomBytes(32));

this.keyPair = nacl.sign.keyPair.fromSeed(
Uint8Array.from(bs58check.decode(this.seed)).slice(2)
Expand All @@ -59,7 +59,7 @@ export default class Meerkat extends EventEmitter {
this.lastwirecount = null;

this.webTorrent = new WebTorrent();
this.torrent = this.webTorrent.seed(
/*this.torrent = this.webTorrent.seed(
Buffer.from(this.identifier),
{ name: this.identifier, announce: this.announce },
() => {
Expand All @@ -80,7 +80,7 @@ export default class Meerkat extends EventEmitter {
}
);
this.torrentCreated = true;
this.torrentCreated = true;*/
//this.torrent.on("wire", this.attach(this, this.identifier));
}

Expand Down Expand Up @@ -126,7 +126,7 @@ export default class Meerkat extends EventEmitter {
i: this.identifier,
pk: this.publicKey,
ek: this.encryptedPublicKey,
n: randomBytes(8),
n: nacl.randomBytes(8),
};

const encodedPacket = bencode_encode(packet);
Expand Down
210 changes: 210 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b36ed5a

Please sign in to comment.