@ethersphere/bee-js 5.1.1 → 5.1.2
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 +14 -6
- package/dist/223.index.browser.min.js +3 -0
- package/dist/223.index.browser.min.js.LICENSE.txt +1 -0
- package/dist/223.index.browser.min.js.map +1 -0
- package/dist/cjs/bee-debug.js +208 -312
- package/dist/cjs/bee.js +258 -353
- package/dist/cjs/chunk/signer.js +11 -22
- package/dist/cjs/chunk/soc.js +33 -50
- package/dist/cjs/chunk/span.js +1 -1
- package/dist/cjs/feed/index.js +50 -65
- package/dist/cjs/feed/json.js +8 -21
- package/dist/cjs/feed/retrievable.js +14 -27
- package/dist/cjs/modules/bytes.js +25 -37
- package/dist/cjs/modules/bzz.js +63 -68
- package/dist/cjs/modules/chunk.js +17 -27
- package/dist/cjs/modules/debug/balance.js +24 -41
- package/dist/cjs/modules/debug/chequebook.js +71 -96
- package/dist/cjs/modules/debug/chunk.js +13 -26
- package/dist/cjs/modules/debug/connectivity.js +32 -53
- package/dist/cjs/modules/debug/settlements.js +12 -25
- package/dist/cjs/modules/debug/stake.js +20 -33
- package/dist/cjs/modules/debug/stamps.js +45 -66
- package/dist/cjs/modules/debug/states.js +27 -40
- package/dist/cjs/modules/debug/status.js +53 -80
- package/dist/cjs/modules/debug/tag.js +6 -17
- package/dist/cjs/modules/debug/transactions.js +23 -40
- package/dist/cjs/modules/feed.js +17 -27
- package/dist/cjs/modules/pinning.js +24 -41
- package/dist/cjs/modules/pss.js +9 -20
- package/dist/cjs/modules/soc.js +12 -20
- package/dist/cjs/modules/status.js +4 -15
- package/dist/cjs/modules/stewardship.js +10 -23
- package/dist/cjs/modules/tag.js +28 -47
- package/dist/cjs/utils/collection.browser.js +4 -17
- package/dist/cjs/utils/collection.js +11 -22
- package/dist/cjs/utils/collection.node.js +42 -86
- package/dist/cjs/utils/data.browser.js +46 -59
- package/dist/cjs/utils/data.js +22 -35
- package/dist/cjs/utils/eth.js +31 -43
- package/dist/cjs/utils/file.js +9 -20
- package/dist/cjs/utils/headers.js +4 -4
- package/dist/cjs/utils/http.js +78 -93
- package/dist/cjs/utils/merge.js +1 -1
- package/dist/cjs/utils/sleep.js +2 -13
- package/dist/cjs/utils/type.js +14 -12
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +1 -3
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +209 -450
- package/dist/mjs/bee.js +256 -491
- package/dist/mjs/chunk/bmt.js +4 -10
- package/dist/mjs/chunk/cac.js +0 -3
- package/dist/mjs/chunk/signer.js +12 -63
- package/dist/mjs/chunk/soc.js +33 -85
- package/dist/mjs/chunk/span.js +3 -6
- package/dist/mjs/feed/identifier.js +0 -6
- package/dist/mjs/feed/index.js +53 -97
- package/dist/mjs/feed/json.js +10 -49
- package/dist/mjs/feed/retrievable.js +13 -64
- package/dist/mjs/feed/topic.js +0 -2
- package/dist/mjs/index.js +1 -2
- package/dist/mjs/modules/bytes.js +25 -65
- package/dist/mjs/modules/bzz.js +64 -108
- package/dist/mjs/modules/chunk.js +17 -54
- package/dist/mjs/modules/debug/balance.js +24 -68
- package/dist/mjs/modules/debug/chequebook.js +75 -138
- package/dist/mjs/modules/debug/chunk.js +13 -51
- package/dist/mjs/modules/debug/connectivity.js +32 -76
- package/dist/mjs/modules/debug/settlements.js +12 -50
- package/dist/mjs/modules/debug/stake.js +20 -61
- package/dist/mjs/modules/debug/stamps.js +47 -94
- package/dist/mjs/modules/debug/states.js +25 -66
- package/dist/mjs/modules/debug/status.js +66 -125
- package/dist/mjs/modules/debug/tag.js +6 -41
- package/dist/mjs/modules/debug/transactions.js +25 -69
- package/dist/mjs/modules/feed.js +17 -57
- package/dist/mjs/modules/pinning.js +24 -68
- package/dist/mjs/modules/pss.js +11 -47
- package/dist/mjs/modules/soc.js +14 -48
- package/dist/mjs/modules/status.js +4 -39
- package/dist/mjs/modules/stewardship.js +10 -47
- package/dist/mjs/modules/tag.js +31 -78
- package/dist/mjs/types/debug.js +0 -1
- package/dist/mjs/types/index.js +0 -4
- package/dist/mjs/utils/bytes.js +6 -14
- package/dist/mjs/utils/collection.browser.js +4 -42
- package/dist/mjs/utils/collection.js +11 -57
- package/dist/mjs/utils/collection.node.js +42 -150
- package/dist/mjs/utils/data.browser.js +49 -94
- package/dist/mjs/utils/data.js +19 -62
- package/dist/mjs/utils/error.js +0 -5
- package/dist/mjs/utils/eth.js +37 -95
- package/dist/mjs/utils/file.js +11 -50
- package/dist/mjs/utils/hash.js +0 -1
- package/dist/mjs/utils/headers.js +6 -14
- package/dist/mjs/utils/hex.js +6 -25
- package/dist/mjs/utils/http.js +80 -138
- package/dist/mjs/utils/merge.js +3 -7
- package/dist/mjs/utils/pss.js +0 -2
- package/dist/mjs/utils/reference.js +2 -5
- package/dist/mjs/utils/sleep.js +2 -37
- package/dist/mjs/utils/stream.js +0 -23
- package/dist/mjs/utils/tar.js +2 -5
- package/dist/mjs/utils/type.js +18 -82
- package/dist/mjs/utils/uint64.js +0 -1
- package/dist/mjs/utils/url.js +2 -10
- package/dist/types/bee-debug.d.ts +2 -2
- package/dist/types/bee.d.ts +2 -26
- package/dist/types/chunk/cac.d.ts +1 -1
- package/dist/types/chunk/soc.d.ts +8 -7
- package/dist/types/feed/index.d.ts +9 -8
- package/dist/types/feed/type.d.ts +1 -1
- package/dist/types/modules/bytes.d.ts +6 -5
- package/dist/types/modules/bzz.d.ts +9 -8
- package/dist/types/modules/chunk.d.ts +5 -4
- package/dist/types/modules/debug/balance.d.ts +10 -9
- package/dist/types/modules/debug/chequebook.d.ts +18 -17
- package/dist/types/modules/debug/chunk.d.ts +6 -5
- package/dist/types/modules/debug/connectivity.d.ts +8 -7
- package/dist/types/modules/debug/settlements.d.ts +6 -5
- package/dist/types/modules/debug/stake.d.ts +5 -4
- package/dist/types/modules/debug/stamps.d.ts +8 -7
- package/dist/types/modules/debug/states.d.ts +8 -7
- package/dist/types/modules/debug/status.d.ts +15 -15
- package/dist/types/modules/debug/tag.d.ts +4 -3
- package/dist/types/modules/debug/transactions.d.ts +6 -5
- package/dist/types/modules/feed.d.ts +4 -3
- package/dist/types/modules/pinning.d.ts +8 -7
- package/dist/types/modules/pss.d.ts +4 -3
- package/dist/types/modules/soc.d.ts +3 -2
- package/dist/types/modules/status.d.ts +3 -3
- package/dist/types/modules/stewardship.d.ts +4 -3
- package/dist/types/modules/tag.d.ts +7 -6
- package/dist/types/types/debug.d.ts +1 -1
- package/dist/types/types/index.d.ts +30 -34
- package/dist/types/utils/eth.d.ts +3 -3
- package/dist/types/utils/hex.d.ts +2 -2
- package/dist/types/utils/http.d.ts +6 -6
- package/package.json +34 -39
- 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/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/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,50 +1,15 @@
|
|
|
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
1
|
import { http } from "../../utils/http.js";
|
|
34
2
|
const endpoint = 'tags';
|
|
35
3
|
/**
|
|
36
4
|
* Retrieve tag with extended information from Bee node
|
|
37
5
|
*
|
|
38
|
-
* @param
|
|
6
|
+
* @param kyOptions Ky Options for making requests
|
|
39
7
|
* @param uid UID of tag to be retrieved
|
|
40
8
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
path: `${endpoint}/${uid}`,
|
|
46
|
-
responseType: 'json'
|
|
47
|
-
});
|
|
48
|
-
return response.data;
|
|
9
|
+
export async function retrieveExtendedTag(kyOptions, uid) {
|
|
10
|
+
const response = await http(kyOptions, {
|
|
11
|
+
path: `${endpoint}/${uid}`,
|
|
12
|
+
responseType: 'json'
|
|
49
13
|
});
|
|
14
|
+
return response.parsedData;
|
|
50
15
|
}
|
|
@@ -1,35 +1,3 @@
|
|
|
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
1
|
import { http } from "../../utils/http.js";
|
|
34
2
|
const transactionsEndpoint = 'transactions';
|
|
35
3
|
/**
|
|
@@ -37,15 +5,12 @@ const transactionsEndpoint = 'transactions';
|
|
|
37
5
|
*
|
|
38
6
|
* @param ky Debug Ky instance
|
|
39
7
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
path: transactionsEndpoint,
|
|
45
|
-
responseType: 'json'
|
|
46
|
-
});
|
|
47
|
-
return response.data.pendingTransactions;
|
|
8
|
+
export async function getAllTransactions(kyOptions) {
|
|
9
|
+
const response = await http(kyOptions, {
|
|
10
|
+
path: transactionsEndpoint,
|
|
11
|
+
responseType: 'json'
|
|
48
12
|
});
|
|
13
|
+
return response.parsedData.pendingTransactions;
|
|
49
14
|
}
|
|
50
15
|
/**
|
|
51
16
|
* Get information for specific pending transactions
|
|
@@ -53,15 +18,12 @@ export function getAllTransactions(ky) {
|
|
|
53
18
|
* @param ky Debug Ky instance
|
|
54
19
|
* @param transactionHash Hash of the transaction
|
|
55
20
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
61
|
-
responseType: 'json'
|
|
62
|
-
});
|
|
63
|
-
return response.data;
|
|
21
|
+
export async function getTransaction(kyOptions, transactionHash) {
|
|
22
|
+
const response = await http(kyOptions, {
|
|
23
|
+
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
24
|
+
responseType: 'json'
|
|
64
25
|
});
|
|
26
|
+
return response.parsedData;
|
|
65
27
|
}
|
|
66
28
|
/**
|
|
67
29
|
* Rebroadcast existing transaction
|
|
@@ -69,16 +31,13 @@ export function getTransaction(ky, transactionHash) {
|
|
|
69
31
|
* @param ky Debug Ky instance
|
|
70
32
|
* @param transactionHash Hash of the transaction
|
|
71
33
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
78
|
-
responseType: 'json'
|
|
79
|
-
});
|
|
80
|
-
return response.data.transactionHash;
|
|
34
|
+
export async function rebroadcastTransaction(kyOptions, transactionHash) {
|
|
35
|
+
const response = await http(kyOptions, {
|
|
36
|
+
method: 'post',
|
|
37
|
+
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
38
|
+
responseType: 'json'
|
|
81
39
|
});
|
|
40
|
+
return response.parsedData.transactionHash;
|
|
82
41
|
}
|
|
83
42
|
/**
|
|
84
43
|
* Cancel existing transaction
|
|
@@ -87,17 +46,14 @@ export function rebroadcastTransaction(ky, transactionHash) {
|
|
|
87
46
|
* @param transactionHash Hash of the transaction
|
|
88
47
|
* @param gasPrice Optional gas price
|
|
89
48
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
99
|
-
responseType: 'json'
|
|
100
|
-
});
|
|
101
|
-
return response.data.transactionHash;
|
|
49
|
+
export async function cancelTransaction(kyOptions, transactionHash, gasPrice) {
|
|
50
|
+
const response = await http(kyOptions, {
|
|
51
|
+
method: 'delete',
|
|
52
|
+
headers: {
|
|
53
|
+
'gas-price': gasPrice
|
|
54
|
+
},
|
|
55
|
+
path: `${transactionsEndpoint}/${transactionHash}`,
|
|
56
|
+
responseType: 'json'
|
|
102
57
|
});
|
|
58
|
+
return response.parsedData.transactionHash;
|
|
103
59
|
}
|
package/dist/mjs/modules/feed.js
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
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
1
|
import { filterHeaders, http } from "../utils/http.js";
|
|
34
2
|
import { extractUploadHeaders } from "../utils/headers.js";
|
|
35
3
|
import { BeeError } from "../utils/error.js";
|
|
@@ -43,32 +11,25 @@ const feedEndpoint = 'feeds';
|
|
|
43
11
|
* @param postageBatchId Postage BatchId to be used to create the Feed Manifest
|
|
44
12
|
* @param options Additional options, like type (default: 'sequence')
|
|
45
13
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
searchParams: filterHeaders(options),
|
|
54
|
-
headers: extractUploadHeaders(postageBatchId)
|
|
55
|
-
});
|
|
56
|
-
return response.data.reference;
|
|
14
|
+
export async function createFeedManifest(kyOptions, owner, topic, postageBatchId, options) {
|
|
15
|
+
const response = await http(kyOptions, {
|
|
16
|
+
method: 'post',
|
|
17
|
+
responseType: 'json',
|
|
18
|
+
path: `${feedEndpoint}/${owner}/${topic}`,
|
|
19
|
+
searchParams: filterHeaders(options),
|
|
20
|
+
headers: extractUploadHeaders(postageBatchId)
|
|
57
21
|
});
|
|
22
|
+
return response.parsedData.reference;
|
|
58
23
|
}
|
|
59
|
-
|
|
60
24
|
function readFeedUpdateHeaders(headers) {
|
|
61
25
|
const feedIndex = headers.get('swarm-feed-index');
|
|
62
26
|
const feedIndexNext = headers.get('swarm-feed-index-next');
|
|
63
|
-
|
|
64
27
|
if (!feedIndex) {
|
|
65
28
|
throw new BeeError('Response did not contain expected swarm-feed-index!');
|
|
66
29
|
}
|
|
67
|
-
|
|
68
30
|
if (!feedIndexNext) {
|
|
69
31
|
throw new BeeError('Response did not contain expected swarm-feed-index-next!');
|
|
70
32
|
}
|
|
71
|
-
|
|
72
33
|
return {
|
|
73
34
|
feedIndex,
|
|
74
35
|
feedIndexNext
|
|
@@ -87,15 +48,14 @@ function readFeedUpdateHeaders(headers) {
|
|
|
87
48
|
* @param topic Topic in hex
|
|
88
49
|
* @param options Additional options, like index, at, type
|
|
89
50
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
responseType: 'json',
|
|
96
|
-
path: `${feedEndpoint}/${owner}/${topic}`,
|
|
97
|
-
searchParams: filterHeaders(options)
|
|
98
|
-
});
|
|
99
|
-
return Object.assign(Object.assign({}, response.data), readFeedUpdateHeaders(response.headers));
|
|
51
|
+
export async function fetchLatestFeedUpdate(kyOptions, owner, topic, options) {
|
|
52
|
+
const response = await http(kyOptions, {
|
|
53
|
+
responseType: 'json',
|
|
54
|
+
path: `${feedEndpoint}/${owner}/${topic}`,
|
|
55
|
+
searchParams: filterHeaders(options)
|
|
100
56
|
});
|
|
57
|
+
return {
|
|
58
|
+
...response.parsedData,
|
|
59
|
+
...readFeedUpdateHeaders(response.headers)
|
|
60
|
+
};
|
|
101
61
|
}
|
|
@@ -1,67 +1,29 @@
|
|
|
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
1
|
import { http } from "../utils/http.js";
|
|
34
2
|
const PINNING_ENDPOINT = 'pins';
|
|
35
3
|
/**
|
|
36
4
|
* Pin data with given reference
|
|
37
5
|
*
|
|
38
|
-
* @param
|
|
6
|
+
* @param kyOptions Ky Options for making requests
|
|
39
7
|
* @param reference Bee data reference
|
|
40
8
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
responseType: 'json',
|
|
47
|
-
path: `${PINNING_ENDPOINT}/${reference}`
|
|
48
|
-
});
|
|
9
|
+
export async function pin(kyOptions, reference) {
|
|
10
|
+
await http(kyOptions, {
|
|
11
|
+
method: 'post',
|
|
12
|
+
responseType: 'json',
|
|
13
|
+
path: `${PINNING_ENDPOINT}/${reference}`
|
|
49
14
|
});
|
|
50
15
|
}
|
|
51
16
|
/**
|
|
52
17
|
* Unpin data with given reference
|
|
53
18
|
*
|
|
54
|
-
* @param
|
|
19
|
+
* @param kyOptions Ky Options for making requests
|
|
55
20
|
* @param reference Bee data reference
|
|
56
21
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
responseType: 'json',
|
|
63
|
-
path: `${PINNING_ENDPOINT}/${reference}`
|
|
64
|
-
});
|
|
22
|
+
export async function unpin(kyOptions, reference) {
|
|
23
|
+
await http(kyOptions, {
|
|
24
|
+
method: 'delete',
|
|
25
|
+
responseType: 'json',
|
|
26
|
+
path: `${PINNING_ENDPOINT}/${reference}`
|
|
65
27
|
});
|
|
66
28
|
}
|
|
67
29
|
/**
|
|
@@ -71,30 +33,24 @@ export function unpin(ky, reference) {
|
|
|
71
33
|
* @param reference
|
|
72
34
|
* @throws Error if given address is not pinned
|
|
73
35
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
responseType: 'json',
|
|
80
|
-
path: `${PINNING_ENDPOINT}/${reference}`
|
|
81
|
-
});
|
|
82
|
-
return response.data;
|
|
36
|
+
export async function getPin(kyOptions, reference) {
|
|
37
|
+
const response = await http(kyOptions, {
|
|
38
|
+
method: 'get',
|
|
39
|
+
responseType: 'json',
|
|
40
|
+
path: `${PINNING_ENDPOINT}/${reference}`
|
|
83
41
|
});
|
|
42
|
+
return response.parsedData;
|
|
84
43
|
}
|
|
85
44
|
/**
|
|
86
45
|
* Get list of all pins
|
|
87
46
|
*
|
|
88
47
|
* @param ky Ky instance
|
|
89
48
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
responseType: 'json',
|
|
96
|
-
path: `${PINNING_ENDPOINT}`
|
|
97
|
-
});
|
|
98
|
-
return response.data.references;
|
|
49
|
+
export async function getAllPins(kyOptions) {
|
|
50
|
+
const response = await http(kyOptions, {
|
|
51
|
+
method: 'get',
|
|
52
|
+
responseType: 'json',
|
|
53
|
+
path: `${PINNING_ENDPOINT}`
|
|
99
54
|
});
|
|
55
|
+
return response.parsedData.references;
|
|
100
56
|
}
|
package/dist/mjs/modules/pss.js
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
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
1
|
import WebSocket from 'isomorphic-ws';
|
|
34
2
|
import { prepareData } from "../utils/data.js";
|
|
35
3
|
import { http } from "../utils/http.js";
|
|
@@ -38,7 +6,7 @@ const endpoint = 'pss';
|
|
|
38
6
|
/**
|
|
39
7
|
* Send to recipient or target with Postal Service for Swarm
|
|
40
8
|
*
|
|
41
|
-
* @param
|
|
9
|
+
* @param kyOptions Ky Options for making requests
|
|
42
10
|
* @param topic Topic name
|
|
43
11
|
* @param target Target message address prefix
|
|
44
12
|
* @param data
|
|
@@ -46,19 +14,16 @@ const endpoint = 'pss';
|
|
|
46
14
|
* @param recipient Recipient public key
|
|
47
15
|
*
|
|
48
16
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
headers: extractUploadHeaders(postageBatchId)
|
|
61
|
-
});
|
|
17
|
+
export async function send(kyOptions, topic, target, data, postageBatchId, recipient) {
|
|
18
|
+
await http(kyOptions, {
|
|
19
|
+
method: 'post',
|
|
20
|
+
path: `${endpoint}/send/${topic}/${target}`,
|
|
21
|
+
body: await prepareData(data),
|
|
22
|
+
responseType: 'json',
|
|
23
|
+
searchParams: {
|
|
24
|
+
recipient
|
|
25
|
+
},
|
|
26
|
+
headers: extractUploadHeaders(postageBatchId)
|
|
62
27
|
});
|
|
63
28
|
}
|
|
64
29
|
/**
|
|
@@ -67,7 +32,6 @@ export function send(ky, topic, target, data, postageBatchId, recipient) {
|
|
|
67
32
|
* @param url Bee node URL
|
|
68
33
|
* @param topic Topic name
|
|
69
34
|
*/
|
|
70
|
-
|
|
71
35
|
export function subscribe(url, topic) {
|
|
72
36
|
const wsUrl = url.replace(/^http/i, 'ws');
|
|
73
37
|
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${topic}`);
|
package/dist/mjs/modules/soc.js
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
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
1
|
import { extractUploadHeaders } from "../utils/headers.js";
|
|
34
2
|
import { http } from "../utils/http.js";
|
|
35
3
|
const socEndpoint = 'soc';
|
|
@@ -44,21 +12,19 @@ const socEndpoint = 'soc';
|
|
|
44
12
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
45
13
|
* @param options Additional options like tag, encryption, pinning
|
|
46
14
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return response.data.reference;
|
|
15
|
+
export async function upload(kyOptions, owner, identifier, signature, data, postageBatchId, options) {
|
|
16
|
+
const response = await http(kyOptions, {
|
|
17
|
+
method: 'post',
|
|
18
|
+
path: `${socEndpoint}/${owner}/${identifier}`,
|
|
19
|
+
body: data,
|
|
20
|
+
headers: {
|
|
21
|
+
'content-type': 'application/octet-stream',
|
|
22
|
+
...extractUploadHeaders(postageBatchId, options)
|
|
23
|
+
},
|
|
24
|
+
responseType: 'json',
|
|
25
|
+
searchParams: {
|
|
26
|
+
sig: signature
|
|
27
|
+
}
|
|
63
28
|
});
|
|
29
|
+
return response.parsedData.reference;
|
|
64
30
|
}
|
|
@@ -1,46 +1,11 @@
|
|
|
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
1
|
import { http } from "../utils/http.js";
|
|
34
2
|
/**
|
|
35
3
|
* Ping the base bee URL. If connection was not successful throw error
|
|
36
4
|
*
|
|
37
|
-
* @param
|
|
5
|
+
* @param kyOptions Ky instance for given Bee class instance
|
|
38
6
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
yield http(ky, {
|
|
43
|
-
path: ''
|
|
44
|
-
});
|
|
7
|
+
export async function checkConnection(kyOptions) {
|
|
8
|
+
await http(kyOptions, {
|
|
9
|
+
path: ''
|
|
45
10
|
});
|
|
46
11
|
}
|
|
@@ -1,35 +1,3 @@
|
|
|
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
1
|
import { http } from "../utils/http.js";
|
|
34
2
|
const stewardshipEndpoint = 'stewardship';
|
|
35
3
|
/**
|
|
@@ -39,22 +7,17 @@ const stewardshipEndpoint = 'stewardship';
|
|
|
39
7
|
* @param options
|
|
40
8
|
* @throws BeeResponseError if not locally pinned or invalid data
|
|
41
9
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
method: 'put',
|
|
47
|
-
path: `${stewardshipEndpoint}/${reference}`
|
|
48
|
-
});
|
|
10
|
+
export async function reupload(kyOptions, reference) {
|
|
11
|
+
await http(kyOptions, {
|
|
12
|
+
method: 'put',
|
|
13
|
+
path: `${stewardshipEndpoint}/${reference}`
|
|
49
14
|
});
|
|
50
15
|
}
|
|
51
|
-
export function isRetrievable(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
path: `${stewardshipEndpoint}/${reference}`
|
|
57
|
-
});
|
|
58
|
-
return response.data.isRetrievable;
|
|
16
|
+
export async function isRetrievable(kyOptions, reference) {
|
|
17
|
+
const response = await http(kyOptions, {
|
|
18
|
+
method: 'get',
|
|
19
|
+
responseType: 'json',
|
|
20
|
+
path: `${stewardshipEndpoint}/${reference}`
|
|
59
21
|
});
|
|
22
|
+
return response.parsedData.isRetrievable;
|
|
60
23
|
}
|