diff --git a/docs/IDENTITIES.md b/docs/IDENTITIES.md index 4e479f6..a41037e 100644 --- a/docs/IDENTITIES.md +++ b/docs/IDENTITIES.md @@ -128,4 +128,43 @@ The resulting output is a JSON object containing the identity information: publicKey: '30450221008291e9e12d586129de2882e731f286b4168cbed43d2ecf90d8ae9c53e15c56110220204ac640b22e75bf6083a6715a7e6c988659fc08f79022fab8af62563e9fdd67' } } -``` \ No newline at end of file +``` + +## Custom identity providers + +A custom identity provider can be used provided the module takes the following form: +```javascript +// A unique name for the identity provider +const type = 'custom' + +// check whether the identity was signed by the identity's id. +const verifyIdentity = identity => { + +} +// The identity provider. +const MyCustomIdentityProvider = ({ keystore }) => { + const getId = async ({ id } = {}) => { + + } + + const signIdentity = async (data, { id } = {}) => { + + } + + return { + getId, + signIdentity + } +} + +export { MyCustomIdentityProvider as default, verifyIdentity, type } +``` + +To use it, add it to the list of known identity providers: + +```javascript +import as MyCustomIdentityProvider from 'my-custom-identity-provider' +addIdentityProvider(MyCustomIdentityProvider) +``` + +where my-custom-identity-provider is the custom module. \ No newline at end of file diff --git a/src/identities/providers/index.js b/src/identities/providers/index.js index 2387052..573d200 100644 --- a/src/identities/providers/index.js +++ b/src/identities/providers/index.js @@ -1,57 +1,13 @@ /** * @module IdentityProviders * @description - * Identity providers. - * - * ## Custom Providers - * - * An identity provider provides a method for signing and verifying an - * identity using a particular cryptographic mechanism. - * - * A custom identity provider can be used provided the module takes the - * following form: - * ```javascript - * // A unique name for the identity provider - * const type = 'custom' - * - * // check whether the identity was signed by the identity's id. - * const verifyIdentity = identity => { - * - * } - * - * // The identity provider. - * const MyCustomIdentityProvider = ({ keystore }) => { - * const getId = async ({ id } = {}) => { - * - * } - * - * const signIdentity = async (data, { id } = {}) => { - * - * } - * - * return { - * getId, - * signIdentity - * } - * } - * - * export { MyCustomIdentityProvider as default, verifyIdentity, type } - * ``` - * - * To use it, add it to the list of known identity providers: - * ```javascript - * import * as MyCustomIdentityProvider from 'my-custom-identity-provider' - * addIdentityProvider(MyCustomIdentityProvider) - * ``` - * - * where my-custom-identity-provider is the custom module. + * Identity providers for signing and verifying an identity using various + * cryptographic mechanism. */ import * as PublicKeyIdentityProvider from './publickey.js' const identityProviders = { publickey: PublicKeyIdentityProvider - // [DIDIdentityProvider.type]: DIDIdentityProvider, - // [EthIdentityProvider.type]: EthIdentityProvider } /**