user 6 år sedan
förälder
incheckning
a5f6d75db7
4 ändrade filer med 14 tillägg och 1 borttagningar
  1. 2 0
      lib/index.d.ts
  2. 6 0
      lib/index.js
  3. 1 1
      lib/index.js.map
  4. 5 0
      src/index.ts

+ 2 - 0
lib/index.d.ts

@@ -1,3 +1,4 @@
+import { ContactBook } from './contact-book';
 import { ContactItem } from './contact-item';
 import { ContentItem } from './content-item';
 import { Storage } from './storage';
@@ -30,6 +31,7 @@ export declare class BankClient {
     subscribePrivate(peerAddr: string, topic: string, connectCallback: () => void, messageCallback: (data: any) => void): Promise<void>;
     getOrCreateContact(peerId: string, contactAddr: string): Promise<ContactItem>;
     getAllContacts(peerId: string): Promise<ContactItem[]>;
+    getContactBook(peerId: string): Promise<ContactBook>;
     getContactById(peerId: string, contactId: string): Promise<ContactItem>;
     updateContact(peerId: string, contactId: string, newProperties: any): Promise<ContactItem>;
     getContentItemByHash(hash: string): Promise<ContentItem>;

+ 6 - 0
lib/index.js

@@ -11,6 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
     return (mod && mod.__esModule) ? mod : { "default": mod };
 };
 Object.defineProperty(exports, "__esModule", { value: true });
+const contact_book_1 = require("./contact-book");
 const crypto = require("libp2p-crypto");
 const ws_1 = __importDefault(require("ws"));
 const contact_item_1 = require("./contact-item");
@@ -258,6 +259,11 @@ class BankClient {
             return items.map(data => new contact_item_1.ContactItem(data));
         });
     }
+    getContactBook(peerId) {
+        return __awaiter(this, void 0, void 0, function* () {
+            return new contact_book_1.ContactBook(yield this.getAllContacts(peerId));
+        });
+    }
     getContactById(peerId, contactId) {
         return __awaiter(this, void 0, void 0, function* () {
             const itemList = yield this.getAllContacts(peerId);

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
lib/index.js.map


+ 5 - 0
src/index.ts

@@ -1,3 +1,4 @@
+import { ContactBook } from './contact-book';
 import crypto = require('libp2p-crypto');
 import WebSocket from 'ws';
 import { ContactItem } from './contact-item';
@@ -250,6 +251,10 @@ export class BankClient {
       return items.map(data => new ContactItem(data));
     }
 
+    public async getContactBook(peerId: string): Promise<ContactBook> {
+      return new ContactBook(await this.getAllContacts(peerId));
+    }
+
     public async getContactById(peerId: string, contactId: string): Promise<ContactItem> {
       const itemList = await this.getAllContacts(peerId);
       const existing = itemList.filter(item => item.id === contactId)[0];