Deliver images and video with tiered access (DataUserVC / Stage T)¶
This page continues Tier the response by trust (DataUserVC / Stage T) (§0–§7) and carries the actual image / video bytes end-to-end. Section numbers continue from the first page (§8–§11).
What you'll do: Deliver images and video through the HTTP media gateway (Option B) and IPFS (Option C), receive them in the PWA viewer, and provide them from the PWA Provider
Prerequisites: §0–§7 of Tier the response by trust (DataUserVC / Stage T)
Keep running: the publisher and mosquitto started in §1 of the first page
What you need: PC + smartphone (iw3ip-wallet)
Time required: approx. 90 min
Where this page belongs
- This is the second page of 2.5 in Part 2 (Hands-on).
- Previous page: Tier the response by trust (DataUserVC / Stage T)
- Next page: Tier by semantic level (VLM and semantic representation / Stage T)
- The first time, do §8 (Option B), §10 and §11 in that order. §9 (Option C, IPFS) is optional; you can skip it and still go on to the next page. §13 of the next page uses
/viewerfrom §10 and/providerfrom §11.
As on the first page, the command examples assume that the course repository is cloned to
~/program/Blockchain_IoT_Marketplace. $HOST_IP and <HOST_IP> are the PC's LAN IP (see Hands-on for how to set it). Options A / B / C are compared in
§0b.
8. Real-data integration (Option B — HTTP media gateway)¶
Through §7 on the first page, Tier the response by trust (DataUserVC / Stage T), you verified the keys image_cid / video_cid /
video_duration_sec appear or disappear per tier. To carry the actual
image / video bytes end-to-end, the provider side uploads a sample JPEG / MP4
fixture to the publisher's /media/upload, takes back the URL, and
folds it into the event payload as image_url / video_url.
8.1 One-shot provider script¶
The script does not register a consent (ConsentVC), so register one first (not needed if you did it in §4a of the first page; consents are stored on the publisher volume, so they survive a container recreate).
cd ~/program/Blockchain_IoT_Marketplace
curl -s -X POST localhost:8080/consents \
-H 'content-type: application/json' \
-d @examples/consent_possible_littering.json | jq .status
Expected output:
"stored"
python3 examples/hands_on/data_user_vc_tiered/provider_with_media.py \
--base-url http://$HOST_IP:8080
The script:
- Prepares a sample JPEG / MP4 fixture under
fixtures/(a 16×16 grey JPEG of 285 bytes; the MP4 is the same JPEG bytes handled asvideo/mp4, so it does not play). - Uploads both via
POST /media/upload(sha256 dedupe). - Posts a
possible_litteringevent carryingimage_url/video_url/video_duration_secto/simulate/publish.
The final [publish] output should show "status": "allowed". If it says denied, check the consent registration.
If you ran this script before
The fixture in older versions of the course repository was a 155-byte JPEG with no image data, which browsers, OpenCV and the VLM could not decode. Run git pull to update the course repository and then run the script; it automatically replaces the old file under fixtures/ with the new JPEG.
8.2 Receiver (unchanged — same Tier 3 / 2 / 1 flow as §3–§7)¶
Use the §3–§7 flow as is. Fetching /platform/data per tier gives:
- Tier 3 (gov full) →
event+image_url+video_url+video_duration_sec - Tier 2 (enterprise) →
event+image_urlonly - Tier 1 (default) →
eventonly
Tap image_url in iPhone Safari → a small grey image (16×16 pixels) opens directly. To try a
real photo / clip:
python3 examples/hands_on/data_user_vc_tiered/provider_with_media.py \
--base-url http://$HOST_IP:8080 \
--image /path/to/snapshot.jpg \
--video /path/to/clip.mp4 \
--video-duration-sec 12
8.3 Limitations of Option B¶
- Coexists with
image_cid/video_cid(Option A / coming-up Option C). - Limitation: not content-addressed — anyone with the URL can GET the blob.
- Limitation: single replica, no pinning.
When content-addressing + distributed storage matter, move on to
Option C (IPFS). The /media/upload response
shape ({url, sha256, content_type, byte_size, cid, ipfs_gateway_url, c2pa})
stays the same so the provider script doesn't change — only the
backend swaps.
9. Option C: local kubo IPFS daemon for distributed delivery¶
This section is optional. It is another way to deliver the media, using IPFS instead of Option B in §8. The first time, you can skip it and go on to §10.
Option B served the blob from a single publisher instance. Option C
hashes the same blob into a content-addressed CID and stores it on
an IPFS network. Receivers can dereference the CID through any IPFS
gateway — the publisher's built-in /ipfs/<cid> proxy, the public
https://ipfs.io/ipfs/<cid>, etc. — so the data survives a publisher
outage.
9.1 Bring kubo up alongside the publisher¶
Activate the ipfs compose profile:
cd ~/program/Blockchain_IoT_Marketplace
export IPFS_API_URL=http://ipfs:5001
export IPFS_GATEWAY_URL=http://ipfs:8080
docker compose -f infra/docker-compose.yml --profile ipfs up -d --force-recreate publisher ipfs
docker compose -f infra/docker-compose.yml ps ipfs
In the ps output, the iw3ip-ipfs container should be Up.
Recreating the publisher container with --force-recreate clears the claims, ViewerTokens, and event rows it kept in memory. After publishing again in §9.2, redo only the presentation (getting a ViewerToken) in §4 of the first page. The cards in the wallet stay usable because the issuer key is kept on the volume. Redoing the claims in §3 would add three more cards with the same names. Consents are stored on the volume, so you do not need to register them again.
Verify the publisher picked up the env vars:
curl -s http://$HOST_IP:8080/.well-known/openid-credential-issuer >/dev/null
docker compose -f infra/docker-compose.yml exec publisher \
python -c "from publisher.app.config import Settings; \
s=Settings(); \
print('IPFS_API_URL=', s.ipfs_api_url); \
print('IPFS_GATEWAY_URL=', s.ipfs_gateway_url)"
9.2 Confirm CIDs come back from upload¶
provider_with_media.py is unchanged but now sees cid and
ipfs_gateway_url in the response. Without --image / --video it uses the same fixtures as §8.1
(examples/hands_on/data_user_vc_tiered/fixtures/stage_t_demo.jpg / stage_t_demo.mp4):
python3 examples/hands_on/data_user_vc_tiered/provider_with_media.py \
--base-url http://$HOST_IP:8080
Expected output (cid starts with bafk...). With the default fixture, sha256 and cid match the values below. c2pa is null because the C2PA check (Stage P) is not enabled:
[upload] {
"image": {
"url": "http://<HOST_IP>:8080/media/<sha256>.jpg",
"sha256": "e6e34dda2552486336ad63a0ef24752c012963a3c08aaa234035caac7928e134",
"content_type": "image/jpeg",
"byte_size": 285,
"cid": "bafkreihg4ng5ujksjbrtnlldudxsi5jmaeuwhi6arkvcgqbvzkwhskhbgq",
"ipfs_gateway_url": "http://<HOST_IP>:8080/ipfs/bafkreihg4ng5ujksjbrtnlldudxsi5jmaeuwhi6arkvcgqbvzkwhskhbgq",
"c2pa": null
},
...
}
The provider script automatically folds the CID into the event payload
as image_cid / video_cid, so the receiver §3–§7 flow keeps
working.
9.3 Receiver: CID or URL — pick one¶
/platform/data now hands back both image_cid and image_url
for Tier 2 / Tier 3. $VIEWER_TOKEN is a Tier 3 ViewerToken extracted as in §4 of the first page (valid for 60 seconds). The rows are listed oldest first, so .rows[-1] shows the last row (the event published in §9.2):
curl -s -H "authorization: Bearer $VIEWER_TOKEN" \
"http://$HOST_IP:8080/platform/data?dataset_id=home/event/possible_littering" \
| jq --arg h "$HOST_IP" '.rows[-1] | {image_cid, image_url, ipfs_gateway: ("http://"+$h+":8080/ipfs/"+.image_cid)}'
Open any of these on the buyer's iPhone Safari:
| Method | Example URL |
|---|---|
| Publisher HTTP gateway | http://<HOST_IP>:8080/media/<sha256>.jpg (Option B compatible) |
| Publisher IPFS proxy | http://<HOST_IP>:8080/ipfs/<cid> |
| Public IPFS gateway | https://ipfs.io/ipfs/<cid> (needs internet) |
If the last one, the public IPFS gateway, returns the data, you have confirmed that the CID alone is enough to fetch it even when the publisher is offline (content addressing works).
9.4 Pros, caveats, and follow-ups¶
- Content-addressed: CID is a hash of the bytes — tamper-evident, multi-gateway.
- Publisher outage tolerant: any peer with a replica can serve.
- Option-B compatible: response gains
cid+ipfs_gateway_url; existing fields are unchanged. - Note: if the kubo daemon is unreachable,
/media/uploadstill returns 200 but withcid: null— graceful fallback to Option B. - Note: public-gateway resolution depends on IPFS network propagation (can take minutes).
- Pairing with a pinning service (Web3.Storage / Pinata) would improve cross-network durability (not supported yet; future work).
9.5 Troubleshooting¶
| Symptom | Fix |
|---|---|
cid: null in upload response |
Check that the kubo container is Up with docker compose -f infra/docker-compose.yml --profile ipfs ps ipfs; if it is stopped, start it with docker compose -f infra/docker-compose.yml --profile ipfs up -d ipfs |
/ipfs/<cid> returns 502 |
Publisher can't reach http://ipfs:8080. Check Docker network membership |
/ipfs/<cid> returns 404 |
IPFS_GATEWAY_URL is empty. Set .env or export and recreate |
| Public gateway can't fetch | Behind NAT, kubo not visible to peers. Run docker compose -f infra/docker-compose.yml exec ipfs ipfs swarm peers to verify |
10. PWA viewer (one UX for phone and PC)¶
§3–§9 (§3–§7 are on the first page, Tier the response by trust (DataUserVC / Stage T)) walked through the dev-style flow ("call /verifier/request,
collect the token, curl /platform/data"). The publisher now ships a
built-in PWA viewer (/buyer/start + /viewer) so a buyer just
opens one URL and the rest is automatic, on iPhone Safari or
PC Chrome / Edge / Firefox.
On iPhone Safari:
sequenceDiagram
participant S as iPhone Safari
participant W as iw3ip-wallet
participant P as publisher
S->>S: /buyer/start
S->>W: auto-redirect to deeplink, iw3ip-wallet opens
W->>P: present Tier 3
P->>P: mint ViewerToken
P-->>S: redirect_uri = /viewer?vt=...
Note over S: Safari resumes → /viewer auto-renders image/video
On PC Chrome:
sequenceDiagram
participant C as PC Chrome
participant W as iPhone<br>(wallet)
participant P as publisher
C->>C: /buyer/start
C->>C: shows QR + polls every 2 s
C-->>W: scan QR with iPhone
W->>P: wallet → present
P->>P: mint ViewerToken
P-->>C: /verifier/status returns viewer_url
Note over C: PC browser auto-navigates to /viewer → image renders
10.1 Bring it up¶
No special setup. Open /buyer/start?ds=<dataset_id> from the same
URL on either device — the page detects the user agent and switches
mode:
iPhone Safari: http://<HOST_IP>:8080/buyer/start?ds=home/event/possible_littering
PC Chrome: http://<HOST_IP>:8080/buyer/start?ds=home/event/possible_littering
10.2 Same-device (iPhone) flow¶
- Open the URL in Safari.
- The page calls
/verifier/requestto fetch a deeplink. window.location = deeplinklaunches iw3ip-wallet automatically.- In the wallet, pick "IW3IP Purchase Viewer (Full • event + image + video)" and present.
- The wallet receives
redirect_uri = /viewer?vt=...&ds=...and... - ...Safari resumes automatically and the image / video renders.
You do not need to copy and paste URLs as in the curl steps.
10.3 Cross-device (PC + iPhone) flow¶
- Open the URL on a PC browser.
- The page renders a large QR code (the OID4VP deeplink).
- Scan it with the iPhone camera or directly inside the wallet → wallet → present.
- The PC page polls
/verifier/status?state=...every 2 seconds. - Once the wallet completes, the response includes
viewer_url. - The PC navigates to
/viewerand the same image / video renders.
10.4 What /viewer shows¶
/viewer?vt=<viewer_token>&ds=<dataset_id> renders:
- A tier badge (
event/event+image/event+image+video) up top. image_urlas an inline<img>.video_urlas a playable<video controls>.image_cid(if Option C is on) as a clickable link to the publisher's/ipfs/<cid>proxy.- Raw row JSON tucked under a
<details>toggle.
If the ViewerToken's 60-second TTL has expired you get a 401 plus a message asking you to "reload from /buyer/start."
10.5 What each tier looks like (real-device screenshots)¶
Wallet side: three distinct cards¶
After receiving the three PurchaseViewerVCs, iw3ip-wallet (Sphereon mobile-wallet fork)
shows the PurchaseViewerVCs as three independent cards — same VCT, different
credential_configuration_id, different display name.

https://iw3ip.example/credentials/PurchaseViewerVC/v1;
the credential_configuration_id split (.full /
.access / .event) is what gives them their distinct
labels.
Viewer side: response shape changes per presented tier¶
Below are real-device /viewer screenshots from iPhone Safari (◀ SphereonWallet
in the top-left = Safari was opened by the wallet via redirect_uri). The
badge color and which media keys disappear show which tier was used.
| Tier 3 (gov / Full) | Tier 2 (enterprise / Access) | Tier 1 (default / Event-only) |
|---|---|---|
![]() |
![]() |
![]() |
green badge tier: event+image+video |
orange badge tier: event+image |
gray badge tier: event |
| inline image + video player | image only, video player gone | text and timestamp only |
image_cid / image_url / video_url / video_duration_sec all present |
image_cid / image_url only |
every media key dropped |
The three screenshots come from the same dataset (home/event/possible_littering)
fetched with three different PurchaseViewerVC tiers. The server-side data is
identical — what changes is which keys ViewerToken's allowed_views lets
through.
10.6 Why both devices matter¶
| Manual curl flow (§§3–9) | PWA viewer | |
|---|---|---|
| Easy on phone | ✗ — copy URLs | ✓ |
| Works on PC | ✗ — no wallet on PC | ✓ — QR + polling every 2 s |
| App install on PC | iw3ip-wallet (phone) | none beyond a browser |
| Re-fetch after TTL | redo curl | reload the page |
| Public demo cost | long handout | hand over one URL |
10.7 Troubleshooting¶
| Symptom | Fix |
|---|---|
| iPhone deeplink doesn't open the wallet | Tap the visible 「ウォレットで開く」 ("Open in wallet") link; check Safari's "Open in App" permission |
| PC doesn't show a QR | The browser couldn't reach the CDN (cdn.jsdelivr.net). It fails in an offline environment |
| PC poll never finishes | Confirm the wallet actually presented a valid VC: docker compose -f infra/docker-compose.yml logs publisher should show a 200 /verifier/response |
/viewer returns 401 |
ViewerToken TTL (60 s) lapsed. Reload /buyer/start |
/buyer/start shows a red box headed "データを閲覧する権限がありません" |
See §10.8 below |
10.8 Deny UX (when the verifier rejects a presentation)¶
When the verifier rejects a presented VC, /verifier/status returns a
reason code together with a human-readable human_message_ja /
human_message_en pair. The /buyer/start page picks that up during
its polling and replaces the QR with a red box headed "データを閲覧する権限がありません" (you are not allowed to view the data),
the message, a reason code: line, and a "このページをリロード" (reload this page) link
(see publisher/app/viewer_routes.py and publisher/app/ssi/verifier_routes.py).
Main reason codes and their messages (the page shows human_message_ja when it is present):
| reason | EN message | JA message |
|---|---|---|
dataset_mismatch |
The presented VC is bound to a different dataset. | 提示された VC のデータセットが、要求されたデータセットと一致しません。 |
action_not_allowed |
The presented VC does not include the required action (read). | 提示された VC では、このデータの読み取り権限がありません。 |
purpose_mismatch |
The presented VC's allowed_purposes does not cover this purpose. | 提示された VC の許可目的に、今回の用途が含まれていません。 |
missing_entityType / missing_purpose / missing_dataHandlingPolicy |
DataUserVC is missing XXX. (missing_legalCompliance and missing_misuseRecord give a generic "presentation denied (reason)" message) |
DataUserVC に XXX が含まれていません。 |
verification_failed |
VC verification failed. | VC の署名検証に失敗しました。 |
/buyer/start asks only for a PurchaseViewerVC, so the missing_* rows (for DataUserVC) and purpose_mismatch (for ConsentVC) do not appear on this page. Every PurchaseViewerVC this issuer mints has read, so action_not_allowed does not appear either. A dataset or VC-type mismatch is rejected by the presentation-definition match before dataset_mismatch is checked (so dataset_mismatch does not appear either), and shows as field_mismatch:$.dataset_id or field_mismatch:$.vct with the generic message "提示が拒否されました (reason)。". verification_failed appears only when the sidecar returns no reason. With a bad signature on the default path, the reason is verify_error:... and the page shows the generic "提示が拒否されました (verify_error:...)。" message.
Publisher-side flow (not yet validated on a real device — read from the implementation; as noted below, step 2 does not happen with a normal wallet):
- PC opens
/buyer/start?ds=home/event/possible_littering→ QR appears. - Suppose a wallet sends a PurchaseViewerVC bound to a different dataset (e.g.
home/event/another_dataset). A normal wallet does not offer such a card and shows "No Available Credential" instead. - publisher receives
/verifier/response; the value does not match$.dataset_idin the presentation definition, so it records{"verified": false, "reason": "field_mismatch:$.dataset_id"}(on the default path this check rejects it beforedataset_mismatchis examined). - The PC's
/verifier/statuspoll returns aresultholdingverified: false, thereason, and thehuman_message_*strings. - The page replaces the QR with a
<div class="err">holding "データを閲覧する権限がありません" and the generic message "提示が拒否されました (field_mismatch:$.dataset_id)。", then showsreason code: field_mismatch:$.dataset_idand a "このページをリロード" (reload this page) link. /audit/logsgains a row withraw_topicoid4vp/response,actiondeny, andreasonfield_mismatch:$.dataset_id(check withcurl -s localhost:8080/audit/logs | jq '[.[] | select(.raw_topic == "oid4vp/response")][0]').
In normal use this denial does not happen. The presentation request includes the target dataset, and the wallet does not offer cards that do not match (it shows "No Available Credential" instead). The flow above is the publisher's defence in case a wallet sends a non-matching card anyway.
11. PWA Provider (the data-provider side)¶
§10 covered the receiver side reading data through the PWA Viewer.
§11 covers the symmetric provider side: a PWA where a data provider
authenticates with SSI and uploads + publishes data through the same
publisher container — /provider/start + /provider + /provider/publish
replace the curl steps in provider_with_media.py with a browser-only
flow.
sequenceDiagram
participant B as PC browser
participant W as iPhone<br>(wallet)
participant P as publisher
B->>B: /provider/start
B->>B: QR + polling every 2 s
B-->>W: scan QR with iPhone wallet
W->>P: present SellerVC
P->>P: mint SellerToken
P-->>B: /verifier/status returns seller_token + licensed_datasets
B->>B: PC page renders the licensed_datasets list
B->>B: pick one and click "Continue to upload"
B->>B: /provider?pt=#lt;seller_token#gt;&ds=#lt;dataset_id#gt;
B->>P: file pick / camera capture / browser recorder → /media/upload
P-->>B: URL + (CID)
B->>B: "Publish" button
B->>P: POST /provider/publish (Bearer SellerToken)
P->>P: use_seller_token → process_message
P-->>B: {"status":"allowed", ...}
/provider/start is the SellerVC counterpart of /buyer/start — same
OID4VP implementation pattern, just with vc_kind=SellerVC and a SellerToken minted
on success.
11.1 Open the page¶
The publisher must be running (docker compose -f infra/docker-compose.yml up -d publisher).
If the wallet has no SellerVC yet, first open the following URL in a PC browser and scan the QR code with the wallet to receive one.
http://<HOST_IP>:8080/issuer/offer?type=SellerVC&seller_id=seller-handson&licensed_datasets=home/event/possible_littering
Then open this URL in a PC browser:
http://<HOST_IP>:8080/provider/start?ds=home/event/possible_littering
ds= is a hint only (SellerVC verification isn't dataset-scoped),
but it shows in the page header so the operator knows which dataset
they're working on.
11.2 Present a SellerVC (OID4VP)¶
PC shows a QR. Scan it from the iPhone wallet and present a SellerVC (not a PurchaseViewerVC — they're different cards in the wallet).
On success the page swaps to a result panel:
- Green banner "SellerVC 提示が承認されました" (Presentation accepted)
- The full licensed_datasets list straight from the SellerVC claims
seller_idand the SellerToken expiry (default 24 h)- A "Continue to upload →" button next to a radio list
Click through to land on /provider?pt=<seller_token>&ds=<chosen ds>.
Deny UX
If the SellerVC is missing seller_id or licensed_datasets,
/verifier/status surfaces human_message_ja / human_message_en
via a red banner (reason codes: missing_seller_id /
missing_licensed_datasets), and offers a one-click reload to retry
with a different VC.
11.3 Three ways to provide data¶
The /provider page has three input modes. All of them go through
the same /media/upload URL/CID delivery, so the receiver side at
/viewer shows the data the same way whichever one was used.
| Mode | Behaviour | Best on |
|---|---|---|
| 📁 File picker | OS file dialog, pick an existing file | PC + phone |
| 📷 Camera capture | <input capture="environment"> — iPhone Safari opens the rear camera directly; PC falls back to file picker |
iPhone (capture-on-the-spot) |
| 🔴 Browser recorder | MediaRecorder against getUserMedia({video,audio}). Click 録画開始 (Start recording), see live preview, click 停止 (Stop) to auto-upload as WebM/VP9. Firefox falls back to VP8. Only Safari 16 and earlier fall back to MP4 — Safari 17+ has native WebM/VP9 support |
PC webcam |
All three call the same uploadBlob() pipeline: preview →
POST /media/upload → result panel → enable the Publish button.
Storage stays bounded because uploads are deduplicated by SHA-256.
Why browser recording matters for demos
PC webcam → SSI auth → publish in one browser tab is a 30-second demo of "data with provenance attached." It complements the Share detections, not raw frames: that one streams continuously, this one captures discrete clips with on-the-spot attribution.
When you stop a recording, the video_duration_sec form field is
auto-filled with the measured length.
11.4 Publish + the licensed_datasets gate¶
Once an upload completes, the Publish button enables. The form holds:
topic— defaults tohomeassistant/event/<last segment of ds>purpose— defaults tocommunity_cleaningcamera_id,video_duration_secextra payload keys— optional JSON merge
Click Publish event. The browser POSTs to /provider/publish with
Authorization: Bearer <seller_token>. Server-side:
schemas.normalize(topic, payload)derivesdataset_id(for ahomeassistant/event/...topic it buildshome/event/<event_type>from the payload'sevent_type; this page fixesevent_typetopossible_littering, unless anevent_typein the extra payload keys overrides it).ssi_state.use_seller_token(token, dataset_id=<resolved>)enforces thatdataset_id ∈ licensed_datasets[].- On success it calls
processor.process_message(same path as/simulate/publish). - Response is augmented with
seller_token_jti+register_count.
SellerToken is multi-use (same semantics as /marketplace/register),
so a single SellerVC presentation covers a whole upload session — you
can watch register_count grow in the response details panel.
Deny cases:
| Failure | HTTP | reason |
|---|---|---|
missing Authorization header |
401 | missing_authorization_header |
Authorization header not in the form Bearer <token> |
401 | invalid_authorization_header |
| unknown SellerToken | 401 | seller_token_unknown |
| expired SellerToken | 401 | seller_token_expired |
derived dataset not in licensed_datasets[] |
403 | seller_token_dataset_not_licensed |
topic not recognised by normalize() |
400 | unsupported_topic:... |
The seller_token_* errors (401 and 403) are recorded in /audit/logs with action=deny. The 401s for a missing or malformed Authorization header and the 400 for unsupported_topic are returned before any audit write, so they are not recorded.
11.5 Confirm from the receiver side¶
The footer of /provider auto-generates a link to /buyer/start for
the same dataset. Open it in a separate tab, present a Tier 3
PurchaseViewerVC, and the image / video you just published renders in
/viewer (the same screen as §10.5 screenshots).
The whole provide → auth → publish → receive → verify flow runs in two browser tabs.
Verified end-to-end (2026-04-30)
A video/quicktime clip recorded on iPhone Safari, published via
/provider, was rendered inline by the <video> tag in /viewer
on macOS Safari (see scenario A in §11.8). The same wallet held both the
SellerVC (provider side) and the PurchaseViewerVC.full (receiver
side); each /buyer/start or /provider/start page picked the
right one automatically. Screenshot:
images/data-user-vc-tiered/provider/A-macsafari-viewer-tier3.jpg.
11.6 Symmetry with /buyer/start¶
| Aspect | /buyer/start (§10) |
/provider/start (§11) |
|---|---|---|
| VC presented | PurchaseViewerVC | SellerVC |
| Token minted on verify | ViewerToken (TTL 60 s) | SellerToken (TTL 24 h) |
| Used as Bearer for | /platform/data |
/provider/publish |
| Single-use vs multi-use | multi-use (continuous read) | multi-use (one auth, many publishes) |
| Dataset scoping | VC is bound to a dataset_id | SellerVC carries licensed_datasets[] set |
| Deny message shape | §10.8 common format | same human_message_ja/en shape |
11.7 Troubleshooting¶
| Symptom | Fix |
|---|---|
The wallet shows "No Available Credential" after scanning the /provider/start QR |
Issue one first: /issuer/offer?type=SellerVC&seller_id=...&licensed_datasets=... and scan the offer URI from the wallet |
| 📷 Camera capture opens the file picker on iPhone Safari | Some iOS versions don't honor the combination accept="image/*,video/*" capture="environment". Switching accept to video/* only forces the camera reliably |
| 🔴 Browser recorder button does nothing | getUserMedia only works on HTTPS or localhost. Opening over a LAN IP (http://192.168.x.x) makes the browser deny camera/mic permission. Use localhost:8080 or run behind HTTPS |
/provider/publish returns 403 seller_token_dataset_not_licensed |
The derived dataset_id isn't in your SellerVC's licensed_datasets[]. This page fixes event_type to possible_littering (unless overridden in the extra payload keys), so any homeassistant/event/ topic gives home/event/possible_littering. Include it in the SellerVC |
Publish response has status: send_error |
The publisher's PLATFORM_API_URL is unreachable. The SellerToken gate did pass and register_count did increment — auth was OK, downstream delivery failed |
/provider/publish returns 401 seller_token_unknown |
SSIStateStore is in-memory; restarting the publisher container wipes every token. Re-present the SellerVC at /provider/start to mint a fresh one (the SellerVC itself stays in the wallet, no re-issuance needed). For hands-on sessions that bounce the container, plan one extra OID4VP loop after each restart |
| Wallet shows "Retrieving access token failed: 400 / Error Screen" | OID4VCI offers are single-use. Sphereon-family wallets retry /issuer/token internally; the second call fails with invalid_grant (400). The first call already issued the VC into the wallet — the error screen is misleading. Dismiss it and check the wallet's credential list; the new card should be there |
11.8 Real-device validation log¶
End-to-end runs of the three §11.3 input modes across four
environments. Screenshots live under
docs/hands-on/images/data-user-vc-tiered/provider/.
| Scenario | Environment | Status | Observation |
|---|---|---|---|
A iPhone camera capture (capture="environment") |
iPhone Safari (iOS 18.x) | verified (2026-04-30) | upload video/quicktime 273KB → Publish status=allowed → receiver /viewer plays the .MOV inline (macOS Safari) |
| B PC browser recording (MediaRecorder) | macOS Chrome 147 | codec confirmed (2026-04-30) | Supports all 4: vp9,opus / vp8,opus / webm / mp4 → preference picks VP9. Recording + Publish to be verified after switching the wallet's IP |
| C Firefox VP8 fallback | macOS Firefox 139 | verified (2026-04-30) | Supports 2: vp8,opus / webm (no VP9 — Firefox MediaRecorder lacks VP9 support) → VP8 selected. Recording → upload → Publish round-trip completed: media_uploaded ext=.webm bytes=89909 (WebM/VP8, 89KB) + POST /provider/publish 200 OK. The pickRecorderMime() VP8 fallback path is exercised end-to-end |
| D ~~macOS Safari MP4 fallback~~ macOS Safari WebM/VP9 | macOS Safari 17+ | verified (2026-04-30) | Supports all 4: vp9,opus / vp8,opus / webm / mp4 → preference picks VP9 (not MP4). Recording → upload → Publish round-trip completed: seller_token_issued ertl-bcd-final + POST /provider/publish 200 OK. Safari 17+ has native WebM/VP9 support; the original "Safari falls back to MP4" assumption applies only to Safari 16 and earlier |
Bugs surfaced during the first real-device run (scenario A)¶
The first scenario-A pass exposed 2 implementation bugs and 2 operational
behaviors that unit tests cannot catch (real-device UA, iPhone-specific file
formats, in-memory state, wallet retry behavior). The two implementation bugs
are fixed in the latest main.
| # | Symptom | Cause | Fix / Resolution |
|---|---|---|---|
| 1 | /provider/start returned HTTP 404 no_presentation_definition_for_dataset |
The /provider/start page-side JS was passing dataset_id=<hint> to /verifier/request. The verifier only registers SellerVC presentation defs under the * sentinel, so the lookup missed |
Blockchain_IoT_Marketplace#41 — hard-codes dataset_id="*" |
| 2 | Upload returned HTTP 415 unsupported media type |
iPhone Safari <input capture> saves video as QuickTime .MOV (video/quicktime); media_routes._ALLOWED_EXT didn't include it |
Blockchain_IoT_Marketplace#42 — adds .mov to allowlist |
| 3 | Publish returned HTTP 401 seller_token_unknown right before success |
SSIStateStore is in-memory; container rebuilds wipe every token. Re-presenting the SellerVC via /provider/start mints a fresh one (the SellerVC itself stays in the wallet, no re-issuance needed) |
Documented as operational behavior in §11.7 |
| 4 | Wallet showed "Retrieving access token failed: 400 / Error Screen" | OID4VCI offers are single-use, but Sphereon-family wallets retry /issuer/token internally. The 2nd call fails with invalid_grant (400). The 1st call already issued the VC into the wallet — the error screen is misleading. Dismiss it and the credential list shows the new card |
Wallet behavior, documented in §11.7 |
Reproduction steps and verification points for each scenario are below. Use them as a reference when you try the flow in your own environment.
Common preconditions¶
For all scenarios:
docker compose -f infra/docker-compose.yml up -d publisher mosquittois up- Wallet holds a SellerVC whose
licensed_datasetscontainshome/event/possible_littering - Publisher host is reachable from both PC and iPhone (same LAN recommended)
-
The publisher has been restarted so that its QR codes point at the PC's LAN IP. The PC browser opens the page via
localhostfor the reason below, so otherwise the QR target is alsolocalhostand the iPhone wallet cannot reach it.cd ~/program/Blockchain_IoT_Marketplace SSI_ISSUER_BASE_URL=http://$HOST_IP:8080 docker compose -f infra/docker-compose.yml up -d publisherThe restart clears the in-memory SellerToken, so present the SellerVC again.
The "browser recorder" mode (B/C/D) only works over localhost or
HTTPS because of getUserMedia. Open the page on the same machine
running the publisher, via http://localhost:8080. A LAN IP
(http://192.168.x.x:8080) makes the browser deny camera/mic
permission silently.
A. iPhone camera capture (capture="environment")¶
Goal: confirm
<input type="file" accept="image/*,video/*" capture="environment">
opens the camera directly in iOS Safari.
Steps:
- iPhone Safari →
http://<publisher-host>:8080/provider/start?ds=home/event/possible_littering - Present a SellerVC from the wallet → land on
/provider?pt=...&ds=... - Tap the "📷 カメラで撮影" (Capture with camera) input
- Confirm whether iOS shows "Take Video" as the default, or jumps straight to the camera
- Record 5–10 s → return → page auto-POSTs to
/media/upload - Press "Publish event" and confirm 200
Observed (2026-04-30, iPhone Safari, iOS 18.x):
- Tap "📷 カメラで撮影" (Capture with camera) → "ファイルを選択" (Choose file) → iOS sheet shows "Take Video / Photo Library / Choose File" → pick "Take Video" → camera opens
- Note: the sheet does not open the camera directly.
accept="image/*,video/*"+captureis a hint, not a hard switch. - Upload result:
content_type: video/quicktime/byte_size: 273897/sha256=11367cf4cb1b... - Expected
video/mp4, but iPhone Safari saves recordings as QuickTime (.MOV). - Publish response:
status: allowed,dataset_id=home/event/possible_littering,seller_token_jti=49bf45c467a65ddc,register_count=1 - Receiver
/viewer(macOS Safari, Tier 3 PurchaseViewerVC.full): green badgetier: event+image+videoand the<video>tag plays the clip inline - macOS Safari natively plays
video/quicktime. This confirms that Option B (HTTP media gateway) handles the QuickTime format.
Screenshots:
images/data-user-vc-tiered/provider/A-iphone-404-original.png # pre-fix: 404 no_presentation_definition_for_dataset
images/data-user-vc-tiered/provider/A-iphone-415-mov-rejected.png # pre-fix: 415 .MOV unsupported
images/data-user-vc-tiered/provider/A-iphone-401-token-unknown.png # operational: container rebuild wiped token
images/data-user-vc-tiered/provider/A-iphone-after-publish.png # success: green Published banner + register_count=1
images/data-user-vc-tiered/provider/A-macsafari-viewer-tier3.jpg # receiver: /viewer plays the .MOV inline
iOS-version note: on iOS 18.x, accept="image/*,video/*" +
capture="environment" does not open the camera directly — the
"Take Video / Photo Library / Choose File" sheet appears first. To
force camera-only behavior, narrow accept to video/* (at the cost
of losing the existing-file path). The current implementation keeps
both modes; the extra tap is acceptable.
B. PC browser recording — Chrome (VP9)¶
Goal: confirm MediaRecorder + getUserMedia records from the PC
webcam, auto-uploads, publishes, and that Chromium-family browsers
pick VP9.
Steps:
- Same machine running publisher; Chrome →
http://localhost:8080/provider/start?ds=home/event/possible_littering - Present SellerVC from the iPhone wallet (scan QR; same LAN)
- Pick a dataset on the success panel →
/provider - In the "🔴 ブラウザで録画" (Record in browser) section, click 録画開始 (Start recording)
- Allow camera/mic in the browser permission dialog
- Confirm the live
<video>preview shows the webcam - Wait 5–10 s, click 停止 & アップロード (Stop & upload)
recStatustransitions through "録画完了 (Ns) — アップロード中…" (Recorded — uploading) → "録画完了 (Ns)" (Recorded)- Upload result shows
content_type: video/webm video_duration_secform is auto-filled with the measured length- Publish succeeds
Codec check:
In DevTools console:
['video/webm;codecs=vp9,opus','video/webm;codecs=vp8,opus','video/webm','video/mp4']
.filter(m => MediaRecorder.isTypeSupported(m))
Expected: ["video/webm;codecs=vp9,opus", "video/webm;codecs=vp8,opus", "video/webm", "video/mp4"]
(first entry = the one actually picked).
C. PC browser recording — Firefox (VP8 fallback)¶
Goal: confirm Firefox completes the same flow and falls back to VP8 when VP9 is unavailable.
Steps: same as B in Firefox.
Verification points: run the same DevTools snippet and confirm
vp9,opus returns false while vp8,opus (or bare webm) returns
true. Upload should still produce content_type: video/webm.
D. macOS Safari (Safari 17+ uses WebM/VP9; Safari 16 and earlier fall back to MP4)¶
Goal: confirm codec selection branches between modern (17+) and legacy (≤16) Safari. Real-device validation on 2026-04-30 found Safari 17+ has native WebM/VP9 support, so the original MP4-fallback assumption only applies to legacy Safari.
Steps: same as B in macOS Safari.
Verification points:
| Safari version | Supported codecs | Picked codec | Upload content_type |
|---|---|---|---|
| 17+ (modern) | vp9, vp8, webm, mp4 | VP9 | video/webm |
| 16 and earlier | mp4 only | MP4 | video/mp4 |
MediaRecorder.isTypeSupported('video/webm;codecs=vp9,opus'):
- Safari 17+:
true→ VP9 selected (same behavior as Chrome) - Safari 16 and earlier:
false→ falls back to MP4
Run the codec list in DevTools console to make the branch visible.
Safari-specific notes:
- Safari prior to 14.1 has no
MediaRecorderat all;recStatussurfaces "このブラウザは録画に対応していません" (this browser does not support recording). In that case, use a newer Safari or Chrome / Firefox. - Camera/mic permission may need to be granted via the address-bar Safari settings icon in some setups.
Next steps¶
Next is the follow-up page Tier by semantic level (VLM and semantic representation / Stage T). §12–§13 cover semantic-level tiering with a VLM and the semantic intermediate representation.
- You can leave the publisher running. §12.2 of the next page recreates it with the VLM settings.
- You redo the claim and the presentation in §12.4 of the next page.
To go back to the previous page: Tier the response by trust (DataUserVC / Stage T) — §0–§7 (issuing DataUserVC and tiering the response)


