@ethersphere/bee-js 3.3.2-pre.1 → 3.3.3
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/dist/mjs/bee-debug.js +294 -189
- package/dist/mjs/bee.js +316 -237
- package/dist/mjs/chunk/signer.js +46 -12
- package/dist/mjs/chunk/soc.js +71 -31
- package/dist/mjs/chunk/span.js +1 -1
- package/dist/mjs/feed/index.js +86 -42
- package/dist/mjs/feed/json.js +46 -10
- package/dist/mjs/index.js +2 -1
- package/dist/mjs/modules/bytes.js +61 -24
- package/dist/mjs/modules/bzz.js +96 -58
- package/dist/mjs/modules/chunk.js +51 -16
- package/dist/mjs/modules/debug/balance.js +60 -20
- package/dist/mjs/modules/debug/chequebook.js +115 -67
- package/dist/mjs/modules/debug/chunk.js +47 -11
- package/dist/mjs/modules/debug/connectivity.js +76 -32
- package/dist/mjs/modules/debug/settlements.js +46 -10
- package/dist/mjs/modules/debug/stamps.js +91 -47
- package/dist/mjs/modules/debug/states.js +48 -12
- package/dist/mjs/modules/debug/status.js +97 -49
- package/dist/mjs/modules/debug/tag.js +39 -5
- package/dist/mjs/modules/debug/transactions.js +65 -25
- package/dist/mjs/modules/feed.js +50 -16
- package/dist/mjs/modules/pinning.js +67 -27
- package/dist/mjs/modules/pss.js +44 -10
- package/dist/mjs/modules/soc.js +47 -14
- package/dist/mjs/modules/status.js +37 -3
- package/dist/mjs/modules/stewardship.js +46 -10
- package/dist/mjs/modules/tag.js +73 -31
- package/dist/mjs/utils/collection.browser.js +41 -4
- package/dist/mjs/utils/collection.js +45 -11
- package/dist/mjs/utils/collection.node.js +137 -42
- package/dist/mjs/utils/data.browser.js +88 -52
- package/dist/mjs/utils/data.js +57 -21
- package/dist/mjs/utils/error.js +0 -9
- package/dist/mjs/utils/eth.js +68 -32
- package/dist/mjs/utils/file.js +42 -8
- package/dist/mjs/utils/headers.js +4 -4
- package/dist/mjs/utils/http.js +110 -64
- package/dist/mjs/utils/merge.js +2 -2
- package/dist/mjs/utils/stream.js +0 -4
- package/dist/mjs/utils/type.js +6 -6
- package/package.json +2 -2
|
@@ -1,3 +1,35 @@
|
|
|
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
|
+
|
|
1
33
|
import { http } from "../../utils/http.js";
|
|
2
34
|
import getMajorSemver from 'semver/functions/major.js'; // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
3
35
|
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
@@ -14,13 +46,15 @@ const HEALTH_URL = 'health';
|
|
|
14
46
|
* @param ky Ky debug instance
|
|
15
47
|
*/
|
|
16
48
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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;
|
|
22
57
|
});
|
|
23
|
-
return response.data;
|
|
24
58
|
}
|
|
25
59
|
/**
|
|
26
60
|
* Get information about Bee node
|
|
@@ -28,13 +62,15 @@ export async function getHealth(ky) {
|
|
|
28
62
|
* @param ky Ky debug instance
|
|
29
63
|
*/
|
|
30
64
|
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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;
|
|
36
73
|
});
|
|
37
|
-
return response.data;
|
|
38
74
|
}
|
|
39
75
|
/**
|
|
40
76
|
* Connects to a node and checks if it is a supported Bee version by the bee-js
|
|
@@ -45,8 +81,10 @@ export async function getNodeInfo(ky) {
|
|
|
45
81
|
* @deprecated Use `isSupportedExactVersion` instead
|
|
46
82
|
*/
|
|
47
83
|
|
|
48
|
-
export
|
|
49
|
-
return
|
|
84
|
+
export function isSupportedVersion(ky) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
return isSupportedExactVersion(ky);
|
|
87
|
+
});
|
|
50
88
|
}
|
|
51
89
|
/**
|
|
52
90
|
* Connects to a node and checks if its version matches with the one that bee-js supports.
|
|
@@ -59,11 +97,13 @@ export async function isSupportedVersion(ky) {
|
|
|
59
97
|
* @param ky
|
|
60
98
|
*/
|
|
61
99
|
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
+
});
|
|
67
107
|
}
|
|
68
108
|
/**
|
|
69
109
|
* Connects to a node and checks if its main's API version matches with the one that bee-js supports.
|
|
@@ -74,11 +114,13 @@ export async function isSupportedExactVersion(ky) {
|
|
|
74
114
|
* @param ky
|
|
75
115
|
*/
|
|
76
116
|
|
|
77
|
-
export
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
});
|
|
82
124
|
}
|
|
83
125
|
/**
|
|
84
126
|
* Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
|
|
@@ -89,11 +131,13 @@ export async function isSupportedMainApiVersion(ky) {
|
|
|
89
131
|
* @param ky
|
|
90
132
|
*/
|
|
91
133
|
|
|
92
|
-
export
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
+
});
|
|
97
141
|
}
|
|
98
142
|
/**
|
|
99
143
|
* Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
|
|
@@ -103,12 +147,14 @@ export async function isSupportedDebugApiVersion(ky) {
|
|
|
103
147
|
* @param ky
|
|
104
148
|
*/
|
|
105
149
|
|
|
106
|
-
export
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
});
|
|
112
158
|
}
|
|
113
159
|
/**
|
|
114
160
|
* Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
|
|
@@ -117,18 +163,20 @@ export async function isSupportedApiVersion(ky) {
|
|
|
117
163
|
* @param ky
|
|
118
164
|
*/
|
|
119
165
|
|
|
120
|
-
export
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
+
});
|
|
134
182
|
}
|
|
@@ -1,3 +1,35 @@
|
|
|
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
|
+
|
|
1
33
|
import { http } from "../../utils/http.js";
|
|
2
34
|
const endpoint = 'tags';
|
|
3
35
|
/**
|
|
@@ -7,10 +39,12 @@ const endpoint = 'tags';
|
|
|
7
39
|
* @param uid UID of tag to be retrieved
|
|
8
40
|
*/
|
|
9
41
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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;
|
|
14
49
|
});
|
|
15
|
-
return response.data;
|
|
16
50
|
}
|
|
@@ -1,3 +1,35 @@
|
|
|
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
|
+
|
|
1
33
|
import { http } from "../../utils/http.js";
|
|
2
34
|
const transactionsEndpoint = 'transactions';
|
|
3
35
|
/**
|
|
@@ -6,12 +38,14 @@ const transactionsEndpoint = 'transactions';
|
|
|
6
38
|
* @param ky Debug Ky instance
|
|
7
39
|
*/
|
|
8
40
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
13
48
|
});
|
|
14
|
-
return response.data.pendingTransactions;
|
|
15
49
|
}
|
|
16
50
|
/**
|
|
17
51
|
* Get information for specific pending transactions
|
|
@@ -20,12 +54,14 @@ export async function getAllTransactions(ky) {
|
|
|
20
54
|
* @param transactionHash Hash of the transaction
|
|
21
55
|
*/
|
|
22
56
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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;
|
|
27
64
|
});
|
|
28
|
-
return response.data;
|
|
29
65
|
}
|
|
30
66
|
/**
|
|
31
67
|
* Rebroadcast existing transaction
|
|
@@ -34,13 +70,15 @@ export async function getTransaction(ky, transactionHash) {
|
|
|
34
70
|
* @param transactionHash Hash of the transaction
|
|
35
71
|
*/
|
|
36
72
|
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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;
|
|
42
81
|
});
|
|
43
|
-
return response.data.transactionHash;
|
|
44
82
|
}
|
|
45
83
|
/**
|
|
46
84
|
* Cancel existing transaction
|
|
@@ -50,14 +88,16 @@ export async function rebroadcastTransaction(ky, transactionHash) {
|
|
|
50
88
|
* @param gasPrice Optional gas price
|
|
51
89
|
*/
|
|
52
90
|
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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;
|
|
61
102
|
});
|
|
62
|
-
return response.data.transactionHash;
|
|
63
103
|
}
|
package/dist/mjs/modules/feed.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
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
|
+
|
|
1
33
|
import { filterHeaders, http } from "../utils/http.js";
|
|
2
34
|
import { extractUploadHeaders } from "../utils/headers.js";
|
|
3
35
|
import { BeeError } from "../utils/error.js";
|
|
@@ -12,15 +44,17 @@ const feedEndpoint = 'feeds';
|
|
|
12
44
|
* @param options Additional options, like type (default: 'sequence')
|
|
13
45
|
*/
|
|
14
46
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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;
|
|
22
57
|
});
|
|
23
|
-
return response.data.reference;
|
|
24
58
|
}
|
|
25
59
|
|
|
26
60
|
function readFeedUpdateHeaders(headers) {
|
|
@@ -55,13 +89,13 @@ function readFeedUpdateHeaders(headers) {
|
|
|
55
89
|
*/
|
|
56
90
|
|
|
57
91
|
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
export function fetchFeedUpdate(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));
|
|
63
100
|
});
|
|
64
|
-
return { ...response.data,
|
|
65
|
-
...readFeedUpdateHeaders(response.headers)
|
|
66
|
-
};
|
|
67
101
|
}
|
|
@@ -1,3 +1,35 @@
|
|
|
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
|
+
|
|
1
33
|
import { http } from "../utils/http.js";
|
|
2
34
|
const PINNING_ENDPOINT = 'pins';
|
|
3
35
|
/**
|
|
@@ -7,11 +39,13 @@ const PINNING_ENDPOINT = 'pins';
|
|
|
7
39
|
* @param reference Bee data reference
|
|
8
40
|
*/
|
|
9
41
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
});
|
|
15
49
|
});
|
|
16
50
|
}
|
|
17
51
|
/**
|
|
@@ -21,11 +55,13 @@ export async function pin(ky, reference) {
|
|
|
21
55
|
* @param reference Bee data reference
|
|
22
56
|
*/
|
|
23
57
|
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
});
|
|
29
65
|
});
|
|
30
66
|
}
|
|
31
67
|
/**
|
|
@@ -36,13 +72,15 @@ export async function unpin(ky, reference) {
|
|
|
36
72
|
* @throws Error if given address is not pinned
|
|
37
73
|
*/
|
|
38
74
|
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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;
|
|
44
83
|
});
|
|
45
|
-
return response.data;
|
|
46
84
|
}
|
|
47
85
|
/**
|
|
48
86
|
* Get list of all pins
|
|
@@ -50,17 +88,19 @@ export async function getPin(ky, reference) {
|
|
|
50
88
|
* @param ky Ky instance
|
|
51
89
|
*/
|
|
52
90
|
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
const result = response.data.references;
|
|
60
99
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
100
|
+
if (result === null) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
64
103
|
|
|
65
|
-
|
|
104
|
+
return result;
|
|
105
|
+
});
|
|
66
106
|
}
|
package/dist/mjs/modules/pss.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
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
|
+
|
|
1
33
|
import WebSocket from 'isomorphic-ws';
|
|
2
34
|
import { prepareData } from "../utils/data.js";
|
|
3
35
|
import { http } from "../utils/http.js";
|
|
@@ -15,16 +47,18 @@ const endpoint = 'pss';
|
|
|
15
47
|
*
|
|
16
48
|
*/
|
|
17
49
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
});
|
|
28
62
|
});
|
|
29
63
|
}
|
|
30
64
|
/**
|