{"id":20642409,"url":"https://github.com/ipld/js-dag-ucan","last_synced_at":"2025-04-07T08:27:04.714Z","repository":{"id":37850634,"uuid":"477883469","full_name":"ipld/js-dag-ucan","owner":"ipld","description":"UCAN codec for IPLD","archived":false,"fork":false,"pushed_at":"2025-01-27T00:45:36.000Z","size":613,"stargazers_count":25,"open_issues_count":7,"forks_count":7,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-31T06:07:30.025Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ipld.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-04T21:43:33.000Z","updated_at":"2025-02-19T05:17:33.000Z","dependencies_parsed_at":"2024-06-18T16:57:20.747Z","dependency_job_id":"c400798c-adf9-4064-84fc-2baab34cd4a1","html_url":"https://github.com/ipld/js-dag-ucan","commit_stats":{"total_commits":86,"total_committers":7,"mean_commits":"12.285714285714286","dds":0.4767441860465116,"last_synced_commit":"21bae4e0ad7ff76e0c7b73938dcc228726854a43"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-dag-ucan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-dag-ucan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-dag-ucan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-dag-ucan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipld","download_url":"https://codeload.github.com/ipld/js-dag-ucan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247617698,"owners_count":20967657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T16:09:00.046Z","updated_at":"2025-04-07T08:27:04.690Z","avatar_url":"https://github.com/ipld.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @ipld/dag-ucan\n\n![UCAN](https://img.shields.io/badge/UCAN-v0.9.1-blue)\n\nAn implementation of [UCAN][]s in [IPLD][] via [Advanced Data Layout (ADL)](ADL), designed for use with [multiformats][].\n\n![mascot][]\n\n\n## Overview\n\nThis library provides an [ADL][] for representing [UCAN]s natively in [IPLD][]. It implements [UCAN IPLD][] specification and uses [DAG-CBOR][] as a primary encoding, which is hash consistent and more compact than a secondary RAW JWT encoding. Every UCAN in either encoding can be formatted into a valid JWT string and consumed by other spec compliant [UCAN][] implementations. However [UCAN][]s issued by other libraries may end up in represented in secondory RAW JWT encoding, that is because whitespaces and key order in JWT affects signatures and there for can't be represented accurately in CBOR. When parsing UCANs library will use CBOR representation and fallback to RAW JWT, which allows interop with all existing tokens in the wild.\n\n\n## API\n\n```ts\nimport * as UCAN from \"@ipld/dag-ucan\"\n```\n\n#### `UCAN.parse(jwt: string): UCAN.View`\n\nParses UCAN formatted as JWT string into a representatino that can be encoded, formatted and queried.\n\n```ts\nconst ucan = UCAN.parse(jwt)\nucan.issuer.did() // did:key:z6Mkk89bC3JrVqKie71YEcc5M1SMVxuCgNx6zLZ8SYJsxALi\n```\n\n#### `UCAN.format(ucan: UCAN.UCAN): string`\n\nFormats UCAN into a JWT string.\n\n```ts\nUCAN.format(UCAN.parse(jwt)) === jwt // true\n```\n\n#### `UCAN.encode(ucan: UCAN.UCAN): Uint8Array`\n\nEncodes UCAN into a binary representation.\n\n```ts\nUCAN.encode(UCAN.parse(jwt)) // Uint8Array(679)\n```\n\n#### `UCAN.decode(bytes: Uint8Array): UCAN.UCAN`\n\nDecodes UCAN from binary representation into object representation.\n\n```ts\nUCAN.decode(UCAN.encode(ucan))\n```\n\n#### `UCAN.issue(options: UCAN.UCANOptions): Promise\u003cUCAN.UCAN\u003e`\n\nIssues a signed UCAN.\n\n\u003e Please note that no capability or time bound validation takes place.\n\n```ts\nconst ucan = await UCAN.issue({\n  issuer: alice,\n  audience: bob,\n  capabilities: [\n    {\n      can: \"fs/read\",\n      with: `storage://${alice.did()}/public/photos/`,\n    },\n    {\n      can: \"pin/add\",\n      with: alice.did(),\n    },\n  ],\n})\n```\n\n### Embedding Proofs\n\nWhile not recommended, it is possible to inline proofs inside a single UCAN using CIDs with identity\nmultihash:\n\n```ts\nimport { identity } from \"multiformats/hashes/identity\"\nconst proof = await UCAN.issue({\n  issuer: alice,\n  audience: bob,\n  capabilities: [{ can: \"store/add\", with: alice.did() }],\n})\n\nconst delegation = await UCAN.issue({\n  issuer: bob,\n  audience: mallory,\n  capabilities: proof.capabilities,\n  proofs: [await UCAN.link(proof, { hasher: identity })],\n})\n```\n\n## License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / \u003chttp://opensource.org/licenses/MIT\u003e)\n\n\n## Contribute\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n\n[ipld]: https://ipld.io/\n[ucan]: https://github.com/ucan-wg/spec/\n[ucan ipld]: https://github.com/ucan-wg/ucan-ipld/\n[ipld schema]: https://ipld.io/docs/schemas/using/authoring-guide/\n[dag-cbor]: https://ipld.io/docs/codecs/known/dag-cbor/\n[multiformats]: https://github.com/multiformats/js-multiformats\n[adl]: https://ipld.io/docs/advanced-data-layouts/\n[mascot]:https://bafybeiap2x7s5hjxdghbpfzd7kkc6l5vqgbwnj4tjbcivnfjfcobwuqo44.ipfs.w3s.link/UCAN%20IPLD%20Mascot.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipld%2Fjs-dag-ucan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipld%2Fjs-dag-ucan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipld%2Fjs-dag-ucan/lists"}