-
-
Save fforbeck/a03872dd71b2b01695c31b914bc44844 to your computer and use it in GitHub Desktop.
Visualise a delegation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'node:fs' | |
import { Readable } from 'node:stream' | |
import { CARReaderStream } from 'carstream' | |
import * as dagCBOR from '@ipld/dag-cbor' | |
import * as dagJSON from '@ipld/dag-json' | |
import * as DID from '@ipld/dag-ucan/did' | |
Readable.toWeb(fs.createReadStream('proof.car')) | |
.pipeThrough(new CARReaderStream()) | |
.pipeTo(new WritableStream({ | |
write (block) { | |
console.log(block.cid.toString()) | |
const obj = dagCBOR.decode(block.bytes) | |
if (obj.iss) { | |
obj.iss = DID.decode(obj.iss).did() | |
} | |
if (obj.aud) { | |
obj.aud = DID.decode(obj.aud).did() | |
} | |
console.log(JSON.stringify(JSON.parse(dagJSON.format(obj)), null, 2)) | |
console.log('===') | |
} | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment