Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add local ipfs pinning service api adaptor #69

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

olizilla
Copy link
Contributor

@olizilla olizilla commented Mar 27, 2023

POC based on https://hackmd.io/@olizilla/beam

Adds w3 ps command to run an http server on localhost to allow you to use the IPFS pinning service api with w3up and get ucan auth in pinning service mode.

$ w3 ps
⁂ IPFS Pinning Service on http://127.0.0.1:1337

## Add w3 as a remote
$ ipfs pin remote service add w3 'http://127.0.0.1:1337' 'did:key:z6MkvqaczHouddZ91gWNsuy2QFm419WFodXbVjBJykvzw1eK'

## Pin to w3
$ ipfs pin remote add --service w3 <cid>

Screenshot 2023-03-27 at 16 55 44

License: MIT

Adds `w3 ps` command to run an http server on localhost to allow you to use the IPFS pinning service api with w3up and get ucan auth in pinning service mode.

```sh
$ w3 ps
⁂ IPFS Pinning Service on http://127.0.0.1:1337

$ ipfs pin remote service add w3 'http://127.0.0.1:1337' 'did:key:z6MkvqaczHouddZ91gWNsuy2QFm419WFodXbVjBJykvzw1eK'

$ ipfs pin remote add --service w3 <cid>
```

License: MIT
Signed-off-by: Oli Evans <[email protected]>
const pinCache = new Map()
const client = await getClient()
const whoami = client.agent().did()
const token = key ?? whoami
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The http api bound to loopback ip, so token auth is less critical, but kubo requires the user to provide a key when setting up a pin service remote.

@alanshaw suggested setting this as the space DID that we want the local pin service to write to, which would be rad, but we also need changes to the w3up-client to allow users to pass in a space did (with) when doing an upload. The upload client supports it but it's not exposed in w3up-client

pin.js Outdated
const rootCID = CID.parse(cid)
const ipfsUrl = new URL(`/ipfs/${cid}?format=car`, ipfsGatewayUrl, { signal })
const res = await fetch(ipfsUrl)
const storedCID = await client.uploadCAR({ stream: () => res.body }, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should tweak the w3up-client uploadCAR to allow users to pass a stream, as currently it requires a blob but just calls stream on it, and it means we can't pass a stream directly, and need this madness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant