{"id":13715136,"url":"https://github.com/ceramicstudio/js-3id-did-provider","last_synced_at":"2025-05-07T03:31:21.074Z","repository":{"id":41970689,"uuid":"196352247","full_name":"ceramicstudio/js-3id-did-provider","owner":"ceramicstudio","description":"DID Provider for 3IDs in JavaScript","archived":true,"fork":false,"pushed_at":"2022-04-21T12:43:18.000Z","size":3801,"stargazers_count":62,"open_issues_count":3,"forks_count":18,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-30T15:09:42.333Z","etag":null,"topics":["3id-did","ceramic","did-provider","dids"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ceramicstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-11T08:25:49.000Z","updated_at":"2024-12-09T16:32:01.000Z","dependencies_parsed_at":"2022-08-12T01:00:46.325Z","dependency_job_id":null,"html_url":"https://github.com/ceramicstudio/js-3id-did-provider","commit_stats":null,"previous_names":["3box/identity-wallet-js"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicstudio%2Fjs-3id-did-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicstudio%2Fjs-3id-did-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicstudio%2Fjs-3id-did-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicstudio%2Fjs-3id-did-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceramicstudio","download_url":"https://codeload.github.com/ceramicstudio/js-3id-did-provider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252782571,"owners_count":21803403,"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":["3id-did","ceramic","did-provider","dids"],"created_at":"2024-08-03T00:00:54.558Z","updated_at":"2025-05-07T03:31:16.064Z","avatar_url":"https://github.com/ceramicstudio.png","language":"TypeScript","funding_links":[],"categories":["Awesome List","TypeScript"],"sub_categories":["Developer Tools"],"readme":"# ⚠️ Library moved\n\nThe 3ID DID provider source has been moved to the [3ID repository](https://github.com/ceramicstudio/js-3id/tree/develop/packages/did-provider) and the package is now [available on npm as `@3id/did-provider`](https://www.npmjs.com/package/@3id/did-provider).\n\nThe `3id-did-provider` package is no longer maintained.\n\n# ThreeIdProvider\n\nThreeIdProvider is a JavaScript SDK that allows developers to create and manage 3ID identities on the Ceramic network. It exposes a [DID Provider](https://eips.ethereum.org/EIPS/eip-2844) interface which exposes JOSE signing and decryption though a JSON-RPC interface. ThreeIdProvider can be used in combination with [js-did](https://github.com/ceramicnetwork/js-did).\n\n\n## Getting Started\n### \u003ca name=\"install\"\u003e\u003c/a\u003eInstallation\nInstall 3id-did-provider in your npm project:\n```\n$ npm install 3id-did-provider\n```\n\n### \u003ca name=\"usage\"\u003e\u003c/a\u003eUsage\n#### Import ThreeIdProvider into your project\nImport the 3id-did-provider module\n```js\nimport { ThreeIdProvider } from '3id-did-provider'\n```\nImport using the dist build in your html code\n```js\n\u003cscript type=\"text/javascript\" src=\"../dist/threeid-provider.js\"\u003e\u003c/script\u003e\n```\n\n#### Understanding the `getPermission` function\nthe `getPermission` configuration parameter is always required when creating an instance of ThreeIdProvider. It is used to give an application permission to decrypt and sign data. What this function should do is to present a dialog to the user in the wallet UI, asking for permission to access the given paths.\n\nThe function is called with one parameter which is the `request` object. It looks like this:\n```js\n{\n  type: 'authenticate',\n  origin: 'https://my.app.origin',\n  payload: {\n    paths: ['/path/1', '/path/2']\n  }\n}\n```\nIn the above example the app with origin `https://my.app.origin` is requesting access to `/path/1` and `/path/2`. If the user consents to this the function should just return the `paths` array, otherwise an empty array. Note that an array containing only some of the requested paths may also be returned.\n\n#### Instantiate ThreeIdProvider with an authentication method\nTo create an instance with an auth method you can pass two params to the create function as shown below. If the auth method doesn't have a 3ID associated with it yet a new 3ID will be created. This means that a seed will be randomly generated in the background. and the given *authSecret* will be added as an authentication method to the newly created 3ID.\n```js\nconst authSecret = new Uint8Array([ ... ]) // 32 bytes of entropy used to authenticate\nconst authId = 'myAuthenticationMethod' // a name of the auth method\nconst ceramic = ... // An instance of Ceramic (either @ceramicnetwork/core, or @ceramicnetwork/http-client)\n\nconst threeId = await ThreeIdProvider.create({ getPermission, authSecret, authId, ceramic })\n```\n\n#### Instantiate ThreeIdProvider with a seed\nTo create a wallet with a seed you can simply pass it as an option to the constructor. This will create an instance of the ThreeIdProvider that derives all it's keys from this seed. Be careful, if this seed is lost the DID and all of it's data will be lost as well. Note that you will get different 3IDs every time the `create` method is invoked with the same seed. An authentication method must be used in order to interact with the same 3ID consistently.\n```js\nconst seed = new Uint8Array([ ... ]) // 32 bytes of entropy used as the seed\nconst ceramic = ... // An instance of Ceramic (either @ceramicnetwork/core, or @ceramicnetwork/http-client)\n\nconst threeId = await ThreeIdProvider.create({ getPermission, seed, ceramic })\n```\n\n#### Using the ThreeIdProvider with js-did\nAn instance of the DID provider from ThreeIdProvider can be passed directly to js-did.\n```js\nimport ThreeIdResolver from '@ceramicnetwork/3id-did-resolve'\nimport Ceramic from '@ceramicnetwork/http-client'\n\nconst provider = threeId.getDidProvider()\nconst resolver = ThreeIdResolver.getResolver(new Ceramic())\n\nconst did = new DID({ provider, resolver })\n```\n\n## Maintainers\n[@oed](https://github.com/oed)\n\n## \u003ca name=\"api\"\u003e\u003c/a\u003e API Documentation\n\u003ca name=\"Keychain\"\u003e\u003c/a\u003e\n\n### Keychain\n**Kind**: global class  \n\n* [Keychain](#Keychain)\n    * [new Keychain()](#new_Keychain_new)\n    * [.list()](#Keychain+list) ⇒ \u003ccode\u003eArray.\u0026lt;string\u0026gt;\u003c/code\u003e\n    * [.add(authId, authSecret)](#Keychain+add)\n    * [.remove(authId)](#Keychain+remove)\n    * [.status()](#Keychain+status) ⇒ \u003ccode\u003eKeychainStatus\u003c/code\u003e\n    * [.commit()](#Keychain+commit)\n\n\u003ca name=\"new_Keychain_new\"\u003e\u003c/a\u003e\n\n#### new Keychain()\nThe Keychain enables adding and removing of authentication methods.\n\n\u003ca name=\"Keychain+list\"\u003e\u003c/a\u003e\n\n#### keychain.list() ⇒ \u003ccode\u003eArray.\u0026lt;string\u0026gt;\u003c/code\u003e\nList all current authentication methods.\n\n**Kind**: instance method of [\u003ccode\u003eKeychain\u003c/code\u003e](#Keychain)  \n**Returns**: \u003ccode\u003eArray.\u0026lt;string\u0026gt;\u003c/code\u003e - A list of authIds.  \n\u003ca name=\"Keychain+add\"\u003e\u003c/a\u003e\n\n#### keychain.add(authId, authSecret)\nAdd a new authentication method (adds to staging).\n\n**Kind**: instance method of [\u003ccode\u003eKeychain\u003c/code\u003e](#Keychain)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| authId | \u003ccode\u003eString\u003c/code\u003e | An identifier for the auth method |\n| authSecret | \u003ccode\u003eUint8Array\u003c/code\u003e | The authSecret to use, should be of sufficient entropy |\n\n\u003ca name=\"Keychain+remove\"\u003e\u003c/a\u003e\n\n#### keychain.remove(authId)\nRemove an authentication method (adds to staging).\n\n**Kind**: instance method of [\u003ccode\u003eKeychain\u003c/code\u003e](#Keychain)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| authId | \u003ccode\u003eString\u003c/code\u003e | An identifier for the auth method |\n\n\u003ca name=\"Keychain+status\"\u003e\u003c/a\u003e\n\n#### keychain.status() ⇒ \u003ccode\u003eKeychainStatus\u003c/code\u003e\nShow the staging status of the keychain.\nSince removing auth methods will rotate the keys of the 3ID its a good idea\nto remove multiple auth methods at once if desired. Therefore we introduce\na commit pattern to do multiple updates to the keychain at once.\n\n**Kind**: instance method of [\u003ccode\u003eKeychain\u003c/code\u003e](#Keychain)  \n**Returns**: \u003ccode\u003eKeychainStatus\u003c/code\u003e - Object that states the staging status of the keychain  \n\u003ca name=\"Keychain+commit\"\u003e\u003c/a\u003e\n\n#### keychain.commit()\nCommit the staged changes to the keychain.\n\n**Kind**: instance method of [\u003ccode\u003eKeychain\u003c/code\u003e](#Keychain)  \n\u003ca name=\"Permissions\"\u003e\u003c/a\u003e\n\n### Permissions\n**Kind**: global class  \n\n* [Permissions](#Permissions)\n    * [new Permissions()](#new_Permissions_new)\n    * [.request(origin, paths)](#Permissions+request) ⇒ \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e\n    * [.has(origin, paths)](#Permissions+has) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\n    * [.get(origin)](#Permissions+get) ⇒ \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e\n    * [.set(origin, paths)](#Permissions+set)\n\n\u003ca name=\"new_Permissions_new\"\u003e\u003c/a\u003e\n\n#### new Permissions()\nThe Permissions class exposes methods to read and update the given permissions\n\n\u003ca name=\"Permissions+request\"\u003e\u003c/a\u003e\n\n#### permissions.request(origin, paths) ⇒ \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e\nRequest permission for given paths for a given origin.\n\n**Kind**: instance method of [\u003ccode\u003ePermissions\u003c/code\u003e](#Permissions)  \n**Returns**: \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e - The paths that where granted permission for  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eString\u003c/code\u003e | Application domain |\n| paths | \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e | The desired paths |\n\n\u003ca name=\"Permissions+has\"\u003e\u003c/a\u003e\n\n#### permissions.has(origin, paths) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\nDetermine if permission has been given for paths for a given origin.\n\n**Kind**: instance method of [\u003ccode\u003ePermissions\u003c/code\u003e](#Permissions)  \n**Returns**: \u003ccode\u003eBoolean\u003c/code\u003e - True if permission has previously been given  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eString\u003c/code\u003e | Application domain |\n| paths | \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e | The desired paths |\n\n\u003ca name=\"Permissions+get\"\u003e\u003c/a\u003e\n\n#### permissions.get(origin) ⇒ \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e\nGet the paths which the given origin has permission for.\n\n**Kind**: instance method of [\u003ccode\u003ePermissions\u003c/code\u003e](#Permissions)  \n**Returns**: \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e - The permissioned paths  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eString\u003c/code\u003e | Application domain |\n\n\u003ca name=\"Permissions+set\"\u003e\u003c/a\u003e\n\n#### permissions.set(origin, paths)\nSet the paths which the given origin should have permission for.\n\n**Kind**: instance method of [\u003ccode\u003ePermissions\u003c/code\u003e](#Permissions)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eString\u003c/code\u003e | Application domain |\n| paths | \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e | The desired paths |\n\n\u003ca name=\"ThreeIdProvider\"\u003e\u003c/a\u003e\n\n### ThreeIdProvider\n**Kind**: global class  \n\n* [ThreeIdProvider](#ThreeIdProvider)\n    * [new ThreeIdProvider()](#new_ThreeIdProvider_new)\n    * _instance_\n        * [.keychain](#ThreeIdProvider+keychain)\n        * [.permissions](#ThreeIdProvider+permissions)\n        * [.id](#ThreeIdProvider+id)\n        * [.getDidProvider()](#ThreeIdProvider+getDidProvider) ⇒ \u003ccode\u003eDidProvider\u003c/code\u003e\n    * _static_\n        * [.create(config)](#ThreeIdProvider.create) ⇒ [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider)\n\n\u003ca name=\"new_ThreeIdProvider_new\"\u003e\u003c/a\u003e\n\n#### new ThreeIdProvider()\nUse ThreeIdProvider.create() to create an ThreeIdProvider instance\n\n\u003ca name=\"ThreeIdProvider+keychain\"\u003e\u003c/a\u003e\n\n#### threeIdProvider.keychain\n**Kind**: instance property of [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider)  \n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| keychain | [\u003ccode\u003eKeychain\u003c/code\u003e](#Keychain) | Edit the keychain |\n\n\u003ca name=\"ThreeIdProvider+permissions\"\u003e\u003c/a\u003e\n\n#### threeIdProvider.permissions\n**Kind**: instance property of [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider)  \n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| permissions | [\u003ccode\u003ePermissions\u003c/code\u003e](#Permissions) | Edit permissions |\n\n\u003ca name=\"ThreeIdProvider+id\"\u003e\u003c/a\u003e\n\n#### threeIdProvider.id\n**Kind**: instance property of [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider)  \n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| id | \u003ccode\u003estring\u003c/code\u003e | The DID of the ThreeIdProvider instance |\n\n\u003ca name=\"ThreeIdProvider+getDidProvider\"\u003e\u003c/a\u003e\n\n#### threeIdProvider.getDidProvider() ⇒ \u003ccode\u003eDidProvider\u003c/code\u003e\nGet the DIDProvider\n\n**Kind**: instance method of [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider)  \n**Returns**: \u003ccode\u003eDidProvider\u003c/code\u003e - The DIDProvider for this ThreeIdProvider instance  \n\u003ca name=\"ThreeIdProvider.create\"\u003e\u003c/a\u003e\n\n#### ThreeIdProvider.create(config) ⇒ [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider)\nCreates an instance of ThreeIdProvider\n\n**Kind**: static method of [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider)  \n**Returns**: [\u003ccode\u003eThreeIdProvider\u003c/code\u003e](#ThreeIdProvider) - An ThreeIdProvider instance  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| config | \u003ccode\u003eObject\u003c/code\u003e | The configuration to be used |\n| config.getPermission | \u003ccode\u003efunction\u003c/code\u003e | The function that is called to ask the user for permission |\n| config.ceramic | \u003ccode\u003eCeramicApi\u003c/code\u003e | The ceramic instance to use |\n| config.loader | \u003ccode\u003eTileLoader\u003c/code\u003e | An optional TileLoader instance to use |\n| config.seed | \u003ccode\u003eUint8Array\u003c/code\u003e | The seed of the 3ID, 32 bytes |\n| config.authSecret | \u003ccode\u003eUint8Array\u003c/code\u003e | The authSecret to use, 32 bytes |\n| config.authId | \u003ccode\u003eString\u003c/code\u003e | The authId is used to identify the authSecret |\n| config.disableIDX | \u003ccode\u003eBoolean\u003c/code\u003e | Disable creation of the IDX document |\n| config.v03ID | \u003ccode\u003eString\u003c/code\u003e | A v0 3ID, has to be passed if a migration is being preformed |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceramicstudio%2Fjs-3id-did-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceramicstudio%2Fjs-3id-did-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceramicstudio%2Fjs-3id-did-provider/lists"}