@ethersphere/bee-js 5.0.0 → 6.0.0-pre.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 +9 -1
- package/dist/index.browser.js +33 -0
- package/dist/index.browser.js.map +7 -0
- package/dist/src/bee-debug.js +624 -0
- package/dist/{mjs → src}/bee.js +243 -340
- package/dist/{mjs → src}/chunk/bmt.js +0 -0
- package/dist/{mjs → src}/chunk/cac.js +0 -0
- package/dist/{mjs → src}/chunk/serialize.js +0 -0
- package/dist/{mjs → src}/chunk/signer.js +13 -47
- package/dist/{mjs → src}/chunk/soc.js +31 -71
- package/dist/{mjs → src}/chunk/span.js +1 -1
- package/dist/{mjs → src}/feed/identifier.js +0 -0
- package/dist/src/feed/index.js +92 -0
- package/dist/src/feed/json.js +27 -0
- package/dist/src/feed/retrievable.js +67 -0
- package/dist/{mjs → src}/feed/topic.js +0 -0
- package/dist/{mjs → src}/feed/type.js +0 -0
- package/dist/{mjs → src}/index.js +1 -2
- package/dist/src/modules/bytes.js +59 -0
- package/dist/src/modules/bzz.js +122 -0
- package/dist/src/modules/chunk.js +45 -0
- package/dist/src/modules/debug/balance.js +57 -0
- package/dist/src/modules/debug/chequebook.js +150 -0
- package/dist/src/modules/debug/chunk.js +35 -0
- package/dist/src/modules/debug/connectivity.js +45 -0
- package/dist/src/modules/debug/settlements.js +29 -0
- package/dist/src/modules/debug/stamps.js +64 -0
- package/dist/src/modules/debug/states.js +46 -0
- package/dist/src/modules/debug/status.js +134 -0
- package/dist/src/modules/debug/tag.js +16 -0
- package/dist/src/modules/debug/transactions.js +69 -0
- package/dist/src/modules/feed.js +67 -0
- package/dist/src/modules/pinning.js +60 -0
- package/dist/src/modules/pss.js +40 -0
- package/dist/src/modules/soc.js +31 -0
- package/dist/src/modules/status.js +12 -0
- package/dist/src/modules/stewardship.js +24 -0
- package/dist/src/modules/tag.js +77 -0
- package/dist/{mjs → src}/types/debug.js +0 -0
- package/dist/{mjs → src}/types/index.js +0 -0
- package/dist/{mjs → src}/utils/bytes.js +3 -2
- package/dist/src/utils/collection-browser.js +19 -0
- package/dist/src/utils/collection-node.js +74 -0
- package/dist/src/utils/collection.js +64 -0
- package/dist/src/utils/data.browser.js +72 -0
- package/dist/src/utils/data.js +42 -0
- package/dist/{mjs → src}/utils/error.js +0 -0
- package/dist/{mjs → src}/utils/eth.js +32 -68
- package/dist/{mjs → src}/utils/expose.js +1 -1
- package/dist/src/utils/file.js +36 -0
- package/dist/{mjs → src}/utils/hash.js +0 -0
- package/dist/{mjs → src}/utils/headers.js +4 -4
- package/dist/{mjs → src}/utils/hex.js +0 -0
- package/dist/src/utils/http.js +162 -0
- package/dist/{mjs → src}/utils/merge.js +2 -2
- package/dist/{mjs → src}/utils/pss.js +0 -0
- package/dist/{mjs → src}/utils/reference.js +0 -0
- package/dist/src/utils/sleep.js +8 -0
- package/dist/{mjs → src}/utils/stamps.js +0 -0
- package/dist/{mjs → src}/utils/stream.js +3 -3
- package/dist/{mjs → src}/utils/tar.js +0 -0
- package/dist/{mjs → src}/utils/type.js +12 -13
- package/dist/{mjs → src}/utils/uint64.js +0 -0
- package/dist/{mjs → src}/utils/url.js +0 -0
- package/dist/types/chunk/bmt.d.ts +1 -1
- package/dist/types/chunk/soc.d.ts +1 -1
- package/dist/types/chunk/span.d.ts +1 -1
- package/dist/types/feed/index.d.ts +1 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/modules/bzz.d.ts +1 -1
- package/dist/types/types/index.d.ts +8 -8
- package/dist/types/utils/{collection.browser.d.ts → collection-browser.d.ts} +0 -0
- package/dist/types/utils/{collection.node.d.ts → collection-node.d.ts} +0 -0
- package/dist/types/utils/error.d.ts +1 -1
- package/dist/types/utils/eth.d.ts +3 -3
- package/dist/types/utils/expose.d.ts +7 -4
- package/dist/types/utils/hash.d.ts +1 -1
- package/dist/types/utils/hex.d.ts +2 -2
- package/dist/types/utils/http.d.ts +3 -3
- package/dist/types/utils/stream.d.ts +1 -1
- package/dist/types/utils/uint64.d.ts +1 -1
- package/package.json +44 -59
- package/dist/cjs/bee-debug.js +0 -642
- package/dist/cjs/bee.js +0 -983
- package/dist/cjs/chunk/bmt.js +0 -55
- package/dist/cjs/chunk/cac.js +0 -56
- package/dist/cjs/chunk/serialize.js +0 -19
- package/dist/cjs/chunk/signer.js +0 -137
- package/dist/cjs/chunk/soc.js +0 -176
- package/dist/cjs/chunk/span.js +0 -29
- package/dist/cjs/feed/identifier.js +0 -35
- package/dist/cjs/feed/index.js +0 -132
- package/dist/cjs/feed/json.js +0 -41
- package/dist/cjs/feed/retrievable.js +0 -72
- package/dist/cjs/feed/topic.js +0 -25
- package/dist/cjs/feed/type.js +0 -15
- package/dist/cjs/index.js +0 -39
- package/dist/cjs/modules/bytes.js +0 -74
- package/dist/cjs/modules/bzz.js +0 -131
- package/dist/cjs/modules/chunk.js +0 -58
- package/dist/cjs/modules/debug/balance.js +0 -77
- package/dist/cjs/modules/debug/chequebook.js +0 -167
- package/dist/cjs/modules/debug/chunk.js +0 -51
- package/dist/cjs/modules/debug/connectivity.js +0 -75
- package/dist/cjs/modules/debug/settlements.js +0 -45
- package/dist/cjs/modules/debug/stamps.js +0 -89
- package/dist/cjs/modules/debug/states.js +0 -64
- package/dist/cjs/modules/debug/status.js +0 -153
- package/dist/cjs/modules/debug/tag.js +0 -30
- package/dist/cjs/modules/debug/transactions.js +0 -81
- package/dist/cjs/modules/feed.js +0 -76
- package/dist/cjs/modules/pinning.js +0 -80
- package/dist/cjs/modules/pss.js +0 -55
- package/dist/cjs/modules/soc.js +0 -40
- package/dist/cjs/modules/status.js +0 -26
- package/dist/cjs/modules/stewardship.js +0 -41
- package/dist/cjs/modules/tag.js +0 -96
- package/dist/cjs/package.json +0 -8
- package/dist/cjs/types/debug.js +0 -10
- package/dist/cjs/types/index.js +0 -51
- package/dist/cjs/types/ky-options.js +0 -8
- package/dist/cjs/types/ky-universal/common.js +0 -8
- package/dist/cjs/types/ky-universal/hooks.js +0 -8
- package/dist/cjs/types/ky-universal/retry.js +0 -8
- package/dist/cjs/utils/bytes.js +0 -121
- package/dist/cjs/utils/collection.browser.js +0 -36
- package/dist/cjs/utils/collection.js +0 -70
- package/dist/cjs/utils/collection.node.js +0 -115
- package/dist/cjs/utils/data.browser.js +0 -74
- package/dist/cjs/utils/data.js +0 -58
- package/dist/cjs/utils/error.js +0 -50
- package/dist/cjs/utils/eth.js +0 -211
- package/dist/cjs/utils/expose.js +0 -44
- package/dist/cjs/utils/file.js +0 -49
- package/dist/cjs/utils/hash.js +0 -21
- package/dist/cjs/utils/headers.js +0 -59
- package/dist/cjs/utils/hex.js +0 -150
- package/dist/cjs/utils/http.js +0 -172
- package/dist/cjs/utils/merge.js +0 -34
- package/dist/cjs/utils/pss.js +0 -18
- package/dist/cjs/utils/reference.js +0 -36
- package/dist/cjs/utils/sleep.js +0 -23
- package/dist/cjs/utils/stamps.js +0 -17
- package/dist/cjs/utils/stream.js +0 -146
- package/dist/cjs/utils/tar.js +0 -25
- package/dist/cjs/utils/type.js +0 -426
- package/dist/cjs/utils/uint64.js +0 -29
- package/dist/cjs/utils/url.js +0 -56
- package/dist/index.browser.min.js +0 -3
- package/dist/index.browser.min.js.LICENSE.txt +0 -60
- package/dist/index.browser.min.js.map +0 -1
- package/dist/mjs/bee-debug.js +0 -744
- package/dist/mjs/feed/index.js +0 -134
- package/dist/mjs/feed/json.js +0 -63
- package/dist/mjs/feed/retrievable.js +0 -105
- package/dist/mjs/modules/bytes.js +0 -96
- package/dist/mjs/modules/bzz.js +0 -160
- package/dist/mjs/modules/chunk.js +0 -80
- package/dist/mjs/modules/debug/balance.js +0 -97
- package/dist/mjs/modules/debug/chequebook.js +0 -198
- package/dist/mjs/modules/debug/chunk.js +0 -71
- package/dist/mjs/modules/debug/connectivity.js +0 -89
- package/dist/mjs/modules/debug/settlements.js +0 -65
- package/dist/mjs/modules/debug/stamps.js +0 -108
- package/dist/mjs/modules/debug/states.js +0 -84
- package/dist/mjs/modules/debug/status.js +0 -182
- package/dist/mjs/modules/debug/tag.js +0 -50
- package/dist/mjs/modules/debug/transactions.js +0 -103
- package/dist/mjs/modules/feed.js +0 -101
- package/dist/mjs/modules/pinning.js +0 -100
- package/dist/mjs/modules/pss.js +0 -74
- package/dist/mjs/modules/soc.js +0 -64
- package/dist/mjs/modules/status.js +0 -46
- package/dist/mjs/modules/stewardship.js +0 -60
- package/dist/mjs/modules/tag.js +0 -119
- package/dist/mjs/package.json +0 -8
- package/dist/mjs/types/ky-options.js +0 -7
- package/dist/mjs/types/ky-universal/common.js +0 -7
- package/dist/mjs/types/ky-universal/hooks.js +0 -7
- package/dist/mjs/types/ky-universal/retry.js +0 -7
- package/dist/mjs/utils/collection.browser.js +0 -56
- package/dist/mjs/utils/collection.js +0 -98
- package/dist/mjs/utils/collection.node.js +0 -169
- package/dist/mjs/utils/data.browser.js +0 -108
- package/dist/mjs/utils/data.js +0 -78
- package/dist/mjs/utils/file.js +0 -70
- package/dist/mjs/utils/http.js +0 -208
- package/dist/mjs/utils/sleep.js +0 -43
- package/dist/types/types/ky-options.d.ts +0 -221
- package/dist/types/types/ky-universal/common.d.ts +0 -13
- package/dist/types/types/ky-universal/hooks.d.ts +0 -92
- package/dist/types/types/ky-universal/retry.d.ts +0 -38
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
import { http } from "../../utils/http.js";
|
|
34
|
-
import getMajorSemver from 'semver/functions/major.js'; // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
35
|
-
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
36
|
-
|
|
37
|
-
export const SUPPORTED_BEE_VERSION_EXACT = '1.7.0-bbf13011';
|
|
38
|
-
export const SUPPORTED_API_VERSION = '3.0.2';
|
|
39
|
-
export const SUPPORTED_DEBUG_API_VERSION = '3.0.2';
|
|
40
|
-
export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.substring(0, SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
|
|
41
|
-
const NODE_INFO_URL = 'node';
|
|
42
|
-
const HEALTH_URL = 'health';
|
|
43
|
-
/**
|
|
44
|
-
* Get health of node
|
|
45
|
-
*
|
|
46
|
-
* @param ky Ky debug instance
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
export function getHealth(ky) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const response = yield http(ky, {
|
|
52
|
-
method: 'get',
|
|
53
|
-
path: HEALTH_URL,
|
|
54
|
-
responseType: 'json'
|
|
55
|
-
});
|
|
56
|
-
return response.data;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get information about Bee node
|
|
61
|
-
*
|
|
62
|
-
* @param ky Ky debug instance
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
export function getNodeInfo(ky) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const response = yield http(ky, {
|
|
68
|
-
method: 'get',
|
|
69
|
-
path: NODE_INFO_URL,
|
|
70
|
-
responseType: 'json'
|
|
71
|
-
});
|
|
72
|
-
return response.data;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Connects to a node and checks if it is a supported Bee version by the bee-js
|
|
77
|
-
*
|
|
78
|
-
* @param ky Ky debug instance
|
|
79
|
-
*
|
|
80
|
-
* @returns true if the Bee node version is supported
|
|
81
|
-
* @deprecated Use `isSupportedExactVersion` instead
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
export function isSupportedVersion(ky) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return isSupportedExactVersion(ky);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Connects to a node and checks if its version matches with the one that bee-js supports.
|
|
91
|
-
*
|
|
92
|
-
* Be aware that this is the most strict version check and most probably
|
|
93
|
-
* you will want to use more relaxed API-versions based checks like
|
|
94
|
-
* `isSupportedApiVersion`, `isSupportedMainApiVersion` or `isSupportedDebugApiVersion`
|
|
95
|
-
* based on your use-case.
|
|
96
|
-
*
|
|
97
|
-
* @param ky
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
export function isSupportedExactVersion(ky) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
const {
|
|
103
|
-
version
|
|
104
|
-
} = yield getHealth(ky);
|
|
105
|
-
return version === SUPPORTED_BEE_VERSION_EXACT;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Connects to a node and checks if its main's API version matches with the one that bee-js supports.
|
|
110
|
-
*
|
|
111
|
-
* This is useful if you are not using `BeeDebug` class (for anything else then this check)
|
|
112
|
-
* and want to make sure about compatibility.
|
|
113
|
-
*
|
|
114
|
-
* @param ky
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
export function isSupportedMainApiVersion(ky) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
const {
|
|
120
|
-
apiVersion
|
|
121
|
-
} = yield getHealth(ky);
|
|
122
|
-
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
|
|
127
|
-
*
|
|
128
|
-
* This is useful if you are not using `Bee` class in your application and want to make sure
|
|
129
|
-
* about compatibility.
|
|
130
|
-
*
|
|
131
|
-
* @param ky
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
export function isSupportedDebugApiVersion(ky) {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
const {
|
|
137
|
-
debugApiVersion
|
|
138
|
-
} = yield getHealth(ky);
|
|
139
|
-
return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
|
|
144
|
-
*
|
|
145
|
-
* This should be the main way how to check compatibility for your app and Bee node.
|
|
146
|
-
*
|
|
147
|
-
* @param ky
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
export function isSupportedApiVersion(ky) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const {
|
|
153
|
-
apiVersion,
|
|
154
|
-
debugApiVersion
|
|
155
|
-
} = yield getHealth(ky);
|
|
156
|
-
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) && getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
|
|
161
|
-
* and versions that bee-js supports (properties prefixed with `supported*`).
|
|
162
|
-
*
|
|
163
|
-
* @param ky
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
export function getVersions(ky) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const {
|
|
169
|
-
version,
|
|
170
|
-
apiVersion,
|
|
171
|
-
debugApiVersion
|
|
172
|
-
} = yield getHealth(ky);
|
|
173
|
-
return {
|
|
174
|
-
supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
|
|
175
|
-
supportedBeeApiVersion: SUPPORTED_API_VERSION,
|
|
176
|
-
supportedBeeDebugApiVersion: SUPPORTED_DEBUG_API_VERSION,
|
|
177
|
-
beeVersion: version,
|
|
178
|
-
beeApiVersion: apiVersion,
|
|
179
|
-
beeDebugApiVersion: debugApiVersion
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
import { http } from "../../utils/http.js";
|
|
34
|
-
const endpoint = 'tags';
|
|
35
|
-
/**
|
|
36
|
-
* Retrieve tag with extended information from Bee node
|
|
37
|
-
*
|
|
38
|
-
* @param ky Ky debug instance
|
|
39
|
-
* @param uid UID of tag to be retrieved
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
export function retrieveExtendedTag(ky, uid) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const response = yield http(ky, {
|
|
45
|
-
path: `${endpoint}/${uid}`,
|
|
46
|
-
responseType: 'json'
|
|
47
|
-
});
|
|
48
|
-
return response.data;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
import { http } from "../../utils/http.js";
|
|
34
|
-
const transactionsEndpoint = 'transactions';
|
|
35
|
-
/**
|
|
36
|
-
* Get list of all pending transactions
|
|
37
|
-
*
|
|
38
|
-
* @param ky Debug Ky instance
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
export function getAllTransactions(ky) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const response = yield http(ky, {
|
|
44
|
-
path: transactionsEndpoint,
|
|
45
|
-
responseType: 'json'
|
|
46
|
-
});
|
|
47
|
-
return response.data.pendingTransactions;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Get information for specific pending transactions
|
|
52
|
-
*
|
|
53
|
-
* @param ky Debug Ky instance
|
|
54
|
-
* @param transactionHash Hash of the transaction
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
export function getTransaction(ky, transactionHash) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const response = yield http(ky, {
|
|
60
|
-
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
61
|
-
responseType: 'json'
|
|
62
|
-
});
|
|
63
|
-
return response.data;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Rebroadcast existing transaction
|
|
68
|
-
*
|
|
69
|
-
* @param ky Debug Ky instance
|
|
70
|
-
* @param transactionHash Hash of the transaction
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
export function rebroadcastTransaction(ky, transactionHash) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const response = yield http(ky, {
|
|
76
|
-
method: 'post',
|
|
77
|
-
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
78
|
-
responseType: 'json'
|
|
79
|
-
});
|
|
80
|
-
return response.data.transactionHash;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Cancel existing transaction
|
|
85
|
-
*
|
|
86
|
-
* @param ky Debug Ky instance
|
|
87
|
-
* @param transactionHash Hash of the transaction
|
|
88
|
-
* @param gasPrice Optional gas price
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
export function cancelTransaction(ky, transactionHash, gasPrice) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const response = yield http(ky, {
|
|
94
|
-
method: 'delete',
|
|
95
|
-
headers: {
|
|
96
|
-
'gas-price': gasPrice
|
|
97
|
-
},
|
|
98
|
-
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
99
|
-
responseType: 'json'
|
|
100
|
-
});
|
|
101
|
-
return response.data.transactionHash;
|
|
102
|
-
});
|
|
103
|
-
}
|
package/dist/mjs/modules/feed.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
import { filterHeaders, http } from "../utils/http.js";
|
|
34
|
-
import { extractUploadHeaders } from "../utils/headers.js";
|
|
35
|
-
import { BeeError } from "../utils/error.js";
|
|
36
|
-
const feedEndpoint = 'feeds';
|
|
37
|
-
/**
|
|
38
|
-
* Create an initial feed root manifest
|
|
39
|
-
*
|
|
40
|
-
* @param ky Ky instance
|
|
41
|
-
* @param owner Owner's ethereum address in hex
|
|
42
|
-
* @param topic Topic in hex
|
|
43
|
-
* @param postageBatchId Postage BatchId to be used to create the Feed Manifest
|
|
44
|
-
* @param options Additional options, like type (default: 'sequence')
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
export function createFeedManifest(ky, owner, topic, postageBatchId, options) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const response = yield http(ky, {
|
|
50
|
-
method: 'post',
|
|
51
|
-
responseType: 'json',
|
|
52
|
-
path: `${feedEndpoint}/${owner}/${topic}`,
|
|
53
|
-
searchParams: filterHeaders(options),
|
|
54
|
-
headers: extractUploadHeaders(postageBatchId)
|
|
55
|
-
});
|
|
56
|
-
return response.data.reference;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function readFeedUpdateHeaders(headers) {
|
|
61
|
-
const feedIndex = headers.get('swarm-feed-index');
|
|
62
|
-
const feedIndexNext = headers.get('swarm-feed-index-next');
|
|
63
|
-
|
|
64
|
-
if (!feedIndex) {
|
|
65
|
-
throw new BeeError('Response did not contain expected swarm-feed-index!');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!feedIndexNext) {
|
|
69
|
-
throw new BeeError('Response did not contain expected swarm-feed-index-next!');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
feedIndex,
|
|
74
|
-
feedIndexNext
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Find and retrieve feed update
|
|
79
|
-
*
|
|
80
|
-
* The feed consists of updates. This endpoint looks up an
|
|
81
|
-
* update that matches the provided parameters and returns
|
|
82
|
-
* the reference it contains along with its index and the
|
|
83
|
-
* index of the subsequent update.
|
|
84
|
-
*
|
|
85
|
-
* @param ky Ky instance
|
|
86
|
-
* @param owner Owner's ethereum address in hex
|
|
87
|
-
* @param topic Topic in hex
|
|
88
|
-
* @param options Additional options, like index, at, type
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
export function fetchLatestFeedUpdate(ky, owner, topic, options) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const response = yield http(ky, {
|
|
95
|
-
responseType: 'json',
|
|
96
|
-
path: `${feedEndpoint}/${owner}/${topic}`,
|
|
97
|
-
searchParams: filterHeaders(options)
|
|
98
|
-
});
|
|
99
|
-
return Object.assign(Object.assign({}, response.data), readFeedUpdateHeaders(response.headers));
|
|
100
|
-
});
|
|
101
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
import { http } from "../utils/http.js";
|
|
34
|
-
const PINNING_ENDPOINT = 'pins';
|
|
35
|
-
/**
|
|
36
|
-
* Pin data with given reference
|
|
37
|
-
*
|
|
38
|
-
* @param ky Ky instance for given Bee class instance
|
|
39
|
-
* @param reference Bee data reference
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
export function pin(ky, reference) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
yield http(ky, {
|
|
45
|
-
method: 'post',
|
|
46
|
-
responseType: 'json',
|
|
47
|
-
path: `${PINNING_ENDPOINT}/${reference}`
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Unpin data with given reference
|
|
53
|
-
*
|
|
54
|
-
* @param ky Ky instance for given Bee class instance
|
|
55
|
-
* @param reference Bee data reference
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export function unpin(ky, reference) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
yield http(ky, {
|
|
61
|
-
method: 'delete',
|
|
62
|
-
responseType: 'json',
|
|
63
|
-
path: `${PINNING_ENDPOINT}/${reference}`
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get pin status for specific address.
|
|
69
|
-
*
|
|
70
|
-
* @param ky Ky instance
|
|
71
|
-
* @param reference
|
|
72
|
-
* @throws Error if given address is not pinned
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
export function getPin(ky, reference) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const response = yield http(ky, {
|
|
78
|
-
method: 'get',
|
|
79
|
-
responseType: 'json',
|
|
80
|
-
path: `${PINNING_ENDPOINT}/${reference}`
|
|
81
|
-
});
|
|
82
|
-
return response.data;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get list of all pins
|
|
87
|
-
*
|
|
88
|
-
* @param ky Ky instance
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
export function getAllPins(ky) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const response = yield http(ky, {
|
|
94
|
-
method: 'get',
|
|
95
|
-
responseType: 'json',
|
|
96
|
-
path: `${PINNING_ENDPOINT}`
|
|
97
|
-
});
|
|
98
|
-
return response.data.references;
|
|
99
|
-
});
|
|
100
|
-
}
|
package/dist/mjs/modules/pss.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
import WebSocket from 'isomorphic-ws';
|
|
34
|
-
import { prepareData } from "../utils/data.js";
|
|
35
|
-
import { http } from "../utils/http.js";
|
|
36
|
-
import { extractUploadHeaders } from "../utils/headers.js";
|
|
37
|
-
const endpoint = 'pss';
|
|
38
|
-
/**
|
|
39
|
-
* Send to recipient or target with Postal Service for Swarm
|
|
40
|
-
*
|
|
41
|
-
* @param ky Ky instance for given Bee class instance
|
|
42
|
-
* @param topic Topic name
|
|
43
|
-
* @param target Target message address prefix
|
|
44
|
-
* @param data
|
|
45
|
-
* @param postageBatchId Postage BatchId that will be assigned to sent message
|
|
46
|
-
* @param recipient Recipient public key
|
|
47
|
-
*
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
export function send(ky, topic, target, data, postageBatchId, recipient) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
yield http(ky, {
|
|
53
|
-
method: 'post',
|
|
54
|
-
path: `${endpoint}/send/${topic}/${target}`,
|
|
55
|
-
body: yield prepareData(data),
|
|
56
|
-
responseType: 'json',
|
|
57
|
-
searchParams: {
|
|
58
|
-
recipient
|
|
59
|
-
},
|
|
60
|
-
headers: extractUploadHeaders(postageBatchId)
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Subscribe for messages on the given topic
|
|
66
|
-
*
|
|
67
|
-
* @param url Bee node URL
|
|
68
|
-
* @param topic Topic name
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
export function subscribe(url, topic) {
|
|
72
|
-
const wsUrl = url.replace(/^http/i, 'ws');
|
|
73
|
-
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${topic}`);
|
|
74
|
-
}
|
package/dist/mjs/modules/soc.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
import { extractUploadHeaders } from "../utils/headers.js";
|
|
34
|
-
import { http } from "../utils/http.js";
|
|
35
|
-
const socEndpoint = 'soc';
|
|
36
|
-
/**
|
|
37
|
-
* Upload single owner chunk (SOC) to a Bee node
|
|
38
|
-
*
|
|
39
|
-
* @param ky Ky instance
|
|
40
|
-
* @param owner Owner's ethereum address in hex
|
|
41
|
-
* @param identifier Arbitrary identifier in hex
|
|
42
|
-
* @param signature Signature in hex
|
|
43
|
-
* @param data Content addressed chunk data to be uploaded
|
|
44
|
-
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
45
|
-
* @param options Additional options like tag, encryption, pinning
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
export function upload(ky, owner, identifier, signature, data, postageBatchId, options) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const response = yield http(ky, {
|
|
51
|
-
method: 'post',
|
|
52
|
-
path: `${socEndpoint}/${owner}/${identifier}`,
|
|
53
|
-
body: data,
|
|
54
|
-
headers: Object.assign({
|
|
55
|
-
'content-type': 'application/octet-stream'
|
|
56
|
-
}, extractUploadHeaders(postageBatchId, options)),
|
|
57
|
-
responseType: 'json',
|
|
58
|
-
searchParams: {
|
|
59
|
-
sig: signature
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return response.data.reference;
|
|
63
|
-
});
|
|
64
|
-
}
|