Public
Edited
May 8, 2023
1 fork
Insert cell
Insert cell
import {
Agent,
Client,
HTTP,
invoke,
delegate,
capability,
Schema,
ed25519,
base64,
Delegation,
CAR,
CBOR,
DID
} from "@gozala/ucanto"
Insert cell
agent = Agent.create(await load())
Insert cell
client = agent.connect({
id: "did:web:web3.storage",
type: "ucanto",
serviceEndpoint: "https://up.web3.storage/"
})
Insert cell
Insert cell
conn = Client.connect({
id: DID.parse("did:web:staging.web3.storage"), //.parse("did:web:web3.storage"),
channel: HTTP.open({ url: new URL("https://staging.up.web3.storage/") }),
codec: CAR.outbound
})
Insert cell
invoke({
issuer: agent,
audience: conn.id,
capability: {
can: "console/log",
with: agent.did(),
value: { test: "hello" }
}
}).execute(conn)
Insert cell
invoke({
issuer: agent,
audience: conn.id,
capability: {
can: "store/list",
with: agent.did()
}
}).execute(conn)

Insert cell
invoke({
issuer: agent,
audience: conn.id,
capability: {
can: "upload/list",
with: agent.did()
}
}).execute(conn)
Insert cell
me = agent.signer
Insert cell
r = await invoke({
issuer: me,
audience: conn.id,
capability: {
can: "access/authorize",
with: me.did(),
nb: {
iss: "did:mailto:gozala.io:contact",
att: [{ can: "*" }]
}
}
}).execute(conn)
Insert cell
r.out
Insert cell
r2 = await invoke({
issuer: me,
audience: conn.id,
capability: {
can: "access/claim",
with: me.did()
}
}).execute(conn)
Insert cell
r2.out
Insert cell
d1 = CAR.codec.decode(
r2.out.ok.delegations[
"bafyreidd277qyz73ghcnciw4rguv6bnzsqfszwifrizsiu25imxemhixvu"
]
)
Insert cell
ucan = Delegation.view({ root: d1.roots[0], blocks: d1.blocks })
Insert cell
Delegation.view
Insert cell
invoke({
issuer: agent,
audience: conn.id,
capability: {
can: "store/list",
with: agent.did()
}
}).execute(conn)
Insert cell
LegacyClient = import("https://cdn.skypack.dev/@ucanto/client@5.1.0")
Insert cell
TR = import("https://cdn.skypack.dev/@ucanto/transport@5.1.1")
Insert cell
cl = LegacyClient.connect({
id: DID.parse("did:web:staging.web3.storage"), //.parse("did:web:web3.storage"),
channel: HTTP.open({ url: new URL("https://staging.up.web3.storage/") }),
encoder: TR.CAR,
decoder: TR.CBOR
})
Insert cell
invoke({
issuer: agent,
audience: conn.id,
capability: {
can: "store/list",
with: agent.did()
}
}).execute(cl)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more