diff --git a/src/buckets.spec.ts b/src/buckets.spec.ts index c95b85196..75492ba61 100644 --- a/src/buckets.spec.ts +++ b/src/buckets.spec.ts @@ -180,6 +180,14 @@ describe('Buckets...', () => { expect(list.item?.itemsList).to.have.length(1) }) + it('should list bucket links', async () => { + const rootKey = buck.root?.key || '' + + const rep = await client.links(rootKey) + expect(rep.url).to.not.equal('') + expect(rep.ipns).to.not.equal('') + }) + it('should remove an entire bucket', async () => { const rootKey = buck.root?.key || '' const rep = await client.listPath(rootKey, 'dir1/file1.jpg') diff --git a/src/buckets.ts b/src/buckets.ts index 04c90c537..749861a51 100644 --- a/src/buckets.ts +++ b/src/buckets.ts @@ -61,6 +61,19 @@ export class Buckets { return res.toObject().rootsList } + /** + * Returns a list of bucket links. + * @param key Unique (IPNS compatible) identifier key for a bucket. + * @param ctx Context object containing web-gRPC headers and settings. + */ + async links(key: string, ctx?: Context) { + logger.debug('link request') + const req = new pb.LinksRequest() + req.setKey(key) + const res: pb.LinksReply = await this.unary(API.Links, req, ctx) + return res.toObject() + } + /** * Returns information about a bucket path. * @param key Unique (IPNS compatible) identifier key for a bucket.