@ethersphere/bee-js 13.0.0-upcoming.gcfb9756 → 13.0.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.
- package/README.md +104 -103
- package/dist/cjs/api/bytes.js +3 -4
- package/dist/cjs/api/bzz.js +5 -6
- package/dist/cjs/api/chunk.js +3 -3
- package/dist/cjs/api/envelope.js +3 -2
- package/dist/cjs/api/feed.js +4 -5
- package/dist/cjs/api/pin.js +2 -2
- package/dist/cjs/api/soc.js +2 -2
- package/dist/cjs/bee.js +18 -19
- package/dist/cjs/chunk/soc.js +21 -63
- package/dist/cjs/feed/identifier.js +3 -4
- package/dist/cjs/feed/index.js +17 -19
- package/dist/cjs/feed/retrievable.js +2 -2
- package/dist/cjs/index.js +18 -8
- package/dist/cjs/manifest/manifest.js +97 -333
- package/dist/cjs/modules/balance.js +3 -3
- package/dist/cjs/modules/cheque.js +4 -4
- package/dist/cjs/modules/chunk.js +8 -8
- package/dist/cjs/modules/collection.js +6 -6
- package/dist/cjs/modules/connectivity.js +3 -3
- package/dist/cjs/modules/data.js +6 -6
- package/dist/cjs/modules/feed.js +10 -10
- package/dist/cjs/modules/file.js +3 -3
- package/dist/cjs/modules/grantee.js +9 -9
- package/dist/cjs/modules/messaging.js +15 -17
- package/dist/cjs/modules/pin.js +6 -6
- package/dist/cjs/modules/settlement.js +2 -2
- package/dist/cjs/modules/soc.js +3 -3
- package/dist/cjs/modules/stamp.js +7 -7
- package/dist/cjs/modules/tag.js +2 -2
- package/dist/cjs/modules/transaction.js +4 -4
- package/dist/cjs/modules/wallet.js +3 -3
- package/dist/cjs/types/schema/chequebook.js +5 -5
- package/dist/cjs/types/schema/connectivity.js +5 -5
- package/dist/cjs/types/schema/envelope.js +5 -5
- package/dist/cjs/types/schema/grantee.js +4 -4
- package/dist/cjs/types/schema/stake.js +2 -2
- package/dist/cjs/types/schema/stamps.js +4 -4
- package/dist/cjs/types/schema/states.js +2 -2
- package/dist/cjs/types/schema/transactions.js +3 -3
- package/dist/cjs/types/schema/upload.js +2 -2
- package/dist/cjs/utils/chunk-stream.browser.js +24 -16
- package/dist/cjs/utils/chunk-stream.js +17 -9
- package/dist/cjs/utils/constants.js +3 -3
- package/dist/cjs/utils/expose.js +4 -4
- package/dist/cjs/utils/headers.js +4 -4
- package/dist/cjs/utils/http.js +3 -1
- package/dist/cjs/utils/pss.js +2 -2
- package/dist/cjs/utils/resource-locator.js +2 -2
- package/dist/cjs/utils/schema.js +4 -4
- package/dist/cjs/utils/stamps.js +15 -130
- package/dist/cjs/utils/type.js +2 -2
- package/dist/codemod/index.js +141 -0
- package/dist/codemod/transforms/v13.js +524 -0
- package/dist/index.browser.min.js +2 -1
- package/dist/index.browser.min.js.LICENSE.txt +3 -0
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/api/bytes.js +1 -2
- package/dist/mjs/api/bzz.js +1 -2
- package/dist/mjs/api/chunk.js +1 -1
- package/dist/mjs/api/envelope.js +3 -2
- package/dist/mjs/api/feed.js +1 -2
- package/dist/mjs/api/pin.js +1 -1
- package/dist/mjs/api/soc.js +1 -1
- package/dist/mjs/bee.js +13 -14
- package/dist/mjs/chunk/soc.js +11 -49
- package/dist/mjs/feed/identifier.js +2 -3
- package/dist/mjs/feed/index.js +6 -8
- package/dist/mjs/feed/retrievable.js +1 -1
- package/dist/mjs/index.js +2 -5
- package/dist/mjs/manifest/manifest.js +95 -339
- package/dist/mjs/modules/balance.js +1 -1
- package/dist/mjs/modules/cheque.js +1 -1
- package/dist/mjs/modules/chunk.js +1 -1
- package/dist/mjs/modules/collection.js +1 -1
- package/dist/mjs/modules/connectivity.js +1 -1
- package/dist/mjs/modules/data.js +3 -3
- package/dist/mjs/modules/feed.js +1 -1
- package/dist/mjs/modules/file.js +1 -1
- package/dist/mjs/modules/grantee.js +1 -1
- package/dist/mjs/modules/messaging.js +3 -5
- package/dist/mjs/modules/pin.js +1 -1
- package/dist/mjs/modules/settlement.js +1 -1
- package/dist/mjs/modules/soc.js +1 -1
- package/dist/mjs/modules/stamp.js +1 -1
- package/dist/mjs/modules/tag.js +1 -1
- package/dist/mjs/modules/transaction.js +1 -1
- package/dist/mjs/modules/wallet.js +1 -1
- package/dist/mjs/types/schema/chequebook.js +1 -1
- package/dist/mjs/types/schema/connectivity.js +1 -1
- package/dist/mjs/types/schema/envelope.js +5 -5
- package/dist/mjs/types/schema/grantee.js +1 -1
- package/dist/mjs/types/schema/stake.js +1 -1
- package/dist/mjs/types/schema/stamps.js +1 -1
- package/dist/mjs/types/schema/states.js +1 -1
- package/dist/mjs/types/schema/transactions.js +1 -1
- package/dist/mjs/types/schema/upload.js +1 -1
- package/dist/mjs/utils/chunk-stream.browser.js +28 -18
- package/dist/mjs/utils/chunk-stream.js +21 -11
- package/dist/mjs/utils/constants.js +1 -1
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/headers.js +1 -1
- package/dist/mjs/utils/http.js +6 -1
- package/dist/mjs/utils/pss.js +1 -1
- package/dist/mjs/utils/resource-locator.js +1 -1
- package/dist/mjs/utils/schema.js +1 -1
- package/dist/mjs/utils/stamps.js +5 -99
- package/dist/mjs/utils/type.js +2 -2
- package/dist/types/api/balance.d.ts +1 -1
- package/dist/types/api/batches.d.ts +1 -1
- package/dist/types/api/bytes.d.ts +3 -3
- package/dist/types/api/bzz.d.ts +1 -2
- package/dist/types/api/chequebook.d.ts +1 -1
- package/dist/types/api/chunk.d.ts +1 -1
- package/dist/types/api/connectivity.d.ts +1 -1
- package/dist/types/api/consumed.d.ts +1 -1
- package/dist/types/api/envelope.d.ts +1 -1
- package/dist/types/api/feed.d.ts +1 -2
- package/dist/types/api/grantee.d.ts +1 -1
- package/dist/types/api/pin.d.ts +1 -1
- package/dist/types/api/pss.d.ts +1 -1
- package/dist/types/api/settlement.d.ts +1 -1
- package/dist/types/api/soc.d.ts +1 -1
- package/dist/types/api/stake.d.ts +1 -1
- package/dist/types/api/stamp.d.ts +1 -1
- package/dist/types/api/stewardship.d.ts +1 -1
- package/dist/types/api/tag.d.ts +1 -1
- package/dist/types/api/transaction.d.ts +1 -1
- package/dist/types/api/wallet.d.ts +1 -1
- package/dist/types/bee.d.ts +11 -13
- package/dist/types/chunk/soc.d.ts +3 -48
- package/dist/types/feed/identifier.d.ts +1 -1
- package/dist/types/feed/index.d.ts +1 -3
- package/dist/types/feed/retrievable.d.ts +1 -1
- package/dist/types/index.d.ts +17 -20
- package/dist/types/manifest/manifest.d.ts +24 -33
- package/dist/types/modules/balance.d.ts +1 -1
- package/dist/types/modules/cheque.d.ts +1 -1
- package/dist/types/modules/chequebook.d.ts +1 -1
- package/dist/types/modules/chunk.d.ts +1 -2
- package/dist/types/modules/collection.d.ts +2 -2
- package/dist/types/modules/connectivity.d.ts +1 -1
- package/dist/types/modules/context.d.ts +1 -1
- package/dist/types/modules/data.d.ts +3 -3
- package/dist/types/modules/feed.d.ts +1 -1
- package/dist/types/modules/file.d.ts +1 -2
- package/dist/types/modules/grantee.d.ts +1 -1
- package/dist/types/modules/messaging.d.ts +1 -2
- package/dist/types/modules/pin.d.ts +1 -1
- package/dist/types/modules/settlement.d.ts +1 -1
- package/dist/types/modules/soc.d.ts +1 -1
- package/dist/types/modules/stake.d.ts +1 -1
- package/dist/types/modules/stamp.d.ts +1 -1
- package/dist/types/modules/storage.d.ts +1 -1
- package/dist/types/modules/tag.d.ts +1 -1
- package/dist/types/modules/transaction.d.ts +1 -1
- package/dist/types/modules/wallet.d.ts +1 -1
- package/dist/types/types/debug.d.ts +1 -1
- package/dist/types/types/index.d.ts +2 -11
- package/dist/types/types/schema/chequebook.d.ts +1 -1
- package/dist/types/types/schema/connectivity.d.ts +1 -1
- package/dist/types/types/schema/grantee.d.ts +1 -1
- package/dist/types/types/schema/stake.d.ts +1 -1
- package/dist/types/types/schema/stamps.d.ts +1 -1
- package/dist/types/types/schema/states.d.ts +1 -1
- package/dist/types/types/schema/transactions.d.ts +1 -1
- package/dist/types/types/schema/upload.d.ts +1 -1
- package/dist/types/utils/chunk-stream.browser.d.ts +1 -1
- package/dist/types/utils/chunk-stream.d.ts +2 -2
- package/dist/types/utils/constants.d.ts +1 -1
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/headers.d.ts +1 -1
- package/dist/types/utils/pss.d.ts +1 -1
- package/dist/types/utils/resource-locator.d.ts +1 -1
- package/dist/types/utils/schema.d.ts +1 -1
- package/dist/types/utils/stamps.d.ts +2 -27
- package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
- package/dist/types/utils/tar-uploader.d.ts +1 -1
- package/dist/types/utils/type.d.ts +1 -1
- package/package.json +7 -2
- package/dist/cjs/chunk/bmt.js +0 -37
- package/dist/cjs/chunk/cac.js +0 -43
- package/dist/cjs/stamper/stamper.js +0 -44
- package/dist/cjs/utils/bytes.js +0 -116
- package/dist/cjs/utils/cid.js +0 -37
- package/dist/cjs/utils/redundancy.js +0 -133
- package/dist/cjs/utils/typed-bytes.js +0 -186
- package/dist/mjs/chunk/bmt.js +0 -34
- package/dist/mjs/chunk/cac.js +0 -34
- package/dist/mjs/stamper/stamper.js +0 -40
- package/dist/mjs/utils/bytes.js +0 -102
- package/dist/mjs/utils/cid.js +0 -32
- package/dist/mjs/utils/redundancy.js +0 -98
- package/dist/mjs/utils/typed-bytes.js +0 -167
- package/dist/types/chunk/bmt.d.ts +0 -16
- package/dist/types/chunk/cac.d.ts +0 -40
- package/dist/types/stamper/stamper.d.ts +0 -15
- package/dist/types/utils/bytes.d.ts +0 -19
- package/dist/types/utils/cid.d.ts +0 -10
- package/dist/types/utils/redundancy.d.ts +0 -21
- package/dist/types/utils/typed-bytes.d.ts +0 -69
package/dist/mjs/api/bytes.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { Bytes, Reference } from '@ethersphere/core-sdk';
|
|
1
2
|
import { Optional } from 'cafe-utility';
|
|
2
3
|
import { UploadResultBody } from "../types/schema/upload.js";
|
|
3
|
-
import { Bytes } from "../utils/bytes.js";
|
|
4
4
|
import { prepareRequestHeaders } from "../utils/headers.js";
|
|
5
5
|
import { http } from "../utils/http.js";
|
|
6
6
|
import { DownloadOptionsSchema } from "../utils/schema.js";
|
|
7
7
|
import { makeTagUid } from "../utils/type.js";
|
|
8
|
-
import { Reference } from "../utils/typed-bytes.js";
|
|
9
8
|
const endpoint = 'bytes';
|
|
10
9
|
/**
|
|
11
10
|
* Raw HTTP calls for the `/bytes` endpoint.
|
package/dist/mjs/api/bzz.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { Bytes, Reference } from '@ethersphere/core-sdk';
|
|
1
2
|
import { Optional } from 'cafe-utility';
|
|
2
3
|
import { UploadResultBody } from "../types/schema/upload.js";
|
|
3
|
-
import { Bytes } from "../utils/bytes.js";
|
|
4
4
|
import { assertCollection } from "../utils/collection.js";
|
|
5
5
|
import { prepareRequestHeaders, readFileHeaders } from "../utils/headers.js";
|
|
6
6
|
import { http } from "../utils/http.js";
|
|
7
7
|
import { uploadTar } from "../utils/tar-uploader.js";
|
|
8
8
|
import { isReadable, makeTagUid } from "../utils/type.js";
|
|
9
|
-
import { Reference } from "../utils/typed-bytes.js";
|
|
10
9
|
const bzzEndpoint = 'bzz';
|
|
11
10
|
/**
|
|
12
11
|
* Raw HTTP calls for the `/bzz` endpoint.
|
package/dist/mjs/api/chunk.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Reference } from '@ethersphere/core-sdk';
|
|
1
2
|
import { Optional } from 'cafe-utility';
|
|
2
3
|
import { UploadResultBody } from "../types/schema/upload.js";
|
|
3
4
|
import { prepareRequestHeaders } from "../utils/headers.js";
|
|
4
5
|
import { http } from "../utils/http.js";
|
|
5
6
|
import { makeTagUid } from "../utils/type.js";
|
|
6
|
-
import { Reference } from "../utils/typed-bytes.js";
|
|
7
7
|
const endpoint = 'chunks';
|
|
8
8
|
/**
|
|
9
9
|
* Raw HTTP calls for the `/chunks` endpoint.
|
package/dist/mjs/api/envelope.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EthAddress, Signature } from '@ethersphere/core-sdk';
|
|
1
2
|
import { PostEnvelopeBodyResponse } from "../types/schema/envelope.js";
|
|
2
3
|
import { http } from "../utils/http.js";
|
|
3
4
|
const ENVELOPE_ENDPOINT = 'envelope';
|
|
@@ -12,10 +13,10 @@ export async function postEnvelope(requestOptions, postageBatchId, reference) {
|
|
|
12
13
|
});
|
|
13
14
|
const body = PostEnvelopeBodyResponse.parse(response.data);
|
|
14
15
|
return {
|
|
15
|
-
issuer: body.issuer,
|
|
16
|
+
issuer: new EthAddress(body.issuer),
|
|
16
17
|
index: body.index,
|
|
17
18
|
timestamp: body.timestamp,
|
|
18
|
-
signature: body.signature,
|
|
19
|
+
signature: new Signature(body.signature),
|
|
19
20
|
batchId: postageBatchId
|
|
20
21
|
};
|
|
21
22
|
}
|
package/dist/mjs/api/feed.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { Bytes, FeedIndex } from '@ethersphere/core-sdk';
|
|
1
2
|
import { UploadResultBody } from "../types/schema/upload.js";
|
|
2
|
-
import { Bytes } from "../utils/bytes.js";
|
|
3
3
|
import { BeeError } from "../utils/error.js";
|
|
4
4
|
import { prepareRequestHeaders } from "../utils/headers.js";
|
|
5
5
|
import { http } from "../utils/http.js";
|
|
6
|
-
import { FeedIndex } from "../utils/typed-bytes.js";
|
|
7
6
|
const feedEndpoint = 'feeds';
|
|
8
7
|
export async function createFeedManifest(requestOptions, owner, topic, stamp, options) {
|
|
9
8
|
const response = await http(requestOptions, {
|
package/dist/mjs/api/pin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Reference } from '@ethersphere/core-sdk';
|
|
1
2
|
import { GetAllPinsResponse } from "../types/schema/pinning.js";
|
|
2
3
|
import { UploadResultBody } from "../types/schema/upload.js";
|
|
3
4
|
import { http } from "../utils/http.js";
|
|
4
|
-
import { Reference } from "../utils/typed-bytes.js";
|
|
5
5
|
const PINNING_ENDPOINT = 'pins';
|
|
6
6
|
/** Pins local data with the given reference. */
|
|
7
7
|
export async function pin(requestOptions, reference) {
|
package/dist/mjs/api/soc.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Reference } from '@ethersphere/core-sdk';
|
|
1
2
|
import { Optional } from 'cafe-utility';
|
|
2
3
|
import { UploadResultBody } from "../types/schema/upload.js";
|
|
3
4
|
import { prepareRequestHeaders } from "../utils/headers.js";
|
|
4
5
|
import { http } from "../utils/http.js";
|
|
5
6
|
import { makeTagUid } from "../utils/type.js";
|
|
6
|
-
import { Reference } from "../utils/typed-bytes.js";
|
|
7
7
|
const socEndpoint = 'soc';
|
|
8
8
|
/**
|
|
9
9
|
* Raw HTTP calls for the `/soc` endpoint.
|
package/dist/mjs/bee.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { Objects } from 'cafe-utility';
|
|
2
|
-
import { makeContentAddressedChunk, unmarshalContentAddressedChunk } from
|
|
2
|
+
import { BatchId, PrivateKey, Reference, makeContentAddressedChunk, unmarshalContentAddressedChunk } from '@ethersphere/core-sdk';
|
|
3
|
+
import { postEnvelope } from "./api/envelope.js";
|
|
4
|
+
import { rchash } from "./api/rchash.js";
|
|
3
5
|
import { makeSOCAddress, makeSingleOwnerChunk, unmarshalSingleOwnerChunk } from "./chunk/soc.js";
|
|
4
6
|
import { Balance } from "./modules/balance.js";
|
|
5
7
|
import { Cheque } from "./modules/cheque.js";
|
|
6
8
|
import { Chequebook } from "./modules/chequebook.js";
|
|
7
|
-
import { Connectivity } from "./modules/connectivity.js";
|
|
8
|
-
import { Settlement } from "./modules/settlement.js";
|
|
9
|
-
import { Stake } from "./modules/stake.js";
|
|
10
|
-
import { Stamp } from "./modules/stamp.js";
|
|
11
|
-
import { Storage } from "./modules/storage.js";
|
|
12
|
-
import { Status } from "./modules/status.js";
|
|
13
|
-
import { Wallet } from "./modules/wallet.js";
|
|
14
|
-
import { Transaction } from "./modules/transaction.js";
|
|
15
|
-
import { postEnvelope } from "./api/envelope.js";
|
|
16
9
|
import { Chunk as ChunkNamespace } from "./modules/chunk.js";
|
|
17
10
|
import { Collection } from "./modules/collection.js";
|
|
11
|
+
import { Connectivity } from "./modules/connectivity.js";
|
|
18
12
|
import { Data } from "./modules/data.js";
|
|
19
|
-
import { File as FileNamespace } from "./modules/file.js";
|
|
20
13
|
import { Feed } from "./modules/feed.js";
|
|
21
|
-
import {
|
|
14
|
+
import { File as FileNamespace } from "./modules/file.js";
|
|
22
15
|
import { Grantee } from "./modules/grantee.js";
|
|
23
16
|
import { Messaging } from "./modules/messaging.js";
|
|
24
17
|
import { Pin } from "./modules/pin.js";
|
|
25
|
-
import {
|
|
18
|
+
import { Settlement } from "./modules/settlement.js";
|
|
19
|
+
import { Soc } from "./modules/soc.js";
|
|
20
|
+
import { Stake } from "./modules/stake.js";
|
|
21
|
+
import { Stamp } from "./modules/stamp.js";
|
|
22
|
+
import { Status } from "./modules/status.js";
|
|
23
|
+
import { Storage } from "./modules/storage.js";
|
|
26
24
|
import { Tag } from "./modules/tag.js";
|
|
25
|
+
import { Transaction } from "./modules/transaction.js";
|
|
26
|
+
import { Wallet } from "./modules/wallet.js";
|
|
27
27
|
import { BeeRequestOptionsSchema } from "./utils/schema.js";
|
|
28
|
-
import { BatchId, PrivateKey, Reference } from "./utils/typed-bytes.js";
|
|
29
28
|
import { assertBeeUrl, stripLastSlash } from "./utils/url.js";
|
|
30
29
|
/**
|
|
31
30
|
* The main component that abstracts operations available on the Bee API.
|
package/dist/mjs/chunk/soc.js
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bytes, EthAddress, Identifier, PrivateKey, makeContentAddressedChunk, makeSOCAddress, makeSingleOwnerChunk as coreMakeSingleOwnerChunk, unmarshalSingleOwnerChunk as coreUnmarshalSingleOwnerChunk } from '@ethersphere/core-sdk';
|
|
2
2
|
import * as chunkAPI from "../api/chunk.js";
|
|
3
3
|
import * as socAPI from "../api/soc.js";
|
|
4
|
-
import { Bytes } from "../utils/bytes.js";
|
|
5
4
|
import { BeeError } from "../utils/error.js";
|
|
6
|
-
|
|
7
|
-
import { calculateChunkAddress } from "./bmt.js";
|
|
8
|
-
import { makeContentAddressedChunk } from "./cac.js";
|
|
9
|
-
const SOC_SIGNATURE_OFFSET = Identifier.LENGTH;
|
|
10
|
-
const SOC_SPAN_OFFSET = Identifier.LENGTH + Signature.LENGTH;
|
|
11
|
-
const SOC_PAYLOAD_OFFSET = Identifier.LENGTH + Signature.LENGTH + Span.LENGTH;
|
|
12
|
-
function recoverChunkOwner(data) {
|
|
13
|
-
const cacData = data.slice(SOC_SPAN_OFFSET);
|
|
14
|
-
const chunkAddress = calculateChunkAddress(cacData);
|
|
15
|
-
const signature = Signature.fromSlice(data, SOC_SIGNATURE_OFFSET);
|
|
16
|
-
const identifier = Bytes.fromSlice(data, 0, Identifier.LENGTH);
|
|
17
|
-
const digest = Binary.concatBytes(identifier.toUint8Array(), chunkAddress.toUint8Array());
|
|
18
|
-
const ownerAddress = signature.recoverPublicKey(digest).address();
|
|
19
|
-
return ownerAddress;
|
|
20
|
-
}
|
|
5
|
+
export { makeSOCAddress };
|
|
21
6
|
/**
|
|
22
7
|
* Unmarshals arbitrary data into a Single Owner Chunk.
|
|
23
8
|
* Throws an error if the data is not a valid SOC.
|
|
@@ -28,29 +13,11 @@ function recoverChunkOwner(data) {
|
|
|
28
13
|
* @returns a single owner chunk or throws error
|
|
29
14
|
*/
|
|
30
15
|
export function unmarshalSingleOwnerChunk(data, address) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const socAddress = new Reference(Binary.keccak256(Binary.concatBytes(identifier.toUint8Array(), ownerAddress.toUint8Array())));
|
|
36
|
-
if (!Binary.equals(address.toUint8Array(), socAddress.toUint8Array())) {
|
|
37
|
-
throw new BeeError('SOC data does not match given address!');
|
|
16
|
+
try {
|
|
17
|
+
return coreUnmarshalSingleOwnerChunk(data, address);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw new BeeError(e.message);
|
|
38
20
|
}
|
|
39
|
-
const signature = Signature.fromSlice(data, SOC_SIGNATURE_OFFSET);
|
|
40
|
-
const span = Span.fromSlice(data, SOC_SPAN_OFFSET);
|
|
41
|
-
const payload = Bytes.fromSlice(data, SOC_PAYLOAD_OFFSET);
|
|
42
|
-
return {
|
|
43
|
-
data,
|
|
44
|
-
identifier,
|
|
45
|
-
signature,
|
|
46
|
-
span,
|
|
47
|
-
payload,
|
|
48
|
-
address: socAddress,
|
|
49
|
-
owner: ownerAddress
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export function makeSOCAddress(identifier, address) {
|
|
53
|
-
return new Reference(Binary.keccak256(Binary.concatBytes(identifier.toUint8Array(), address.toUint8Array())));
|
|
54
21
|
}
|
|
55
22
|
/**
|
|
56
23
|
* Creates a single owner chunk object
|
|
@@ -62,18 +29,13 @@ export function makeSOCAddress(identifier, address) {
|
|
|
62
29
|
export function makeSingleOwnerChunk(address, span, payload, identifier, signer) {
|
|
63
30
|
identifier = new Identifier(identifier);
|
|
64
31
|
signer = new PrivateKey(signer);
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const data = Binary.concatBytes(identifier.toUint8Array(), signature.toUint8Array(), span.toUint8Array(), payload.toUint8Array());
|
|
68
|
-
return {
|
|
69
|
-
data,
|
|
70
|
-
identifier,
|
|
71
|
-
signature,
|
|
32
|
+
const wrappedChunk = {
|
|
33
|
+
data: Bytes.concat(span.toUint8Array(), payload.toUint8Array()),
|
|
72
34
|
span,
|
|
73
35
|
payload,
|
|
74
|
-
address
|
|
75
|
-
owner: signer.publicKey().address()
|
|
36
|
+
address
|
|
76
37
|
};
|
|
38
|
+
return coreMakeSingleOwnerChunk(wrappedChunk, identifier, signer.toBigInt());
|
|
77
39
|
}
|
|
78
40
|
/**
|
|
79
41
|
* Helper function to upload a chunk.
|
|
@@ -86,7 +48,7 @@ export function makeSingleOwnerChunk(address, span, payload, identifier, signer)
|
|
|
86
48
|
* @param options Upload options
|
|
87
49
|
*/
|
|
88
50
|
export async function uploadSingleOwnerChunk(requestOptions, chunk, stamp, options) {
|
|
89
|
-
const data =
|
|
51
|
+
const data = Bytes.concat(chunk.span.toUint8Array(), chunk.payload.toUint8Array());
|
|
90
52
|
return socAPI.upload(requestOptions, chunk.owner, chunk.identifier, chunk.signature, data, stamp, options);
|
|
91
53
|
}
|
|
92
54
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FeedIndex, Identifier } from "../utils/typed-bytes.js";
|
|
1
|
+
import { Bytes, FeedIndex, Identifier, keccak256 } from '@ethersphere/core-sdk';
|
|
3
2
|
export function makeFeedIdentifier(topic, index) {
|
|
4
3
|
index = typeof index === 'number' ? FeedIndex.fromBigInt(BigInt(index)) : index;
|
|
5
|
-
return new Identifier(
|
|
4
|
+
return new Identifier(keccak256(Bytes.concat(topic.toUint8Array(), index.toUint8Array())));
|
|
6
5
|
}
|
package/dist/mjs/feed/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Optional } from 'cafe-utility';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { makeContentAddressedChunk, unmarshalContentAddressedChunk } from
|
|
3
|
+
import { Bytes, FeedIndex, Reference, keccak256, makeContentAddressedChunk, numberToUint64, uint64ToNumber, unmarshalContentAddressedChunk } from '@ethersphere/core-sdk';
|
|
4
4
|
import { unmarshalSingleOwnerChunk, uploadSingleOwnerChunkData, uploadSingleOwnerChunkWithWrappedChunk } from "../chunk/soc.js";
|
|
5
5
|
import * as bytes from "../api/bytes.js";
|
|
6
6
|
import * as chunkAPI from "../api/chunk.js";
|
|
7
7
|
import { fetchLatestFeedUpdate, probeFeed } from "../api/feed.js";
|
|
8
|
-
import { Bytes } from "../utils/bytes.js";
|
|
9
8
|
import { BeeResponseError } from "../utils/error.js";
|
|
10
9
|
import { ResourceLocator } from "../utils/resource-locator.js";
|
|
11
|
-
import { FeedIndex, Reference } from "../utils/typed-bytes.js";
|
|
12
10
|
import { makeFeedIdentifier } from "./identifier.js";
|
|
13
11
|
const TIMESTAMP_PAYLOAD_OFFSET = 0;
|
|
14
12
|
const TIMESTAMP_PAYLOAD_SIZE = 8;
|
|
@@ -32,8 +30,8 @@ export async function updateFeedWithReference(requestOptions, signer, topic, ref
|
|
|
32
30
|
const nextIndex = options?.index ?? (await findNextIndex(requestOptions, signer.publicKey().address(), topic));
|
|
33
31
|
const identifier = makeFeedIdentifier(topic, nextIndex);
|
|
34
32
|
const at = options?.at ?? Date.now() / 1000.0;
|
|
35
|
-
const timestamp =
|
|
36
|
-
const payloadBytes =
|
|
33
|
+
const timestamp = numberToUint64(BigInt(Math.floor(at)), 'BE');
|
|
34
|
+
const payloadBytes = Bytes.concat(timestamp, reference.toUint8Array());
|
|
37
35
|
return uploadSingleOwnerChunkData(requestOptions, signer, postageBatchId, identifier, payloadBytes, options);
|
|
38
36
|
}
|
|
39
37
|
export async function updateFeedWithPayload(requestOptions, signer, topic, data, postageBatchId, options) {
|
|
@@ -49,7 +47,7 @@ export async function updateFeedWithPayload(requestOptions, signer, topic, data,
|
|
|
49
47
|
}
|
|
50
48
|
export function getFeedUpdateChunkReference(owner, topic, index) {
|
|
51
49
|
const identifier = makeFeedIdentifier(topic, index);
|
|
52
|
-
return new Reference(
|
|
50
|
+
return new Reference(keccak256(Bytes.concat(identifier.toUint8Array(), owner.toUint8Array())));
|
|
53
51
|
}
|
|
54
52
|
export async function downloadFeedUpdate(requestOptions, owner, topic, index, hasTimestamp = false) {
|
|
55
53
|
index = typeof index === 'number' ? FeedIndex.fromBigInt(BigInt(index)) : index;
|
|
@@ -59,7 +57,7 @@ export async function downloadFeedUpdate(requestOptions, owner, topic, index, ha
|
|
|
59
57
|
let timestamp = Optional.empty();
|
|
60
58
|
if (hasTimestamp) {
|
|
61
59
|
const timestampBytes = Bytes.fromSlice(soc.payload.toUint8Array(), TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
|
|
62
|
-
timestamp = Optional.of(Number(
|
|
60
|
+
timestamp = Optional.of(Number(uint64ToNumber(timestampBytes.toUint8Array(), 'BE')));
|
|
63
61
|
}
|
|
64
62
|
return {
|
|
65
63
|
timestamp,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { FeedIndex } from '@ethersphere/core-sdk';
|
|
1
2
|
import { Objects } from 'cafe-utility';
|
|
2
|
-
import { FeedIndex } from "../utils/typed-bytes.js";
|
|
3
3
|
import { getFeedUpdateChunkReference } from "./index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Function that checks if a chunk is retrievable by actually downloading it.
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Bee } from "./bee.js";
|
|
2
|
-
|
|
3
|
-
export { MerkleTree } from 'cafe-utility';
|
|
2
|
+
export { BatchId, Bytes, ChunkBuilder, ChunkSplitter, EthAddress, FeedIndex, Identifier, PeerAddress, PrivateKey, PublicKey, Reference, Signature, Span, Stamper, Topic, TransactionId } from '@ethersphere/core-sdk';
|
|
4
3
|
export { MantarayNode } from "./manifest/manifest.js";
|
|
5
4
|
export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./version.js";
|
|
6
5
|
export * from "./types/index.js";
|
|
7
|
-
export { Bytes } from "./utils/bytes.js";
|
|
8
6
|
export * from "./utils/constants.js";
|
|
9
7
|
export { Duration } from "./utils/duration.js";
|
|
10
8
|
export * from "./utils/error.js";
|
|
11
9
|
export * as Utils from "./utils/expose.js";
|
|
12
10
|
export { Size } from "./utils/size.js";
|
|
13
11
|
export * from "./utils/tokens.js";
|
|
14
|
-
export
|
|
15
|
-
export { Bee, Stamper };
|
|
12
|
+
export { Bee };
|