You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,81 +14,170 @@ import TabItem from '@theme/TabItem'
14
14
The [Access Control Trie (ACT)](https://solarpunk.buzz/introducing-the-access-control-trie-act-in-swarm/) is an essential feature designed to manage access control in Swarm’s decentralized storage infrastructure. It enables __publishers__ to grant or revoke access to specific content at the chunk level using encrypted session keys. This guide will walk you through the key concepts and practical aspects of using __ACT__ to protect your data in Swarm.
15
15
16
16
:::warning Postage stamps
17
-
18
-
Uploading to Swarm network require to have Postage stamps for every write operation. To understand better what does it mean see [Bee docs - Keep your data alive](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
17
+
Uploading to the Swarm network requires Postage stamps for every write operation. To understand this better, see [Bee docs - Keep your data alive](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive). In the following examples, we assume that we already have a `postageBatchId`.
19
18
:::
20
19
21
-
### Data
20
+
We also need an instance of Bee to interact with the Bee node.
21
+
22
+
```ts
23
+
import { Bee } from"@ethersphere/bee-js"
22
24
23
-
The same data structures can be handled with ACT as without ACT.
25
+
const bee =newBee('http://localhost:1633')
26
+
```
24
27
25
28
### Upload with ACT
26
29
27
-
When uploading, we can indicate that we are uploading with ACT in the optional requestOptions of bee-jsuploadData method.
30
+
When uploading, we can specify that we are using ACT in the optional `requestOptions` of the `bee-js``uploadData` method.
28
31
29
32
```ts
30
33
const beeRequestOptionsUpload = {
31
34
act: true,
32
35
}
33
36
const uploadResultACT =awaitbee.uploadData(
34
-
postageBatchId, "Bee is awesome with ACT!",
35
-
beeRequestOptionsUpload)
37
+
postageBatchId,
38
+
"Bee is awesome with ACT!",
39
+
beeRequestOptionsUpload
40
+
)
36
41
console.log(uploadResultACT)
37
42
```
38
43
39
-
The return value provides a reference and a history reference. Both will be needed for the download.
44
+
The return value provides a `reference` and a `historyAddress`. Both will be needed for the download.
During the upload, the publisher will be the uploading node.
55
+
During the upload process, the node performing the upload acts as the __publisher__. The __public key__ of this uploading node will be used as the publisher's public key.
51
56
:::
52
57
53
-
### Get Node Public Key
58
+
### Download with ACT
54
59
55
-
```js
56
-
import { Bee } from"@ethersphere/bee-js"
60
+
When downloading, we can specify that we are using __ACT__ in the optional `requestOptions` of the `bee-js``downloadData` method.
57
61
58
-
constbee=newBee('http://localhost:1633')
59
-
constaddr=awaitbee.getNodeAddresses();
62
+
:::warning
63
+
Downloading is only possible with the knowledge of the __publisher's__ public key.
64
+
:::
65
+
66
+
```ts
67
+
const addr =awaitbee.getNodeAddresses()
60
68
61
69
// node public key (publisher public key)
62
70
const pubk =addr.publicKey
63
-
```
64
71
65
-
### Download with ACT
72
+
const beeRequestOptionsDownload = {
73
+
baseURL: BEE_API_URL,
74
+
timeout: 0, // false converted to number
75
+
headers: {
76
+
'swarm-act': 'true',
77
+
'swarm-act-publisher': pubk, // publisher public key
console.log(awaitretrievedData.text()) // prints 'Bee is awesome with ACT!'
84
+
```
66
85
67
-
When downloading, we can indicate that we are downloading with __ACT__ in the optional requestOptions of `bee-js``downloadData` method.
86
+
### Create Grantees
68
87
69
-
:::warning
70
-
The download is only possible with the knowledge of the publisher's public key.
71
-
:::
88
+
To download from another node, we need to create a grantee list for the uploaded data that includes the public key of the downloading node. In the following example, we create a grantee list with three public keys. This list can be modified later using the `patchGrantees` method.
72
89
73
90
```ts
74
-
const beeRequestOptionsDownload = {
75
-
baseURL: BEE_API_URL,
76
-
timeout: 0, // false converted to number
77
-
headers: {
78
-
'swarm-act': 'true',
79
-
'swarm-act-publisher': pubk, // publisher public key
The grantee list can be modified with `patchGrantees`. In our example, we add a new element and remove the last two elements from the `granteePublicKeys` list.
0 commit comments