worldwatch 0.1.0__tar.gz
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.
- worldwatch-0.1.0/.claude/settings.json +21 -0
- worldwatch-0.1.0/.claude/skills/swarm/SKILL.md +137 -0
- worldwatch-0.1.0/.claude/skills/swarm-act/SKILL.md +240 -0
- worldwatch-0.1.0/.claude/skills/swarm-blog/SKILL.md +337 -0
- worldwatch-0.1.0/.claude/skills/swarm-build-app/SKILL.md +183 -0
- worldwatch-0.1.0/.claude/skills/swarm-docs/SKILL.md +101 -0
- worldwatch-0.1.0/.claude/skills/swarm-feed/SKILL.md +203 -0
- worldwatch-0.1.0/.claude/skills/swarm-host-website/SKILL.md +218 -0
- worldwatch-0.1.0/.claude/skills/swarm-messaging/SKILL.md +203 -0
- worldwatch-0.1.0/.claude/skills/swarm-setup-bee/SKILL.md +286 -0
- worldwatch-0.1.0/.claude/skills/swarm-setup-bee-interactive/SKILL.md +437 -0
- worldwatch-0.1.0/.claude/skills/swarm-stamps/REFERENCE.md +192 -0
- worldwatch-0.1.0/.claude/skills/swarm-stamps/SKILL.md +222 -0
- worldwatch-0.1.0/.claude/skills/swarm-troubleshoot/SKILL.md +235 -0
- worldwatch-0.1.0/.claude/skills/swarm-upload-download/SKILL.md +201 -0
- worldwatch-0.1.0/.github/workflows/tests.yml +21 -0
- worldwatch-0.1.0/.gitignore +24 -0
- worldwatch-0.1.0/.pre-commit-config.yaml +14 -0
- worldwatch-0.1.0/CLAUDE.md +139 -0
- worldwatch-0.1.0/LICENSE +28 -0
- worldwatch-0.1.0/PKG-INFO +171 -0
- worldwatch-0.1.0/README.md +138 -0
- worldwatch-0.1.0/doc/CONVERSATION-ARCHIVE.md +300 -0
- worldwatch-0.1.0/doc/OPERATOR-SETUP-GUIDE.md +215 -0
- worldwatch-0.1.0/doc/OPERATOR-TODO.md +54 -0
- worldwatch-0.1.0/doc/PROGRESS.md +196 -0
- worldwatch-0.1.0/doc/fullchat.txt +186 -0
- worldwatch-0.1.0/doc/global-anomaly-sources.md +54 -0
- worldwatch-0.1.0/doc/p0-implementation-plan.md +170 -0
- worldwatch-0.1.0/doc/tier1-onboarding-status.md +63 -0
- worldwatch-0.1.0/doc/toCheck +1 -0
- worldwatch-0.1.0/doc/worldwatch-architecture-v0.1.md +252 -0
- worldwatch-0.1.0/further_info_sources +6 -0
- worldwatch-0.1.0/ops/README.md +71 -0
- worldwatch-0.1.0/ops/backup/restic-backup.sh +17 -0
- worldwatch-0.1.0/ops/deploy.sh +54 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-api.service +15 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-consolidate.service +8 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-consolidate.timer +10 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-detect.service +8 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-detect.timer +10 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-poll.service +16 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-presence.service +8 -0
- worldwatch-0.1.0/ops/systemd/worldwatch-presence.timer +10 -0
- worldwatch-0.1.0/ops/worldwatch.env.example +24 -0
- worldwatch-0.1.0/pyproject.toml +65 -0
- worldwatch-0.1.0/src/worldwatch/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/__main__.py +6 -0
- worldwatch-0.1.0/src/worldwatch/alerts/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/alerts/engine.py +200 -0
- worldwatch-0.1.0/src/worldwatch/allocate/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/api/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/api/app.py +188 -0
- worldwatch-0.1.0/src/worldwatch/api/notify.py +113 -0
- worldwatch-0.1.0/src/worldwatch/api/static/index.html +114 -0
- worldwatch-0.1.0/src/worldwatch/cascade/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/cascade/bins.py +88 -0
- worldwatch-0.1.0/src/worldwatch/cascade/consolidator.py +144 -0
- worldwatch-0.1.0/src/worldwatch/cascade/tdigest.py +170 -0
- worldwatch-0.1.0/src/worldwatch/cascade/welford.py +58 -0
- worldwatch-0.1.0/src/worldwatch/cli.py +117 -0
- worldwatch-0.1.0/src/worldwatch/config/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/config/loader.py +86 -0
- worldwatch-0.1.0/src/worldwatch/config/sources/tier1.toml +358 -0
- worldwatch-0.1.0/src/worldwatch/db.py +154 -0
- worldwatch-0.1.0/src/worldwatch/ingest/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/ingest/geocode.py +47 -0
- worldwatch-0.1.0/src/worldwatch/ingest/models.py +24 -0
- worldwatch-0.1.0/src/worldwatch/ingest/parsers.py +430 -0
- worldwatch-0.1.0/src/worldwatch/instrument.py +29 -0
- worldwatch-0.1.0/src/worldwatch/layer0/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/layer0/continuous.py +214 -0
- worldwatch-0.1.0/src/worldwatch/layer0/count.py +180 -0
- worldwatch-0.1.0/src/worldwatch/layer0/models.py +65 -0
- worldwatch-0.1.0/src/worldwatch/layer0/presence.py +296 -0
- worldwatch-0.1.0/src/worldwatch/layer0/runner.py +169 -0
- worldwatch-0.1.0/src/worldwatch/layer1/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/poll/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/poll/fetch.py +246 -0
- worldwatch-0.1.0/src/worldwatch/poll/http.py +65 -0
- worldwatch-0.1.0/src/worldwatch/poll/poller.py +125 -0
- worldwatch-0.1.0/src/worldwatch/poll/url.py +50 -0
- worldwatch-0.1.0/src/worldwatch/probe/__init__.py +0 -0
- worldwatch-0.1.0/src/worldwatch/runtime.py +44 -0
- worldwatch-0.1.0/src/worldwatch/store.py +62 -0
- worldwatch-0.1.0/tests/conftest.py +25 -0
- worldwatch-0.1.0/tests/fixtures/cloudflare_radar_sample.json +23 -0
- worldwatch-0.1.0/tests/fixtures/gdelt_export_sample.zip +0 -0
- worldwatch-0.1.0/tests/fixtures/nws_alerts_sample.json +41 -0
- worldwatch-0.1.0/tests/fixtures/usgs_sample.json +24 -0
- worldwatch-0.1.0/tests/fixtures/wikimedia_sample.json +7 -0
- worldwatch-0.1.0/tests/test_alerts.py +166 -0
- worldwatch-0.1.0/tests/test_api.py +123 -0
- worldwatch-0.1.0/tests/test_bins.py +141 -0
- worldwatch-0.1.0/tests/test_cli.py +67 -0
- worldwatch-0.1.0/tests/test_consolidator.py +163 -0
- worldwatch-0.1.0/tests/test_continuous.py +131 -0
- worldwatch-0.1.0/tests/test_count.py +123 -0
- worldwatch-0.1.0/tests/test_fetch.py +294 -0
- worldwatch-0.1.0/tests/test_notify.py +165 -0
- worldwatch-0.1.0/tests/test_parsers.py +296 -0
- worldwatch-0.1.0/tests/test_poller.py +186 -0
- worldwatch-0.1.0/tests/test_presence.py +88 -0
- worldwatch-0.1.0/tests/test_presence_pass.py +193 -0
- worldwatch-0.1.0/tests/test_runner.py +168 -0
- worldwatch-0.1.0/tests/test_tdigest.py +76 -0
- worldwatch-0.1.0/tests/test_url.py +44 -0
- worldwatch-0.1.0/tests/test_welford.py +53 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(git add *)",
|
|
5
|
+
"Bash(git commit -m ' *)",
|
|
6
|
+
"Bash(git push *)",
|
|
7
|
+
"Bash(git checkout *)",
|
|
8
|
+
"Bash(curl -s https://api.github.com/repos/ethersphere/bee/releases/latest)",
|
|
9
|
+
"Bash(curl *)",
|
|
10
|
+
"Bash(jq)",
|
|
11
|
+
"Bash(npm --version)",
|
|
12
|
+
"Bash(swarm-cli *)",
|
|
13
|
+
"Bash(node *)",
|
|
14
|
+
"Bash(echo *)",
|
|
15
|
+
"Bash(bee version *)",
|
|
16
|
+
"Edit(.claude/skills/*)",
|
|
17
|
+
"WebFetch(domain:github.com)",
|
|
18
|
+
"WebFetch(domain:docs.ethswarm.org)"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swarm
|
|
3
|
+
description: Primary Swarm entry point — detects whether Bee is installed and running, routes to setup/troubleshoot if not, and otherwise shows the full skill menu and routes the developer to the right workflow (storage, website, app, access control, messaging). Use at the start of any Swarm task or when unsure where to begin.
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Swarm Entry Point
|
|
8
|
+
|
|
9
|
+
The starting point for building on Swarm. This skill detects whether Bee is installed and running, routes the user to setup or troubleshooting if needed, and once a node is ready, shows the full menu of skills and routes the user to the right one.
|
|
10
|
+
|
|
11
|
+
## Formatting
|
|
12
|
+
|
|
13
|
+
When presenting to the user, use consistent labels before each code block:
|
|
14
|
+
- **Run in your terminal:** — a command the user should execute
|
|
15
|
+
- **Expected output:** — example of what a successful result looks like
|
|
16
|
+
- **Save as `filename`:** — file contents the user should write to disk
|
|
17
|
+
|
|
18
|
+
Add a `---` horizontal rule before each labeled code block to visually separate it from surrounding text.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Step 1 — Check if Bee is running
|
|
23
|
+
|
|
24
|
+
**Say "Checking your Bee node…"**, then probe the default API endpoint directly — don't use swarm-cli here (it may not be installed yet), and don't pause for confirmation (read-only check):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
curl -s http://localhost:1633/status | jq .beeMode
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If it returns a `beeMode` value (`ultra-light`, `light`, or `full`), Bee is running → go to **Step 3** with that value.
|
|
31
|
+
|
|
32
|
+
If the request fails or returns no output, continue to Step 2.
|
|
33
|
+
|
|
34
|
+
## Step 2 — Check if Bee is installed
|
|
35
|
+
|
|
36
|
+
Silently look for a Bee binary in common locations. Run these checks without showing the commands to the user:
|
|
37
|
+
|
|
38
|
+
**All platforms:**
|
|
39
|
+
```bash
|
|
40
|
+
bee version
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Windows (PowerShell):**
|
|
44
|
+
```powershell
|
|
45
|
+
where.exe bee
|
|
46
|
+
Get-Command bee -ErrorAction SilentlyContinue
|
|
47
|
+
Test-Path "$env:APPDATA\bee\bee.exe"
|
|
48
|
+
Test-Path "$env:LOCALAPPDATA\bee\bee.exe"
|
|
49
|
+
Test-Path "$env:PROGRAMFILES\bee\bee.exe"
|
|
50
|
+
Test-Path "$env:PROGRAMFILES(x86)\bee\bee.exe"
|
|
51
|
+
Test-Path "$env:USERPROFILE\.bee\bee.exe"
|
|
52
|
+
Get-Service bee -ErrorAction SilentlyContinue
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Linux/macOS:**
|
|
56
|
+
```bash
|
|
57
|
+
ls /usr/local/bin/bee /usr/bin/bee ~/.bee/bin/bee 2>/dev/null
|
|
58
|
+
systemctl status bee 2>/dev/null
|
|
59
|
+
brew list bee 2>/dev/null
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Route based on findings
|
|
63
|
+
|
|
64
|
+
**Bee found but not responding at localhost:1633:**
|
|
65
|
+
|
|
66
|
+
Tell the user:
|
|
67
|
+
> "I detected a Bee installation on your system, but I'm not getting a response from the default endpoint at `http://localhost:1633`. Please start your Bee node and then run `/swarm` again — or, if your node is running on a non-default endpoint, let me know the address and I'll use that instead."
|
|
68
|
+
|
|
69
|
+
- If they provide a different endpoint: use it in place of `localhost:1633` for all subsequent checks and pass it along to any skill you route to.
|
|
70
|
+
- If they start their node and re-run `/swarm`: continue from Step 1.
|
|
71
|
+
- If they need help or can't get it running: route to `/swarm-troubleshoot`.
|
|
72
|
+
|
|
73
|
+
**Bee not found anywhere:**
|
|
74
|
+
|
|
75
|
+
Tell the user Bee doesn't appear to be installed, and let them choose `/swarm-setup-bee-interactive` (guided, step-by-step with verification) or `/swarm-setup-bee` (reference, all steps at once) to set up their node. Briefly explain the difference between the two.
|
|
76
|
+
|
|
77
|
+
## Step 3 — Bee is running
|
|
78
|
+
|
|
79
|
+
Use the `beeMode` value from Step 1 — no extra command needed:
|
|
80
|
+
|
|
81
|
+
- **ultra-light:** Tell the user their node is running in ultra-light mode and uploads won't work. Ask if they want to upgrade to light mode — if yes, route to `/swarm-setup-bee-interactive`. Otherwise, show the menu below (downloads still work).
|
|
82
|
+
- **light or full:** Tell the user their node is ready, then show the menu below and ask what they want to build.
|
|
83
|
+
|
|
84
|
+
## Step 4 — Show the menu
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
Welcome! Here's what I can help you with:
|
|
88
|
+
|
|
89
|
+
🐝 Setup & Infrastructure
|
|
90
|
+
/swarm-setup-bee-interactive — Install and run a Bee node, step-by-step with verification
|
|
91
|
+
/swarm-setup-bee — Install and run a Bee node (reference, all steps at once)
|
|
92
|
+
/swarm-stamps — Buy or manage postage stamps (required for uploads)
|
|
93
|
+
/swarm-troubleshoot — Diagnose node, connectivity, or upload issues
|
|
94
|
+
|
|
95
|
+
📦 Store & Retrieve
|
|
96
|
+
/swarm-upload-download — Upload and download data, files, or directories
|
|
97
|
+
/swarm-host-website — Deploy a website to Swarm (with optional ENS)
|
|
98
|
+
|
|
99
|
+
🔧 Build
|
|
100
|
+
/swarm-build-app — Scaffold a Swarm dApp or add bee-js to your project
|
|
101
|
+
/swarm-feed — Create updateable content at a fixed address
|
|
102
|
+
/swarm-blog — Build a blog with posts, feeds, and a permanent URL
|
|
103
|
+
|
|
104
|
+
🔒 Advanced
|
|
105
|
+
/swarm-act — Encrypt data with per-account access control
|
|
106
|
+
/swarm-messaging — Real-time messaging (GSOC or PSS)
|
|
107
|
+
|
|
108
|
+
📚 Questions
|
|
109
|
+
/swarm-docs — Answer Swarm concepts from the authoritative docs
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Then route
|
|
113
|
+
|
|
114
|
+
"What are you looking to build?" and route based on their answer:
|
|
115
|
+
|
|
116
|
+
| They say... | Route to |
|
|
117
|
+
|---|---|
|
|
118
|
+
| "I'm new" / "getting started" / "first time" | `/swarm-setup-bee-interactive` (guided) or `/swarm-setup-bee` (reference) |
|
|
119
|
+
| "upload" / "store data" / "download" | `/swarm-upload-download` |
|
|
120
|
+
| "deploy a website" / "host a site" | `/swarm-host-website` |
|
|
121
|
+
| "build an app" / "scaffold" / "dApp" | `/swarm-build-app` |
|
|
122
|
+
| "feed" / "dynamic content" / "update without changing URL" | `/swarm-feed` |
|
|
123
|
+
| "blog" / "posts" / "publish articles" | `/swarm-blog` |
|
|
124
|
+
| "stamp" / "storage" / "how much does it cost" | `/swarm-stamps` |
|
|
125
|
+
| "encrypt" / "private" / "access control" | `/swarm-act` |
|
|
126
|
+
| "chat" / "messaging" / "real-time" / "notifications" | `/swarm-messaging` |
|
|
127
|
+
| "how does X work" / "explain" / concept question | `/swarm-docs` |
|
|
128
|
+
| "not working" / "error" / "can't connect" | `/swarm-troubleshoot` |
|
|
129
|
+
| "no code" / "just deploy" | Suggest Beeport (beeport.ethswarm.org) — no node needed |
|
|
130
|
+
|
|
131
|
+
### Quick path check
|
|
132
|
+
|
|
133
|
+
If still unclear where they are in their journey:
|
|
134
|
+
|
|
135
|
+
1. **Do you have a Bee node running?** No → `/swarm-setup-bee-interactive` (guided) or `/swarm-setup-bee` (reference)
|
|
136
|
+
2. **Do you have a postage stamp?** No → `/swarm-stamps`
|
|
137
|
+
3. **What do you want to build?** → route to the right skill
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swarm-act
|
|
3
|
+
description: Guide to Swarm ACT encryption and access control: create grantees, upload protected data, grant/revoke access, and troubleshoot not-found/history issues.
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Access Control (ACT)
|
|
8
|
+
|
|
9
|
+
Guide a developer through encrypting data on Swarm and controlling who can read it. ACT (Access Control Trie) lets you define per-account read permissions using Ethereum public keys.
|
|
10
|
+
|
|
11
|
+
## Formatting
|
|
12
|
+
|
|
13
|
+
When presenting to the user, use consistent labels before each code block:
|
|
14
|
+
- **Run in your terminal:** — a command the user should execute
|
|
15
|
+
- **Expected output:** — example of what a successful result looks like
|
|
16
|
+
- **Save as `filename`:** — file contents the user should write to disk
|
|
17
|
+
|
|
18
|
+
Add a `---` horizontal rule before each labeled code block to visually separate it from surrounding text.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Before Starting (run immediately)
|
|
23
|
+
|
|
24
|
+
Run these checks now and **narrate each one in a short line** — say what you're checking, run it (don't paste the command), then report the result. Don't pause for confirmation; these are read-only checks.
|
|
25
|
+
|
|
26
|
+
1. **Say "Checking your Bee node…"**, then run:
|
|
27
|
+
```bash
|
|
28
|
+
curl -s http://localhost:1633/status | jq .beeMode
|
|
29
|
+
```
|
|
30
|
+
Reachable → "✓ Node is up." | Fails → "✗ No Bee node running." and offer to walk through `/swarm-setup-bee-interactive`.
|
|
31
|
+
|
|
32
|
+
2. **Say "Checking for a usable postage stamp…"**, then run:
|
|
33
|
+
```bash
|
|
34
|
+
curl -s http://localhost:1633/stamps | jq '.stamps[] | select(.usable==true) | {batchID, depth, batchTTL}'
|
|
35
|
+
```
|
|
36
|
+
Found → "✓ Found a usable stamp." and proceed. | None → "✗ No usable stamp." and route to `/swarm-stamps`.
|
|
37
|
+
|
|
38
|
+
## What to Ask
|
|
39
|
+
|
|
40
|
+
1. **What data are you protecting?** (files, website, app data)
|
|
41
|
+
2. **Who should have access?** (specific Ethereum public keys)
|
|
42
|
+
3. **swarm-cli or bee-js?**
|
|
43
|
+
|
|
44
|
+
## Prerequisites
|
|
45
|
+
|
|
46
|
+
- For swarm-cli: `npm install -g @ethersphere/swarm-cli`
|
|
47
|
+
- For bee-js: `npm install @ethersphere/bee-js`
|
|
48
|
+
|
|
49
|
+
## How ACT Works
|
|
50
|
+
|
|
51
|
+
- Data is uploaded encrypted — only authorized accounts can decrypt
|
|
52
|
+
- Access is controlled via a **grantee list** of Ethereum public keys
|
|
53
|
+
- The publisher manages the list: add or revoke access at any time
|
|
54
|
+
- Unauthorized download attempts return "not found" — the data is invisible without access
|
|
55
|
+
- The publisher always has access
|
|
56
|
+
|
|
57
|
+
## Via swarm-cli
|
|
58
|
+
|
|
59
|
+
### Upload with ACT
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
swarm-cli upload test.txt --act --stamp <BATCH_ID>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
First upload — omit `--act-history-address` to create a new history. The response returns:
|
|
66
|
+
- Encrypted Swarm reference
|
|
67
|
+
- History reference
|
|
68
|
+
|
|
69
|
+
> **Warning:** Save the history reference securely. Losing it means **permanent, irrecoverable loss** of access to your encrypted data. There is no recovery mechanism.
|
|
70
|
+
|
|
71
|
+
For subsequent uploads to the same history:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
swarm-cli upload test.txt --act --stamp <BATCH_ID> --act-history-address <HISTORY_REF>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Download with ACT
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
swarm-cli download <SWARM_HASH> output.txt \
|
|
81
|
+
--act \
|
|
82
|
+
--act-history-address <HISTORY_REF> \
|
|
83
|
+
--act-publisher <PUBLIC_KEY>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- `--act-publisher` — the uploader's public key (needed for decryption). Get it from `swarm-cli addresses` → "Public Key:" field.
|
|
87
|
+
- `--act-timestamp` — optional, defaults to current time. Use to access a specific version.
|
|
88
|
+
|
|
89
|
+
**Without the ACT flags, the download will fail with "not found".**
|
|
90
|
+
|
|
91
|
+
### Create a grantee list
|
|
92
|
+
|
|
93
|
+
Create a JSON file with the public keys of accounts that should have access:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"grantees": [
|
|
98
|
+
"03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa",
|
|
99
|
+
"03fdcab22b455ce08a481d929a4cb9f447752545818eded1ad1785c51581e822c6"
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
swarm-cli grantee create grantees.json --stamp <BATCH_ID>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Returns a grantee reference and history reference — save both.
|
|
109
|
+
|
|
110
|
+
### Update access (add/revoke)
|
|
111
|
+
|
|
112
|
+
Create a patch JSON:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"add": ["03fdcab22b455ce08a481d929a4cb9f447752545818eded1ad1785c51581e822c6"],
|
|
117
|
+
"revoke": ["03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa"]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
swarm-cli grantee patch grantees-patch.json \
|
|
123
|
+
--reference <GRANTEE_REF> \
|
|
124
|
+
--history <GRANTEE_HISTORY_REF> \
|
|
125
|
+
--stamp <BATCH_ID>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Note:** Wait at least 1 second between grantee list updates — updating within the same second causes an error.
|
|
129
|
+
|
|
130
|
+
### View grantee list
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
swarm-cli grantee get <GRANTEE_REF>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Via bee-js
|
|
137
|
+
|
|
138
|
+
### Upload with ACT
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
import { Bee } from '@ethersphere/bee-js'
|
|
142
|
+
|
|
143
|
+
const bee = new Bee('http://localhost:1633')
|
|
144
|
+
|
|
145
|
+
// Upload a file with ACT encryption enabled
|
|
146
|
+
const result = await bee.uploadFile(batchId, 'Secret data', 'secret.txt', {
|
|
147
|
+
act: true
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const historyAddress = result.historyAddress.getOrThrow()
|
|
151
|
+
console.log('Encrypted reference:', result.reference.toHex())
|
|
152
|
+
console.log('History address:', historyAddress.toHex())
|
|
153
|
+
// WARNING: Save both — losing the history address means permanent loss of access to encrypted data
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Download with ACT
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
import { Bee } from '@ethersphere/bee-js'
|
|
160
|
+
|
|
161
|
+
const bee = new Bee('http://localhost:1633')
|
|
162
|
+
|
|
163
|
+
// Get the publisher's public key (share this with grantees):
|
|
164
|
+
const publisherAddresses = await bee.getNodeAddresses()
|
|
165
|
+
const publisherPublicKey = publisherAddresses.publicKey // not pssPublicKey
|
|
166
|
+
|
|
167
|
+
const file = await bee.downloadFile(encryptedReference, 'secret.txt', {
|
|
168
|
+
actHistoryAddress: historyAddress,
|
|
169
|
+
actPublisher: publisherPublicKey
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
console.log('Decrypted:', file.data.toUtf8())
|
|
173
|
+
// Without ACT parameters, this returns "not found"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
> **swarm-cli quirk:** in testing, `swarm-cli download <ref> --act --act-history-address <hist> --act-publisher <pk>` can return 404 even with correct values, while the equivalent Bee HTTP API call (same headers) returns 200. If the CLI download fails, retry via the API or bee-js.
|
|
177
|
+
|
|
178
|
+
### Manage grantees
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
import { Bee } from '@ethersphere/bee-js'
|
|
182
|
+
|
|
183
|
+
const bee = new Bee('http://localhost:1633')
|
|
184
|
+
|
|
185
|
+
// Create grantee list
|
|
186
|
+
const granteeResult = await bee.createGrantees(batchId, [
|
|
187
|
+
'03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa'
|
|
188
|
+
])
|
|
189
|
+
const granteeReference = granteeResult.ref
|
|
190
|
+
const historyReference = granteeResult.historyref
|
|
191
|
+
console.log('Grantee ref:', granteeReference.toHex())
|
|
192
|
+
console.log('History ref:', historyReference.toHex())
|
|
193
|
+
|
|
194
|
+
// Get current grantees
|
|
195
|
+
const granteesResult = await bee.getGrantees(granteeReference)
|
|
196
|
+
console.log('Grantees:', granteesResult.grantees.map(k => k.toCompressedHex()))
|
|
197
|
+
|
|
198
|
+
// Update access — add and revoke
|
|
199
|
+
await bee.patchGrantees(batchId, granteeReference, historyReference, {
|
|
200
|
+
add: ['03fdcab22b455ce08a481d929a4cb9f447752545818eded1ad1785c51581e822c6'],
|
|
201
|
+
revoke: ['03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa']
|
|
202
|
+
})
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Use Cases
|
|
206
|
+
|
|
207
|
+
- **Private file sharing** — share documents with specific accounts
|
|
208
|
+
- **Paid content** — grant access after payment
|
|
209
|
+
- **Subscriber-only access** — manage a grantee list for subscribers
|
|
210
|
+
- **Team collaboration** — restrict project data to team members
|
|
211
|
+
|
|
212
|
+
## Important Notes
|
|
213
|
+
|
|
214
|
+
- Grantees are identified by their **Ethereum public keys** (compressed, 33 bytes hex)
|
|
215
|
+
- Only the publisher (uploader) can manage the grantee list
|
|
216
|
+
- Revoking access prevents future decryption but doesn't delete already-downloaded data
|
|
217
|
+
- Invalid history addresses return "not found" errors
|
|
218
|
+
- Wait at least 1 second between grantee list updates
|
|
219
|
+
|
|
220
|
+
## If Something Goes Wrong
|
|
221
|
+
|
|
222
|
+
| Error | Fix |
|
|
223
|
+
|-------|-----|
|
|
224
|
+
| "not found" on download | Missing ACT flags, wrong history address, or access revoked |
|
|
225
|
+
| "act: invalid history" | Wrong history address — double-check reference |
|
|
226
|
+
| "stamp not usable" | Wait 2-3 minutes after buying |
|
|
227
|
+
| 1-second update error | Wait at least 1 second between grantee list updates |
|
|
228
|
+
| Other errors | Route to `/swarm-troubleshoot` |
|
|
229
|
+
|
|
230
|
+
## Conceptual Questions
|
|
231
|
+
|
|
232
|
+
For any conceptual or technical question not covered by the steps above, invoke `/swarm-docs` to find the relevant authoritative source rather than answering from prior knowledge.
|
|
233
|
+
|
|
234
|
+
## Reference
|
|
235
|
+
|
|
236
|
+
- ACT guide: https://docs.ethswarm.org/docs/develop/act
|
|
237
|
+
- ACT concepts: https://docs.ethswarm.org/docs/concepts/access-control
|
|
238
|
+
- bee-js docs: https://bee-js.ethswarm.org/docs/
|
|
239
|
+
- swarm-cli: https://github.com/ethersphere/swarm-cli
|
|
240
|
+
|