@ethersphere/bee-js 8.1.0 → 8.3.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 +27 -1
- package/dist/cjs/bee.js +30 -16
- package/dist/cjs/chunk/soc.js +4 -6
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/modules/bytes.js +18 -1
- package/dist/cjs/modules/chunk.js +4 -4
- package/dist/cjs/modules/envelope.js +23 -0
- package/dist/cjs/modules/feed.js +2 -2
- package/dist/cjs/modules/grantee.js +2 -2
- package/dist/cjs/modules/soc.js +2 -2
- package/dist/cjs/utils/cid.js +38 -0
- package/dist/cjs/utils/constants.js +6 -0
- package/dist/cjs/utils/expose.js +4 -1
- package/dist/cjs/utils/headers.js +11 -6
- package/dist/cjs/utils/http.js +0 -5
- package/dist/cjs/utils/stamps.js +22 -1
- package/dist/cjs/utils/tar.browser.js +3 -0
- package/dist/cjs/utils/tar.js +3 -0
- package/dist/cjs/utils/type.js +5 -9
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +31 -17
- package/dist/mjs/chunk/soc.js +4 -6
- package/dist/mjs/index.js +1 -0
- package/dist/mjs/modules/bytes.js +16 -0
- package/dist/mjs/modules/chunk.js +4 -4
- package/dist/mjs/modules/envelope.js +33 -0
- package/dist/mjs/modules/feed.js +2 -2
- package/dist/mjs/modules/grantee.js +2 -2
- package/dist/mjs/modules/soc.js +2 -2
- package/dist/mjs/utils/cid.js +33 -0
- package/dist/mjs/utils/constants.js +3 -0
- package/dist/mjs/utils/expose.js +2 -1
- package/dist/mjs/utils/headers.js +10 -6
- package/dist/mjs/utils/http.js +0 -7
- package/dist/mjs/utils/stamps.js +19 -0
- package/dist/mjs/utils/tar.browser.js +3 -0
- package/dist/mjs/utils/tar.js +3 -0
- package/dist/mjs/utils/type.js +4 -7
- package/dist/types/bee.d.ts +10 -3
- package/dist/types/chunk/soc.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/modules/bytes.d.ts +8 -1
- package/dist/types/modules/chunk.d.ts +3 -3
- package/dist/types/modules/envelope.d.ts +2 -0
- package/dist/types/modules/feed.d.ts +1 -1
- package/dist/types/modules/soc.d.ts +1 -1
- package/dist/types/types/index.d.ts +12 -8
- package/dist/types/utils/cid.d.ts +9 -0
- package/dist/types/utils/constants.d.ts +4 -0
- package/dist/types/utils/expose.d.ts +1 -0
- package/dist/types/utils/headers.d.ts +1 -1
- package/dist/types/utils/stamps.d.ts +3 -1
- package/dist/types/utils/type.d.ts +3 -5
- package/package.json +2 -5
|
@@ -10,4 +10,4 @@ import { BatchId, BeeRequestOptions, UploadOptions, UploadResult } from '../type
|
|
|
10
10
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
11
11
|
* @param options Additional options like tag, encryption, pinning
|
|
12
12
|
*/
|
|
13
|
-
export declare function upload(requestOptions: BeeRequestOptions, owner: string, identifier: string, signature: string, data: Uint8Array,
|
|
13
|
+
export declare function upload(requestOptions: BeeRequestOptions, owner: string, identifier: string, signature: string, data: Uint8Array, stamp: BatchId | Uint8Array | string, options?: UploadOptions): Promise<UploadResult>;
|
|
@@ -7,9 +7,6 @@ import type { BeeError } from '../utils/error';
|
|
|
7
7
|
import type { EthAddress, HexEthAddress } from '../utils/eth';
|
|
8
8
|
import type { HexString } from '../utils/hex';
|
|
9
9
|
export * from './debug';
|
|
10
|
-
export interface Dictionary<T> {
|
|
11
|
-
[Key: string]: T;
|
|
12
|
-
}
|
|
13
10
|
export declare const SPAN_SIZE = 8;
|
|
14
11
|
export declare const SECTION_SIZE = 32;
|
|
15
12
|
export declare const BRANCHES = 128;
|
|
@@ -73,6 +70,8 @@ export type BeeRequestOptions = {
|
|
|
73
70
|
timeout?: number | false;
|
|
74
71
|
headers?: Record<string, string>;
|
|
75
72
|
onRequest?: (request: BeeRequest) => void;
|
|
73
|
+
httpAgent?: any;
|
|
74
|
+
httpsAgent?: any;
|
|
76
75
|
};
|
|
77
76
|
export interface BeeOptions extends BeeRequestOptions {
|
|
78
77
|
/**
|
|
@@ -96,7 +95,6 @@ export interface UploadResultWithCid extends UploadResult {
|
|
|
96
95
|
* Function that converts the reference into Swarm CIDs
|
|
97
96
|
*
|
|
98
97
|
* @throws TypeError if the reference is encrypted reference (eq. 128 chars long) which is not supported in CID
|
|
99
|
-
* @see https://github.com/ethersphere/swarm-cid-js
|
|
100
98
|
*/
|
|
101
99
|
cid: () => string;
|
|
102
100
|
}
|
|
@@ -120,7 +118,6 @@ export interface UploadResult {
|
|
|
120
118
|
export interface UploadOptions {
|
|
121
119
|
/**
|
|
122
120
|
* If set to true, an ACT will be created for the uploaded data.
|
|
123
|
-
*
|
|
124
121
|
*/
|
|
125
122
|
act?: boolean;
|
|
126
123
|
/**
|
|
@@ -295,6 +292,9 @@ export interface FileData<T> extends FileHeaders {
|
|
|
295
292
|
export interface Pin {
|
|
296
293
|
reference: string;
|
|
297
294
|
}
|
|
295
|
+
export interface ReferenceInformation {
|
|
296
|
+
contentLength: number;
|
|
297
|
+
}
|
|
298
298
|
/**
|
|
299
299
|
* Helper interface that adds utility functions
|
|
300
300
|
* to work more conveniently with bytes in normal
|
|
@@ -377,8 +377,6 @@ export interface FeedManifestResult {
|
|
|
377
377
|
reference: Reference;
|
|
378
378
|
/**
|
|
379
379
|
* Function that converts the reference into Swarm Feed CID.
|
|
380
|
-
*
|
|
381
|
-
* @see https://github.com/ethersphere/swarm-cid-js
|
|
382
380
|
*/
|
|
383
381
|
cid: () => string;
|
|
384
382
|
}
|
|
@@ -446,7 +444,7 @@ export interface SOCWriter extends SOCReader {
|
|
|
446
444
|
* @param data The chunk payload data
|
|
447
445
|
* @param options Upload options
|
|
448
446
|
*/
|
|
449
|
-
upload: (
|
|
447
|
+
upload: (stamp: BatchId | Uint8Array | string, identifier: Identifier, data: Uint8Array, options?: UploadOptions) => Promise<UploadResult>;
|
|
450
448
|
}
|
|
451
449
|
/**
|
|
452
450
|
* Interface representing Postage stamp batch.
|
|
@@ -519,6 +517,12 @@ export interface PostageBatchOptions {
|
|
|
519
517
|
*/
|
|
520
518
|
waitForUsableTimeout?: number;
|
|
521
519
|
}
|
|
520
|
+
export interface Envelope {
|
|
521
|
+
issuer: Uint8Array;
|
|
522
|
+
index: Uint8Array;
|
|
523
|
+
timestamp: Uint8Array;
|
|
524
|
+
signature: Uint8Array;
|
|
525
|
+
}
|
|
522
526
|
/**
|
|
523
527
|
* With this type a number should be represented in a string
|
|
524
528
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Reference } from '..';
|
|
2
|
+
export declare const SWARM_MANIFEST_CODEC = 250;
|
|
3
|
+
export declare const SWARM_FEED_CODEC = 251;
|
|
4
|
+
export type DecodedCID = {
|
|
5
|
+
type: 'feed' | 'manifest';
|
|
6
|
+
reference: Reference;
|
|
7
|
+
};
|
|
8
|
+
export declare function convertReferenceToCid(reference: Reference | string, type: 'feed' | 'manifest'): string;
|
|
9
|
+
export declare function convertCidToReference(cid: string): DecodedCID;
|
|
@@ -7,3 +7,4 @@ export { keccak256Hash } from './hash';
|
|
|
7
7
|
export { makeMaxTarget } from './pss';
|
|
8
8
|
export { getAmountForTtl, getDepthForCapacity, getStampCostInBzz, getStampCostInPlur, getStampEffectiveBytes, getStampMaximumCapacityBytes, getStampTtlSeconds, getStampUsage, } from './stamps';
|
|
9
9
|
export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy';
|
|
10
|
+
export { convertCidToReference, convertReferenceToCid } from './cid';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BatchId, DownloadRedundancyOptions, FileHeaders, UploadOptions, UploadRedundancyOptions } from '../types';
|
|
2
2
|
export declare function readFileHeaders(headers: Record<string, string>): FileHeaders;
|
|
3
|
-
export declare function extractUploadHeaders(
|
|
3
|
+
export declare function extractUploadHeaders(stamp: BatchId | Uint8Array | string, options?: UploadOptions): Record<string, string>;
|
|
4
4
|
export declare function extractRedundantUploadHeaders(postageBatchId: BatchId, options?: UploadOptions & UploadRedundancyOptions): Record<string, string>;
|
|
5
5
|
export declare function extractDownloadHeaders(options?: DownloadRedundancyOptions): Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NumberString } from '../types';
|
|
1
|
+
import { BatchId, Envelope, NumberString } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
|
|
4
4
|
*
|
|
@@ -62,3 +62,5 @@ export declare function getAmountForTtl(days: number): NumberString;
|
|
|
62
62
|
* @returns {number} The calculated depth necessary to achieve the specified capacity.
|
|
63
63
|
*/
|
|
64
64
|
export declare function getDepthForCapacity(gigabytes: number): number;
|
|
65
|
+
export declare function convertEnvelopeToMarshaledStamp(batchID: BatchId, envelope: Envelope): Uint8Array;
|
|
66
|
+
export declare function marshalStamp(signature: Uint8Array, batchID: Uint8Array, timestamp: Uint8Array, index: Uint8Array): Uint8Array;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ReferenceType } from '@ethersphere/swarm-cid';
|
|
3
2
|
import { Readable } from 'stream';
|
|
4
3
|
import { Address, AddressPrefix, AllTagsOptions, BatchId, BeeRequestOptions, CashoutOptions, CollectionUploadOptions, FileUploadOptions, NumberString, PostageBatchOptions, PssMessageHandler, PublicKey, Reference, ReferenceOrEns, Tag, TransactionHash, TransactionOptions, UploadOptions } from '../types';
|
|
5
4
|
export declare function isReadable(obj: unknown): obj is Readable;
|
|
6
|
-
export declare function isUint8Array(obj: unknown): obj is Uint8Array;
|
|
7
5
|
export declare function isInteger(value: unknown): value is number | NumberString;
|
|
8
6
|
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
9
7
|
export declare function isStrictlyObject(value: unknown): value is Record<string, unknown>;
|
|
@@ -26,15 +24,15 @@ export declare function assertReferenceOrEns(value: unknown): asserts value is R
|
|
|
26
24
|
* @param value
|
|
27
25
|
* @param expectedCidType
|
|
28
26
|
*/
|
|
29
|
-
export declare function makeReferenceOrEns(value: unknown, expectedCidType:
|
|
27
|
+
export declare function makeReferenceOrEns(value: unknown, expectedCidType: 'feed' | 'manifest'): ReferenceOrEns;
|
|
30
28
|
/**
|
|
31
29
|
* Function that adds getter which converts the reference into CID base32 encoded string.
|
|
32
30
|
* @param result
|
|
33
|
-
* @param cidType
|
|
31
|
+
* @param cidType feed or manifest
|
|
34
32
|
*/
|
|
35
33
|
export declare function addCidConversionFunction<T extends {
|
|
36
34
|
reference: string;
|
|
37
|
-
}>(result: T, cidType:
|
|
35
|
+
}>(result: T, cidType: 'feed' | 'manifest'): T & {
|
|
38
36
|
cid: () => string;
|
|
39
37
|
};
|
|
40
38
|
export declare function assertAddress(value: unknown): asserts value is Address;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -61,9 +61,8 @@
|
|
|
61
61
|
"bee": "npx @fairdatasociety/fdp-play@3.2.0 start --detach --fresh"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@ethersphere/swarm-cid": "^0.1.0",
|
|
65
64
|
"axios": "^0.28.1",
|
|
66
|
-
"cafe-utility": "^
|
|
65
|
+
"cafe-utility": "^23.10.0",
|
|
67
66
|
"elliptic": "^6.5.4",
|
|
68
67
|
"isomorphic-ws": "^4.0.1",
|
|
69
68
|
"js-sha3": "^0.8.0",
|
|
@@ -79,7 +78,6 @@
|
|
|
79
78
|
"@babel/preset-typescript": "^7.18.6",
|
|
80
79
|
"@commitlint/cli": "^17.0.2",
|
|
81
80
|
"@commitlint/config-conventional": "^17.4.2",
|
|
82
|
-
"@fluffy-spoon/substitute": "^1.208.0",
|
|
83
81
|
"@jest/types": "^29.6.3",
|
|
84
82
|
"@naholyr/cross-env": "^1.0.0",
|
|
85
83
|
"@types/elliptic": "^6.4.14",
|
|
@@ -100,7 +98,6 @@
|
|
|
100
98
|
"husky": "^8.0.1",
|
|
101
99
|
"jest": "^29.7.0",
|
|
102
100
|
"nock": "^13.3.0",
|
|
103
|
-
"playwright-test": "^8.1.2",
|
|
104
101
|
"prettier": "^2.6.2",
|
|
105
102
|
"rimraf": "^3.0.2",
|
|
106
103
|
"terser-webpack-plugin": "^5.3.1",
|