{"id":21659019,"url":"https://github.com/3box/muport-core-js","last_synced_at":"2025-07-17T21:32:07.946Z","repository":{"id":57305519,"uuid":"123418089","full_name":"3box/muport-core-js","owner":"3box","description":"JavaScript framework for associating a DID to an Ethereum address","archived":true,"fork":false,"pushed_at":"2019-05-23T22:28:55.000Z","size":618,"stargazers_count":11,"open_issues_count":2,"forks_count":3,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-25T09:43:42.794Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/3box.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-03-01T10:13:00.000Z","updated_at":"2023-01-28T14:16:38.000Z","dependencies_parsed_at":"2022-09-20T20:50:54.552Z","dependency_job_id":null,"html_url":"https://github.com/3box/muport-core-js","commit_stats":null,"previous_names":["uport-project/muport-core-js"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/3box/muport-core-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3box%2Fmuport-core-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3box%2Fmuport-core-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3box%2Fmuport-core-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3box%2Fmuport-core-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3box","download_url":"https://codeload.github.com/3box/muport-core-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3box%2Fmuport-core-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265663004,"owners_count":23807463,"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-25T09:30:18.239Z","updated_at":"2025-07-17T21:32:07.655Z","avatar_url":"https://github.com/3box.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# µPort core\n[![CircleCI](https://circleci.com/gh/uport-project/muport-core-js.svg?style=svg\u0026circle-token=d007f3bfb7d76e05bea029ca9aa1dd523c97d453)](https://circleci.com/gh/uport-project/muport-core-js) [![codecov](https://codecov.io/gh/uport-project/muport-core-js/branch/master/graph/badge.svg?token=G53BcQfF8N)](https://codecov.io/gh/uport-project/muport-core-js)\n\nThis library is intended to be used to create, update, and recover µPort identities, as well as using the identity to sign and encrypt data.\n\n## Usage\nSimply install using npm\n```\n$ npm install muport-core\n```\nand then import into your project\n```js\nconst MuPort = require('muport-core')\n```\n\n\u003ca name=\"MuPort\"\u003e\u003c/a\u003e\n\n## MuPort\nPrimary object for interacting with a µPort identity. MuPort enables creation and\nupdating of µPort identities. It also provides functionality to sign claims and\nhelp other identities recover.\n\n**Kind**: global class  \n\n* [MuPort](#MuPort)\n    * [new MuPort(serializeState, [opts])](#new_MuPort_new)\n    * _instance_\n        * [.helpRecover(did)](#MuPort+helpRecover) ⇒ \u003ccode\u003ePromise.\u0026lt;String, Error\u0026gt;\u003c/code\u003e\n        * [.getDid()](#MuPort+getDid) ⇒ \u003ccode\u003eString\u003c/code\u003e\n        * [.getDidDocument()](#MuPort+getDidDocument) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.getRecoveryDelegateDids()](#MuPort+getRecoveryDelegateDids) ⇒ \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e\n        * [.updateIdentity(publicProfile, delegateDids)](#MuPort+updateIdentity) ⇒ \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e\n        * [.signJWT(payload)](#MuPort+signJWT) ⇒ \u003ccode\u003ePromise.\u0026lt;String, Error\u0026gt;\u003c/code\u003e\n        * [.verifyJWT(jwt, audience)](#MuPort+verifyJWT) ⇒ \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e\n        * [.encrypt(msg, toPublic, nonce)](#MuPort+encrypt) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.decrypt(ciphertext, fromPublic, nonce, toBuffer)](#MuPort+decrypt) ⇒ \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eBuffer\u003c/code\u003e\n        * [.symEncrypt(msg, nonce)](#MuPort+symEncrypt) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.symDecrypt(ciphertext, nonce, toBuffer)](#MuPort+symDecrypt) ⇒ \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eBuffer\u003c/code\u003e\n        * [.serializeState()](#MuPort+serializeState) ⇒ \u003ccode\u003eString\u003c/code\u003e\n    * _static_\n        * [.newIdentity(publicProfile, delegateDids, [opts])](#MuPort.newIdentity) ⇒ \u003ccode\u003ePromise.\u0026lt;MuPort, Error\u0026gt;\u003c/code\u003e\n        * [.recoverIdentity(did, shares, [opts])](#MuPort.recoverIdentity) ⇒ \u003ccode\u003ePromise.\u0026lt;MuPort, Error\u0026gt;\u003c/code\u003e\n        * [.resolveIdentityDocument(did, [opts])](#MuPort.resolveIdentityDocument) ⇒ \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e\n\n\u003ca name=\"new_MuPort_new\"\u003e\u003c/a\u003e\n\n### new MuPort(serializeState, [opts])\nInstantiates a µPort identity from its serialized state.\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| serializeState | \u003ccode\u003eString\u003c/code\u003e | the serialized state of a µPort identity |\n| [opts] | \u003ccode\u003eObject\u003c/code\u003e | optional parameters |\n| opts.ipfsConf | \u003ccode\u003eObject\u003c/code\u003e | configuration options for ipfs-mini |\n| opts.rpcProviderUrl | \u003ccode\u003eString\u003c/code\u003e | rpc url to a custom ethereum node |\n\n\u003ca name=\"MuPort+helpRecover\"\u003e\u003c/a\u003e\n\n### muPort.helpRecover(did) ⇒ \u003ccode\u003ePromise.\u0026lt;String, Error\u0026gt;\u003c/code\u003e\nHelp another identity recover. Returns a decrypted share if the current identity is a delegate\nreturns undefined otherwise\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;String, Error\u0026gt;\u003c/code\u003e - a share that the recovering identity can use  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| did | \u003ccode\u003eString\u003c/code\u003e | the did of the identity that should be recovered |\n\n\u003ca name=\"MuPort+getDid\"\u003e\u003c/a\u003e\n\n### muPort.getDid() ⇒ \u003ccode\u003eString\u003c/code\u003e\nThe DID is the identifier of the identity. This is a unique string that can be used to\nlook up information about the identity.\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - the DID  \n\u003ca name=\"MuPort+getDidDocument\"\u003e\u003c/a\u003e\n\n### muPort.getDidDocument() ⇒ \u003ccode\u003eObject\u003c/code\u003e\nThe DID Document is a json object that contains information such as public keys\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - the DID Document  \n\u003ca name=\"MuPort+getRecoveryDelegateDids\"\u003e\u003c/a\u003e\n\n### muPort.getRecoveryDelegateDids() ⇒ \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e\nThe recovery delegates that can help this identity recover\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e - an array containing the DIDs of the delegates  \n\u003ca name=\"MuPort+updateIdentity\"\u003e\u003c/a\u003e\n\n### muPort.updateIdentity(publicProfile, delegateDids) ⇒ \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e\nThis function is used to update the publicProfile and/or the recoveryNetwork of the identity.\nThe returned object has three properties; `address` an ethereum address, `costInEther` a number,\nand `finishUpdate` a function.\nIn order to complete the update of the delegates you have to\nsend `costInEther` ether to the `address` on mainnet (or other network if you are using\na custom config). Once that is done the `finishUpdate` function can be called. This\nfunction sends a transaction to the network that updates the identity. The function\nwill throw an error if there is to little ether in the `address`.\nBoth publicProfile and delegateDids are optional and you may pass null if you don't wish to\nupdate one of them.\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e - an object with the data needed to finalize the update  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| publicProfile | \u003ccode\u003eObject\u003c/code\u003e | a new public profile for the identity |\n| delegateDids | \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e | an array containing the 3 DIDs of the new delegates |\n\n\u003ca name=\"MuPort+signJWT\"\u003e\u003c/a\u003e\n\n### muPort.signJWT(payload) ⇒ \u003ccode\u003ePromise.\u0026lt;String, Error\u0026gt;\u003c/code\u003e\nSigns the given payload (claim) and return a promis with the JWT.\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;String, Error\u0026gt;\u003c/code\u003e - a promise that resolves to a JWT  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| payload | \u003ccode\u003e\\*\u003c/code\u003e | the payload to sign |\n\n\u003ca name=\"MuPort+verifyJWT\"\u003e\u003c/a\u003e\n\n### muPort.verifyJWT(jwt, audience) ⇒ \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e\nVerifies a JWT.\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e - a promise that resolves to the decoded JWT  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| jwt | \u003ccode\u003eString\u003c/code\u003e |  | the JWT to verify |\n| audience | \u003ccode\u003eString\u003c/code\u003e | \u003ccode\u003ethis.did\u003c/code\u003e | the audience, defaults to did of current identity |\n\n\u003ca name=\"MuPort+encrypt\"\u003e\u003c/a\u003e\n\n### muPort.encrypt(msg, toPublic, nonce) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nAsymmetrically encrypt a message\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - an object containing the nonce and the ciphertext  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| msg | \u003ccode\u003eString\u003c/code\u003e | the message to encrypt |\n| toPublic | \u003ccode\u003eString\u003c/code\u003e | the public key to encrypt to, encoded as a base64 string |\n| nonce | \u003ccode\u003eString\u003c/code\u003e | (optional) the nonce, encoded as a base64 string |\n\n\u003ca name=\"MuPort+decrypt\"\u003e\u003c/a\u003e\n\n### muPort.decrypt(ciphertext, fromPublic, nonce, toBuffer) ⇒ \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eBuffer\u003c/code\u003e\nDecrypt an asymmetrically encrypted message\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eBuffer\u003c/code\u003e - the decrypted message  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| ciphertext | \u003ccode\u003eString\u003c/code\u003e | the ciphertext to decrypt, encoded as a base64 string |\n| fromPublic | \u003ccode\u003eString\u003c/code\u003e | the public key of the entity that encrypted the msg, encoded as a base64 string |\n| nonce | \u003ccode\u003eString\u003c/code\u003e | the nonce, encoded as a base64 string |\n| toBuffer | \u003ccode\u003eBoolean\u003c/code\u003e | a boolean deciding whether to |\n\n\u003ca name=\"MuPort+symEncrypt\"\u003e\u003c/a\u003e\n\n### muPort.symEncrypt(msg, nonce) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nSymmetrically encrypt a message\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - an object containing the nonce and the ciphertext  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| msg | \u003ccode\u003eString\u003c/code\u003e | the message to encrypt |\n| nonce | \u003ccode\u003eString\u003c/code\u003e | (optional) the nonce, encoded as a base64 string |\n\n\u003ca name=\"MuPort+symDecrypt\"\u003e\u003c/a\u003e\n\n### muPort.symDecrypt(ciphertext, nonce, toBuffer) ⇒ \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eBuffer\u003c/code\u003e\nDecrypt a symmetrically encrypted message\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eBuffer\u003c/code\u003e - the decrypted message  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| ciphertext | \u003ccode\u003eString\u003c/code\u003e | the ciphertext to decrypt, encoded as a base64 string |\n| nonce | \u003ccode\u003eString\u003c/code\u003e | the nonce, encoded as a base64 string |\n| toBuffer | \u003ccode\u003eBoolean\u003c/code\u003e | a boolean deciding whether to |\n\n\u003ca name=\"MuPort+serializeState\"\u003e\u003c/a\u003e\n\n### muPort.serializeState() ⇒ \u003ccode\u003eString\u003c/code\u003e\nSerialize the state of the current identity to be able to reconstruct it later.\n\n**Kind**: instance method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003eString\u003c/code\u003e - the serialized state  \n\u003ca name=\"MuPort.newIdentity\"\u003e\u003c/a\u003e\n\n### MuPort.newIdentity(publicProfile, delegateDids, [opts]) ⇒ \u003ccode\u003ePromise.\u0026lt;MuPort, Error\u0026gt;\u003c/code\u003e\nCreates a new µPort identity.\n\n**Kind**: static method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;MuPort, Error\u0026gt;\u003c/code\u003e - a promise that resolves to an instance of the MuPort class  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| publicProfile | \u003ccode\u003eObject\u003c/code\u003e | a public profile for the new identity |\n| delegateDids | \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e | three DIDs that can be used to recover the identity at a later point (optional) |\n| [opts] | \u003ccode\u003eObject\u003c/code\u003e | optional parameters |\n| opts.externalMgmtKey | \u003ccode\u003eString\u003c/code\u003e | an ethereum address to be used as an external managementKey |\n| opts.ipfsConf | \u003ccode\u003eObject\u003c/code\u003e | configuration options for ipfs-mini |\n| opts.rpcProviderUrl | \u003ccode\u003eString\u003c/code\u003e | rpc url to a custom ethereum node |\n\n\u003ca name=\"MuPort.recoverIdentity\"\u003e\u003c/a\u003e\n\n### MuPort.recoverIdentity(did, shares, [opts]) ⇒ \u003ccode\u003ePromise.\u0026lt;MuPort, Error\u0026gt;\u003c/code\u003e\nRecovers a µPort identity.\n\n**Kind**: static method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;MuPort, Error\u0026gt;\u003c/code\u003e - a promise that resolves to an instance of the MuPort class  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| did | \u003ccode\u003eString\u003c/code\u003e | the DID of the identity to be recovered |\n| shares | \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e | atleast two shares that your delegates helped recover |\n| [opts] | \u003ccode\u003eObject\u003c/code\u003e | optional parameters |\n| opts.ipfsConf | \u003ccode\u003eObject\u003c/code\u003e | configuration options for ipfs-mini |\n| opts.rpcProviderUrl | \u003ccode\u003eString\u003c/code\u003e | rpc url to a custom ethereum node |\n\n\u003ca name=\"MuPort.resolveIdentityDocument\"\u003e\u003c/a\u003e\n\n### MuPort.resolveIdentityDocument(did, [opts]) ⇒ \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e\nResovles the identity document for the given DID.\n\n**Kind**: static method of [\u003ccode\u003eMuPort\u003c/code\u003e](#MuPort)  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;Object, Error\u0026gt;\u003c/code\u003e - a promise that resolves to the identity document  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| did | \u003ccode\u003eString\u003c/code\u003e | the DID of the identity |\n| [opts] | \u003ccode\u003eObject\u003c/code\u003e | optional parameters |\n| opts.ipfsConf | \u003ccode\u003eObject\u003c/code\u003e | configuration options for ipfs-mini |\n| opts.rpcProviderUrl | \u003ccode\u003eString\u003c/code\u003e | rpc url to a custom ethereum node |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3box%2Fmuport-core-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3box%2Fmuport-core-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3box%2Fmuport-core-js/lists"}