{"id":26121819,"url":"https://github.com/ipfs-shipyard/js-did-ipid","last_synced_at":"2025-04-13T13:05:55.390Z","repository":{"id":34616816,"uuid":"174973093","full_name":"ipfs-shipyard/js-did-ipid","owner":"ipfs-shipyard","description":"The IPID DID method implementation in JavaScript","archived":false,"fork":false,"pushed_at":"2023-01-03T19:06:24.000Z","size":2000,"stargazers_count":21,"open_issues_count":32,"forks_count":9,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-13T13:05:18.309Z","etag":null,"topics":["did","did-method","ipfs","ipld","ipns"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ipfs-shipyard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-11T10:03:28.000Z","updated_at":"2025-03-27T08:24:49.000Z","dependencies_parsed_at":"2023-01-15T08:06:21.346Z","dependency_job_id":null,"html_url":"https://github.com/ipfs-shipyard/js-did-ipid","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fjs-did-ipid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fjs-did-ipid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fjs-did-ipid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fjs-did-ipid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipfs-shipyard","download_url":"https://codeload.github.com/ipfs-shipyard/js-did-ipid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717242,"owners_count":21150389,"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":["did","did-method","ipfs","ipld","ipns"],"created_at":"2025-03-10T14:36:48.564Z","updated_at":"2025-04-13T13:05:55.353Z","avatar_url":"https://github.com/ipfs-shipyard.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# did-ipid\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]\n\n[npm-url]:https://npmjs.org/package/did-ipid\n[downloads-image]:http://img.shields.io/npm/dm/did-ipid.svg\n[npm-image]:http://img.shields.io/npm/v/did-ipid.svg\n[travis-url]:https://travis-ci.org/ipfs-shipyard/js-did-ipid\n[travis-image]:http://img.shields.io/travis/ipfs-shipyard/js-did-ipid/master.svg\n[codecov-url]:https://codecov.io/gh/ipfs-shipyard/js-did-ipid\n[codecov-image]:https://img.shields.io/codecov/c/github/ipfs-shipyard/js-did-ipid/master.svg\n[david-dm-url]:https://david-dm.org/ipfs-shipyard/js-did-ipid\n[david-dm-image]:https://img.shields.io/david/ipfs-shipyard/js-did-ipid.svg\n[david-dm-dev-url]:https://david-dm.org/ipfs-shipyard/js-did-ipid?type=dev\n[david-dm-dev-image]:https://img.shields.io/david/dev/ipfs-shipyard/js-did-ipid.svg\n\nThe [IPID DID method](https://github.com/jonnycrunch/ipid) implementation in JavaScript.\n\n\n## Installation\n\n```sh\n$ npm install did-ipid\n```\n\nThis library is written in modern JavaScript and is published in both CommonJS and ES module transpiled variants.\nIf you target older browsers please make sure to transpile accordingly. \n\n\n## Usage\n\n```js\nimport createIpid, { getDid } from 'did-ipid';\n\nconst did = await getDid(pem);\n//=\u003e Returns the DID associated to a private key in PEM format.\n\nconst ipid = await createIpid(ipfs);\n\nconst didDocument = await ipid.resolve('did:ipid:QmUTE4cxTxihntPEFqTprgbqyyS9YRaRcC8FXp6PACEjFG');\n//=\u003e Resolves a DID and returns the respective DID Document.\n\nconst didDocument = await ipid.create(pem, (document) =\u003e {\n    const publicKey = document.addPublicKey({\n    \ttype: 'RsaVerificationKey2018',\n        publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71',\n    });\n\n    const authentication = document.addAuthentication(publicKey.id);\n\n    const service = document.addService({\n    \tid: 'hub',\n    \ttype: 'HubService',\n    \tserviceEndpoint: 'https://hub.example.com/',\n    });\n});\n//=\u003e Creates a new DID and the corresponding DID Document based on the provided private key pem.\n//=\u003e The DID Document is published with the added publicKey, authentication and service.\n\nconst didDocument = await ipid.update(pem, (document) =\u003e {\n    document.removeService('hub');\n\n    document.addService({\n    \tid: 'messages',\n    \ttype: 'MessagingService',\n    \tserviceEndpoint: 'https://example.com/messages/8377464',\n    });\n});\n//=\u003e Updates a DID Document based on the DID associated to the provided private key pem.\n//=\u003e The DID Document is published without the `hub` service and with a new one called `messages`. \n\n```\n\n## API\n\n### getDid(pem)\n\nReturns the DID associated to a private key in PEM format.\n\n#### pem\n\nType: `string`\n\nA private key in PEM format.\n\nSupported formats: `pkcs1-pem` or `pkcs8-pem`.\n\nExample:\n```js\n-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQDCQZyRCPMcBPL2J2SuI2TduR7sy28wmcRzfj8fXQTbj1zJURku\n...\n-----END RSA PRIVATE KEY-----\n```\n\n### IPID\n\nAn IPFS node is required to create an IPID instance. Please be sure to check [js-ipfs](https://github.com/ipfs/js-ipfs), the JavaScript implementation of the IPFS protocol, to learn how to create one.\n\nThere is currently only one option available during the creation of an IPID instance. The `lifetime` option defines the duration of the DID document availability.\n\nExample:\n```js\nimport createIpid from 'did-ipid';\n\nconst ipid = await createIpid(ipfs, { lifetime: '24h' });\n```\n\nNotes:\n- Please make sure that the IPFS node is `ready` to use.\n- This package uses the Key Management provided by IPFS. So during the creation of the node a password must be defined, as an option, to encrypt/decrypt your keys. \n\n#### resolve(did)\n\nResolves a DID and provides the respective DID Document.\n\nReturns a Promise that resolves to the DID Document.\n\n##### did\n\nType: `string`\n\nThe DID to resolve.\n\nExample:\n```\ndid:ipid:QmUTE4cxTxihntPEFqTprgbqyyS9YRaRcC8FXp6PACEjFG\n```\n\n#### create(privateKeyPem, operations)\n\nCreates a new DID and respective DID Document by applying all the specified operations.\n\nReturns a Promise that resolves to the DID Document.\n\n##### privateKeyPem\n\nType: `string`\n\nA private key in PEM format.\n\nExample:\n```js\n-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQDCQZyRCPMcBPL2J2SuI2TduR7sy28wmcRzfj8fXQTbj1zJURku\n...\n-----END RSA PRIVATE KEY-----\n```\n\n##### operations\n\nType: `Function`\n\nA function that receives a Document instance that provides methods to modify its content.\n\n\n#### update(privateKeyPem, operations)\n\nUpdates an existing DID Document by applying all the specified operations.\n\nReturns a Promise that resolves to the DID Document.\n\n##### privateKeyPem\n\nType: `string`\n\nA private key in PEM format.\n\nExample:\n```js\n-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQDCQZyRCPMcBPL2J2SuI2TduR7sy28wmcRzfj8fXQTbj1zJURku\n...\n-----END RSA PRIVATE KEY-----\n```\n\n##### operations\n\nType: `Function`\n\nA function that receives a Document instance that provides methods to modify its content.\n\n\n### Document\n\n#### getContent()\n\nReturns the current state of the documents content.\n\n#### addPublicKey(publicKey, [options])\n\nAdds a new Public Key to the document.\n\nReturns the added public key.\n\n##### publicKey\n\nType: `Object`\n\nAn object with all the Public Key required properties as defined in the [DID Public Keys spec](https://w3c-ccg.github.io/did-spec/#public-keys).\n\n- `id` should be provided without a prefixed did.\n- If no `id` is provided, one will be generated.\n- If no `controller` is provided, it is assumed that it is its own DID. \n\n##### options\n\nType: `Object`\n\nOptions to be used while adding a public key.\n\n###### idPrefix\n\nType: `string`\n\nA prefix to be added to the public key id.\n\n#### revokePublicKey(id)\n\nRevokes a Public Key from the document.\n\nAlso revokes an authentication that references this public key.\n\n##### id\n\nType: `string` \n\nThe id of the public key.\n\n#### addAuthentication(authentication)\n\nAdds a new Authentication to the document.\n\nReturns the added authentication.\n\n##### authentication\n\nType: `string`\n\nThe id of the public key that is being referenced.\n\n#### removeAuthentication(id)\n\nRevokes an Authentication from the document.\n\n##### id\n\nType: `string` \n\nThe id authentication.\n\n#### addService(service, [options])\n\nAdds a new Service Endpoint to the document.\n\nReturns the added service.\n\n##### service\n\nType: `Object`\n\nAn object with all the Service Endpoint required properties as defined in the [DID Service Endpoints spec](https://w3c-ccg.github.io/did-spec/#service-endpoints).\n\n- `id` should be provided without a prefixed did.\n- If no `id` is provided, one will be generated.\n\n##### options\n\nType: `Object`\n\nOptions to be used while adding a service.\n\n###### idPrefix\n\nType: `string`\n\nA prefix to be added to the service id.\n\n#### removeService(id)\n\nRevokes a Service Endpoint from the document.\n\n##### id\n\nType: `string` \n\nThe id of the service endpoint.\n\n\n## Tests\n\n```sh\n$ npm test\n$ npm test -- --watch # during development\n```\n\n## License\n\nReleased under the [MIT License](http://www.opensource.org/licenses/mit-license.php).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs-shipyard%2Fjs-did-ipid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipfs-shipyard%2Fjs-did-ipid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs-shipyard%2Fjs-did-ipid/lists"}