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!: upgrade proof ls #136

Merged
merged 2 commits into from
Nov 27, 2023
Merged

feat!: upgrade proof ls #136

merged 2 commits into from
Nov 27, 2023

Conversation

olizilla
Copy link
Contributor

@olizilla olizilla commented Nov 25, 2023

Screenshot 2023-11-25 at 22 09 32
  • w3 proof ls now shows lots more info with ucan flavour properties so it matches what you'd see in the spec or at https://ucan.xyz/validator/
    • and with a relative date help for exp e.g # expires in one year.
    • and in valid yaml you can pate into a dingus (tho... what isn't valid yaml).
    • and in colour! (optional)
      • --no-color works automagically with chalk, so no additional plumbing is needed to disable it
    • audience is removed as it is always the did of the current agent, so is redundent.
  • w3 proof ls --json now returns all the info about the proofs. I need this for debugging, and it's neat to be able to dig into them with jq
    • this is a breaking change as it changes the json output format to use the default ucan/ipld flavour property names rather than custom ones.
    • e.g. att instead of capabilities. / for the root cid, rather than cid

w3 proof ls --json

# all issuers
$  w3 proof ls --json | jq '.iss'
"did:mailto:protocol.ai:oli"
"did:web:web3.storage"
"did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp"
"did:key:z6MkhfzTwZJ28aRobCp76uXRqzsjH6GNu18WFwMumkAF5ojW"
"did:key:z6Mku56ywWspVnzkcVQbeSkw6egVRSNKVSYgS38HhKcUJRiN"
"did:key:z6Mktg5HxV1fifagzK8tnXXgCDsw1o4ekQHQpp9DKbLkh9hU"
"did:web:web3.storage"

# all space names
$ ❯ w3 proof ls --json | jq '.fct[].space.name | select(.)'
"clean"
"toots"
"fruits"
"veg"

# all ucan cids
$ w3 proof ls --json | jq '.["/"]'
"bafyreiaxpxm7oqdesq3nbjzcku3qqsb5onx25ab2tp23fl3edmjwllemgm"
"bafyreifwqxlcwwwb4xll3deyq6zlvui26k5bq2oq4rcaam4pmg5rfmtqnu"
"bafyreid2kvymk6nearlhg262zigjxitcl77ncsavcin2twdmhqmrlhxwui"
"bafyreibpxq7zqbmphfprnn7qotfaowryr63nh5sg6kk75zmm3hsx6vhdfy"
"bafyreietbar6chzhwp6bbxor6qydxkyhela7xpo2zmdmjbycoabgzxuexi"
"bafyreigu6g2psglmekpfo73zapgebs5sbydcctibgq6obwilbvepap3l3a"
"bafyreifwqxlcwwwb4xll3deyq6zlvui26k5bq2oq4rcaam4pmg5rfmtqnu"

w3 proof ls

# bafyreiaxpxm7oqdesq3nbjzcku3qqsb5onx25ab2tp23fl3edmjwllemgm
iss: did:mailto:protocol.ai:oli
att:
  - can: *
    with: ucan:*
fct:
  - {"access/confirm":{"/":"bafyreidaljxvbccdts7dwoogds57a37y5fxy4b6wiq5h7oaz5npihtsgcq"},"access/request":{"/":"bafyreiabnffvury7onrouhhbsj6pi3de7oejxazkuoxbrjkl4vxuvdxjmm"}}

# bafyreifwqxlcwwwb4xll3deyq6zlvui26k5bq2oq4rcaam4pmg5rfmtqnu
iss: did:web:web3.storage
att:
  - can: ucan/attest
    with: did:web:web3.storage
    nb: {"proof":{"/":"bafyreiaxpxm7oqdesq3nbjzcku3qqsb5onx25ab2tp23fl3edmjwllemgm"}}
fct:
  - {"access/confirm":{"/":"bafyreidaljxvbccdts7dwoogds57a37y5fxy4b6wiq5h7oaz5npihtsgcq"},"access/request":{"/":"bafyreiabnffvury7onrouhhbsj6pi3de7oejxazkuoxbrjkl4vxuvdxjmm"}}

# bafyreid2kvymk6nearlhg262zigjxitcl77ncsavcin2twdmhqmrlhxwui
iss: did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp
exp: 1731519367  # expires in a year
att:
  - can: space/*
    with: did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp
  - can: store/*
    with: did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp
  - can: upload/*
    with: did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp
  - can: access/*
    with: did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp
  - can: filecoin/*
    with: did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp
  - can: usage/*
    with: did:key:z6MknD58DihJ7j3XdPZLuJPVPt8LC8BtdTULatbWmoqr8Awp
fct:
  - {"space":{"name":"clean"}}

License: MIT

- `w3 proof ls --json` now returns **all** the info about the proofs. I need this for debugging, and it's neat to be able to dig into them with `jq`
  - this is a breaking change as it changes the json output format to use the default ucan/ipld flavour property names rather than custom ones.
  - e.g. `att` instead of `capabilities`. `/` for the root cid, rather than `cid`
- `w3 proof ls` now shows more info.
  - and in colour!
  - and with a relative date help for `exp` e.g `# expires in one year`.
  - and in valid yaml you can pate into a dingus (tho... what isn't valid yaml).
  - but audience is removed as it is always the did of the current agent, so is redundent.
  - `--no-color` works automagically with chalk, so no additional plumbing is needed to disable it

License: MIT
Signed-off-by: Oli Evans <[email protected]>
Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

🤩 wow yeah this is badass.

audience is removed as it is always the did of the current agent, so is redundent.

I would...maybe just include it anyway? So if you copypasta it somewhere you don't lose context.

index.js Outdated
console.log(` - ${JSON.stringify(capability.nb)}`)
}
}
console.log('fct:')
Copy link
Member

Choose a reason for hiding this comment

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

Omit if !proof.facts.length?

@olizilla
Copy link
Contributor Author

Thanks! I tried a bunch of different options but this one was the most pleasing without adding a bunch of complexity.

I'll try putting audience back in but I lean towards making the default list output be quick'n'easy to interpret. w3 proofs ls currently means "show me all ucan delegations where the current agent is the audience" so leaving out the audience reduces the amount of information that we blast at the user. I really want to focus the eyes on the capability names here.

Also I was thinking we'd encourage folks to use the --json flag where they need the data.

License: MIT
Signed-off-by: Oli Evans <[email protected]>
@olizilla olizilla merged commit d95d1a4 into main Nov 27, 2023
1 check passed
@olizilla olizilla deleted the proof-ls-moar branch November 27, 2023 14:28
@gobengo
Copy link
Contributor

gobengo commented Nov 28, 2023

this is a breaking change as it changes the json output format to use the default ucan/ipld flavour property names rather than custom ones.

love this ty

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.

3 participants