@upcoming/bee-js 0.10.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { Binary } from 'cafe-utility';
1
+ import { Binary, Optional, Types } from 'cafe-utility';
2
2
  import { makeSingleOwnerChunkFromData, uploadSingleOwnerChunkData } from "../chunk/soc.js";
3
3
  import * as chunkAPI from "../modules/chunk.js";
4
- import { fetchLatestFeedUpdate } from "../modules/feed.js";
4
+ import { fetchLatestFeedUpdate, probeFeed } from "../modules/feed.js";
5
5
  import { Bytes } from "../utils/bytes.js";
6
6
  import { BeeResponseError } from "../utils/error.js";
7
7
  import { FeedIndex, Reference } from "../utils/typed-bytes.js";
@@ -23,7 +23,7 @@ export async function findNextIndex(requestOptions, owner, topic) {
23
23
  throw e;
24
24
  }
25
25
  }
26
- export async function updateFeed(requestOptions, signer, topic, reference, postageBatchId, options) {
26
+ export async function updateFeedWithReference(requestOptions, signer, topic, reference, postageBatchId, options) {
27
27
  reference = new Reference(reference);
28
28
  const nextIndex = options?.index ?? (await findNextIndex(requestOptions, signer.publicKey().address(), topic));
29
29
  const identifier = makeFeedIdentifier(topic, nextIndex);
@@ -32,45 +32,87 @@ export async function updateFeed(requestOptions, signer, topic, reference, posta
32
32
  const payloadBytes = Binary.concatBytes(timestamp, reference.toUint8Array());
33
33
  return uploadSingleOwnerChunkData(requestOptions, signer, postageBatchId, identifier, payloadBytes, options);
34
34
  }
35
+ export async function updateFeedWithPayload(requestOptions, signer, topic, data, postageBatchId, options) {
36
+ const nextIndex = options?.index ?? (await findNextIndex(requestOptions, signer.publicKey().address(), topic));
37
+ const identifier = makeFeedIdentifier(topic, nextIndex);
38
+ return uploadSingleOwnerChunkData(requestOptions, signer, postageBatchId, identifier, Types.isString(data) ? Bytes.fromUtf8(data).toUint8Array() : data, options);
39
+ }
35
40
  export function getFeedUpdateChunkReference(owner, topic, index) {
36
41
  const identifier = makeFeedIdentifier(topic, index);
37
42
  return new Reference(Binary.keccak256(Binary.concatBytes(identifier.toUint8Array(), owner.toUint8Array())));
38
43
  }
39
- export async function downloadFeedUpdate(requestOptions, owner, topic, index) {
44
+ export async function downloadFeedUpdate(requestOptions, owner, topic, index, hasTimestamp = false) {
40
45
  index = typeof index === 'number' ? FeedIndex.fromBigInt(BigInt(index)) : index;
41
46
  const address = getFeedUpdateChunkReference(owner, topic, index);
42
47
  const data = await chunkAPI.download(requestOptions, address.toHex());
43
48
  const soc = makeSingleOwnerChunkFromData(data, address);
44
- const timestampBytes = Bytes.fromSlice(soc.payload.toUint8Array(), TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
45
- const timestamp = Number(Binary.uint64ToNumber(timestampBytes.toUint8Array(), 'BE'));
49
+ let timestamp = Optional.empty();
50
+ if (hasTimestamp) {
51
+ const timestampBytes = Bytes.fromSlice(soc.payload.toUint8Array(), TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
52
+ timestamp = Optional.of(Number(Binary.uint64ToNumber(timestampBytes.toUint8Array(), 'BE')));
53
+ }
46
54
  return {
47
55
  timestamp,
48
- payload: new Bytes(soc.payload.offset(REFERENCE_PAYLOAD_OFFSET))
56
+ payload: new Bytes(soc.payload.offset(hasTimestamp ? REFERENCE_PAYLOAD_OFFSET : 0))
49
57
  };
50
58
  }
51
59
  export function makeFeedReader(requestOptions, topic, owner) {
60
+ // TODO: remove after enough time has passed in deprecated version
61
+ const download = async options => {
62
+ if (options?.index === undefined) {
63
+ return fetchLatestFeedUpdate(requestOptions, owner, topic);
64
+ }
65
+ const update = await downloadFeedUpdate(requestOptions, owner, topic, options.index, options.hasTimestamp ?? true);
66
+ const feedIndex = typeof options.index === 'number' ? FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
67
+ return {
68
+ payload: update.payload,
69
+ feedIndex
70
+ };
71
+ };
72
+ const downloadPayload = async options => {
73
+ if (options?.index === undefined) {
74
+ return fetchLatestFeedUpdate(requestOptions, owner, topic);
75
+ }
76
+ const update = await downloadFeedUpdate(requestOptions, owner, topic, options.index, options.hasTimestamp);
77
+ const feedIndex = typeof options.index === 'number' ? FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
78
+ return {
79
+ payload: update.payload,
80
+ feedIndex
81
+ };
82
+ };
83
+ const downloadReference = async options => {
84
+ let index = options?.index;
85
+ if (index === undefined) {
86
+ index = (await probeFeed(requestOptions, owner, topic)).feedIndex;
87
+ }
88
+ const payload = await download({
89
+ ...options,
90
+ index: index
91
+ });
92
+ return {
93
+ reference: new Reference(payload.payload.toUint8Array()),
94
+ feedIndex: payload.feedIndex
95
+ };
96
+ };
52
97
  return {
98
+ download,
99
+ downloadPayload,
100
+ downloadReference,
53
101
  owner,
54
- topic,
55
- async download(options) {
56
- if (options?.index === undefined) {
57
- return fetchLatestFeedUpdate(requestOptions, owner, topic);
58
- }
59
- const update = await downloadFeedUpdate(requestOptions, owner, topic, options.index);
60
- const feedIndex = typeof options.index === 'number' ? FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
61
- return {
62
- payload: update.payload,
63
- feedIndex
64
- };
65
- }
102
+ topic
66
103
  };
67
104
  }
68
105
  export function makeFeedWriter(requestOptions, topic, signer) {
69
106
  const upload = async (postageBatchId, reference, options) => {
70
- return updateFeed(requestOptions, signer, topic, reference, postageBatchId, options);
107
+ return updateFeedWithReference(requestOptions, signer, topic, reference, postageBatchId, options);
108
+ };
109
+ const uploadPayload = async (postageBatchId, data, options) => {
110
+ return updateFeedWithPayload(requestOptions, signer, topic, data, postageBatchId, options);
71
111
  };
72
112
  return {
73
113
  ...makeFeedReader(requestOptions, topic, signer.publicKey().address()),
74
- upload
114
+ upload,
115
+ uploadReference: upload,
116
+ uploadPayload
75
117
  };
76
118
  }
package/dist/mjs/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Bee } from "./bee.js";
2
2
  import { BeeDev } from "./bee-dev.js";
3
+ import { Stamper } from "./stamper/stamper.js";
3
4
  export { MerkleTree } from 'cafe-utility';
4
5
  export { MantarayNode } from "./manifest/manifest.js";
5
6
  export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./modules/debug/status.js";
@@ -11,4 +12,4 @@ export * from "./utils/error.js";
11
12
  export * as Utils from "./utils/expose.js";
12
13
  export * from "./utils/tokens.js";
13
14
  export * from "./utils/typed-bytes.js";
14
- export { Bee, BeeDev };
15
+ export { Bee, BeeDev, Stamper };
@@ -49,8 +49,8 @@ function readFeedUpdateHeaders(headers) {
49
49
  * index of the subsequent update.
50
50
  *
51
51
  * @param requestOptions Options for making requests
52
- * @param owner Owner's ethereum address in hex
53
- * @param topic Topic in hex
52
+ * @param owner Owner's ethereum address
53
+ * @param topic Topic
54
54
  * @param options Additional options, like index, at, type
55
55
  */
56
56
  export async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
@@ -63,4 +63,14 @@ export async function fetchLatestFeedUpdate(requestOptions, owner, topic, option
63
63
  payload: new Bytes(response.data),
64
64
  ...readFeedUpdateHeaders(response.headers)
65
65
  };
66
+ }
67
+ export async function probeFeed(requestOptions, owner, topic) {
68
+ const response = await http(requestOptions, {
69
+ responseType: 'arraybuffer',
70
+ url: `${feedEndpoint}/${owner}/${topic}`,
71
+ params: {
72
+ 'Swarm-Only-Root-Chunk': true
73
+ }
74
+ });
75
+ return readFeedUpdateHeaders(response.headers);
66
76
  }
@@ -0,0 +1,39 @@
1
+ import { Binary } from 'cafe-utility';
2
+ import { BatchId, PrivateKey } from "../utils/typed-bytes.js";
3
+ export class Stamper {
4
+ constructor(signer, batchId, buckets, depth) {
5
+ this.signer = new PrivateKey(signer);
6
+ this.batchId = new BatchId(batchId);
7
+ this.buckets = buckets;
8
+ this.depth = depth;
9
+ this.maxSlot = 2 ** (this.depth - 16);
10
+ }
11
+ static fromBlank(signer, batchId, depth) {
12
+ return new Stamper(signer, batchId, new Uint32Array(65536), depth);
13
+ }
14
+ static fromState(signer, batchId, buckets, depth) {
15
+ return new Stamper(signer, batchId, buckets, depth);
16
+ }
17
+ stamp(chunk) {
18
+ const address = chunk.hash();
19
+ const bucket = Binary.uint16ToNumber(address, 'BE');
20
+ const height = this.buckets[bucket];
21
+ if (height >= this.maxSlot) {
22
+ throw Error('Bucket is full');
23
+ }
24
+ this.buckets[bucket]++;
25
+ const index = Binary.concatBytes(Binary.numberToUint32(bucket, 'BE'), Binary.numberToUint32(height, 'BE'));
26
+ const timestamp = Binary.numberToUint64(BigInt(Date.now()), 'BE');
27
+ const signature = this.signer.sign(Binary.concatBytes(address, this.batchId.toUint8Array(), index, timestamp));
28
+ return {
29
+ batchId: this.batchId,
30
+ index,
31
+ issuer: this.signer.publicKey().address().toUint8Array(),
32
+ signature: signature.toUint8Array(),
33
+ timestamp
34
+ };
35
+ }
36
+ getState() {
37
+ return this.buckets;
38
+ }
39
+ }
@@ -61,4 +61,7 @@ export class Bytes {
61
61
  toJSON() {
62
62
  return JSON.parse(this.toUtf8());
63
63
  }
64
+ equals(other) {
65
+ return this.toHex() === new Bytes(other).toHex();
66
+ }
64
67
  }
@@ -55,6 +55,9 @@ export class Identifier extends Bytes {
55
55
  constructor(bytes) {
56
56
  super(bytes, 32);
57
57
  }
58
+ static fromString(value) {
59
+ return new Identifier(Binary.keccak256(ENCODER.encode(value)));
60
+ }
58
61
  }
59
62
  Identifier.LENGTH = 32;
60
63
  export class Reference extends Bytes {
@@ -126,6 +129,11 @@ export class Signature extends Bytes {
126
129
  const [x, y] = Elliptic.recoverPublicKey(Binary.concatBytes(ENCODER.encode(`\x19Ethereum Signed Message:\n32`), Binary.keccak256(digest instanceof Uint8Array ? digest : ENCODER.encode(digest))), r, s, v);
127
130
  return new PublicKey(Binary.concatBytes(Binary.numberToUint256(x, 'BE'), Binary.numberToUint256(y, 'BE')));
128
131
  }
132
+ isValid(digest, expectedAddress) {
133
+ const publicKey = this.recoverPublicKey(digest);
134
+ const address = publicKey.address();
135
+ return address.equals(expectedAddress);
136
+ }
129
137
  }
130
138
  Signature.LENGTH = 65;
131
139
  export class Topic extends Bytes {
@@ -148,4 +156,5 @@ export class FeedIndex extends Bytes {
148
156
  return Binary.uint64ToNumber(this.bytes, 'BE');
149
157
  }
150
158
  }
151
- FeedIndex.LENGTH = 8;
159
+ FeedIndex.LENGTH = 8;
160
+ FeedIndex.MINUS_ONE = new FeedIndex(new Uint8Array(8).fill(0xff, 0, 8));
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'stream';
3
3
  import { Chunk } from './chunk/cac';
4
- import { FetchFeedUpdateResponse } from './modules/feed';
4
+ import { FeedPayloadResult } from './modules/feed';
5
5
  import type { AllSettlements, BalanceResponse, BeeOptions, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, CollectionUploadOptions, DebugStatus, DownloadOptions, EnvelopeWithBatchId, FeedReader, FeedWriter, FileData, FileUploadOptions, GetGranteesResult, GlobalPostageBatch, GranteesResult, GsocMessageHandler, GsocSubscription, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, Pin, PingResponse, PostageBatch, PostageBatchBuckets, PssMessageHandler, PssSubscription, Readiness, RedistributionState, RedundantUploadOptions, ReferenceInformation, RemovePeerResponse, ReserveState, SOCReader, SOCWriter, Settlements, Tag, Topology, TransactionInfo, UploadOptions, WalletBalance } from './types';
6
6
  import { AllTagsOptions, Collection, PostageBatchOptions, TransactionOptions, UploadResult } from './types';
7
7
  import { Bytes } from './utils/bytes';
@@ -456,7 +456,7 @@ export declare class Bee {
456
456
  * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
457
457
  */
458
458
  makeFeedWriter(topic: Topic | Uint8Array | string, signer?: PrivateKey | Uint8Array | string, options?: BeeRequestOptions): FeedWriter;
459
- fetchLatestFeedUpdate(topic: Topic | Uint8Array | string, owner: EthAddress | Uint8Array | string, requestOptions?: BeeRequestOptions): Promise<FetchFeedUpdateResponse>;
459
+ fetchLatestFeedUpdate(topic: Topic | Uint8Array | string, owner: EthAddress | Uint8Array | string, requestOptions?: BeeRequestOptions): Promise<FeedPayloadResult>;
460
460
  /**
461
461
  * Returns an object for reading single owner chunks
462
462
  *
@@ -1,3 +1,4 @@
1
+ import { Optional } from 'cafe-utility';
1
2
  import { FeedUpdateOptions } from '../modules/feed';
2
3
  import { BeeRequestOptions, FeedReader, FeedWriter, UploadOptions, UploadResult } from '../types';
3
4
  import { Bytes } from '../utils/bytes';
@@ -9,12 +10,13 @@ export interface Epoch {
9
10
  export interface FeedUploadOptions extends UploadOptions, FeedUpdateOptions {
10
11
  }
11
12
  export interface FeedUpdate {
12
- timestamp: number;
13
+ timestamp: Optional<number>;
13
14
  payload: Bytes;
14
15
  }
15
16
  export declare function findNextIndex(requestOptions: BeeRequestOptions, owner: EthAddress, topic: Topic): Promise<FeedIndex>;
16
- export declare function updateFeed(requestOptions: BeeRequestOptions, signer: PrivateKey, topic: Topic, reference: Reference | string | Uint8Array, postageBatchId: BatchId, options?: FeedUploadOptions): Promise<UploadResult>;
17
+ export declare function updateFeedWithReference(requestOptions: BeeRequestOptions, signer: PrivateKey, topic: Topic, reference: Reference | string | Uint8Array, postageBatchId: BatchId, options?: FeedUploadOptions): Promise<UploadResult>;
18
+ export declare function updateFeedWithPayload(requestOptions: BeeRequestOptions, signer: PrivateKey, topic: Topic, data: Uint8Array | string, postageBatchId: BatchId, options?: FeedUploadOptions): Promise<UploadResult>;
17
19
  export declare function getFeedUpdateChunkReference(owner: EthAddress, topic: Topic, index: FeedIndex): Reference;
18
- export declare function downloadFeedUpdate(requestOptions: BeeRequestOptions, owner: EthAddress, topic: Topic, index: FeedIndex | number): Promise<FeedUpdate>;
20
+ export declare function downloadFeedUpdate(requestOptions: BeeRequestOptions, owner: EthAddress, topic: Topic, index: FeedIndex | number, hasTimestamp?: boolean): Promise<FeedUpdate>;
19
21
  export declare function makeFeedReader(requestOptions: BeeRequestOptions, topic: Topic, owner: EthAddress): FeedReader;
20
22
  export declare function makeFeedWriter(requestOptions: BeeRequestOptions, topic: Topic, signer: PrivateKey): FeedWriter;
@@ -1,5 +1,6 @@
1
1
  import { Bee } from './bee';
2
2
  import { BeeDev } from './bee-dev';
3
+ import { Stamper } from './stamper/stamper';
3
4
  export { MerkleTree } from 'cafe-utility';
4
5
  export { MantarayNode } from './manifest/manifest';
5
6
  export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from './modules/debug/status';
@@ -11,12 +12,13 @@ export * from './utils/error';
11
12
  export * as Utils from './utils/expose';
12
13
  export * from './utils/tokens';
13
14
  export * from './utils/typed-bytes';
14
- export { Bee, BeeDev };
15
+ export { Bee, BeeDev, Stamper };
15
16
  declare global {
16
17
  interface Window {
17
18
  BeeJs: {
18
19
  Bee: typeof import('./bee').Bee;
19
20
  BeeDev: typeof import('./bee-dev').BeeDev;
21
+ Stamper: typeof import('./stamper/stamper').Stamper;
20
22
  Utils: typeof import('./utils/expose');
21
23
  Duration: typeof import('./utils/duration').Duration;
22
24
  BeeError: typeof import('./utils/error').BeeError;
@@ -1,6 +1,6 @@
1
1
  import { Optional, Uint8ArrayReader } from 'cafe-utility';
2
2
  import { Bee, BeeRequestOptions, DownloadOptions, UploadOptions, UploadResult } from '..';
3
- import { FetchFeedUpdateResponse } from '../modules/feed';
3
+ import { FeedPayloadResult } from '../modules/feed';
4
4
  import { Bytes } from '../utils/bytes';
5
5
  import { BatchId, Reference } from '../utils/typed-bytes';
6
6
  export declare class Fork {
@@ -44,7 +44,7 @@ export declare class MantarayNode {
44
44
  /**
45
45
  * Attempts to resolve the manifest as a feed, returning the latest update.
46
46
  */
47
- resolveFeed(bee: Bee, requestOptions?: BeeRequestOptions): Promise<Optional<FetchFeedUpdateResponse>>;
47
+ resolveFeed(bee: Bee, requestOptions?: BeeRequestOptions): Promise<Optional<FeedPayloadResult>>;
48
48
  /**
49
49
  * Gets the binary representation of the node.
50
50
  */
@@ -10,6 +10,10 @@ export interface FeedUpdateOptions {
10
10
  * Fetch specific previous Feed's update (default fetches latest update)
11
11
  */
12
12
  index?: FeedIndex | number;
13
+ /**
14
+ * Whether the first 8 bytes of the payload are a timestamp
15
+ */
16
+ hasTimestamp?: boolean;
13
17
  }
14
18
  interface FeedUpdateHeaders {
15
19
  /**
@@ -22,9 +26,12 @@ interface FeedUpdateHeaders {
22
26
  */
23
27
  feedIndexNext?: FeedIndex;
24
28
  }
25
- export interface FetchFeedUpdateResponse extends FeedUpdateHeaders {
29
+ export interface FeedPayloadResult extends FeedUpdateHeaders {
26
30
  payload: Bytes;
27
31
  }
32
+ export interface FeedReferenceResult extends FeedUpdateHeaders {
33
+ reference: Reference;
34
+ }
28
35
  /**
29
36
  * Create an initial feed root manifest
30
37
  *
@@ -44,9 +51,10 @@ export declare function createFeedManifest(requestOptions: BeeRequestOptions, ow
44
51
  * index of the subsequent update.
45
52
  *
46
53
  * @param requestOptions Options for making requests
47
- * @param owner Owner's ethereum address in hex
48
- * @param topic Topic in hex
54
+ * @param owner Owner's ethereum address
55
+ * @param topic Topic
49
56
  * @param options Additional options, like index, at, type
50
57
  */
51
- export declare function fetchLatestFeedUpdate(requestOptions: BeeRequestOptions, owner: EthAddress, topic: Topic, options?: FeedUpdateOptions): Promise<FetchFeedUpdateResponse>;
58
+ export declare function fetchLatestFeedUpdate(requestOptions: BeeRequestOptions, owner: EthAddress, topic: Topic, options?: FeedUpdateOptions): Promise<FeedPayloadResult>;
59
+ export declare function probeFeed(requestOptions: BeeRequestOptions, owner: EthAddress, topic: Topic): Promise<FeedUpdateHeaders>;
52
60
  export {};
@@ -0,0 +1,15 @@
1
+ import { Chunk } from 'cafe-utility';
2
+ import { EnvelopeWithBatchId } from '../types';
3
+ import { BatchId, PrivateKey } from '../utils/typed-bytes';
4
+ export declare class Stamper {
5
+ signer: PrivateKey;
6
+ batchId: BatchId;
7
+ buckets: Uint32Array;
8
+ depth: number;
9
+ maxSlot: number;
10
+ private constructor();
11
+ static fromBlank(signer: PrivateKey | Uint8Array | string, batchId: BatchId | Uint8Array | string, depth: number): Stamper;
12
+ static fromState(signer: PrivateKey | Uint8Array | string, batchId: BatchId | Uint8Array | string, buckets: Uint32Array, depth: number): Stamper;
13
+ stamp(chunk: Chunk): EnvelopeWithBatchId;
14
+ getState(): Uint32Array;
15
+ }
@@ -1,7 +1,7 @@
1
1
  import { Optional } from 'cafe-utility';
2
2
  import type { SingleOwnerChunk } from '../chunk/soc';
3
3
  import type { FeedUploadOptions } from '../feed';
4
- import type { FeedUpdateOptions, FetchFeedUpdateResponse } from '../modules/feed';
4
+ import type { FeedPayloadResult, FeedReferenceResult, FeedUpdateOptions } from '../modules/feed';
5
5
  import { Bytes } from '../utils/bytes';
6
6
  import { Duration } from '../utils/duration';
7
7
  import type { BeeError } from '../utils/error';
@@ -301,9 +301,17 @@ export interface FeedReader {
301
301
  readonly owner: EthAddress;
302
302
  readonly topic: Topic;
303
303
  /**
304
- * Download the latest feed update
304
+ * @deprecated Use `downloadReference` or `downloadPayload` instead to disambiguate how the data should be interpreted.
305
305
  */
306
- download(options?: FeedUpdateOptions): Promise<FetchFeedUpdateResponse>;
306
+ download(options?: FeedUpdateOptions): Promise<FeedPayloadResult>;
307
+ /**
308
+ * Downloads the feed update (latest if no index is specified) and returns it as a reference.
309
+ */
310
+ downloadReference(options?: FeedUpdateOptions): Promise<FeedReferenceResult>;
311
+ /**
312
+ * Downloads the feed update (latest if no index is specified) and returns it as a payload.
313
+ */
314
+ downloadPayload(options?: FeedUpdateOptions): Promise<FeedPayloadResult>;
307
315
  }
308
316
  /**
309
317
  * FeedWriter is an interface for updating feeds
@@ -312,6 +320,8 @@ export interface FeedWriter extends FeedReader {
312
320
  /**
313
321
  * Upload a new feed update
314
322
  *
323
+ * @deprecated Use `uploadReference` or `uploadPayload` instead to disambiguate how the data should be interpreted.
324
+ *
315
325
  * @param postageBatchId Postage BatchId to be used to upload the data with
316
326
  * @param reference The reference to be stored in the new update
317
327
  * @param options Additional options like `at`
@@ -319,6 +329,8 @@ export interface FeedWriter extends FeedReader {
319
329
  * @returns UpdateResult that points at Single Owner Chunk that contains the new update and pointer to the updated chunk reference.
320
330
  */
321
331
  upload(postageBatchId: string | BatchId, reference: Reference | string | Uint8Array, options?: FeedUploadOptions): Promise<UploadResult>;
332
+ uploadReference(postageBatchId: string | BatchId, reference: Reference | string | Uint8Array, options?: FeedUploadOptions): Promise<UploadResult>;
333
+ uploadPayload(postageBatchId: string | BatchId, payload: Uint8Array | string, options?: FeedUploadOptions): Promise<UploadResult>;
322
334
  }
323
335
  /**
324
336
  * Interface for downloading single owner chunks
@@ -13,4 +13,5 @@ export declare class Bytes {
13
13
  toString(): string;
14
14
  toUtf8(): string;
15
15
  toJSON(): unknown;
16
+ equals(other: Bytes | Uint8Array | string): boolean;
16
17
  }
@@ -20,6 +20,7 @@ export declare class EthAddress extends Bytes {
20
20
  export declare class Identifier extends Bytes {
21
21
  static readonly LENGTH = 32;
22
22
  constructor(bytes: Uint8Array | string | Bytes);
23
+ static fromString(value: string): Identifier;
23
24
  }
24
25
  export declare class Reference extends Bytes {
25
26
  static readonly LENGTH = 32;
@@ -51,6 +52,7 @@ export declare class Signature extends Bytes {
51
52
  constructor(bytes: Uint8Array | string | Bytes);
52
53
  static fromSlice(bytes: Uint8Array, start: number): Signature;
53
54
  recoverPublicKey(digest: Uint8Array | string): PublicKey;
55
+ isValid(digest: Uint8Array | string, expectedAddress: EthAddress | Uint8Array | string): boolean;
54
56
  }
55
57
  export declare class Topic extends Bytes {
56
58
  static readonly LENGTH = 32;
@@ -59,6 +61,7 @@ export declare class Topic extends Bytes {
59
61
  }
60
62
  export declare class FeedIndex extends Bytes {
61
63
  static readonly LENGTH = 8;
64
+ static readonly MINUS_ONE: FeedIndex;
62
65
  constructor(bytes: Uint8Array | string | Bytes);
63
66
  static fromBigInt(number: bigint): FeedIndex;
64
67
  toBigInt(): bigint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upcoming/bee-js",
3
- "version": "0.10.1",
3
+ "version": "0.12.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",