w3up
w3up copied to clipboard
Error: cannot delegate capability provider/add with did:key:####
I wanted to create delegated PROOF
that can be used to create spaces and upload car files. I used ucan-key ed --json
to create the audienceDid
and privateKey
and I used the audienceDid
in w3 delegation create
to create a delegation. Full command is:
w3 delegation create did:key:#### --can 'store/add' --can 'upload/add' --can 'provider/add' | base64
Unfortunately, it threw an error
$ w3 delegation create did:key:#### --can 'store/add' --can 'upload/add' --can 'provider/add' | base64
file:///C:/Users/aaron/AppData/Roaming/npm/node_modules/@web3-storage/w3cli/node_modules/@web3-storage/access/dist/src/agent.js:379
throw new Error(`cannot delegate capability ${cap.can} with ${cap.with}`);
^
Error: cannot delegate capability provider/add with did:key:###
at Agent.delegate (file:///C:/Users/aaron/AppData/Roaming/npm/node_modules/@web3-storage/w3cli/node_modules/@web3-storage/access/dist/src/agent.js:379:23)
at Client.createDelegation (file:///C:/Users/aaron/AppData/Roaming/npm/node_modules/@web3-storage/w3cli/node_modules/@web3-storage/w3up-client/dist/src/client.js:246:52)
at createDelegation (file:///C:/Users/aaron/AppData/Roaming/npm/node_modules/@web3-storage/w3cli/index.js:364:35)
Node.js v20.9.0
Why create delegation with provider/add
?
I wanted to instantiate a client that can create spaces for our users. The code that is below: Code:
const principal = Signer.parse(STAURO_W3SPACE_UCAN_PRIVATE_KEY!)
const client = await Client.create({ principal, store: new StoreMemory() })
const proof = await parseProof(STAURO_W3SPACE_PROOF!)
const space = await client.addSpace(proof)
await client.setCurrentSpace(space.did())
const userSpace = await client.createSpace(projectId)
console.log(userSpace.registered()) // false
await client.setCurrentSpace(userSpace.did())
await client.registerSpace(my_email)
console.log(userSpace.registered())
Running the above code throws the following error:
ERR Error: no proofs available for resource did:mailto:my_email and ability provider/add
at Agent.invoke (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/@[email protected]/node_modules/@web3-storage/access/src/agent.js:544:13)
at Agent.invokeAndExecute (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/@[email protected]/node_modules/@web3-storage/access/src/agent.js:474:28)
at addProvider (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/@[email protected]/node_modules/@web3-storage/access/src/agent-use-cases.js:78:31)
at addProviderAndDelegateToAccount (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/@[email protected]/node_modules/@web3-storage/access/src/agent-use-cases.js:323:9)
at Agent.registerSpace (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/@[email protected]/node_modules/@web3-storage/access/src/agent.js:398:18)
at Client.registerSpace (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/@[email protected]/node_modules/@web3-storage/w3up-client/src/client.js:168:23)
at resolve (c:\Users\aaron\Documents\projects\flash\api\packages\api\src\resolvers\W3SUpSpace\mutations\createClientWithDelegation.ts:28:20)
at async file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/@[email protected]/node_modules/@envelop/core/esm/orchestrator.js:377:27
at async YogaServer.getResultForParams (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-yoga/esm/server.js:306:26)
at async YogaServer.handle (file:///C:/Users/aaron/Documents/projects/flash/api/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-yoga/esm/server.js:73:29) {
path: [ 'createClientWithDelegation' ],
locations: [ { line: 84, column: 3 } ],
extensions: [Object: null prototype] {}
}
STAURO_W3SPACE_UCAN_PRIVATE_KEY STAURO_W3SPACE_PROOF
What are these two parameters and where can I see them!!!
STAURO_W3SPACE_UCAN_PRIVATE_KEY STAURO_W3SPACE_PROOF
What are these two parameters and where can I see them!!!
These are contants whose values were generated by following the steps in the docs
// from "bring your own Agent" example in `Creating a client object" section`
// used command line to generate KEY and PROOF (stored in env variables)
// KEY: `npx ucan-key ed --json` in command line, which returns private key and DID for Agent (the private key is stored in KEY)
// PROOF: w3cli used to run `w3 delegation create <did_from_ucan-key_command_above> --can 'blob/add' --can 'index/add' --can 'filecoin/offer' --can 'upload/add' | base64`, which returns the delegation from Space to the Agent we're using (stored in PROOF)