{"id":21610634,"url":"https://github.com/douganderson444/did-ar","last_synced_at":"2025-04-11T05:22:44.578Z","repository":{"id":105931220,"uuid":"544556845","full_name":"DougAnderson444/did-ar","owner":"DougAnderson444","description":"✔️📇 Your Own Permanent Identity on Web3, with 1 click!","archived":false,"fork":false,"pushed_at":"2024-04-17T19:15:53.000Z","size":15173,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T06:54:09.069Z","etag":null,"topics":["arweave","did","did-core"],"latest_commit_sha":null,"homepage":"https://douganderson444.github.io/did-ar/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DougAnderson444.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-10-02T19:18:20.000Z","updated_at":"2023-05-04T22:52:15.000Z","dependencies_parsed_at":"2023-03-17T15:16:11.492Z","dependency_job_id":null,"html_url":"https://github.com/DougAnderson444/did-ar","commit_stats":{"total_commits":166,"total_committers":1,"mean_commits":166.0,"dds":0.0,"last_synced_commit":"a5422b5befdaa09d3718ddfe7b8e0a2edb43cf3c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DougAnderson444%2Fdid-ar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DougAnderson444%2Fdid-ar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DougAnderson444%2Fdid-ar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DougAnderson444%2Fdid-ar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DougAnderson444","download_url":"https://codeload.github.com/DougAnderson444/did-ar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248346365,"owners_count":21088445,"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":["arweave","did","did-core"],"created_at":"2024-11-24T21:08:56.752Z","updated_at":"2025-04-11T05:22:44.512Z","avatar_url":"https://github.com/DougAnderson444.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DID:AR\n\nI just wrote this, so there will be some changes, improvements and bugs. But feel free to play around with it.\n\nEnables users to create a [smartweave contract](https://arweave.medium.com/introducing-smartweave-building-smart-contracts-with-arweave-1fc85cb3b632) on [Arweave](https://www.arweave.org/) to store their [Decentralized Identity Document](https://www.w3.org/TR/did-core/) (DID Doc).\n\n✔️📇 Your Own Permanent Identity on Web3\n\n✔️🗃️ [Resolve DID](https://douganderson444.github.io/did-ar/search?name=douganderson444) from `.ar` name, so `douganderson444.ar` -\u003e `did:ar:....`\n\n✔️💰 No Tokens / cryptocurrency (under 100kb), thanks to [Bundlr](https://bundlr.network/)!\n\n✔️♾️ Lasts forever, thanks to [Arweave](https://www.arweave.org/)!\n\n✔️💻 Saves to your OWN device, thanks to [PeerPiper](https://peerpiper.github.io/iframe-wallet-sdk/)!\n\n✔️🗃️ Conveniently Control Your Data\n\n## Install\n\nPackage [deployed to npm](https://www.npmjs.com/package/@peerpiper/did-ar) `@peerpiper/did-ar`\n\n```sh\nnpm i @peerpiper/did-ar\n```\n\n## Initialize\n\n```ts\nimport { init } from 'did-ar';\n\nconst didar: DIDAr = await init({\n\t// local: true, // default is false, uses local Arweave instance\n\t// wallet: JWKInterface, // default is 'use_wallet' if no wallet is set\n});\n\n// which gives you a DIDAr instance:\ninterface DIDAr {\n\twarp: WarpFactory;\n\twallet: JWKInterface | 'use_wallet';\n\tcreate: Function;\n\tread: Function;\n\tupdate: Function;\n}\n```\n\n## Create DID\n\nPass an RSA Public Key JWK and Ed25519PublicKey bytes (Uint8Array) to `create`, which will create a did and did document saved as the Arweave Smartweave contract state.\n\nThe [Demo](https://github.com/DougAnderson444/did-ar/blob/master/src/routes/%2Bpage.svelte) uses the keys from a [PeerPiper/web3-wallet-connector](https://github.com/PeerPiper/web3-wallet-connector) to create the DID.\n\n```js\nconst did = await didar.create({ RSAPublicKey: JWK, Ed25519PublicKey: Uint8Array });\nconsole.log(did); // did:ar:abc123zyx-ELEMENOPee\n// or when running in `vite dev` mode:\nconsole.log(did); // did:arlocal:abc123zyx-ELEMENOPee\n```\n\n## Read DID (Resolve)\n\nIf you have a `didar` instance, you can simply `read` from it:\n\n```js\nconst didDoc = await didar.read(did);\n```\n\nIf you are using DID from an external source, read using the resolver, as this library exports a standalone DID Resolver compliant with the [DIF](https://github.com/decentralized-identity/did-resolver).\n\n```js\nimport { didArResolver } from '@peerpiper/did-ar';\nimport { Resolver } from 'did-resolver'; // Decentralized Identity Foundation\n\nconst did = `did:ar:abc123zyx-ELEMENOPeeeeeeeeeeeeeeee`;\n// or when running in `vite dev` mode:\n// did:arlocal\n\nconst arResolver = didArResolver.getResolver();\nresolver = new Resolver(arResolver);\nconst didDoc = (await resolver.resolve(did)).didDocument;\n\nconsole.log(didDoc.verificationMethod[0].publicKeyJwk); // one of the did's public keys\n```\n\n## Read from `.ar` name (Resolve DID from Arweave Name Service / Name Token)\n\n```js\nimport { arnsResolver } from '@peerpiper/did-ar';\n\nconst arnsName = 'douganderson444'; // From: douganderson444.ar or 'douganderson444.arweave.dev' || 'douganderson444.ar.page';\nconst did = await arnsResolver(arnsName);\n\nconsole.log(did); // did:ar:UGnqpxdraMbkmG-4F6jU7xkFhErNgaXLQf39tW7yYck\n```\n\n## Update DID Document\n\nTo update, just pass the new DID Doc properties you wish to update. Then, `did-ar` verifies that the caller is the wallet owner (and by extention the `did:ar` owner). If anyone other than the owner of the contract tries to update the did document, the contract will only return the current DID Doc state.\n\nThe contract then replaces the old DID Document properties with the new properties.\n\n```js\nconst id = did;\nlet didDoc; // exsiting DID Doc\n\nconst replaceProperties = {\n\tservice: [\n\t\t...didDoc.service, // keep existing service listings\n\t\t{\n\t\t\tid: `${did}#linked-domain`,\n\t\t\ttype: 'LinkedDomains',\n\t\t\tserviceEndpoint: 'https://douganderson444.arweave.dev'\n\t\t}\n\t]\n};\n\nawait didar.update({ id, ...replaceProperties }); // will change service property of DID Doc\n```\n\n## Transfer\n\nYou can add or transfer controller of this DID by [adding/changing the array of controllers](https://w3c.github.io/did-core/#independent-control).\n\n⚠️ Be careful! Only the controller can update the DID Doc. Make sure you know what you are doing here. ⚠️\n\n\u003ca href='https://w3c.github.io/did-core/#independent-control' target=\"_blank\"\u003e\n\n![Controllers](./static/figure-c.1-independent-did-controllers.svg 'Controllers')\n\n\u003c/a\u003e\n\nTransfer is just an update where the controller is updated. Send an `update` command with the added/changed controller property:\n\n```js\nconst id = did;\nlet didDoc; // exsiting DID Doc\n\nconst replaceProperties = {\n\t...didDoc,\n\tcontroller: ['did:ar:newControllerDID']\n};\n\nawait didar.update({ id, ...replaceProperties }); // will change the controller (ie owner) of DID Doc\n```\n\n## Delete\n\nTODO: Implement [ANS-106 Do Not Store Request](https://github.com/ArweaveTeam/arweave-standards/blob/master/ans/ANS-106.md)\n\n## What can you do with a DeID?\n\nYou can grab the keys out of the document. From the RSA key, you can get an Arweave address and look up their Arweave data. You can grab their DAG from ArDAG and interact with that data and apps too.\n\n## Forking The Smart Contract\n\nWith Arweave, using Warp Contract's `deployFromSourceTx` you can use an existing deployed contract and add your own initial state to make a new DID Doc.\n\nTODO: List published version so others can deploy from source.\n\n# References\n\n[DID Core W3C Reccomendation](https://w3c.github.io/did-core/)\n\n[JOSE JWK RFC](https://www.rfc-editor.org/rfc/rfc8037.html#section-2)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouganderson444%2Fdid-ar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdouganderson444%2Fdid-ar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouganderson444%2Fdid-ar/lists"}