user 6 anos atrás
pai
commit
f3d6c808bf
4 arquivos alterados com 23 adições e 1 exclusões
  1. 1 0
      lib/index.d.ts
  2. 11 0
      lib/index.js
  3. 1 1
      lib/index.js.map
  4. 10 0
      src/index.ts

+ 1 - 0
lib/index.d.ts

@@ -30,6 +30,7 @@ export declare class BankClient {
     getOrCreateContact(peerId: string, contactAddr: string): Promise<any>;
     getContactById(peerId: string, contactId: string): Promise<any>;
     updateContact(peerId: string, contactId: string, newProperties: any): Promise<any>;
+    getContentItemByHash(hash: string): Promise<any>;
     private getItemsForCommaList;
     private getPriv;
     private makePlaintextPayload;

+ 11 - 0
lib/index.js

@@ -311,6 +311,17 @@ class BankClient {
             return yield this.getContactById(peerId, contactId);
         });
     }
+    getContentItemByHash(hash) {
+        return __awaiter(this, void 0, void 0, function* () {
+            if (!hash.startsWith('/ipfs/')) {
+                hash = '/ipfs/' + hash;
+            }
+            return this.webClient.requestJSON({
+                method: 'get',
+                url: this.ipfsUrlBase + hash + '/content.json'
+            });
+        });
+    }
     getItemsForCommaList(commaList) {
         return __awaiter(this, void 0, void 0, function* () {
             const itemHashes = commaList.split(',').filter(x => x.trim() !== '');

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
lib/index.js.map


+ 10 - 0
src/index.ts

@@ -303,6 +303,16 @@ export class BankClient {
       return await this.getContactById(peerId, contactId);
     }
 
+    public async getContentItemByHash(hash: string): Promise<any> {
+      if (!hash.startsWith('/ipfs/')) {
+        hash = '/ipfs/' + hash;
+      }
+      return this.webClient.requestJSON({
+        method: 'get',
+        url: this.ipfsUrlBase + hash + '/content.json'
+      });
+    }
+
     private async getItemsForCommaList(commaList: string): Promise<any[]> {
       const itemHashes = commaList.split(',').filter(x => x.trim() !== '');
       const items: any[] = await Promise.all(itemHashes.map(itemId => {