diff --git a/dist/index.d.ts b/dist/index.d.ts index f47ee4e..686e762 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -6,6 +6,7 @@ import { Buffer } from "buffer"; export declare class DHT { connect(pubkey: string): Promise; ready(): Promise; + addRelay(pubkey: string): Promise; } export declare class Socket extends EventEmitter { private id; diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map index 7f9279d..f4e9920 100644 --- a/dist/index.d.ts.map +++ b/dist/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAU,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAehC,qBAAa,GAAG;IACC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ/C,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC;CAGnC;AAED,qBAAa,MAAO,SAAQ,YAAY;IACpC,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,YAAY,CAAqC;gBAE7C,EAAE,EAAE,MAAM;IAKtB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IAkB/D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;IAStC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC,GAAG,IAAI,IAAI;IAIX,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,UAAU;CAIrB"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAU,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAehC,qBAAa,GAAG;IACD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ/C,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC;IAInB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMrD;AAED,qBAAa,MAAO,SAAQ,YAAY;IACtC,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,YAAY,CAAqC;gBAE7C,EAAE,EAAE,MAAM;IAKtB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IAkB/D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;IAStC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC,GAAG,IAAI,IAAI;IAIX,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,UAAU;CAInB"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index e29aa8c..a70be00 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15,13 +15,19 @@ export class DHT { async connect(pubkey) { const [resp, err] = await callModule(DHT_MODULE, "connect", { pubkey }); if (err) { - throw err; + throw new Error(err); } return new Socket(resp.id); } async ready() { return callModule(DHT_MODULE, "ready"); } + async addRelay(pubkey) { + const [, err] = await callModule(DHT_MODULE, "addRelay", { pubkey }); + if (err) { + throw new Error(err); + } + } } export class Socket extends EventEmitter { id;