From 7812e51ee250265bcc308e7fd4db1ee8b2e408a4 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Thu, 17 Dec 2020 19:31:10 +0200 Subject: [PATCH] refactor: Rename Identity to Identifier (#308) BREAKING CHANGE: This rename affects almost all the Identity management API Please look for `IDIDManager.ts` in `daf-core/src/types` to see the new method names. Functionality is the same but some renaming is required if already in use. * refactor: Rename Identity to Identifier * fix: Integration tests * refactor: WebDIDProvider * refactor: EthrDIDProvider * refactor: DIDStore * refactor: Resolver * refactor: DidManagerFind * refactor: DidManagerFind * refactor: DidManagerGet * refactor: DidManagerCreate * refactor: DidManagerGetOrCreate * refactor: DidManagerImport * refactor: DidManagerDelete * refactor: KeyManager * refactor: DefaultDID * refactor: IDIDManager * refactor: IDIDManager.ts --- __tests__/localAgent.test.ts | 40 +- __tests__/restAgent.test.ts | 36 +- __tests__/shared/didManager.ts | 313 ++++++++++++++++ __tests__/shared/documentationExamples.ts | 26 +- __tests__/shared/handleSdrMessage.ts | 41 +- __tests__/shared/identityManager.ts | 313 ---------------- __tests__/shared/keyManager.ts | 44 +-- __tests__/shared/saveClaims.ts | 24 +- __tests__/shared/verifiableData.ts | 19 +- __tests__/shared/webDidFlow.ts | 68 ++-- packages/daf-cli/default/client.yml | 38 +- packages/daf-cli/default/default.yml | 18 +- packages/daf-cli/src/credential.ts | 8 +- packages/daf-cli/src/dev.ts | 2 +- packages/daf-cli/src/did.ts | 56 +-- packages/daf-cli/src/explore/main.ts | 4 +- .../src/explore/managed-identifiers.ts | 67 ++++ .../daf-cli/src/explore/managed-identities.ts | 67 ---- packages/daf-cli/src/presentation.ts | 12 +- packages/daf-cli/src/sdr.ts | 8 +- packages/daf-cli/src/server.ts | 23 +- packages/daf-cli/src/setup.ts | 4 +- packages/daf-core/api/daf-core.api.md | 122 +++--- packages/daf-core/package.json | 2 +- packages/daf-core/plugin.schema.json | 192 +++++----- packages/daf-core/src/index.ts | 6 +- packages/daf-core/src/types/IDIDManager.ts | 339 +++++++++++++++++ .../types/{IIdentity.ts => IIdentifier.ts} | 11 +- .../daf-core/src/types/IIdentityManager.ts | 354 ------------------ packages/daf-core/src/types/IKeyManager.ts | 22 +- packages/daf-core/src/types/IMessage.ts | 13 +- packages/daf-did-comm/api/daf-did-comm.api.md | 6 +- packages/daf-did-comm/plugin.schema.json | 4 +- packages/daf-did-comm/src/action-handler.ts | 14 +- packages/daf-did-comm/src/message-handler.ts | 12 +- packages/daf-ethr-did/api/daf-ethr-did.api.md | 24 +- .../src/__tests__/identity-provider.test.ts | 40 +- ...ity-provider.ts => identifier-provider.ts} | 46 +-- packages/daf-ethr-did/src/index.ts | 4 +- packages/daf-express/api/daf-express.api.md | 4 +- .../daf-express/src/web-did-doc-router.ts | 36 +- .../api/daf-identity-manager.api.md | 124 +++--- .../src/abstract-identifier-provider.ts | 29 ++ .../src/abstract-identifier-store.ts | 13 + .../src/abstract-identity-provider.ts | 29 -- .../src/abstract-identity-store.ts | 13 - .../daf-identity-manager/src/id-manager.ts | 217 +++++++++++ .../src/identity-manager.ts | 223 ----------- packages/daf-identity-manager/src/index.ts | 8 +- .../api/daf-key-manager.api.md | 14 +- packages/daf-key-manager/src/key-manager.ts | 30 +- .../api/daf-selective-disclosure.api.md | 10 +- .../plugin.schema.json | 4 +- .../src/action-handler.ts | 32 +- .../daf-selective-disclosure/src/types.ts | 6 +- packages/daf-typeorm/api/daf-typeorm.api.md | 86 ++--- packages/daf-typeorm/plugin.schema.json | 42 +-- .../src/__tests__/data-store-orm.test.ts | 12 +- .../src/__tests__/entities.test.ts | 42 +-- packages/daf-typeorm/src/data-store-orm.ts | 68 ++-- packages/daf-typeorm/src/entities/claim.ts | 10 +- .../daf-typeorm/src/entities/credential.ts | 14 +- .../entities/{identity.ts => identifier.ts} | 8 +- packages/daf-typeorm/src/entities/key.ts | 6 +- packages/daf-typeorm/src/entities/message.ts | 16 +- .../daf-typeorm/src/entities/presentation.ts | 14 +- packages/daf-typeorm/src/entities/service.ts | 6 +- .../daf-typeorm/src/identifier/did-store.ts | 122 ++++++ .../src/{identity => identifier}/key-store.ts | 0 .../src/identity/identity-store.ts | 114 ------ packages/daf-typeorm/src/index.ts | 14 +- packages/daf-typeorm/src/types.ts | 2 +- .../src/__tests__/message-handler.test.ts | 2 +- packages/daf-w3c/api/daf-w3c.api.md | 2 +- packages/daf-w3c/plugin.schema.json | 8 +- .../src/__tests__/action-handler.test.ts | 26 +- .../src/__tests__/credentialStatus.test.ts | 4 +- packages/daf-w3c/src/action-handler.ts | 28 +- packages/daf-web-did/api/daf-web-did.api.md | 24 +- .../daf-web-did/src/identifier-provider.ts | 71 ++++ packages/daf-web-did/src/identity-provider.ts | 71 ---- packages/daf-web-did/src/index.ts | 4 +- scripts/prepare-integration-tests.ts | 2 +- yarn.lock | 12 +- 84 files changed, 2018 insertions(+), 2046 deletions(-) create mode 100644 __tests__/shared/didManager.ts delete mode 100644 __tests__/shared/identityManager.ts create mode 100644 packages/daf-cli/src/explore/managed-identifiers.ts delete mode 100644 packages/daf-cli/src/explore/managed-identities.ts create mode 100644 packages/daf-core/src/types/IDIDManager.ts rename packages/daf-core/src/types/{IIdentity.ts => IIdentifier.ts} (84%) delete mode 100644 packages/daf-core/src/types/IIdentityManager.ts rename packages/daf-ethr-did/src/{identity-provider.ts => identifier-provider.ts} (70%) create mode 100644 packages/daf-identity-manager/src/abstract-identifier-provider.ts create mode 100644 packages/daf-identity-manager/src/abstract-identifier-store.ts delete mode 100644 packages/daf-identity-manager/src/abstract-identity-provider.ts delete mode 100644 packages/daf-identity-manager/src/abstract-identity-store.ts create mode 100644 packages/daf-identity-manager/src/id-manager.ts delete mode 100644 packages/daf-identity-manager/src/identity-manager.ts rename packages/daf-typeorm/src/entities/{identity.ts => identifier.ts} (90%) create mode 100644 packages/daf-typeorm/src/identifier/did-store.ts rename packages/daf-typeorm/src/{identity => identifier}/key-store.ts (100%) delete mode 100644 packages/daf-typeorm/src/identity/identity-store.ts create mode 100644 packages/daf-web-did/src/identifier-provider.ts delete mode 100644 packages/daf-web-did/src/identity-provider.ts diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index 705af118c..b262320a6 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -1,7 +1,7 @@ import { createAgent, TAgent, - IIdentityManager, + IDIDManager, IResolver, IKeyManager, IDataStore, @@ -10,13 +10,13 @@ import { } from '../packages/daf-core/src' import { MessageHandler } from '../packages/daf-message-handler/src' import { KeyManager } from '../packages/daf-key-manager/src' -import { IdentityManager } from '../packages/daf-identity-manager/src' +import { DIDManager } from '../packages/daf-identity-manager/src' import { createConnection, Connection } from 'typeorm' import { DafResolver } from '../packages/daf-resolver/src' import { JwtMessageHandler } from '../packages/daf-did-jwt/src' import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from '../packages/daf-w3c/src' -import { EthrIdentityProvider } from '../packages/daf-ethr-did/src' -import { WebIdentityProvider } from '../packages/daf-web-did/src' +import { EthrDIDProvider } from '../packages/daf-ethr-did/src' +import { WebDIDProvider } from '../packages/daf-web-did/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/daf-did-comm/src' import { SelectiveDisclosure, @@ -27,7 +27,7 @@ import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium/src' import { Entities, KeyStore, - IdentityStore, + DIDStore, IDataStoreORM, DataStore, DataStoreORM, @@ -47,7 +47,7 @@ import webDidFlow from './shared/webDidFlow' import saveClaims from './shared/saveClaims' import documentationExamples from './shared/documentationExamples' import keyManager from './shared/keyManager' -import identityManager from './shared/identityManager' +import didManager from './shared/didManager' import messageHandler from './shared/messageHandler' const databaseFile = 'local-database.sqlite' @@ -55,7 +55,7 @@ const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c' const secretKey = '29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c' let agent: TAgent< - IIdentityManager & + IDIDManager & IKeyManager & IDataStore & IDataStoreORM & @@ -77,7 +77,7 @@ const setup = async (options?: IAgentOptions): Promise => { }) agent = createAgent< - IIdentityManager & + IDIDManager & IKeyManager & IDataStore & IDataStoreORM & @@ -98,42 +98,42 @@ const setup = async (options?: IAgentOptions): Promise => { local: new KeyManagementSystem(), }, }), - new IdentityManager({ - store: new IdentityStore(dbConnection), + new DIDManager({ + store: new DIDStore(dbConnection), defaultProvider: 'did:ethr:rinkeby', providers: { - 'did:ethr': new EthrIdentityProvider({ + 'did:ethr': new EthrDIDProvider({ defaultKms: 'local', network: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId, gas: 1000001, ttl: 60 * 60 * 24 * 30 * 12 + 1, }), - 'did:ethr:rinkeby': new EthrIdentityProvider({ + 'did:ethr:rinkeby': new EthrDIDProvider({ defaultKms: 'local', network: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId, gas: 1000001, ttl: 60 * 60 * 24 * 30 * 12 + 1, }), - 'did:web': new WebIdentityProvider({ + 'did:web': new WebDIDProvider({ defaultKms: 'local', }), }, }), - new DafResolver({ + new DafResolver({ resolver: new Resolver({ - ethr: ethrDidResolver({ + ...ethrDidResolver({ networks: [ { name: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId }, { name: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId }, { name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/' + infuraProjectId }, { name: 'kovan', rpcUrl: 'https://kovan.infura.io/v3/' + infuraProjectId }, { name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/' + infuraProjectId }, - ] - }).ethr, - web: webDidResolver().web - }) + ], + }), + ...webDidResolver(), + }), }), new DataStore(dbConnection), new DataStoreORM(dbConnection), @@ -171,6 +171,6 @@ describe('Local integration tests', () => { saveClaims(testContext) documentationExamples(testContext) keyManager(testContext) - identityManager(testContext) + didManager(testContext) messageHandler(testContext) }) diff --git a/__tests__/restAgent.test.ts b/__tests__/restAgent.test.ts index d1d0381a3..e82c7fd8a 100644 --- a/__tests__/restAgent.test.ts +++ b/__tests__/restAgent.test.ts @@ -3,7 +3,7 @@ import { Agent, IAgent, createAgent, - IIdentityManager, + IDIDManager, IResolver, IKeyManager, IDataStore, @@ -12,13 +12,13 @@ import { } from '../packages/daf-core/src' import { MessageHandler } from '../packages/daf-message-handler/src' import { KeyManager } from '../packages/daf-key-manager/src' -import { IdentityManager } from '../packages/daf-identity-manager/src' +import { DIDManager } from '../packages/daf-identity-manager/src' import { createConnection, Connection } from 'typeorm' import { DafResolver } from '../packages/daf-resolver/src' import { JwtMessageHandler } from '../packages/daf-did-jwt/src' import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from '../packages/daf-w3c/src' -import { EthrIdentityProvider } from '../packages/daf-ethr-did/src' -import { WebIdentityProvider } from '../packages/daf-web-did/src' +import { EthrDIDProvider } from '../packages/daf-ethr-did/src' +import { WebDIDProvider } from '../packages/daf-web-did/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/daf-did-comm/src' import { SelectiveDisclosure, @@ -29,7 +29,7 @@ import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium/src' import { Entities, KeyStore, - IdentityStore, + DIDStore, IDataStoreORM, DataStore, DataStoreORM, @@ -52,7 +52,7 @@ import resolveDid from './shared/resolveDid' import webDidFlow from './shared/webDidFlow' import documentationExamples from './shared/documentationExamples' import keyManager from './shared/keyManager' -import identityManager from './shared/identityManager' +import didManager from './shared/didManager' import messageHandler from './shared/messageHandler' const databaseFile = 'rest-database.sqlite' @@ -67,7 +67,7 @@ let restServer: Server const getAgent = (options?: IAgentOptions) => createAgent< - IIdentityManager & + IDIDManager & IKeyManager & IDataStore & IDataStoreORM & @@ -81,7 +81,7 @@ const getAgent = (options?: IAgentOptions) => plugins: [ new AgentRestClient({ url: 'http://localhost:' + port + basePath, - enabledMethods: Object.keys(serverAgent.getSchema().components.methods), + enabledMethods: serverAgent.availableMethods(), schema: serverAgent.getSchema(), }), ], @@ -105,30 +105,30 @@ const setup = async (options?: IAgentOptions): Promise => { local: new KeyManagementSystem(), }, }), - new IdentityManager({ - store: new IdentityStore(dbConnection), + new DIDManager({ + store: new DIDStore(dbConnection), defaultProvider: 'did:ethr:rinkeby', providers: { - 'did:ethr': new EthrIdentityProvider({ + 'did:ethr': new EthrDIDProvider({ defaultKms: 'local', network: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId, gas: 1000001, ttl: 60 * 60 * 24 * 30 * 12 + 1, }), - 'did:ethr:rinkeby': new EthrIdentityProvider({ + 'did:ethr:rinkeby': new EthrDIDProvider({ defaultKms: 'local', network: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId, gas: 1000001, ttl: 60 * 60 * 24 * 30 * 12 + 1, }), - 'did:web': new WebIdentityProvider({ + 'did:web': new WebDIDProvider({ defaultKms: 'local', }), }, }), - new DafResolver({ + new DafResolver({ resolver: new Resolver({ ethr: ethrDidResolver({ networks: [ @@ -137,10 +137,10 @@ const setup = async (options?: IAgentOptions): Promise => { { name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/' + infuraProjectId }, { name: 'kovan', rpcUrl: 'https://kovan.infura.io/v3/' + infuraProjectId }, { name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/' + infuraProjectId }, - ] + ], }).ethr, - web: webDidResolver().web - }) + web: webDidResolver().web, + }), }), new DataStore(dbConnection), new DataStoreORM(dbConnection), @@ -188,6 +188,6 @@ describe('REST integration tests', () => { webDidFlow(testContext) documentationExamples(testContext) keyManager(testContext) - identityManager(testContext) + didManager(testContext) messageHandler(testContext) }) diff --git a/__tests__/shared/didManager.ts b/__tests__/shared/didManager.ts new file mode 100644 index 000000000..f198ce4e7 --- /dev/null +++ b/__tests__/shared/didManager.ts @@ -0,0 +1,313 @@ +import { TAgent, IDIDManager, IKeyManager, IIdentifier } from '../../packages/daf-core/src' + +type ConfiguredAgent = TAgent + +export default (testContext: { + getAgent: () => ConfiguredAgent + setup: () => Promise + tearDown: () => Promise +}) => { + describe('DID manager', () => { + let agent: ConfiguredAgent + + beforeAll(async () => { + await testContext.setup() + agent = testContext.getAgent() + return true + }) + afterAll(testContext.tearDown) + + it('should get providers', async () => { + const providers = await agent.didManagerGetProviders() + expect(providers).toEqual(['did:ethr', 'did:ethr:rinkeby', 'did:web']) + }) + + let identifier: IIdentifier + it('should create identifier', async () => { + identifier = await agent.didManagerCreate({ + provider: 'did:web', + alias: 'example.com', + }) + expect(identifier.provider).toEqual('did:web') + expect(identifier.alias).toEqual('example.com') + expect(identifier.did).toEqual('did:web:example.com') + expect(identifier.keys.length).toEqual(1) + expect(identifier.services.length).toEqual(0) + expect(identifier.controllerKeyId).toEqual(identifier.keys[0].kid) + }) + + it('should throw error for existing alias provider combo', async () => { + await expect( + agent.didManagerCreate({ + provider: 'did:web', + alias: 'example.com', + }), + ).rejects.toThrow('Identifier with alias: example.com, provider: did:web already exists') + }) + + it('should get identifier', async () => { + const identifier2 = await agent.didManagerGet({ + did: identifier.did, + }) + expect(identifier2.did).toEqual(identifier.did) + }) + + it('should throw error for non existing did', async () => { + await expect( + agent.didManagerGet({ + did: 'did:web:foobar', + }), + ).rejects.toThrow('Identifier not found') + }) + + it('should get or create identifier', async () => { + const identifier3 = await agent.didManagerGetOrCreate({ + alias: 'alice', + provider: 'did:ethr:rinkeby', + }) + + const identifier4 = await agent.didManagerGetOrCreate({ + alias: 'alice', + provider: 'did:ethr:rinkeby', + }) + + expect(identifier3).toEqual(identifier4) + + const identifier5 = await agent.didManagerGetOrCreate({ + alias: 'alice', + provider: 'did:ethr', + }) + + expect(identifier5).not.toEqual(identifier4) + + const identifier6 = await agent.didManagerGetByAlias({ + alias: 'alice', + provider: 'did:ethr', + }) + + expect(identifier6).toEqual(identifier5) + + const identifier7 = await agent.didManagerGetByAlias({ + alias: 'alice', + // default provider is 'did:ethr:rinkeby' + }) + + expect(identifier7).toEqual(identifier4) + }) + + it('should get identifiers', async () => { + const allIdentifiers = await agent.didManagerFind() + expect(allIdentifiers.length).toEqual(3) + + const aliceIdentifiers = await agent.didManagerFind({ + alias: 'alice', + }) + expect(aliceIdentifiers.length).toEqual(2) + + const rinkebyIdentifiers = await agent.didManagerFind({ + provider: 'did:ethr:rinkeby', + }) + expect(rinkebyIdentifiers.length).toEqual(1) + + // Default provider 'did:ethr:rinkeby' + await agent.didManagerCreate() + + const rinkebyIdentifiers2 = await agent.didManagerFind({ + provider: 'did:ethr:rinkeby', + }) + expect(rinkebyIdentifiers2.length).toEqual(2) + }) + + it('should delete identifier', async () => { + const allIdentifiers = await agent.didManagerFind() + const count = allIdentifiers.length + + const result = await agent.didManagerDelete({ + did: allIdentifiers[0].did, + }) + + expect(result).toEqual(true) + + const allIdentifiers2 = await agent.didManagerFind() + expect(allIdentifiers2.length).toEqual(count - 1) + + await expect( + agent.didManagerGet({ + did: allIdentifiers[0].did, + }), + ).rejects.toThrow('Identifier not found') + }) + + it('should add service to identifier', async () => { + const webIdentifier = await agent.didManagerGetOrCreate({ + alias: 'foobar.com', + provider: 'did:web', + }) + + expect(webIdentifier.services.length).toEqual(0) + + const result = await agent.didManagerAddService({ + did: webIdentifier.did, + service: { + id: 'did:web:foobar.com#msg', + type: 'Messaging', + serviceEndpoint: 'https://foobar.com/messaging', + description: 'Handles incoming messages', + }, + }) + expect(result).toEqual({ success: true }) + + const webIdentifier2 = await agent.didManagerGetOrCreate({ + alias: 'foobar.com', + provider: 'did:web', + }) + + expect(webIdentifier2.services.length).toEqual(1) + expect(webIdentifier2.services[0]).toEqual({ + id: 'did:web:foobar.com#msg', + type: 'Messaging', + serviceEndpoint: 'https://foobar.com/messaging', + description: 'Handles incoming messages', + }) + }) + + it('should remove service from identifier', async () => { + const result = await agent.didManagerRemoveService({ + did: 'did:web:foobar.com', + id: 'did:web:foobar.com#msg', + }) + + expect(result).toEqual({ success: true }) + + const webIdentifier = await agent.didManagerGetOrCreate({ + alias: 'foobar.com', + provider: 'did:web', + }) + + expect(webIdentifier.services.length).toEqual(0) + }) + + it('should add key to identifier', async () => { + const webIdentifier = await agent.didManagerGetOrCreate({ + alias: 'foobar.com', + provider: 'did:web', + }) + + expect(webIdentifier.keys.length).toEqual(1) + + const newKey = await agent.keyManagerCreate({ + kms: 'local', + type: 'Secp256k1', + }) + + const result = await agent.didManagerAddKey({ + did: webIdentifier.did, + key: newKey, + }) + + expect(result).toEqual({ success: true }) + + const webIdentifier2 = await agent.didManagerGetOrCreate({ + alias: 'foobar.com', + provider: 'did:web', + }) + + expect(webIdentifier2.keys.length).toEqual(2) + }) + + it('should remove key from identifier', async () => { + const webIdentifier = await agent.didManagerGet({ + did: 'did:web:foobar.com', + }) + + expect(webIdentifier.keys.length).toEqual(2) + + const result = await agent.didManagerRemoveKey({ + did: 'did:web:foobar.com', + kid: webIdentifier.keys[1].kid, + }) + + expect(result).toEqual({ success: true }) + + const webIdentifier2 = await agent.didManagerGet({ + did: 'did:web:foobar.com', + }) + + expect(webIdentifier2.keys.length).toEqual(1) + expect(webIdentifier2.keys[0].kid).toEqual(webIdentifier.keys[0].kid) + }) + + it('should import identifier', async () => { + const identifier = await agent.didManagerGetOrCreate({ + alias: 'example.org', + provider: 'did:web', + }) + + await agent.didManagerAddService({ + did: identifier.did, + service: { + id: 'did:web:example.org#msg', + type: 'Messaging', + serviceEndpoint: 'https://example.org/messaging', + description: 'Handles incoming messages', + }, + }) + + const signingKeyFull = await agent.keyManagerGet({ + kid: identifier.keys[0].kid, + }) + + const encryptionKey = await agent.keyManagerCreate({ + kms: 'local', + type: 'Ed25519', + }) + + const encryptionKeyFull = await agent.keyManagerGet({ + kid: encryptionKey.kid, + }) + + await agent.didManagerAddKey({ + did: identifier.did, + key: encryptionKey, + }) + + const exportedIdentifier = await agent.didManagerGet({ + did: identifier.did, + }) + + await agent.didManagerDelete({ + did: identifier.did, + }) + + await agent.didManagerImport({ + ...exportedIdentifier, + keys: [signingKeyFull, encryptionKeyFull], + }) + + const importedIdentifier = await agent.didManagerGet({ + did: identifier.did, + }) + expect(importedIdentifier).toEqual(exportedIdentifier) + }) + + it('should set alias for identifier', async () => { + const identifier = await agent.didManagerCreate() + const result = await agent.didManagerSetAlias({ + did: identifier.did, + alias: 'carol', + }) + expect(result).toEqual(true) + + const identifier2 = await agent.didManagerGetByAlias({ + alias: 'carol', + }) + + expect(identifier2).toEqual({ ...identifier, alias: 'carol' }) + }) + + it.todo('should add key for did:ethr') + it.todo('should remove key for did:ethr') + it.todo('should add service for did:ethr') + it.todo('should remove service for did:ethr') + }) +} diff --git a/__tests__/shared/documentationExamples.ts b/__tests__/shared/documentationExamples.ts index e6d0f9204..12454b55f 100644 --- a/__tests__/shared/documentationExamples.ts +++ b/__tests__/shared/documentationExamples.ts @@ -1,10 +1,10 @@ -import { TAgent, IIdentityManager, IDataStore, IMessageHandler } from '../../packages/daf-core/src' +import { TAgent, IDIDManager, IDataStore, IMessageHandler } from '../../packages/daf-core/src' import { ICredentialIssuer } from '../../packages/daf-w3c/src' import { ISelectiveDisclosure } from '../../packages/daf-selective-disclosure/src' import { IDataStoreORM } from '../../packages/daf-typeorm/src' type ConfiguredAgent = TAgent< - IIdentityManager & ICredentialIssuer & IDataStoreORM & IDataStore & IMessageHandler & ISelectiveDisclosure + IDIDManager & ICredentialIssuer & IDataStoreORM & IDataStore & IMessageHandler & ISelectiveDisclosure > export default (testContext: { @@ -48,35 +48,35 @@ export default (testContext: { }) }) - it('daf-core-IIdentityManager-identityManagerCreateIdentity example', async () => { - const identity = await agent.identityManagerCreateIdentity({ + it('daf-core-IDIDManager-didManagerCreate example', async () => { + const identifier = await agent.didManagerCreate({ alias: 'alice', provider: 'did:ethr:rinkeby', kms: 'local', }) }) - it('daf-core-IIdentityManager-identityManagerGetIdentities example', async () => { - const aliceIdentities = await agent.identityManagerGetIdentities({ + it('daf-core-IDIDManager-didManagerFind example', async () => { + const aliceIdentifiers = await agent.didManagerFind({ alias: 'alice', }) - const rinkebyIdentities = await agent.identityManagerGetIdentities({ + const rinkebyIdentifiers = await agent.didManagerFind({ provider: 'did:ethr:rinkeby', }) }) - it('daf-core-IIdentityManager-identityManagerGetIdentityByAlias example', async () => { - const identity = await agent.identityManagerGetIdentityByAlias({ + it('daf-core-IDIDManager-didManagerGetByAlias example', async () => { + const identifier = await agent.didManagerGetByAlias({ alias: 'alice', provider: 'did:ethr:rinkeby', }) }) - it('daf-core-IIdentityManager-identityManagerSetAlias example', async () => { - const identity = await agent.identityManagerCreateIdentity() - const result = await agent.identityManagerSetAlias({ - did: identity.did, + it('daf-core-IDIDManager-didManagerSetAlias example', async () => { + const identifier = await agent.didManagerCreate() + const result = await agent.didManagerSetAlias({ + did: identifier.did, alias: 'carol', }) }) diff --git a/__tests__/shared/handleSdrMessage.ts b/__tests__/shared/handleSdrMessage.ts index d08375e74..d0668edd3 100644 --- a/__tests__/shared/handleSdrMessage.ts +++ b/__tests__/shared/handleSdrMessage.ts @@ -1,10 +1,10 @@ -import { TAgent, IIdentityManager, IIdentity, IDataStore, IMessageHandler } from '../../packages/daf-core/src' +import { TAgent, IDIDManager, IIdentifier, IDataStore, IMessageHandler } from '../../packages/daf-core/src' import { ICredentialIssuer } from '../../packages/daf-w3c/src' import { ISelectiveDisclosure, SelectiveDisclosure } from '../../packages/daf-selective-disclosure/src' import { IDataStoreORM } from '../../packages/daf-typeorm/src' type ConfiguredAgent = TAgent< - IIdentityManager & ICredentialIssuer & IDataStoreORM & IDataStore & IMessageHandler & ISelectiveDisclosure + IDIDManager & ICredentialIssuer & IDataStoreORM & IDataStore & IMessageHandler & ISelectiveDisclosure > export default (testContext: { @@ -14,7 +14,7 @@ export default (testContext: { }) => { describe('handling sdr message', () => { let agent: ConfiguredAgent - let identity: IIdentity + let identifier: IIdentifier let JWT: string let originalRequestSender: string let sdr: SelectiveDisclosure @@ -25,15 +25,15 @@ export default (testContext: { }) afterAll(testContext.tearDown) - it('should create identity', async () => { - identity = await agent.identityManagerCreateIdentity({ kms: 'local' }) - expect(identity).toHaveProperty('did') + it('should create identifier', async () => { + identifier = await agent.didManagerCreate({ kms: 'local' }) + expect(identifier).toHaveProperty('did') }) it('should create verifiable credential', async () => { const verifiableCredential = await agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential'], issuanceDate: new Date().toISOString(), @@ -51,14 +51,16 @@ export default (testContext: { it('should save an SDR message', async () => { JWT = await agent.createSelectiveDisclosureRequest({ data: { - issuer: identity.did, + issuer: identifier.did, tag: 'sdr-one', - claims: [{ - reason: 'We need it', - claimType: 'name', - essential: true - }] - } + claims: [ + { + reason: 'We need it', + claimType: 'name', + essential: true, + }, + ], + }, }) const message = await agent.handleMessage({ @@ -80,14 +82,14 @@ export default (testContext: { }) it('should be able to sign a credential after saving a message', async () => { - const identities = await agent.identityManagerGetIdentities() - const identity = identities[0] + const identifiers = await agent.didManagerFind() + const identifier = identifiers[0] - expect(identities[0].did).toBeDefined() + expect(identifiers[0].did).toBeDefined() const verifiableCredential = await agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential'], issuanceDate: new Date().toISOString(), @@ -132,7 +134,7 @@ export default (testContext: { const verifiablePresentation = await agent.createVerifiablePresentation({ presentation: { verifier: [originalRequestSender], - holder: identity.did, + holder: identifier.did, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiablePresentation'], issuanceDate: new Date().toISOString(), @@ -144,7 +146,6 @@ export default (testContext: { expect(verifiablePresentation).toHaveProperty('proof.jwt') - const validated = await agent.validatePresentationAgainstSdr({ presentation: verifiablePresentation, sdr: { diff --git a/__tests__/shared/identityManager.ts b/__tests__/shared/identityManager.ts deleted file mode 100644 index 23be163b1..000000000 --- a/__tests__/shared/identityManager.ts +++ /dev/null @@ -1,313 +0,0 @@ -import { TAgent, IIdentityManager, IKeyManager, IIdentity } from '../../packages/daf-core/src' - -type ConfiguredAgent = TAgent - -export default (testContext: { - getAgent: () => ConfiguredAgent - setup: () => Promise - tearDown: () => Promise -}) => { - describe('identity manager', () => { - let agent: ConfiguredAgent - - beforeAll(async () => { - await testContext.setup() - agent = testContext.getAgent() - return true - }) - afterAll(testContext.tearDown) - - it('should get providers', async () => { - const providers = await agent.identityManagerGetProviders() - expect(providers).toEqual(['did:ethr', 'did:ethr:rinkeby', 'did:web']) - }) - - let identity: IIdentity - it('should create identity', async () => { - identity = await agent.identityManagerCreateIdentity({ - provider: 'did:web', - alias: 'example.com', - }) - expect(identity.provider).toEqual('did:web') - expect(identity.alias).toEqual('example.com') - expect(identity.did).toEqual('did:web:example.com') - expect(identity.keys.length).toEqual(1) - expect(identity.services.length).toEqual(0) - expect(identity.controllerKeyId).toEqual(identity.keys[0].kid) - }) - - it('should throw error for existing alias provider combo', async () => { - await expect( - agent.identityManagerCreateIdentity({ - provider: 'did:web', - alias: 'example.com', - }), - ).rejects.toThrow('Identity with alias: example.com, provider: did:web already exists') - }) - - it('should get identity', async () => { - const identity2 = await agent.identityManagerGetIdentity({ - did: identity.did, - }) - expect(identity2.did).toEqual(identity.did) - }) - - it('should throw error for non existing did', async () => { - await expect( - agent.identityManagerGetIdentity({ - did: 'did:web:foobar', - }), - ).rejects.toThrow('Identity not found') - }) - - it('should get or create identity', async () => { - const identity3 = await agent.identityManagerGetOrCreateIdentity({ - alias: 'alice', - provider: 'did:ethr:rinkeby', - }) - - const identity4 = await agent.identityManagerGetOrCreateIdentity({ - alias: 'alice', - provider: 'did:ethr:rinkeby', - }) - - expect(identity3).toEqual(identity4) - - const identity5 = await agent.identityManagerGetOrCreateIdentity({ - alias: 'alice', - provider: 'did:ethr', - }) - - expect(identity5).not.toEqual(identity4) - - const identity6 = await agent.identityManagerGetIdentityByAlias({ - alias: 'alice', - provider: 'did:ethr', - }) - - expect(identity6).toEqual(identity5) - - const identity7 = await agent.identityManagerGetIdentityByAlias({ - alias: 'alice', - // default provider is 'did:ethr:rinkeby' - }) - - expect(identity7).toEqual(identity4) - }) - - it('should get identities', async () => { - const allIdentities = await agent.identityManagerGetIdentities() - expect(allIdentities.length).toEqual(3) - - const aliceIdentities = await agent.identityManagerGetIdentities({ - alias: 'alice', - }) - expect(aliceIdentities.length).toEqual(2) - - const rinkebyIdentities = await agent.identityManagerGetIdentities({ - provider: 'did:ethr:rinkeby', - }) - expect(rinkebyIdentities.length).toEqual(1) - - // Default provider 'did:ethr:rinkeby' - await agent.identityManagerCreateIdentity() - - const rinkebyIdentities2 = await agent.identityManagerGetIdentities({ - provider: 'did:ethr:rinkeby', - }) - expect(rinkebyIdentities2.length).toEqual(2) - }) - - it('should delete identity', async () => { - const allIdentities = await agent.identityManagerGetIdentities() - const count = allIdentities.length - - const result = await agent.identityManagerDeleteIdentity({ - did: allIdentities[0].did, - }) - - expect(result).toEqual(true) - - const allIdentities2 = await agent.identityManagerGetIdentities() - expect(allIdentities2.length).toEqual(count - 1) - - await expect( - agent.identityManagerGetIdentity({ - did: allIdentities[0].did, - }), - ).rejects.toThrow('Identity not found') - }) - - it('should add service to identity', async () => { - const webIdentity = await agent.identityManagerGetOrCreateIdentity({ - alias: 'foobar.com', - provider: 'did:web', - }) - - expect(webIdentity.services.length).toEqual(0) - - const result = await agent.identityManagerAddService({ - did: webIdentity.did, - service: { - id: 'did:web:foobar.com#msg', - type: 'Messaging', - serviceEndpoint: 'https://foobar.com/messaging', - description: 'Handles incoming messages', - }, - }) - expect(result).toEqual({success: true}) - - const webIdentity2 = await agent.identityManagerGetOrCreateIdentity({ - alias: 'foobar.com', - provider: 'did:web', - }) - - expect(webIdentity2.services.length).toEqual(1) - expect(webIdentity2.services[0]).toEqual({ - id: 'did:web:foobar.com#msg', - type: 'Messaging', - serviceEndpoint: 'https://foobar.com/messaging', - description: 'Handles incoming messages', - }) - }) - - it('should remove service from identity', async () => { - const result = await agent.identityManagerRemoveService({ - did: 'did:web:foobar.com', - id: 'did:web:foobar.com#msg', - }) - - expect(result).toEqual({success: true}) - - const webIdentity = await agent.identityManagerGetOrCreateIdentity({ - alias: 'foobar.com', - provider: 'did:web', - }) - - expect(webIdentity.services.length).toEqual(0) - }) - - it('should add key to identity', async () => { - const webIdentity = await agent.identityManagerGetOrCreateIdentity({ - alias: 'foobar.com', - provider: 'did:web', - }) - - expect(webIdentity.keys.length).toEqual(1) - - const newKey = await agent.keyManagerCreateKey({ - kms: 'local', - type: 'Secp256k1', - }) - - const result = await agent.identityManagerAddKey({ - did: webIdentity.did, - key: newKey, - }) - - expect(result).toEqual({success: true}) - - const webIdentity2 = await agent.identityManagerGetOrCreateIdentity({ - alias: 'foobar.com', - provider: 'did:web', - }) - - expect(webIdentity2.keys.length).toEqual(2) - }) - - it('should remove key from identity', async () => { - const webIdentity = await agent.identityManagerGetIdentity({ - did: 'did:web:foobar.com', - }) - - expect(webIdentity.keys.length).toEqual(2) - - const result = await agent.identityManagerRemoveKey({ - did: 'did:web:foobar.com', - kid: webIdentity.keys[1].kid, - }) - - expect(result).toEqual({success: true}) - - const webIdentity2 = await agent.identityManagerGetIdentity({ - did: 'did:web:foobar.com', - }) - - expect(webIdentity2.keys.length).toEqual(1) - expect(webIdentity2.keys[0].kid).toEqual(webIdentity.keys[0].kid) - }) - - it('should import identity', async () => { - const identity = await agent.identityManagerGetOrCreateIdentity({ - alias: 'example.org', - provider: 'did:web', - }) - - await agent.identityManagerAddService({ - did: identity.did, - service: { - id: 'did:web:example.org#msg', - type: 'Messaging', - serviceEndpoint: 'https://example.org/messaging', - description: 'Handles incoming messages', - }, - }) - - const signingKeyFull = await agent.keyManagerGetKey({ - kid: identity.keys[0].kid, - }) - - const encryptionKey = await agent.keyManagerCreateKey({ - kms: 'local', - type: 'Ed25519', - }) - - const encryptionKeyFull = await agent.keyManagerGetKey({ - kid: encryptionKey.kid, - }) - - await agent.identityManagerAddKey({ - did: identity.did, - key: encryptionKey, - }) - - const exportedIdentity = await agent.identityManagerGetIdentity({ - did: identity.did, - }) - - await agent.identityManagerDeleteIdentity({ - did: identity.did, - }) - - await agent.identityManagerImportIdentity({ - ...exportedIdentity, - keys: [signingKeyFull, encryptionKeyFull], - }) - - const importedIdentity = await agent.identityManagerGetIdentity({ - did: identity.did, - }) - expect(importedIdentity).toEqual(exportedIdentity) - }) - - it('should set alias for identity', async () => { - const identity = await agent.identityManagerCreateIdentity() - const result = await agent.identityManagerSetAlias({ - did: identity.did, - alias: 'carol', - }) - expect(result).toEqual(true) - - const identity2 = await agent.identityManagerGetIdentityByAlias({ - alias: 'carol', - }) - - expect(identity2).toEqual({ ...identity, alias: 'carol' }) - }) - - it.todo('should add key for did:ethr') - it.todo('should remove key for did:ethr') - it.todo('should add service for did:ethr') - it.todo('should remove service for did:ethr') - }) -} diff --git a/__tests__/shared/keyManager.ts b/__tests__/shared/keyManager.ts index 54c39eedc..3f1524510 100644 --- a/__tests__/shared/keyManager.ts +++ b/__tests__/shared/keyManager.ts @@ -1,6 +1,6 @@ -import { TAgent, IIdentityManager, IKeyManager, IAgentOptions } from '../../packages/daf-core/src' +import { TAgent, IDIDManager, IKeyManager, IAgentOptions } from '../../packages/daf-core/src' -type ConfiguredAgent = TAgent +type ConfiguredAgent = TAgent export default (testContext: { getAgent: () => ConfiguredAgent @@ -23,7 +23,7 @@ export default (testContext: { }) it('should create Secp256k1 key', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Secp256k1', }) @@ -36,7 +36,7 @@ export default (testContext: { }) it('should create Ed25519 key', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Ed25519', }) @@ -50,7 +50,7 @@ export default (testContext: { it('should throw an error for unsupported kms', async () => { await expect( - agent.keyManagerCreateKey({ + agent.keyManagerCreate({ kms: 'foobar', type: 'Secp256k1', }), @@ -59,7 +59,7 @@ export default (testContext: { it('should throw an error for unsupported key type', async () => { await expect( - agent.keyManagerCreateKey({ + agent.keyManagerCreate({ kms: 'local', //@ts-ignore type: 'foobar', @@ -68,7 +68,7 @@ export default (testContext: { }) it('should create key with meta data', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Secp256k1', meta: { @@ -89,12 +89,12 @@ export default (testContext: { }) it('should get key by key id', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Secp256k1', }) - const key2 = await agent.keyManagerGetKey({ + const key2 = await agent.keyManagerGet({ kid: key.kid, }) @@ -103,32 +103,32 @@ export default (testContext: { }) it('should delete key', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Secp256k1', }) - const result = await agent.keyManagerDeleteKey({ + const result = await agent.keyManagerDelete({ kid: key.kid, }) expect(result).toEqual(true) await expect( - agent.keyManagerGetKey({ + agent.keyManagerGet({ kid: key.kid, }), ).rejects.toThrow('Key not found') await expect( - agent.keyManagerDeleteKey({ + agent.keyManagerDelete({ kid: key.kid, }), ).rejects.toThrow('Key not found') }) it('should import key', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Secp256k1', meta: { @@ -136,18 +136,18 @@ export default (testContext: { }, }) - const fullKey = await agent.keyManagerGetKey({ + const fullKey = await agent.keyManagerGet({ kid: key.kid, }) - await agent.keyManagerDeleteKey({ + await agent.keyManagerDelete({ kid: key.kid, }) - const result = await agent.keyManagerImportKey(fullKey) + const result = await agent.keyManagerImport(fullKey) expect(result).toEqual(true) - const key2 = await agent.keyManagerGetKey({ + const key2 = await agent.keyManagerGet({ kid: key.kid, }) @@ -155,7 +155,7 @@ export default (testContext: { }) it('should sign JWT', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Secp256k1', }) @@ -171,7 +171,7 @@ export default (testContext: { }) it('should sign EthTX', async () => { - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: 'local', type: 'Secp256k1', }) @@ -194,12 +194,12 @@ export default (testContext: { // it('Should Encrypt/Decrypt', async () => { // const message = 'foo bar' - // const senderKey = await agent.keyManagerCreateKey({ + // const senderKey = await agent.keyManagerCreate({ // kms: 'local', // type: 'Ed25519', // }) - // const recipientKey = await agent.keyManagerCreateKey({ + // const recipientKey = await agent.keyManagerCreate({ // kms: 'local', // type: 'Ed25519', // }) diff --git a/__tests__/shared/saveClaims.ts b/__tests__/shared/saveClaims.ts index d10ec0425..dc86c61bb 100644 --- a/__tests__/shared/saveClaims.ts +++ b/__tests__/shared/saveClaims.ts @@ -1,10 +1,10 @@ -import { TAgent, IIdentityManager, IIdentity, IDataStore, IMessageHandler } from '../../packages/daf-core/src' +import { TAgent, IDIDManager, IIdentifier, IDataStore, IMessageHandler } from '../../packages/daf-core/src' import { ICredentialIssuer } from '../../packages/daf-w3c/src' import { ISelectiveDisclosure } from '../../packages/daf-selective-disclosure/src' import { IDataStoreORM } from '../../packages/daf-typeorm/src' type ConfiguredAgent = TAgent< - IIdentityManager & ICredentialIssuer & IDataStoreORM & IDataStore & IMessageHandler & ISelectiveDisclosure + IDIDManager & ICredentialIssuer & IDataStoreORM & IDataStore & IMessageHandler & ISelectiveDisclosure > export default (testContext: { @@ -14,7 +14,7 @@ export default (testContext: { }) => { describe('Save credentials and query by claim type', () => { let agent: ConfiguredAgent - let identity: IIdentity + let identifier: IIdentifier beforeAll(() => { testContext.setup() @@ -22,9 +22,9 @@ export default (testContext: { }) afterAll(testContext.tearDown) - it('should create identity', async () => { - identity = await agent.identityManagerCreateIdentity({ kms: 'local' }) - expect(identity).toHaveProperty('did') + it('should create identifier', async () => { + identifier = await agent.didManagerCreate({ kms: 'local' }) + expect(identifier).toHaveProperty('did') }) it('should create verifiable credentials', async () => { @@ -32,12 +32,12 @@ export default (testContext: { await agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential'], issuanceDate: new Date().toISOString(), credentialSubject: { - id: identity.did, + id: identifier.did, topic: 'math', }, }, @@ -47,12 +47,12 @@ export default (testContext: { await agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential'], issuanceDate: new Date().toISOString(), credentialSubject: { - id: identity.did, + id: identifier.did, topic: 'science', }, }, @@ -62,12 +62,12 @@ export default (testContext: { await agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential'], issuanceDate: new Date().toISOString(), credentialSubject: { - id: identity.did, + id: identifier.did, topic: 'art', }, }, diff --git a/__tests__/shared/verifiableData.ts b/__tests__/shared/verifiableData.ts index 71e801924..a18d16f34 100644 --- a/__tests__/shared/verifiableData.ts +++ b/__tests__/shared/verifiableData.ts @@ -1,8 +1,8 @@ -import { TAgent, IIdentityManager, IIdentity, IDataStore } from '../../packages/daf-core/src' +import { TAgent, IDIDManager, IIdentifier, IDataStore } from '../../packages/daf-core/src' import { IDataStoreORM } from '../../packages/daf-typeorm/src' import { ICredentialIssuer } from '../../packages/daf-w3c/src' -type ConfiguredAgent = TAgent +type ConfiguredAgent = TAgent export default (testContext: { getAgent: () => ConfiguredAgent @@ -11,7 +11,7 @@ export default (testContext: { }) => { describe('creating Verifiable Credentials', () => { let agent: ConfiguredAgent - let identity: IIdentity + let identifier: IIdentifier beforeAll(() => { testContext.setup() @@ -19,15 +19,15 @@ export default (testContext: { }) afterAll(testContext.tearDown) - it('should create identity', async () => { - identity = await agent.identityManagerCreateIdentity({ kms: 'local' }) - expect(identity).toHaveProperty('did') + it('should create identifier', async () => { + identifier = await agent.didManagerCreate({ kms: 'local' }) + expect(identifier).toHaveProperty('did') }) it('should create verifiable credential', async () => { const verifiableCredential = await agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential'], issuanceDate: new Date().toISOString(), @@ -51,7 +51,7 @@ export default (testContext: { it('should create verifiable presentation', async () => { const verifiableCredential = await agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential'], issuanceDate: new Date().toISOString(), @@ -65,7 +65,7 @@ export default (testContext: { const verifiablePresentation = await agent.createVerifiablePresentation({ presentation: { - holder: identity.did, + holder: identifier.did, verifier: [], '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiablePresentation'], @@ -115,6 +115,5 @@ export default (testContext: { }), ).rejects.toThrow('Verifiable presentation not found') }) - }) } diff --git a/__tests__/shared/webDidFlow.ts b/__tests__/shared/webDidFlow.ts index cfdbb807e..0b999a018 100644 --- a/__tests__/shared/webDidFlow.ts +++ b/__tests__/shared/webDidFlow.ts @@ -1,7 +1,7 @@ -import { TAgent, IIdentityManager, IIdentity, IKey } from '../../packages/daf-core/src' +import { TAgent, IDIDManager, IIdentifier, IKey } from '../../packages/daf-core/src' import { ICredentialIssuer } from '../../packages/daf-w3c/src' -type ConfiguredAgent = TAgent +type ConfiguredAgent = TAgent export default (testContext: { getAgent: () => ConfiguredAgent @@ -10,10 +10,10 @@ export default (testContext: { }) => { describe('web did flow', () => { let agent: ConfiguredAgent - let serviceIdentity: IIdentity - let serviceIdentityKey: IKey - let alice: IIdentity - let bob: IIdentity + let serviceIdentifier: IIdentifier + let serviceIdentifierKey: IKey + let alice: IIdentifier + let bob: IIdentifier beforeAll(() => { testContext.setup() @@ -21,16 +21,16 @@ export default (testContext: { }) afterAll(testContext.tearDown) - it('should create service identity', async () => { - serviceIdentity = await agent.identityManagerGetOrCreateIdentity({ + it('should create service identifier', async () => { + serviceIdentifier = await agent.didManagerGetOrCreate({ provider: 'did:web', alias: 'example.com', }) - expect(serviceIdentity.provider).toEqual('did:web') - expect(serviceIdentity.alias).toEqual('example.com') - expect(serviceIdentity.did).toEqual('did:web:example.com') - serviceIdentityKey = serviceIdentity.keys[0] + expect(serviceIdentifier.provider).toEqual('did:web') + expect(serviceIdentifier.alias).toEqual('example.com') + expect(serviceIdentifier.did).toEqual('did:web:example.com') + serviceIdentifierKey = serviceIdentifier.keys[0] }) it('should add service endpoint', async () => { @@ -41,29 +41,29 @@ export default (testContext: { serviceEndpoint: 'https://example.com/messaging', } - await agent.identityManagerAddService({ + await agent.didManagerAddService({ did: 'did:web:example.com', service, }) - const testIdentity = await agent.identityManagerGetIdentity({ did: 'did:web:example.com' }) - expect(testIdentity.services[0]).toEqual(service) + const testIdentifier = await agent.didManagerGet({ did: 'did:web:example.com' }) + expect(testIdentifier.services[0]).toEqual(service) }) - it('should get existing service identity', async () => { - const testIdentity = await agent.identityManagerGetOrCreateIdentity({ + it('should get existing service identifier', async () => { + const testIdentifier = await agent.didManagerGetOrCreate({ provider: 'did:web', alias: 'example.com', }) - expect(testIdentity.keys[0]).toEqual(serviceIdentityKey) - expect(testIdentity.provider).toEqual('did:web') - expect(testIdentity.alias).toEqual('example.com') - expect(testIdentity.did).toEqual('did:web:example.com') + expect(testIdentifier.keys[0]).toEqual(serviceIdentifierKey) + expect(testIdentifier.provider).toEqual('did:web') + expect(testIdentifier.alias).toEqual('example.com') + expect(testIdentifier.did).toEqual('did:web:example.com') }) - it('should create identity with alias: alice', async () => { - alice = await agent.identityManagerGetOrCreateIdentity({ + it('should create identifier with alias: alice', async () => { + alice = await agent.didManagerGetOrCreate({ alias: 'alice', }) @@ -72,8 +72,8 @@ export default (testContext: { expect(alice.did).toBeDefined() }) - it('should create identity with alias: bob', async () => { - bob = await agent.identityManagerGetOrCreateIdentity({ + it('should create identifier with alias: bob', async () => { + bob = await agent.didManagerGetOrCreate({ alias: 'bob', }) @@ -82,19 +82,19 @@ export default (testContext: { expect(bob.did).toBeDefined() }) - it('should query identities', async () => { - const identities = await agent.dataStoreORMGetIdentities() - expect(identities.length).toEqual(3) - const count = await agent.dataStoreORMGetIdentitiesCount() + it('should query identifiers', async () => { + const identifiers = await agent.dataStoreORMGetIdentifiers() + expect(identifiers.length).toEqual(3) + const count = await agent.dataStoreORMGetIdentifiersCount() expect(count).toEqual(3) }) describe('should create verifiable credential', () => { - it('issuer: serviceIdentity', async () => { + it('issuer: serviceIdentifier', async () => { const verifiableCredential = await agent.createVerifiableCredential({ save: true, credential: { - issuer: { id: serviceIdentity.did }, + issuer: { id: serviceIdentifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential', 'Profile'], issuanceDate: new Date().toISOString(), @@ -106,17 +106,17 @@ export default (testContext: { proofFormat: 'jwt', }) - expect(verifiableCredential.issuer).toEqual({ id: serviceIdentity.did }) + expect(verifiableCredential.issuer).toEqual({ id: serviceIdentifier.did }) expect(verifiableCredential.credentialSubject).toEqual({ id: alice.did, name: 'Alice' }) expect(verifiableCredential).toHaveProperty('proof.jwt') }) it('issuer - Alice, subject - Bob', async () => { - const a = await agent.identityManagerGetOrCreateIdentity({ + const a = await agent.didManagerGetOrCreate({ alias: 'alice', }) - const b = await agent.identityManagerGetOrCreateIdentity({ + const b = await agent.didManagerGetOrCreate({ alias: 'bob', }) diff --git a/packages/daf-cli/default/client.yml b/packages/daf-cli/default/client.yml index 03912a4a2..56ebb3cdb 100644 --- a/packages/daf-cli/default/client.yml +++ b/packages/daf-cli/default/client.yml @@ -5,7 +5,7 @@ server: schemaPath: /open-api.json apiBasePath: /agent apiDocsPath: /api-docs - defaultIdentity: + defaultDID: create: true messagingServiceEndpoint: /messaging ngrok: @@ -15,7 +15,7 @@ server: # region: eu # exposedMethods: # - resolveDid - # - dataStoreORMGetIdentities + # - dataStoreORMGetIdentifiers agent: $require: daf-core#Agent $args: @@ -28,31 +28,31 @@ agent: # Authorization: Bearer API_KEY enabledMethods: - keyManagerGetKeyManagementSystems - - keyManagerCreateKey - - keyManagerGetKey - - keyManagerDeleteKey - - keyManagerImportKey + - keyManagerCreate + - keyManagerGet + - keyManagerDelete + - keyManagerImport - keyManagerEncryptJWE - keyManagerDecryptJWE - keyManagerSignJWT - keyManagerSignEthTX - - identityManagerGetProviders - - identityManagerGetIdentities - - identityManagerGetIdentity - - identityManagerCreateIdentity - - identityManagerGetOrCreateIdentity - - identityManagerImportIdentity - - identityManagerDeleteIdentity - - identityManagerAddKey - - identityManagerRemoveKey - - identityManagerAddService - - identityManagerRemoveService + - didManagerGetProviders + - didManagerFind + - didManagerGet + - didManagerCreate + - didManagerGetOrCreate + - didManagerImport + - didManagerDelete + - didManagerAddKey + - didManagerRemoveKey + - didManagerAddService + - didManagerRemoveService - resolveDid - dataStoreSaveMessage - dataStoreSaveVerifiableCredential - dataStoreSaveVerifiablePresentation - - dataStoreORMGetIdentities - - dataStoreORMGetIdentitiesCount + - dataStoreORMGetIdentifiers + - dataStoreORMGetIdentifiersCount - dataStoreORMGetMessages - dataStoreORMGetMessagesCount - dataStoreORMGetVerifiableCredentialsByClaims diff --git a/packages/daf-cli/default/default.yml b/packages/daf-cli/default/default.yml index 752d4c1dd..9fbc7609a 100644 --- a/packages/daf-cli/default/default.yml +++ b/packages/daf-cli/default/default.yml @@ -14,7 +14,7 @@ server: apiVersion: 1.0.0 apiBasePath: /agent apiDocsPath: /api-docs - defaultIdentity: + defaultDID: create: true messagingServiceEndpoint: /messaging ngrok: @@ -102,16 +102,16 @@ agent: kms: local: $require: daf-libsodium#KeyManagementSystem - - $require: daf-identity-manager#IdentityManager + - $require: daf-identity-manager#DIDManager $args: - store: - $require: daf-typeorm#IdentityStore + $require: daf-typeorm#DIDStore $args: - $ref: /dbConnection defaultProvider: did:ethr:rinkeby providers: did:ethr: - $require: daf-ethr-did#EthrIdentityProvider + $require: daf-ethr-did#EthrDIDProvider $args: - defaultKms: local network: mainnet @@ -119,7 +119,7 @@ agent: gas: 10001 ttl: 31104001 did:ethr:rinkeby: - $require: daf-ethr-did#EthrIdentityProvider + $require: daf-ethr-did#EthrDIDProvider $args: - defaultKms: local network: rinkeby @@ -127,7 +127,7 @@ agent: gas: 10001 ttl: 31104001 did:ethr:ropsten: - $require: daf-ethr-did#EthrIdentityProvider + $require: daf-ethr-did#EthrDIDProvider $args: - defaultKms: local network: ropsten @@ -135,7 +135,7 @@ agent: gas: 10001 ttl: 31104001 did:ethr:kovan: - $require: daf-ethr-did#EthrIdentityProvider + $require: daf-ethr-did#EthrDIDProvider $args: - defaultKms: local network: kovan @@ -143,7 +143,7 @@ agent: gas: 10001 ttl: 31104001 did:ethr:goerli: - $require: daf-ethr-did#EthrIdentityProvider + $require: daf-ethr-did#EthrDIDProvider $args: - defaultKms: local network: goerli @@ -151,7 +151,7 @@ agent: gas: 10001 ttl: 31104001 did:web: - $require: daf-web-did#WebIdentityProvider + $require: daf-web-did#WebDIDProvider $args: - defaultKms: local - $require: daf-resolver#DafResolver diff --git a/packages/daf-cli/src/credential.ts b/packages/daf-cli/src/credential.ts index 3ac6b790f..144136a3d 100644 --- a/packages/daf-cli/src/credential.ts +++ b/packages/daf-cli/src/credential.ts @@ -13,8 +13,8 @@ credential .option('-q, --qrcode', 'Show qrcode') .action(async (cmd) => { const agent = getAgent(program.config) - const identities = await agent.identityManagerGetIdentities() - if (identities.length === 0) { + const identifiers = await agent.didManagerFind() + if (identifiers.length === 0) { console.error('No dids') process.exit() } @@ -22,7 +22,7 @@ credential { type: 'list', name: 'iss', - choices: identities.map((item) => ({ + choices: identifiers.map((item) => ({ name: `${item.did} ${item.alias}`, value: item.did, })), @@ -32,7 +32,7 @@ credential type: 'input', name: 'sub', message: 'Subject DID', - default: identities[0].did, + default: identifiers[0].did, }, { type: 'input', diff --git a/packages/daf-cli/src/dev.ts b/packages/daf-cli/src/dev.ts index 6249e90df..49c4485d3 100644 --- a/packages/daf-cli/src/dev.ts +++ b/packages/daf-cli/src/dev.ts @@ -15,7 +15,7 @@ import { ApiReturnTypeMixin, ApiMethodSignature, } from '@microsoft/api-extractor-model' -import { IIdentity } from 'daf-core' +import { IIdentifier } from 'daf-core' interface Method { packageName: string diff --git a/packages/daf-cli/src/did.ts b/packages/daf-cli/src/did.ts index 6bc919272..63609c7d4 100644 --- a/packages/daf-cli/src/did.ts +++ b/packages/daf-cli/src/did.ts @@ -1,4 +1,4 @@ -import { IIdentityManagerCreateIdentityArgs } from 'daf-core' +import { IDIDManagerCreateArgs } from 'daf-core' import { getAgent } from './setup' import inquirer from 'inquirer' import program from 'commander' @@ -12,23 +12,23 @@ did .action(async (cmd) => { const agent = getAgent(program.config) - const providers = await agent.identityManagerGetProviders() + const providers = await agent.didManagerGetProviders() const list = providers.map((provider) => ({ provider })) if (list.length > 0) { printTable(list) } else { - console.log('No identity providers') + console.log('No identifier providers') } }) did .command('list', { isDefault: true }) - .description('list managed identities') + .description('list managed identifiers') .action(async (cmd) => { const agent = getAgent(program.config) - const list = await agent.identityManagerGetIdentities() + const list = await agent.didManagerFind() if (list.length > 0) { const dids = list.map((item) => ({ provider: item.provider, alias: item.alias, did: item.did })) @@ -45,16 +45,16 @@ did const agent = getAgent(program.config) try { - const providers = await agent.identityManagerGetProviders() + const providers = await agent.didManagerGetProviders() const kms = await agent.keyManagerGetKeyManagementSystems() - const args: IIdentityManagerCreateIdentityArgs = {} + const args: IDIDManagerCreateArgs = {} const answers = await inquirer.prompt([ { type: 'list', name: 'provider', choices: providers, - message: 'Select identity provider', + message: 'Select identifier provider', }, { type: 'list', @@ -69,8 +69,8 @@ did }, ]) - const identity = await agent.identityManagerCreateIdentity(answers) - printTable([{ provider: identity.provider, alias: identity.alias, did: identity.did }]) + const identifier = await agent.didManagerCreate(answers) + printTable([{ provider: identifier.provider, alias: identifier.alias, did: identifier.did }]) } catch (e) { console.error(e.message) } @@ -83,17 +83,17 @@ did const agent = getAgent(program.config) try { - const identities = await agent.identityManagerGetIdentities() + const identifiers = await agent.didManagerFind() const answers = await inquirer.prompt([ { type: 'list', name: 'did', - choices: identities.map((item) => item.did), + choices: identifiers.map((item) => item.did), message: 'Delete DID', }, ]) - const result = await agent.identityManagerDeleteIdentity({ + const result = await agent.didManagerDelete({ did: answers.did, }) @@ -110,12 +110,12 @@ did const agent = getAgent(program.config) try { - const identities = await agent.identityManagerGetIdentities() + const identifiers = await agent.didManagerFind() const answers = await inquirer.prompt([ { type: 'list', name: 'did', - choices: identities.map((item) => item.did), + choices: identifiers.map((item) => item.did), message: 'Select DID', }, { @@ -136,7 +136,7 @@ did }, ]) - const result = await agent.identityManagerAddService({ + const result = await agent.didManagerAddService({ did: answers.did, service: { type: answers.type, @@ -158,13 +158,13 @@ did const agent = getAgent(program.config) try { - const identities = await agent.identityManagerGetIdentities() + const identifiers = await agent.didManagerFind() const kms = await agent.keyManagerGetKeyManagementSystems() const answers = await inquirer.prompt([ { type: 'list', name: 'did', - choices: identities.map((item) => item.did), + choices: identifiers.map((item) => item.did), message: 'Select DID', }, { @@ -181,12 +181,12 @@ did }, ]) - const key = await agent.keyManagerCreateKey({ + const key = await agent.keyManagerCreate({ kms: answers.kms, type: answers.type, }) - const result = await agent.identityManagerAddKey({ + const result = await agent.didManagerAddKey({ did: answers.did, key, }) @@ -204,12 +204,12 @@ did const agent = getAgent(program.config) try { - const identities = await agent.identityManagerGetIdentities() + const identifiers = await agent.didManagerFind() const answers = await inquirer.prompt([ { type: 'list', name: 'did', - choices: identities.map((item) => ({ + choices: identifiers.map((item) => ({ name: item.did + ' ' + item.alias, value: item.did, })), @@ -217,9 +217,9 @@ did }, ]) - const identity = await agent.identityManagerGetIdentity({ did: answers.did }) + const identifier = await agent.didManagerGet({ did: answers.did }) - console.log(JSON.stringify(identity)) + console.log(JSON.stringify(identifier)) } catch (e) { console.error(e) } @@ -235,13 +235,13 @@ did const answers = await inquirer.prompt([ { type: 'text', - name: 'identity', - message: 'Identity (JSON object)', + name: 'identifier', + message: 'Identifier (JSON object)', }, ]) - const identity = await agent.identityManagerImportIdentity(JSON.parse(answers.identity)) - console.log(identity) + const identifier = await agent.didManagerImport(JSON.parse(answers.identifier)) + console.log(identifier) } catch (e) { console.error(e) } diff --git a/packages/daf-cli/src/explore/main.ts b/packages/daf-cli/src/explore/main.ts index b24b003cb..61b253870 100644 --- a/packages/daf-cli/src/explore/main.ts +++ b/packages/daf-cli/src/explore/main.ts @@ -3,7 +3,7 @@ import { IMessage } from 'daf-core' import { ConfiguredAgent } from '../setup' import { styles } from './styles' -import { getManagedIdentitiesTable } from './managed-identities' +import { getManagedIdentifiersTable } from './managed-identifiers' import { getMessagesTable } from './messages' import { getCredentialsTable } from './credentials' import { getPresentationsTable } from './presentations' @@ -19,7 +19,7 @@ export const renderMainScreen = async (agent: ConfiguredAgent) => { screen.title = defaultScreenTitle const mainMenuItems = [ - { title: 'Managed identities', getComponent: getManagedIdentitiesTable }, + { title: 'Managed identifiers', getComponent: getManagedIdentifiersTable }, { title: 'Messages', getComponent: getMessagesTable }, { title: 'Credentials', getComponent: getCredentialsTable }, { title: 'Presentations', getComponent: getPresentationsTable }, diff --git a/packages/daf-cli/src/explore/managed-identifiers.ts b/packages/daf-cli/src/explore/managed-identifiers.ts new file mode 100644 index 000000000..8070d4ff7 --- /dev/null +++ b/packages/daf-cli/src/explore/managed-identifiers.ts @@ -0,0 +1,67 @@ +import blessed, { Widgets } from 'blessed' +import { IIdentifier } from 'daf-core' +import { ConfiguredAgent } from '../setup' +import { styles } from './styles' + +export const getManagedIdentifiersTable = async (agent: ConfiguredAgent, screen: Widgets.Screen) => { + screen.title = 'Managed identifiers' + + const managedIdentifiersTable = blessed.listtable({ + top: '0', + left: '0', + border: 'line', + align: 'left', + tags: true, + keys: true, + width: '100%', + height: '100%', + mouse: true, + style: styles.listtable, + }) + + const identifiers = await agent.didManagerFind() + managedIdentifiersTable.setData([['DID', 'Alias']].concat(identifiers.map((i) => [i.did, i.alias || '']))) + + managedIdentifiersTable.on('select', async function (data) { + const i = managedIdentifiersTable.getItemIndex(data) + showIdentifier(identifiers[i - 1]) + }) + + function showIdentifier(identifier: IIdentifier) { + const identifierBox = blessed.box({ + label: identifier.did, + top: 'center', + left: 'center', + height: '90%', + width: '90%', + border: 'line', + shadow: true, + mouse: true, + keys: true, + scrollable: true, + vi: true, + alwaysScroll: true, + scrollbar: { + ch: ' ', + track: { + bg: 'grey', + }, + style: { + inverse: false, + }, + }, + + content: JSON.stringify(identifier, null, 2), + }) + identifierBox.key(['escape'], function (ch, key) { + identifierBox.destroy() + screen.render() + }) + + identifierBox.focus() + screen.append(identifierBox) + screen.render() + } + + return managedIdentifiersTable +} diff --git a/packages/daf-cli/src/explore/managed-identities.ts b/packages/daf-cli/src/explore/managed-identities.ts deleted file mode 100644 index aa51a7a9a..000000000 --- a/packages/daf-cli/src/explore/managed-identities.ts +++ /dev/null @@ -1,67 +0,0 @@ -import blessed, { Widgets } from 'blessed' -import { IIdentity } from 'daf-core' -import { ConfiguredAgent } from '../setup' -import { styles } from './styles' - -export const getManagedIdentitiesTable = async (agent: ConfiguredAgent, screen: Widgets.Screen) => { - screen.title = 'Managed identities' - - const managedIdentitiesTable = blessed.listtable({ - top: '0', - left: '0', - border: 'line', - align: 'left', - tags: true, - keys: true, - width: '100%', - height: '100%', - mouse: true, - style: styles.listtable, - }) - - const identities = await agent.identityManagerGetIdentities() - managedIdentitiesTable.setData([['DID', 'Alias']].concat(identities.map((i) => [i.did, i.alias || '']))) - - managedIdentitiesTable.on('select', async function (data) { - const i = managedIdentitiesTable.getItemIndex(data) - showIdentity(identities[i - 1]) - }) - - function showIdentity(identity: IIdentity) { - const identityBox = blessed.box({ - label: identity.did, - top: 'center', - left: 'center', - height: '90%', - width: '90%', - border: 'line', - shadow: true, - mouse: true, - keys: true, - scrollable: true, - vi: true, - alwaysScroll: true, - scrollbar: { - ch: ' ', - track: { - bg: 'grey', - }, - style: { - inverse: false, - }, - }, - - content: JSON.stringify(identity, null, 2), - }) - identityBox.key(['escape'], function (ch, key) { - identityBox.destroy() - screen.render() - }) - - identityBox.focus() - screen.append(identityBox) - screen.render() - } - - return managedIdentitiesTable -} diff --git a/packages/daf-cli/src/presentation.ts b/packages/daf-cli/src/presentation.ts index ca92d0b53..7d6a76cc5 100644 --- a/packages/daf-cli/src/presentation.ts +++ b/packages/daf-cli/src/presentation.ts @@ -13,15 +13,15 @@ presentation .option('-q, --qrcode', 'Show qrcode') .action(async (cmd) => { const agent = getAgent(program.config) - const myIdentities = await agent.identityManagerGetIdentities() - if (myIdentities.length === 0) { + const myIdentifiers = await agent.didManagerFind() + if (myIdentifiers.length === 0) { console.error('No dids') process.exit() } - const ids = await agent.dataStoreORMGetIdentities() + const ids = await agent.dataStoreORMGetIdentifiers() - const identities = [ + const identifiers = [ { name: 'Enter manually', value: 'manual', @@ -34,7 +34,7 @@ presentation { type: 'list', name: 'iss', - choices: myIdentities.map((item) => ({ + choices: myIdentifiers.map((item) => ({ name: `${item.did} ${item.alias}`, value: item.did, })), @@ -51,7 +51,7 @@ presentation type: 'list', name: 'aud', message: 'Verifier DID', - choices: identities, + choices: identifiers, }, { type: 'input', diff --git a/packages/daf-cli/src/sdr.ts b/packages/daf-cli/src/sdr.ts index 6e659d038..908ef4390 100644 --- a/packages/daf-cli/src/sdr.ts +++ b/packages/daf-cli/src/sdr.ts @@ -14,13 +14,13 @@ sdr .description('create Selective Disclosure Request') .action(async (cmd) => { const agent = getAgent(program.config) - const identities = await agent.identityManagerGetIdentities() + const identifiers = await agent.didManagerFind() - const knownDids = await agent.dataStoreORMGetIdentities() + const knownDids = await agent.dataStoreORMGetIdentifiers() const subjects = [...knownDids.map((id) => id.did)] - if (identities.length === 0) { + if (identifiers.length === 0) { console.error('No dids') process.exit() } @@ -28,7 +28,7 @@ sdr { type: 'list', name: 'iss', - choices: identities.map((item) => item.did), + choices: identifiers.map((item) => item.did), message: 'Issuer DID', }, { diff --git a/packages/daf-cli/src/server.ts b/packages/daf-cli/src/server.ts index 56305d1f3..cb5eab0fa 100644 --- a/packages/daf-cli/src/server.ts +++ b/packages/daf-cli/src/server.ts @@ -9,7 +9,7 @@ import { getAgent, getConfig } from './setup' import { createObjects } from './lib/objectCreator' import passport from 'passport' import Bearer from 'passport-http-bearer' -import { IIdentity } from 'daf-core' +import { IIdentifier } from 'daf-core' const exphbs = require('express-handlebars') const hbs = exphbs.create({ helpers: { @@ -118,25 +118,24 @@ program console.log('🧩 Available methods', agent.availableMethods().length) console.log('🛠 Exposed methods', exposedMethods.length) - /** - * Creating server identity and configuring messaging service endpoint + * Creating server identifier and configuring messaging service endpoint */ - let serverIdentity: IIdentity - if (options.defaultIdentity.create) { - serverIdentity = await agent.identityManagerGetOrCreateIdentity({ + let serverIdentifier: IIdentifier + if (options.defaultDID.create) { + serverIdentifier = await agent.didManagerGetOrCreate({ provider: 'did:web', alias: hostname, }) - console.log('🆔', serverIdentity.did) + console.log('🆔', serverIdentifier.did) - const messagingServiceEndpoint = baseUrl + options.defaultIdentity.messagingServiceEndpoint + const messagingServiceEndpoint = baseUrl + options.defaultDID.messagingServiceEndpoint console.log('📨 Messaging endpoint', messagingServiceEndpoint) - await agent.identityManagerAddService({ - did: serverIdentity.did, + await agent.didManagerAddService({ + did: serverIdentifier.did, service: { - id: serverIdentity.did + '#msg', + id: serverIdentifier.did + '#msg', type: 'Messaging', description: 'Handles incoming POST messages', serviceEndpoint: messagingServiceEndpoint, @@ -144,7 +143,7 @@ program }) app.post( - options.defaultIdentity.messagingServiceEndpoint, + options.defaultDID.messagingServiceEndpoint, express.text({ type: '*/*' }), async (req, res) => { try { diff --git a/packages/daf-cli/src/setup.ts b/packages/daf-cli/src/setup.ts index 52832d4ab..87c57532c 100644 --- a/packages/daf-cli/src/setup.ts +++ b/packages/daf-cli/src/setup.ts @@ -1,6 +1,6 @@ import 'cross-fetch/polyfill' import yaml from 'yaml' -import { IDataStore, IIdentityManager, IMessageHandler, IKeyManager, IResolver, TAgent } from 'daf-core' +import { IDataStore, IDIDManager, IMessageHandler, IKeyManager, IResolver, TAgent } from 'daf-core' import { ICredentialIssuer } from 'daf-w3c' import { ISelectiveDisclosure } from 'daf-selective-disclosure' import { IDIDComm } from 'daf-did-comm' @@ -19,7 +19,7 @@ export const getConfig = (fileName: string): any => { return config } -export type EnabledInterfaces = IIdentityManager & +export type EnabledInterfaces = IDIDManager & IKeyManager & IDataStore & IDataStoreORM & diff --git a/packages/daf-core/api/daf-core.api.md b/packages/daf-core/api/daf-core.api.md index 4650fe69c..636fddc42 100644 --- a/packages/daf-core/api/daf-core.api.md +++ b/packages/daf-core/api/daf-core.api.md @@ -125,64 +125,38 @@ export interface IDataStoreSaveVerifiablePresentationArgs { } // @public -export interface IEventListener { - readonly eventTypes?: string[]; - onEvent?(event: { - type: string; - data: any; - }, context: IAgentContext<{}>): Promise; -} - -// @public -export interface IHandleMessageArgs { - metaData?: IMetaData[]; - raw: string; - save?: boolean; -} - -// @public -export interface IIdentity { - alias?: string; - controllerKeyId?: string; - did: string; - keys: IKey[]; - provider: string; - services: IService[]; -} - -// @public -export interface IIdentityManager extends IPluginMethodMap { - identityManagerAddKey(args: IIdentityManagerAddKeyArgs, context: IAgentContext): Promise; - identityManagerAddService(args: IIdentityManagerAddServiceArgs, context: IAgentContext): Promise; - identityManagerCreateIdentity(args: IIdentityManagerCreateIdentityArgs, context: IAgentContext): Promise; - identityManagerDeleteIdentity(args: IIdentityManagerDeleteIdentityArgs, context: IAgentContext): Promise; - identityManagerGetIdentities(args: IIdentityManagerGetIdentitiesArgs): Promise>; - identityManagerGetIdentity(args: IIdentityManagerGetIdentityArgs): Promise; - identityManagerGetIdentityByAlias(args: IIdentityManagerGetIdentityByAliasArgs): Promise; - identityManagerGetOrCreateIdentity(args: IIdentityManagerGetOrCreateIdentityArgs, context: IAgentContext): Promise; - identityManagerGetProviders(): Promise>; - identityManagerImportIdentity(args: IIdentity, context: IAgentContext): Promise; - identityManagerRemoveKey(args: IIdentityManagerRemoveKeyArgs, context: IAgentContext): Promise; - identityManagerRemoveService(args: IIdentityManagerRemoveServiceArgs, context: IAgentContext): Promise; - identityManagerSetAlias(args: IIdentityManagerSetAliasArgs, context: IAgentContext): Promise; -} - -// @public -export interface IIdentityManagerAddKeyArgs { +export interface IDIDManager extends IPluginMethodMap { + didManagerAddKey(args: IDIDManagerAddKeyArgs, context: IAgentContext): Promise; + didManagerAddService(args: IDIDManagerAddServiceArgs, context: IAgentContext): Promise; + didManagerCreate(args: IDIDManagerCreateArgs, context: IAgentContext): Promise; + didManagerDelete(args: IDIDManagerDeleteArgs, context: IAgentContext): Promise; + didManagerFind(args: IDIDManagerFindArgs): Promise>; + didManagerGet(args: IDIDManagerGetArgs): Promise; + didManagerGetByAlias(args: IDIDManagerGetByAliasArgs): Promise; + didManagerGetOrCreate(args: IDIDManagerGetOrCreateArgs, context: IAgentContext): Promise; + didManagerGetProviders(): Promise>; + didManagerImport(args: IIdentifier, context: IAgentContext): Promise; + didManagerRemoveKey(args: IDIDManagerRemoveKeyArgs, context: IAgentContext): Promise; + didManagerRemoveService(args: IDIDManagerRemoveServiceArgs, context: IAgentContext): Promise; + didManagerSetAlias(args: IDIDManagerSetAliasArgs, context: IAgentContext): Promise; +} + +// @public +export interface IDIDManagerAddKeyArgs { did: string; key: IKey; options?: object; } // @public -export interface IIdentityManagerAddServiceArgs { +export interface IDIDManagerAddServiceArgs { did: string; options?: object; service: IService; } // @public -export interface IIdentityManagerCreateIdentityArgs { +export interface IDIDManagerCreateArgs { alias?: string; kms?: string; options?: object; @@ -190,29 +164,29 @@ export interface IIdentityManagerCreateIdentityArgs { } // @public -export interface IIdentityManagerDeleteIdentityArgs { +export interface IDIDManagerDeleteArgs { did: string; } // @public -export interface IIdentityManagerGetIdentitiesArgs { +export interface IDIDManagerFindArgs { alias?: string; provider?: string; } // @public -export interface IIdentityManagerGetIdentityArgs { +export interface IDIDManagerGetArgs { did: string; } // @public -export interface IIdentityManagerGetIdentityByAliasArgs { +export interface IDIDManagerGetByAliasArgs { alias: string; provider?: string; } // @public -export interface IIdentityManagerGetOrCreateIdentityArgs { +export interface IDIDManagerGetOrCreateArgs { alias: string; kms?: string; options?: object; @@ -220,25 +194,51 @@ export interface IIdentityManagerGetOrCreateIdentityArgs { } // @public -export interface IIdentityManagerRemoveKeyArgs { +export interface IDIDManagerRemoveKeyArgs { did: string; kid: string; options?: object; } // @public -export interface IIdentityManagerRemoveServiceArgs { +export interface IDIDManagerRemoveServiceArgs { did: string; id: string; options?: object; } // @public -export interface IIdentityManagerSetAliasArgs { +export interface IDIDManagerSetAliasArgs { alias: string; did: string; } +// @public +export interface IEventListener { + readonly eventTypes?: string[]; + onEvent?(event: { + type: string; + data: any; + }, context: IAgentContext<{}>): Promise; +} + +// @public +export interface IHandleMessageArgs { + metaData?: IMetaData[]; + raw: string; + save?: boolean; +} + +// @public +export interface IIdentifier { + alias?: string; + controllerKeyId?: string; + did: string; + keys: IKey[]; + provider: string; + services: IService[]; +} + // @public export interface IKey { kid: string; @@ -251,21 +251,21 @@ export interface IKey { // @public export interface IKeyManager extends IPluginMethodMap { - keyManagerCreateKey(args: IKeyManagerCreateKeyArgs): Promise; + keyManagerCreate(args: IKeyManagerCreateArgs): Promise; // @beta keyManagerDecryptJWE(args: IKeyManagerDecryptJWEArgs): Promise; - keyManagerDeleteKey(args: IKeyManagerDeleteKeyArgs): Promise; + keyManagerDelete(args: IKeyManagerDeleteArgs): Promise; // @beta keyManagerEncryptJWE(args: IKeyManagerEncryptJWEArgs): Promise; - keyManagerGetKey(args: IKeyManagerGetKeyArgs): Promise; + keyManagerGet(args: IKeyManagerGetArgs): Promise; keyManagerGetKeyManagementSystems(): Promise>; - keyManagerImportKey(args: IKey): Promise; + keyManagerImport(args: IKey): Promise; keyManagerSignEthTX(args: IKeyManagerSignEthTXArgs): Promise; keyManagerSignJWT(args: IKeyManagerSignJWTArgs): Promise; } // @public -export interface IKeyManagerCreateKeyArgs { +export interface IKeyManagerCreateArgs { kms: string; meta?: object; type: TKeyType; @@ -278,7 +278,7 @@ export interface IKeyManagerDecryptJWEArgs { } // @public -export interface IKeyManagerDeleteKeyArgs { +export interface IKeyManagerDeleteArgs { kid: string; } @@ -290,7 +290,7 @@ export interface IKeyManagerEncryptJWEArgs { } // @public -export interface IKeyManagerGetKeyArgs { +export interface IKeyManagerGetArgs { kid: string; } diff --git a/packages/daf-core/package.json b/packages/daf-core/package.json index ea2cc6dd0..249b0e3fa 100644 --- a/packages/daf-core/package.json +++ b/packages/daf-core/package.json @@ -12,7 +12,7 @@ "pluginInterfaces": { "IResolver": "./src/types/IResolver.ts", "IKeyManager": "./src/types/IKeyManager.ts", - "IIdentityManager": "./src/types/IIdentityManager.ts", + "IDIDManager": "./src/types/IDIDManager.ts", "IDataStore": "./src/types/IDataStore.ts", "IMessageHandler": "./src/types/IMessageHandler.ts" } diff --git a/packages/daf-core/plugin.schema.json b/packages/daf-core/plugin.schema.json index c8822494f..b723299da 100644 --- a/packages/daf-core/plugin.schema.json +++ b/packages/daf-core/plugin.schema.json @@ -211,7 +211,7 @@ "IKeyManager": { "components": { "schemas": { - "IKeyManagerCreateKeyArgs": { + "IKeyManagerCreateArgs": { "type": "object", "properties": { "type": { @@ -231,7 +231,7 @@ "type", "kms" ], - "description": "Input arguments for {@link IKeyManager.keyManagerCreateKey | keyManagerCreateKey}" + "description": "Input arguments for {@link IKeyManager.keyManagerCreate | keyManagerCreate}" }, "TKeyType": { "type": "string", @@ -302,7 +302,7 @@ ], "description": "Input arguments for {@link IKeyManager.keyManagerDecryptJWE | keyManagerDecryptJWE}" }, - "IKeyManagerDeleteKeyArgs": { + "IKeyManagerDeleteArgs": { "type": "object", "properties": { "kid": { @@ -313,7 +313,7 @@ "required": [ "kid" ], - "description": "Input arguments for {@link IKeyManager.keyManagerDeleteKey | keyManagerDeleteKey}" + "description": "Input arguments for {@link IKeyManager.keyManagerDelete | keyManagerDelete}" }, "IKeyManagerEncryptJWEArgs": { "type": "object", @@ -372,7 +372,7 @@ ], "description": "Input arguments for {@link IKeyManager.keyManagerEncryptJWE | keyManagerEncryptJWE}" }, - "IKeyManagerGetKeyArgs": { + "IKeyManagerGetArgs": { "type": "object", "properties": { "kid": { @@ -383,7 +383,7 @@ "required": [ "kid" ], - "description": "Input arguments for {@link IKeyManager.keyManagerGetKey | keyManagerGetKey}" + "description": "Input arguments for {@link IKeyManager.keyManagerGet | keyManagerGet}" }, "IKeyManagerSignEthTXArgs": { "type": "object", @@ -443,10 +443,10 @@ } }, "methods": { - "keyManagerCreateKey": { + "keyManagerCreate": { "description": "Creates and returns a new key", "arguments": { - "$ref": "#/components/schemas/IKeyManagerCreateKeyArgs" + "$ref": "#/components/schemas/IKeyManagerCreateArgs" }, "returnType": { "$ref": "#/components/schemas/IKey" @@ -461,10 +461,10 @@ "type": "string" } }, - "keyManagerDeleteKey": { + "keyManagerDelete": { "description": "Deletes a key", "arguments": { - "$ref": "#/components/schemas/IKeyManagerDeleteKeyArgs" + "$ref": "#/components/schemas/IKeyManagerDeleteArgs" }, "returnType": { "type": "boolean" @@ -479,10 +479,10 @@ "type": "string" } }, - "keyManagerGetKey": { + "keyManagerGet": { "description": "Returns an existing key", "arguments": { - "$ref": "#/components/schemas/IKeyManagerGetKeyArgs" + "$ref": "#/components/schemas/IKeyManagerGetArgs" }, "returnType": { "$ref": "#/components/schemas/IKey" @@ -500,7 +500,7 @@ } } }, - "keyManagerImportKey": { + "keyManagerImport": { "description": "Imports a created key", "arguments": { "$ref": "#/components/schemas/IKey" @@ -530,10 +530,10 @@ } } }, - "IIdentityManager": { + "IDIDManager": { "components": { "schemas": { - "IIdentityManagerAddKeyArgs": { + "IDIDManagerAddKeyArgs": { "type": "object", "properties": { "did": { @@ -546,14 +546,14 @@ }, "options": { "type": "object", - "description": "Optional. Identity provider specific options" + "description": "Optional. Identifier provider specific options" } }, "required": [ "did", "key" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerAddKey | identityManagerAddKey}" + "description": "Input arguments for {@link IDIDManager.didManagerAddKey | didManagerAddKey}" }, "IKey": { "type": "object", @@ -606,7 +606,7 @@ ], "description": "Cryptographic key type" }, - "IIdentityManagerAddServiceArgs": { + "IDIDManagerAddServiceArgs": { "type": "object", "properties": { "did": { @@ -619,14 +619,14 @@ }, "options": { "type": "object", - "description": "Optional. Identity provider specific options" + "description": "Optional. Identifier provider specific options" } }, "required": [ "did", "service" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerAddService | identityManagerAddService}" + "description": "Input arguments for {@link IDIDManager.didManagerAddService | didManagerAddService}" }, "IService": { "type": "object", @@ -653,18 +653,18 @@ "type", "serviceEndpoint" ], - "description": "Identity service" + "description": "Identifier service" }, - "IIdentityManagerCreateIdentityArgs": { + "IDIDManagerCreateArgs": { "type": "object", "properties": { "alias": { "type": "string", - "description": "Optional. Identity alias. Can be used to reference an object in an external system" + "description": "Optional. Identifier alias. Can be used to reference an object in an external system" }, "provider": { "type": "string", - "description": "Optional. Identity provider" + "description": "Optional. Identifier provider" }, "kms": { "type": "string", @@ -672,12 +672,12 @@ }, "options": { "type": "object", - "description": "Optional. Identity provider specific options" + "description": "Optional. Identifier provider specific options" } }, - "description": "Input arguments for {@link IIdentityManager.identityManagerCreateIdentity | identityManagerCreateIdentity}" + "description": "Input arguments for {@link IDIDManager.didManagerCreate | didManagerCreate}" }, - "IIdentity": { + "IIdentifier": { "type": "object", "properties": { "did": { @@ -686,11 +686,11 @@ }, "alias": { "type": "string", - "description": "Optional. Identity alias. Can be used to reference an object in an external system" + "description": "Optional. Identifier alias. Can be used to reference an object in an external system" }, "provider": { "type": "string", - "description": "Identity provider name" + "description": "Identifier provider name" }, "controllerKeyId": { "type": "string", @@ -717,9 +717,9 @@ "keys", "services" ], - "description": "Identity interface" + "description": "Identifier interface" }, - "IIdentityManagerDeleteIdentityArgs": { + "IDIDManagerDeleteArgs": { "type": "object", "properties": { "did": { @@ -730,9 +730,9 @@ "required": [ "did" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerDeleteIdentity | identityManagerDeleteIdentity}" + "description": "Input arguments for {@link IDIDManager.didManagerDelete | didManagerDelete}" }, - "IIdentityManagerGetIdentitiesArgs": { + "IDIDManagerFindArgs": { "type": "object", "properties": { "alias": { @@ -744,9 +744,9 @@ "description": "Optional. Provider" } }, - "description": "Input arguments for {@link IIdentityManager.identityManagerGetIdentities | identityManagerGetIdentities}" + "description": "Input arguments for {@link IDIDManager.didManagerFind | didManagerFind}" }, - "IIdentityManagerGetIdentityArgs": { + "IDIDManagerGetArgs": { "type": "object", "properties": { "did": { @@ -757,9 +757,9 @@ "required": [ "did" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerGetIdentity | identityManagerGetIdentity}" + "description": "Input arguments for {@link IDIDManager.didManagerGet | didManagerGet}" }, - "IIdentityManagerGetIdentityByAliasArgs": { + "IDIDManagerGetByAliasArgs": { "type": "object", "properties": { "alias": { @@ -774,18 +774,18 @@ "required": [ "alias" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerGetIdentityByAlias | identityManagerGetIdentityByAlias}" + "description": "Input arguments for {@link IDIDManager.didManagerGetByAlias | didManagerGetByAlias}" }, - "IIdentityManagerGetOrCreateIdentityArgs": { + "IDIDManagerGetOrCreateArgs": { "type": "object", "properties": { "alias": { "type": "string", - "description": "Identity alias. Can be used to reference an object in an external system" + "description": "Identifier alias. Can be used to reference an object in an external system" }, "provider": { "type": "string", - "description": "Optional. Identity provider" + "description": "Optional. Identifier provider" }, "kms": { "type": "string", @@ -793,15 +793,15 @@ }, "options": { "type": "object", - "description": "Optional. Identity provider specific options" + "description": "Optional. Identifier provider specific options" } }, "required": [ "alias" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerGetOrCreateIdentity | identityManagerGetOrCreateIdentity}" + "description": "Input arguments for {@link IDIDManager.didManagerGetOrCreate | didManagerGetOrCreate}" }, - "IIdentityManagerRemoveKeyArgs": { + "IDIDManagerRemoveKeyArgs": { "type": "object", "properties": { "did": { @@ -814,16 +814,16 @@ }, "options": { "type": "object", - "description": "Optional. Identity provider specific options" + "description": "Optional. Identifier provider specific options" } }, "required": [ "did", "kid" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerRemoveKey | identityManagerRemoveKey}" + "description": "Input arguments for {@link IDIDManager.didManagerRemoveKey | didManagerRemoveKey}" }, - "IIdentityManagerRemoveServiceArgs": { + "IDIDManagerRemoveServiceArgs": { "type": "object", "properties": { "did": { @@ -836,16 +836,16 @@ }, "options": { "type": "object", - "description": "Optional. Identity provider specific options" + "description": "Optional. Identifier provider specific options" } }, "required": [ "did", "id" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerRemoveService | identityManagerRemoveService}" + "description": "Input arguments for {@link IDIDManager.didManagerRemoveService | didManagerRemoveService}" }, - "IIdentityManagerSetAliasArgs": { + "IDIDManagerSetAliasArgs": { "type": "object", "properties": { "did": { @@ -854,94 +854,94 @@ }, "alias": { "type": "string", - "description": "Required. Identity alias" + "description": "Required. Identifier alias" } }, "required": [ "did", "alias" ], - "description": "Input arguments for {@link IIdentityManager.identityManagerSetAlias | identityManagerSetAlias}" + "description": "Input arguments for {@link IDIDManager.didManagerSetAlias | didManagerSetAlias}" } }, "methods": { - "identityManagerAddKey": { + "didManagerAddKey": { "description": "Adds a key to a DID Document", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerAddKeyArgs" + "$ref": "#/components/schemas/IDIDManagerAddKeyArgs" }, "returnType": { "type": "object" } }, - "identityManagerAddService": { + "didManagerAddService": { "description": "Adds a service to a DID Document", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerAddServiceArgs" + "$ref": "#/components/schemas/IDIDManagerAddServiceArgs" }, "returnType": { "type": "object" } }, - "identityManagerCreateIdentity": { - "description": "Creates and returns a new identity", + "didManagerCreate": { + "description": "Creates and returns a new identifier", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerCreateIdentityArgs" + "$ref": "#/components/schemas/IDIDManagerCreateArgs" }, "returnType": { - "$ref": "#/components/schemas/IIdentity" + "$ref": "#/components/schemas/IIdentifier" } }, - "identityManagerDeleteIdentity": { - "description": "Deletes identity", + "didManagerDelete": { + "description": "Deletes identifier", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerDeleteIdentityArgs" + "$ref": "#/components/schemas/IDIDManagerDeleteArgs" }, "returnType": { "type": "boolean" } }, - "identityManagerGetIdentities": { - "description": "Returns a list of managed identities", + "didManagerFind": { + "description": "Returns a list of managed identifiers", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerGetIdentitiesArgs" + "$ref": "#/components/schemas/IDIDManagerFindArgs" }, "returnType": { "type": "array", "items": { - "$ref": "#/components/schemas/IIdentity" + "$ref": "#/components/schemas/IIdentifier" } } }, - "identityManagerGetIdentity": { - "description": "Returns a specific identity", + "didManagerGet": { + "description": "Returns a specific identifier", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerGetIdentityArgs" + "$ref": "#/components/schemas/IDIDManagerGetArgs" }, "returnType": { - "$ref": "#/components/schemas/IIdentity" + "$ref": "#/components/schemas/IIdentifier" } }, - "identityManagerGetIdentityByAlias": { - "description": "Returns a specific identity by alias", + "didManagerGetByAlias": { + "description": "Returns a specific identifier by alias", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerGetIdentityByAliasArgs" + "$ref": "#/components/schemas/IDIDManagerGetByAliasArgs" }, "returnType": { - "$ref": "#/components/schemas/IIdentity" + "$ref": "#/components/schemas/IIdentifier" } }, - "identityManagerGetOrCreateIdentity": { - "description": "Returns an existing identity or creates a new one for a specific alias", + "didManagerGetOrCreate": { + "description": "Returns an existing identifier or creates a new one for a specific alias", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerGetOrCreateIdentityArgs" + "$ref": "#/components/schemas/IDIDManagerGetOrCreateArgs" }, "returnType": { - "$ref": "#/components/schemas/IIdentity" + "$ref": "#/components/schemas/IIdentifier" } }, - "identityManagerGetProviders": { - "description": "Returns a list of available identity providers", + "didManagerGetProviders": { + "description": "Returns a list of available identifier providers", "arguments": { "type": "object" }, @@ -952,37 +952,37 @@ } } }, - "identityManagerImportIdentity": { - "description": "Imports identity", + "didManagerImport": { + "description": "Imports identifier", "arguments": { - "$ref": "#/components/schemas/IIdentity" + "$ref": "#/components/schemas/IIdentifier" }, "returnType": { - "$ref": "#/components/schemas/IIdentity" + "$ref": "#/components/schemas/IIdentifier" } }, - "identityManagerRemoveKey": { + "didManagerRemoveKey": { "description": "Removes a key from a DID Document", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerRemoveKeyArgs" + "$ref": "#/components/schemas/IDIDManagerRemoveKeyArgs" }, "returnType": { "type": "object" } }, - "identityManagerRemoveService": { + "didManagerRemoveService": { "description": "Removes a service from a DID Document", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerRemoveServiceArgs" + "$ref": "#/components/schemas/IDIDManagerRemoveServiceArgs" }, "returnType": { "type": "object" } }, - "identityManagerSetAlias": { - "description": "Sets identity alias", + "didManagerSetAlias": { + "description": "Sets identifier alias", "arguments": { - "$ref": "#/components/schemas/IIdentityManagerSetAliasArgs" + "$ref": "#/components/schemas/IDIDManagerSetAliasArgs" }, "returnType": { "type": "boolean" @@ -1191,7 +1191,7 @@ "credentialSubject", "proof" ], - "description": "Verifiable Credential {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "VerifiablePresentation": { "type": "object", @@ -1249,7 +1249,7 @@ "verifiableCredential", "proof" ], - "description": "Verifiable Presentation {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "IDataStoreGetVerifiableCredentialArgs": { "type": "object", @@ -1586,7 +1586,7 @@ "credentialSubject", "proof" ], - "description": "Verifiable Credential {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "VerifiablePresentation": { "type": "object", @@ -1644,7 +1644,7 @@ "verifiableCredential", "proof" ], - "description": "Verifiable Presentation {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}" } }, "methods": { diff --git a/packages/daf-core/src/index.ts b/packages/daf-core/src/index.ts index dbe3e5905..6f5be3561 100644 --- a/packages/daf-core/src/index.ts +++ b/packages/daf-core/src/index.ts @@ -1,5 +1,5 @@ /** - * Provides {@link daf-core#Agent} implementation and defines {@link daf-core#IResolver}, {@link daf-core#IIdentityManager}, {@link daf-core#IKeyManager}, {@link daf-core#IDataStore}, {@link daf-core#IMessageHandler} plugin interfaces + * Provides {@link daf-core#Agent} implementation and defines {@link daf-core#IResolver}, {@link daf-core#IDIDManager}, {@link daf-core#IKeyManager}, {@link daf-core#IDataStore}, {@link daf-core#IMessageHandler} plugin interfaces * * @packageDocumentation */ @@ -8,8 +8,8 @@ export { ValidationError } from './validator' export { CoreEvents } from './coreEvents' export * from './types/IAgent' export * from './types/IDataStore' -export * from './types/IIdentity' -export * from './types/IIdentityManager' +export * from './types/IIdentifier' +export * from './types/IDIDManager' export * from './types/IKeyManager' export * from './types/IMessage' export * from './types/IMessageHandler' diff --git a/packages/daf-core/src/types/IDIDManager.ts b/packages/daf-core/src/types/IDIDManager.ts new file mode 100644 index 000000000..8ca00a232 --- /dev/null +++ b/packages/daf-core/src/types/IDIDManager.ts @@ -0,0 +1,339 @@ +import { IPluginMethodMap, IAgentContext } from './IAgent' +import { IIdentifier, IService, IKey } from './IIdentifier' +import { IKeyManager } from './IKeyManager' + +/** + * Input arguments for {@link IDIDManager.didManagerGet | didManagerGet} + * @public + */ +export interface IDIDManagerGetArgs { + /** + * DID + */ + did: string +} + +/** + * Input arguments for {@link IDIDManager.didManagerFind | didManagerFind} + * @public + */ +export interface IDIDManagerFindArgs { + /** + * Optional. Alias + */ + alias?: string + + /** + * Optional. Provider + */ + provider?: string +} + +/** + * Input arguments for {@link IDIDManager.didManagerGetByAlias | didManagerGetByAlias} + * @public + */ +export interface IDIDManagerGetByAliasArgs { + /** + * Alias + */ + alias: string + + /** + * Optional provider + */ + provider?: string +} + +/** + * Input arguments for {@link IDIDManager.didManagerDelete | didManagerDelete} + * @public + */ +export interface IDIDManagerDeleteArgs { + /** + * DID + */ + did: string +} + +/** + * Input arguments for {@link IDIDManager.didManagerCreate | didManagerCreate} + * @public + */ +export interface IDIDManagerCreateArgs { + /** + * Optional. Identifier alias. Can be used to reference an object in an external system + */ + alias?: string + + /** + * Optional. Identifier provider + */ + provider?: string + + /** + * Optional. Key Management System + */ + kms?: string + + /** + * Optional. Identifier provider specific options + */ + options?: object +} + +/** + * Input arguments for {@link IDIDManager.didManagerSetAlias | didManagerSetAlias} + * @public + */ +export interface IDIDManagerSetAliasArgs { + /** + * Required. DID + */ + did: string + + /** + * Required. Identifier alias + */ + alias: string +} + +/** + * Input arguments for {@link IDIDManager.didManagerGetOrCreate | didManagerGetOrCreate} + * @public + */ +export interface IDIDManagerGetOrCreateArgs { + /** + * Identifier alias. Can be used to reference an object in an external system + */ + alias: string + + /** + * Optional. Identifier provider + */ + provider?: string + + /** + * Optional. Key Management System + */ + kms?: string + + /** + * Optional. Identifier provider specific options + */ + options?: object +} + +/** + * Input arguments for {@link IDIDManager.didManagerAddKey | didManagerAddKey} + * @public + */ +export interface IDIDManagerAddKeyArgs { + /** + * DID + */ + did: string + + /** + * Key object + */ + key: IKey + + /** + * Optional. Identifier provider specific options + */ + options?: object +} + +/** + * Input arguments for {@link IDIDManager.didManagerRemoveKey | didManagerRemoveKey} + * @public + */ +export interface IDIDManagerRemoveKeyArgs { + /** + * DID + */ + did: string + + /** + * Key ID + */ + kid: string + + /** + * Optional. Identifier provider specific options + */ + options?: object +} + +/** + * Input arguments for {@link IDIDManager.didManagerAddService | didManagerAddService} + * @public + */ +export interface IDIDManagerAddServiceArgs { + /** + * DID + */ + did: string + + /** + * Service object + */ + service: IService + + /** + * Optional. Identifier provider specific options + */ + options?: object +} + +/** + * Input arguments for {@link IDIDManager.didManagerRemoveService | didManagerRemoveService} + * @public + */ +export interface IDIDManagerRemoveServiceArgs { + /** + * DID + */ + did: string + + /** + * Service ID + */ + id: string + + /** + * Optional. Identifier provider specific options + */ + options?: object +} + +/** + * Identifier manager interface + * @public + */ +export interface IDIDManager extends IPluginMethodMap { + /** + * Returns a list of available identifier providers + */ + didManagerGetProviders(): Promise> + + /** + * Returns a list of managed identifiers + * + * @param args - Required. Arguments to get the list of identifiers + * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods + * + * @example + * ```typescript + * const aliceIdentifiers = await agent.didManagerFind({ + * alias: 'alice' + * }) + * + * const rinkebyIdentifiers = await agent.didManagerFind({ + * provider: 'did:ethr:rinkeby' + * }) + * ``` + */ + didManagerFind(args: IDIDManagerFindArgs): Promise> + + /** + * Returns a specific identifier + */ + didManagerGet(args: IDIDManagerGetArgs): Promise + + /** + * Returns a specific identifier by alias + * + * @param args - Required. Arguments to get the identifier + * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods + * + * @example + * ```typescript + * const identifier = await agent.didManagerGetByAlias({ + * alias: 'alice', + * provider: 'did:ethr:rinkeby' + * }) + * ``` + */ + didManagerGetByAlias(args: IDIDManagerGetByAliasArgs): Promise + + /** + * Creates and returns a new identifier + * + * @param args - Required. Arguments to create the identifier + * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods + * + * @example + * ```typescript + * const identifier = await agent.didManagerCreate({ + * alias: 'alice', + * provider: 'did:ethr:rinkeby', + * kms: 'local' + * }) + * ``` + */ + didManagerCreate(args: IDIDManagerCreateArgs, context: IAgentContext): Promise + + /** + * Sets identifier alias + * + * @param args - Required. Arguments to set identifier alias + * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods + * + * @example + * ```typescript + * const identifier = await agent.didManagerCreate() + * const result = await agent.didManagerSetAlias({ + * did: identifier.did, + * alias: 'carol', + * }) + * ``` + */ + didManagerSetAlias(args: IDIDManagerSetAliasArgs, context: IAgentContext): Promise + + /** + * Returns an existing identifier or creates a new one for a specific alias + */ + didManagerGetOrCreate( + args: IDIDManagerGetOrCreateArgs, + context: IAgentContext, + ): Promise + + /** + * Imports identifier + */ + didManagerImport(args: IIdentifier, context: IAgentContext): Promise + + /** + * Deletes identifier + */ + didManagerDelete(args: IDIDManagerDeleteArgs, context: IAgentContext): Promise + + /** + * Adds a key to a DID Document + * @returns identifier provider specific response. Can be txHash, etc, + */ + didManagerAddKey(args: IDIDManagerAddKeyArgs, context: IAgentContext): Promise + + /** + * Removes a key from a DID Document + * @returns identifier provider specific response. Can be txHash, etc, + */ + didManagerRemoveKey(args: IDIDManagerRemoveKeyArgs, context: IAgentContext): Promise // txHash? + + /** + * Adds a service to a DID Document + * @returns identifier provider specific response. Can be txHash, etc, + */ + didManagerAddService(args: IDIDManagerAddServiceArgs, context: IAgentContext): Promise //txHash? + + /** + * Removes a service from a DID Document + * @returns identifier provider specific response. Can be txHash, etc, + */ + didManagerRemoveService( + args: IDIDManagerRemoveServiceArgs, + context: IAgentContext, + ): Promise //txHash? +} diff --git a/packages/daf-core/src/types/IIdentity.ts b/packages/daf-core/src/types/IIdentifier.ts similarity index 84% rename from packages/daf-core/src/types/IIdentity.ts rename to packages/daf-core/src/types/IIdentifier.ts index 01dca31b6..111036370 100644 --- a/packages/daf-core/src/types/IIdentity.ts +++ b/packages/daf-core/src/types/IIdentifier.ts @@ -1,20 +1,20 @@ /** - * Identity interface + * Identifier interface * @public */ -export interface IIdentity { +export interface IIdentifier { /** * Decentralized identifier */ did: string /** - * Optional. Identity alias. Can be used to reference an object in an external system + * Optional. Identifier alias. Can be used to reference an object in an external system */ alias?: string /** - * Identity provider name + * Identifier provider name */ provider: string @@ -77,7 +77,7 @@ export interface IKey { } /** - * Identity service + * Identifier service * @public */ export interface IService { @@ -101,4 +101,3 @@ export interface IService { */ description?: string } - diff --git a/packages/daf-core/src/types/IIdentityManager.ts b/packages/daf-core/src/types/IIdentityManager.ts deleted file mode 100644 index 7300d38d2..000000000 --- a/packages/daf-core/src/types/IIdentityManager.ts +++ /dev/null @@ -1,354 +0,0 @@ -import { IPluginMethodMap, IAgentContext } from './IAgent' -import { IIdentity, IService, IKey } from './IIdentity' -import { IKeyManager } from './IKeyManager' - -/** - * Input arguments for {@link IIdentityManager.identityManagerGetIdentity | identityManagerGetIdentity} - * @public - */ -export interface IIdentityManagerGetIdentityArgs { - /** - * DID - */ - did: string -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerGetIdentities | identityManagerGetIdentities} - * @public - */ -export interface IIdentityManagerGetIdentitiesArgs { - /** - * Optional. Alias - */ - alias?: string - - /** - * Optional. Provider - */ - provider?: string -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerGetIdentityByAlias | identityManagerGetIdentityByAlias} - * @public - */ -export interface IIdentityManagerGetIdentityByAliasArgs { - /** - * Alias - */ - alias: string - - /** - * Optional provider - */ - provider?: string -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerDeleteIdentity | identityManagerDeleteIdentity} - * @public - */ -export interface IIdentityManagerDeleteIdentityArgs { - /** - * DID - */ - did: string -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerCreateIdentity | identityManagerCreateIdentity} - * @public - */ -export interface IIdentityManagerCreateIdentityArgs { - /** - * Optional. Identity alias. Can be used to reference an object in an external system - */ - alias?: string - - /** - * Optional. Identity provider - */ - provider?: string - - /** - * Optional. Key Management System - */ - kms?: string - - /** - * Optional. Identity provider specific options - */ - options?: object -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerSetAlias | identityManagerSetAlias} - * @public - */ -export interface IIdentityManagerSetAliasArgs { - /** - * Required. DID - */ - did: string - - /** - * Required. Identity alias - */ - alias: string -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerGetOrCreateIdentity | identityManagerGetOrCreateIdentity} - * @public - */ -export interface IIdentityManagerGetOrCreateIdentityArgs { - /** - * Identity alias. Can be used to reference an object in an external system - */ - alias: string - - /** - * Optional. Identity provider - */ - provider?: string - - /** - * Optional. Key Management System - */ - kms?: string - - /** - * Optional. Identity provider specific options - */ - options?: object -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerAddKey | identityManagerAddKey} - * @public - */ -export interface IIdentityManagerAddKeyArgs { - /** - * DID - */ - did: string - - /** - * Key object - */ - key: IKey - - /** - * Optional. Identity provider specific options - */ - options?: object -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerRemoveKey | identityManagerRemoveKey} - * @public - */ -export interface IIdentityManagerRemoveKeyArgs { - /** - * DID - */ - did: string - - /** - * Key ID - */ - kid: string - - /** - * Optional. Identity provider specific options - */ - options?: object -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerAddService | identityManagerAddService} - * @public - */ -export interface IIdentityManagerAddServiceArgs { - /** - * DID - */ - did: string - - /** - * Service object - */ - service: IService - - /** - * Optional. Identity provider specific options - */ - options?: object -} - -/** - * Input arguments for {@link IIdentityManager.identityManagerRemoveService | identityManagerRemoveService} - * @public - */ -export interface IIdentityManagerRemoveServiceArgs { - /** - * DID - */ - did: string - - /** - * Service ID - */ - id: string - - /** - * Optional. Identity provider specific options - */ - options?: object -} - -/** - * Identity manager interface - * @public - */ -export interface IIdentityManager extends IPluginMethodMap { - /** - * Returns a list of available identity providers - */ - identityManagerGetProviders(): Promise> - - /** - * Returns a list of managed identities - * - * @param args - Required. Arguments to get the list of identities - * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods - * - * @example - * ```typescript - * const aliceIdentities = await agent.identityManagerGetIdentities({ - * alias: 'alice' - * }) - * - * const rinkebyIdentities = await agent.identityManagerGetIdentities({ - * provider: 'did:ethr:rinkeby' - * }) - * ``` - */ - identityManagerGetIdentities(args: IIdentityManagerGetIdentitiesArgs): Promise> - - /** - * Returns a specific identity - */ - identityManagerGetIdentity(args: IIdentityManagerGetIdentityArgs): Promise - - /** - * Returns a specific identity by alias - * - * @param args - Required. Arguments to get the identity - * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods - * - * @example - * ```typescript - * const identity = await agent.identityManagerGetIdentityByAlias({ - * alias: 'alice', - * provider: 'did:ethr:rinkeby' - * }) - * ``` - */ - identityManagerGetIdentityByAlias(args: IIdentityManagerGetIdentityByAliasArgs): Promise - - /** - * Creates and returns a new identity - * - * @param args - Required. Arguments to create the identity - * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods - * - * @example - * ```typescript - * const identity = await agent.identityManagerCreateIdentity({ - * alias: 'alice', - * provider: 'did:ethr:rinkeby', - * kms: 'local' - * }) - * ``` - */ - identityManagerCreateIdentity( - args: IIdentityManagerCreateIdentityArgs, - context: IAgentContext, - ): Promise - - /** - * Sets identity alias - * - * @param args - Required. Arguments to set identity alias - * @param context - Execution context. Requires `agent` that has {@link daf-core#IKeyManager} methods - * - * @example - * ```typescript - * const identity = await agent.identityManagerCreateIdentity() - * const result = await agent.identityManagerSetAlias({ - * did: identity.did, - * alias: 'carol', - * }) - * ``` - */ - identityManagerSetAlias( - args: IIdentityManagerSetAliasArgs, - context: IAgentContext, - ): Promise - - /** - * Returns an existing identity or creates a new one for a specific alias - */ - identityManagerGetOrCreateIdentity( - args: IIdentityManagerGetOrCreateIdentityArgs, - context: IAgentContext, - ): Promise - - /** - * Imports identity - */ - identityManagerImportIdentity(args: IIdentity, context: IAgentContext): Promise - - /** - * Deletes identity - */ - identityManagerDeleteIdentity( - args: IIdentityManagerDeleteIdentityArgs, - context: IAgentContext, - ): Promise - - /** - * Adds a key to a DID Document - * @returns identity provider specific response. Can be txHash, etc, - */ - identityManagerAddKey(args: IIdentityManagerAddKeyArgs, context: IAgentContext): Promise - - /** - * Removes a key from a DID Document - * @returns identity provider specific response. Can be txHash, etc, - */ - identityManagerRemoveKey( - args: IIdentityManagerRemoveKeyArgs, - context: IAgentContext, - ): Promise // txHash? - - /** - * Adds a service to a DID Document - * @returns identity provider specific response. Can be txHash, etc, - */ - identityManagerAddService( - args: IIdentityManagerAddServiceArgs, - context: IAgentContext, - ): Promise //txHash? - - /** - * Removes a service from a DID Document - * @returns identity provider specific response. Can be txHash, etc, - */ - identityManagerRemoveService( - args: IIdentityManagerRemoveServiceArgs, - context: IAgentContext, - ): Promise //txHash? -} diff --git a/packages/daf-core/src/types/IKeyManager.ts b/packages/daf-core/src/types/IKeyManager.ts index 4fb13d681..847900f34 100644 --- a/packages/daf-core/src/types/IKeyManager.ts +++ b/packages/daf-core/src/types/IKeyManager.ts @@ -1,11 +1,11 @@ import { IPluginMethodMap } from './IAgent' -import { TKeyType, IKey } from './IIdentity' +import { TKeyType, IKey } from './IIdentifier' /** - * Input arguments for {@link IKeyManager.keyManagerCreateKey | keyManagerCreateKey} + * Input arguments for {@link IKeyManager.keyManagerCreate | keyManagerCreate} * @public */ -export interface IKeyManagerCreateKeyArgs { +export interface IKeyManagerCreateArgs { /** * Key type */ @@ -23,10 +23,10 @@ export interface IKeyManagerCreateKeyArgs { } /** - * Input arguments for {@link IKeyManager.keyManagerGetKey | keyManagerGetKey} + * Input arguments for {@link IKeyManager.keyManagerGet | keyManagerGet} * @public */ -export interface IKeyManagerGetKeyArgs { +export interface IKeyManagerGetArgs { /** * Key ID */ @@ -34,10 +34,10 @@ export interface IKeyManagerGetKeyArgs { } /** - * Input arguments for {@link IKeyManager.keyManagerDeleteKey | keyManagerDeleteKey} + * Input arguments for {@link IKeyManager.keyManagerDelete | keyManagerDelete} * @public */ -export interface IKeyManagerDeleteKeyArgs { +export interface IKeyManagerDeleteArgs { /** * Key ID */ @@ -132,22 +132,22 @@ export interface IKeyManager extends IPluginMethodMap { /** * Creates and returns a new key */ - keyManagerCreateKey(args: IKeyManagerCreateKeyArgs): Promise + keyManagerCreate(args: IKeyManagerCreateArgs): Promise /** * Returns an existing key */ - keyManagerGetKey(args: IKeyManagerGetKeyArgs): Promise + keyManagerGet(args: IKeyManagerGetArgs): Promise /** * Deletes a key */ - keyManagerDeleteKey(args: IKeyManagerDeleteKeyArgs): Promise + keyManagerDelete(args: IKeyManagerDeleteArgs): Promise /** * Imports a created key */ - keyManagerImportKey(args: IKey): Promise + keyManagerImport(args: IKey): Promise /** * Encrypts data diff --git a/packages/daf-core/src/types/IMessage.ts b/packages/daf-core/src/types/IMessage.ts index 5e8a3609f..048ad5dd4 100644 --- a/packages/daf-core/src/types/IMessage.ts +++ b/packages/daf-core/src/types/IMessage.ts @@ -1,5 +1,5 @@ /** - * Verifiable Credential {@link https://github.com/decentralized-identity/did-jwt-vc} + * Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc} * @public */ export interface VerifiableCredential { @@ -25,7 +25,7 @@ export interface VerifiableCredential { } /** - * Verifiable Presentation {@link https://github.com/decentralized-identity/did-jwt-vc} + * Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc} * @public */ export interface VerifiablePresentation { @@ -44,9 +44,8 @@ export interface VerifiablePresentation { [x: string]: any } - /** - * W3CCredential {@link https://github.com/decentralized-identity/did-jwt-vc} + * W3CCredential {@link https://github.com/decentralized-identifier/did-jwt-vc} * @public */ export interface W3CCredential { @@ -68,7 +67,7 @@ export interface W3CCredential { } /** - * W3CPresentation {@link https://github.com/decentralized-identity/did-jwt-vc} + * W3CPresentation {@link https://github.com/decentralized-identifier/did-jwt-vc} * @public */ export interface W3CPresentation { @@ -127,7 +126,7 @@ export interface IMessage { /** * Optional. Thread ID */ - threadId?: string + threadId?: string /** * Optional. Original message raw data @@ -173,4 +172,4 @@ export interface IMessage { * Optional. Array of attached verifiable presentations */ presentations?: VerifiablePresentation[] -} \ No newline at end of file +} diff --git a/packages/daf-did-comm/api/daf-did-comm.api.md b/packages/daf-did-comm/api/daf-did-comm.api.md index b8b24f6ba..605235ac3 100644 --- a/packages/daf-did-comm/api/daf-did-comm.api.md +++ b/packages/daf-did-comm/api/daf-did-comm.api.md @@ -7,7 +7,7 @@ import { AbstractMessageHandler } from 'daf-message-handler'; import { IAgentContext } from 'daf-core'; import { IAgentPlugin } from 'daf-core'; -import { IIdentityManager } from 'daf-core'; +import { IDIDManager } from 'daf-core'; import { IKeyManager } from 'daf-core'; import { IMessage } from 'daf-core'; import { IMessageHandler } from 'daf-core'; @@ -21,7 +21,7 @@ export class DIDComm implements IAgentPlugin { readonly methods: IDIDComm; // (undocumented) readonly schema: any; - sendMessageDIDCommAlpha1(args: ISendMessageDIDCommAlpha1Args, context: IAgentContext): Promise; + sendMessageDIDCommAlpha1(args: ISendMessageDIDCommAlpha1Args, context: IAgentContext): Promise; } // @beta @@ -35,7 +35,7 @@ export class DIDCommMessageHandler extends AbstractMessageHandler { // @beta export interface IDIDComm extends IPluginMethodMap { - sendMessageDIDCommAlpha1(args: ISendMessageDIDCommAlpha1Args, context: IAgentContext): Promise; + sendMessageDIDCommAlpha1(args: ISendMessageDIDCommAlpha1Args, context: IAgentContext): Promise; } // @beta diff --git a/packages/daf-did-comm/plugin.schema.json b/packages/daf-did-comm/plugin.schema.json index 5ded24371..bd1e28b28 100644 --- a/packages/daf-did-comm/plugin.schema.json +++ b/packages/daf-did-comm/plugin.schema.json @@ -240,7 +240,7 @@ "credentialSubject", "proof" ], - "description": "Verifiable Credential {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "VerifiablePresentation": { "type": "object", @@ -298,7 +298,7 @@ "verifiableCredential", "proof" ], - "description": "Verifiable Presentation {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}" } }, "methods": { diff --git a/packages/daf-did-comm/src/action-handler.ts b/packages/daf-did-comm/src/action-handler.ts index 98bebb5be..15f689a63 100644 --- a/packages/daf-did-comm/src/action-handler.ts +++ b/packages/daf-did-comm/src/action-handler.ts @@ -3,7 +3,7 @@ import { IAgentContext, IResolver, IMessage, - IIdentityManager, + IDIDManager, IKeyManager, IMessageHandler, IPluginMethodMap, @@ -38,7 +38,7 @@ export interface ISendMessageDIDCommAlpha1Args { */ export interface IDIDComm extends IPluginMethodMap { /** - * This is used to create a message according to the initial {@link https://github.com/decentralized-identity/DIDComm-js | DIDComm-js} implementation. + * This is used to create a message according to the initial {@link https://github.com/decentralized-identifier/DIDComm-js | DIDComm-js} implementation. * * @remarks Be advised that this spec is still not final and that this protocol may need to change. * @@ -47,14 +47,14 @@ export interface IDIDComm extends IPluginMethodMap { */ sendMessageDIDCommAlpha1( args: ISendMessageDIDCommAlpha1Args, - context: IAgentContext, + context: IAgentContext, ): Promise } /** * DID Comm plugin for {@link daf-core#Agent} * - * This plugin provides a method of creating an encrypted message according to the initial {@link https://github.com/decentralized-identity/DIDComm-js | DIDComm-js} implementation. + * This plugin provides a method of creating an encrypted message according to the initial {@link https://github.com/decentralized-identifier/DIDComm-js | DIDComm-js} implementation. * * @remarks Be advised that this spec is still not final and that this protocol may need to change. * @@ -74,7 +74,7 @@ export class DIDComm implements IAgentPlugin { /** {@inheritdoc IDIDComm.sendMessageDIDCommAlpha1} */ async sendMessageDIDCommAlpha1( args: ISendMessageDIDCommAlpha1Args, - context: IAgentContext, + context: IAgentContext, ): Promise { const { data, url, headers, save = true } = args @@ -93,8 +93,8 @@ export class DIDComm implements IAgentPlugin { data.id = data.id || uuidv4() let postPayload = JSON.stringify(data) try { - const identity = await context.agent.identityManagerGetIdentity({ did: data.from }) - const key = identity.keys.find((k) => k.type === 'Ed25519') + const identifier = await context.agent.didManagerGet({ did: data.from }) + const key = identifier.keys.find((k) => k.type === 'Ed25519') if (!key) throw Error('No encryption key') const publicKey = didDoc?.publicKey.find((item) => item.type == 'Ed25519VerificationKey2018') if (!publicKey?.publicKeyHex) throw Error('Recipient does not have encryption publicKey') diff --git a/packages/daf-did-comm/src/message-handler.ts b/packages/daf-did-comm/src/message-handler.ts index ca15d780c..93a98b4c3 100644 --- a/packages/daf-did-comm/src/message-handler.ts +++ b/packages/daf-did-comm/src/message-handler.ts @@ -1,9 +1,9 @@ -import { IAgentContext, IIdentityManager, IKeyManager } from 'daf-core' +import { IAgentContext, IDIDManager, IKeyManager } from 'daf-core' import { AbstractMessageHandler, Message } from 'daf-message-handler' import Debug from 'debug' const debug = Debug('daf:did-comm:message-handler') -type IContext = IAgentContext +type IContext = IAgentContext /** * A plugin for the {@link daf-message-handler#MessageHandler} that decrypts DIDComm messages @@ -19,16 +19,16 @@ export class DIDCommMessageHandler extends AbstractMessageHandler { try { const parsed = JSON.parse(message.raw) if (parsed.ciphertext && parsed.protected) { - const identities = await context.agent.identityManagerGetIdentities() - for (const identity of identities) { + const identifiers = await context.agent.didManagerFind() + for (const identifier of identifiers) { let decrypted try { - const key = identity.keys.find((k) => k.type === 'Ed25519') + const key = identifier.keys.find((k) => k.type === 'Ed25519') if (!key) throw Error('No encryption keys') decrypted = await context.agent.keyManagerDecryptJWE({ kid: key.kid, data: message.raw }) } catch (e) {} if (decrypted) { - debug('Decrypted for %s', identity.did) + debug('Decrypted for %s', identifier.did) debug('Message:', decrypted) try { diff --git a/packages/daf-ethr-did/api/daf-ethr-did.api.md b/packages/daf-ethr-did/api/daf-ethr-did.api.md index 655b0dd51..7bbf800a7 100644 --- a/packages/daf-ethr-did/api/daf-ethr-did.api.md +++ b/packages/daf-ethr-did/api/daf-ethr-did.api.md @@ -4,15 +4,15 @@ ```ts -import { AbstractIdentityProvider } from 'daf-identity-manager'; +import { AbstractIdentifierProvider } from 'daf-identity-manager'; import { IAgentContext } from 'daf-core'; -import { IIdentity } from 'daf-core'; +import { IIdentifier } from 'daf-core'; import { IKey } from 'daf-core'; import { IKeyManager } from 'daf-core'; import { IService } from 'daf-core'; // @public -export class EthrIdentityProvider extends AbstractIdentityProvider { +export class EthrDIDProvider extends AbstractIdentifierProvider { constructor(options: { defaultKms: string; network: string; @@ -23,35 +23,35 @@ export class EthrIdentityProvider extends AbstractIdentityProvider { registry?: string; }); // (undocumented) - addKey({ identity, key, options }: { - identity: IIdentity; + addKey({ identifier, key, options }: { + identifier: IIdentifier; key: IKey; options?: any; }, context: IContext): Promise; // (undocumented) - addService({ identity, service, options }: { - identity: IIdentity; + addService({ identifier, service, options }: { + identifier: IIdentifier; service: IService; options?: any; }, context: IContext): Promise; // Warning: (ae-forgotten-export) The symbol "IContext" needs to be exported by the entry point index.d.ts // // (undocumented) - createIdentity({ kms, options }: { + createIdentifier({ kms, options }: { kms?: string; options?: any; - }, context: IContext): Promise>; + }, context: IContext): Promise>; // (undocumented) - deleteIdentity(identity: IIdentity, context: IContext): Promise; + deleteIdentifier(identifier: IIdentifier, context: IContext): Promise; // (undocumented) removeKey(args: { - identity: IIdentity; + identifier: IIdentifier; kid: string; options?: any; }, context: IContext): Promise; // (undocumented) removeService(args: { - identity: IIdentity; + identifier: IIdentifier; id: string; options?: any; }, context: IContext): Promise; diff --git a/packages/daf-ethr-did/src/__tests__/identity-provider.test.ts b/packages/daf-ethr-did/src/__tests__/identity-provider.test.ts index 94d06e692..4b184f792 100644 --- a/packages/daf-ethr-did/src/__tests__/identity-provider.test.ts +++ b/packages/daf-ethr-did/src/__tests__/identity-provider.test.ts @@ -1,7 +1,7 @@ // import SignerProvider from 'ethjs-provider-signer' // import { DafResolver } from 'daf-resolver' -// import { IdentityProvider } from '../identity-provider' -// import { Identity } from '../identity' +// import { IdentifierProvider } from '../identifier-provider' +// import { Identifier } from '../identifier' // import { createJWT, decodeJWT, verifyJWT } from 'did-jwt' // const fs = require('fs') @@ -31,7 +31,7 @@ describe('dummy', () => { // const fileName = './store.json' // const network = 'rinkeby' -// const identityProvider = new IdentityProvider({ +// const identifierProvider = new IdentifierProvider({ // fileName, // network, // resolver, @@ -42,32 +42,32 @@ describe('dummy', () => { // fs.unlinkSync(fileName) // }) -// it('should create identity', async () => { -// const identity = await identityProvider.createIdentity() -// expect(identity).toBeInstanceOf(Identity) +// it('should create identifier', async () => { +// const identifier = await identifierProvider.createIdentifier() +// expect(identifier).toBeInstanceOf(Identifier) // }) -// it('identity signs jwt', async () => { -// const identity = await identityProvider.createIdentity() +// it('identifier signs jwt', async () => { +// const identifier = await identifierProvider.createIdentifier() // const jwt = await createJWT( // { a: 'b' }, // { // alg: 'ES256K-R', -// issuer: identity.did, -// signer: identity.signer(), +// issuer: identifier.did, +// signer: identifier.signer(), // }, // ) // const decoded = await verifyJWT(jwt, { resolver }) -// expect(decoded.payload.iss).toEqual(identity.did) +// expect(decoded.payload.iss).toEqual(identifier.did) // }) -// it('imported identity adds serviceEndpoint', async () => { +// it('imported identifier adds serviceEndpoint', async () => { -// const identity = await identityProvider.importIdentity(JSON.stringify(serialized)) +// const identifier = await identifierProvider.importIdentifier(JSON.stringify(serialized)) -// const result = await identityProvider.addService(identity.did, { +// const result = await identifierProvider.addService(identifier.did, { // id: 'srvc5', // type: 'Messaging', // serviceEndpoint: 'https://localhos/msg/6789', @@ -77,21 +77,21 @@ describe('dummy', () => { // expect(result).toBeTruthy() // }) -// it('imported identity adds Secp256k1 publicKey', async () => { +// it('imported identifier adds Secp256k1 publicKey', async () => { -// const identity = await identityProvider.importIdentity(JSON.stringify(serialized)) +// const identifier = await identifierProvider.importIdentifier(JSON.stringify(serialized)) -// const result = await identityProvider.addPublicKey(identity.did, 'Secp256k1') +// const result = await identifierProvider.addPublicKey(identifier.did, 'Secp256k1') // console.log(result) // expect(result).toBeTruthy() // }) -// it('imported identity adds Ed25519 publicKey', async () => { +// it('imported identifier adds Ed25519 publicKey', async () => { -// const identity = await identityProvider.importIdentity(JSON.stringify(serialized)) +// const identifier = await identifierProvider.importIdentifier(JSON.stringify(serialized)) -// const result = await identityProvider.addPublicKey(identity.did, 'Ed25519') +// const result = await identifierProvider.addPublicKey(identifier.did, 'Ed25519') // console.log(result) // expect(result).toBeTruthy() diff --git a/packages/daf-ethr-did/src/identity-provider.ts b/packages/daf-ethr-did/src/identifier-provider.ts similarity index 70% rename from packages/daf-ethr-did/src/identity-provider.ts rename to packages/daf-ethr-did/src/identifier-provider.ts index 719425d71..9b7779f1c 100644 --- a/packages/daf-ethr-did/src/identity-provider.ts +++ b/packages/daf-ethr-did/src/identifier-provider.ts @@ -1,10 +1,10 @@ -import { IIdentity, IKey, IService, IAgentContext, IKeyManager } from 'daf-core' -import { AbstractIdentityProvider } from 'daf-identity-manager' +import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from 'daf-core' +import { AbstractIdentifierProvider } from 'daf-identity-manager' import { keccak_256 } from 'js-sha3' import Debug from 'debug' const EthrDID = require('ethr-did') const SignerProvider = require('ethjs-provider-signer') -const debug = Debug('daf:ethr-did:identity-provider') +const debug = Debug('daf:ethr-did:identifier-provider') type IContext = IAgentContext @@ -19,10 +19,10 @@ export function toEthereumAddress(hexPublicKey: string): string { } /** - * {@link daf-identity-manager#IdentityManager} identity provider for `did:ethr` identities + * {@link daf-identity-manager#DIDManager} identifier provider for `did:ethr` identifiers * @public */ -export class EthrIdentityProvider extends AbstractIdentityProvider { +export class EthrDIDProvider extends AbstractIdentifierProvider { private defaultKms: string private network: string private web3Provider?: any @@ -50,30 +50,30 @@ export class EthrIdentityProvider extends AbstractIdentityProvider { this.registry = options.registry } - async createIdentity( + async createIdentifier( { kms, options }: { kms?: string; options?: any }, context: IContext, - ): Promise> { - const key = await context.agent.keyManagerCreateKey({ kms: kms || this.defaultKms, type: 'Secp256k1' }) + ): Promise> { + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) const address = toEthereumAddress(key.publicKeyHex) - const identity: Omit = { + const identifier: Omit = { did: 'did:ethr:' + (this.network !== 'mainnet' ? this.network + ':' : '') + address, controllerKeyId: key.kid, keys: [key], services: [], } - debug('Created', identity.did) - return identity + debug('Created', identifier.did) + return identifier } - async deleteIdentity(identity: IIdentity, context: IContext): Promise { - for (const { kid } of identity.keys) { - await context.agent.keyManagerDeleteKey({ kid }) + async deleteIdentifier(identifier: IIdentifier, context: IContext): Promise { + for (const { kid } of identifier.keys) { + await context.agent.keyManagerDelete({ kid }) } return true } - private getWeb3Provider({ controllerKeyId }: IIdentity, context: IContext) { + private getWeb3Provider({ controllerKeyId }: IIdentifier, context: IContext) { if (!this.web3Provider && !this.rpcUrl) throw Error('Web3Provider or rpcUrl required') if (!controllerKeyId) throw Error('ControllerKeyId does not exist') @@ -94,13 +94,13 @@ export class EthrIdentityProvider extends AbstractIdentityProvider { } async addKey( - { identity, key, options }: { identity: IIdentity; key: IKey; options?: any }, + { identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any }, context: IContext, ): Promise { - const address = identity.did.split(':').pop() + const address = identifier.did.split(':').pop() const ethrDid = new EthrDID({ address, - provider: this.getWeb3Provider(identity, context), + provider: this.getWeb3Provider(identifier, context), registry: this.registry, }) @@ -118,12 +118,12 @@ export class EthrIdentityProvider extends AbstractIdentityProvider { } async addService( - { identity, service, options }: { identity: IIdentity; service: IService; options?: any }, + { identifier, service, options }: { identifier: IIdentifier; service: IService; options?: any }, context: IContext, ): Promise { const ethrDid = new EthrDID({ - address: identity.did.split(':').pop(), - provider: this.getWeb3Provider(identity, context), + address: identifier.did.split(':').pop(), + provider: this.getWeb3Provider(identifier, context), registry: this.registry, }) @@ -140,14 +140,14 @@ export class EthrIdentityProvider extends AbstractIdentityProvider { } async removeKey( - args: { identity: IIdentity; kid: string; options?: any }, + args: { identifier: IIdentifier; kid: string; options?: any }, context: IContext, ): Promise { throw Error('Not implemented') } async removeService( - args: { identity: IIdentity; id: string; options?: any }, + args: { identifier: IIdentifier; id: string; options?: any }, context: IContext, ): Promise { throw Error('Not implemented') diff --git a/packages/daf-ethr-did/src/index.ts b/packages/daf-ethr-did/src/index.ts index ba912408a..a56009a64 100644 --- a/packages/daf-ethr-did/src/index.ts +++ b/packages/daf-ethr-did/src/index.ts @@ -1,6 +1,6 @@ /** - * Provides `did:ethr` {@link daf-ethr-did#EthrIdentityProvider | identity provider } for the {@link daf-identity-manager#IdentityManager} + * Provides `did:ethr` {@link daf-ethr-did#EthrDIDProvider | identifier provider } for the {@link daf-identity-manager#DIDManager} * * @packageDocumentation */ -export { EthrIdentityProvider } from './identity-provider' +export { EthrDIDProvider } from './identifier-provider' diff --git a/packages/daf-express/api/daf-express.api.md b/packages/daf-express/api/daf-express.api.md index 53cf2a293..8fccd74f5 100644 --- a/packages/daf-express/api/daf-express.api.md +++ b/packages/daf-express/api/daf-express.api.md @@ -5,7 +5,7 @@ ```ts import { IAgent } from 'daf-core'; -import { IIdentityManager } from 'daf-core'; +import { IDIDManager } from 'daf-core'; import { Request as Request_2 } from 'express'; import { Router } from 'express'; import { TAgent } from 'daf-core'; @@ -40,7 +40,7 @@ export const WebDidDocRouter: (options: WebDidDocRouterOptions) => Router; // @public (undocumented) export interface WebDidDocRouterOptions { - getAgentForRequest: (req: Request_2) => Promise>; + getAgentForRequest: (req: Request_2) => Promise>; } diff --git a/packages/daf-express/src/web-did-doc-router.ts b/packages/daf-express/src/web-did-doc-router.ts index 058b3ac0b..6a75482c7 100644 --- a/packages/daf-express/src/web-did-doc-router.ts +++ b/packages/daf-express/src/web-did-doc-router.ts @@ -1,8 +1,8 @@ -import { IAgent, IIdentity, IIdentityManager, TAgent } from 'daf-core' +import { IAgent, IIdentifier, IDIDManager, TAgent } from 'daf-core' import { Request, Router } from 'express' -interface RequestWithAgentIdentityManager extends Request { - agent?: TAgent +interface RequestWithAgentDIDManager extends Request { + agent?: TAgent } interface RequestWithAgent extends Request { @@ -17,7 +17,7 @@ export interface WebDidDocRouterOptions { /** * Function that returns configured agent for specific request */ - getAgentForRequest: (req: Request) => Promise> + getAgentForRequest: (req: Request) => Promise> } /** * Creates a router that serves `did:web` DID Documents @@ -32,36 +32,36 @@ export const WebDidDocRouter = (options: WebDidDocRouterOptions): Router => { next() }) - const didDocForIdentity = (identity: IIdentity) => { + const didDocForIdentifier = (identifier: IIdentifier) => { const didDoc = { '@context': 'https://w3id.org/did/v1', - id: identity.did, - publicKey: identity.keys.map((key) => ({ - id: identity.did + '#' + key.kid, + id: identifier.did, + publicKey: identifier.keys.map((key) => ({ + id: identifier.did + '#' + key.kid, type: key.type === 'Secp256k1' ? 'Secp256k1VerificationKey2018' : 'Ed25519VerificationKey2018', - controller: identity.did, + controller: identifier.did, publicKeyHex: key.publicKeyHex, })), - authentication: identity.keys.map((key) => ({ + authentication: identifier.keys.map((key) => ({ type: key.type === 'Secp256k1' ? 'Secp256k1SignatureAuthentication2018' : 'Ed25519SignatureAuthentication2018', - publicKey: identity.did + '#' + key.kid, + publicKey: identifier.did + '#' + key.kid, })), - service: identity.services, + service: identifier.services, } return didDoc } - router.get(didDocEndpoint, async (req: RequestWithAgentIdentityManager, res) => { + router.get(didDocEndpoint, async (req: RequestWithAgentDIDManager, res) => { if (req.agent) { try { - const serverIdentity = await req.agent.identityManagerGetIdentity({ + const serverIdentifier = await req.agent.didManagerGet({ did: 'did:web:' + req.hostname, }) - const didDoc = didDocForIdentity(serverIdentity) + const didDoc = didDocForIdentifier(serverIdentifier) res.json(didDoc) } catch (e) { res.status(404).send(e) @@ -69,13 +69,13 @@ export const WebDidDocRouter = (options: WebDidDocRouterOptions): Router => { } }) - router.get(/^\/(.+)\/did.json$/, async (req: RequestWithAgentIdentityManager, res) => { + router.get(/^\/(.+)\/did.json$/, async (req: RequestWithAgentDIDManager, res) => { if (req.agent) { try { - const identity = await req.agent.identityManagerGetIdentity({ + const identifier = await req.agent.didManagerGet({ did: 'did:web:' + req.hostname + ':' + req.params[0].replace('/', ':'), }) - const didDoc = didDocForIdentity(identity) + const didDoc = didDocForIdentifier(identifier) res.json(didDoc) } catch (e) { res.status(404).send(e) diff --git a/packages/daf-identity-manager/api/daf-identity-manager.api.md b/packages/daf-identity-manager/api/daf-identity-manager.api.md index 82800dfc4..a1181801f 100644 --- a/packages/daf-identity-manager/api/daf-identity-manager.api.md +++ b/packages/daf-identity-manager/api/daf-identity-manager.api.md @@ -6,117 +6,117 @@ import { IAgentContext } from 'daf-core'; import { IAgentPlugin } from 'daf-core'; -import { IIdentity } from 'daf-core'; -import { IIdentityManager } from 'daf-core'; -import { IIdentityManagerAddKeyArgs } from 'daf-core'; -import { IIdentityManagerAddServiceArgs } from 'daf-core'; -import { IIdentityManagerCreateIdentityArgs } from 'daf-core'; -import { IIdentityManagerDeleteIdentityArgs } from 'daf-core'; -import { IIdentityManagerGetIdentitiesArgs } from 'daf-core'; -import { IIdentityManagerGetIdentityArgs } from 'daf-core'; -import { IIdentityManagerGetIdentityByAliasArgs } from 'daf-core'; -import { IIdentityManagerGetOrCreateIdentityArgs } from 'daf-core'; -import { IIdentityManagerRemoveKeyArgs } from 'daf-core'; -import { IIdentityManagerRemoveServiceArgs } from 'daf-core'; -import { IIdentityManagerSetAliasArgs } from 'daf-core'; +import { IDIDManager } from 'daf-core'; +import { IDIDManagerAddKeyArgs } from 'daf-core'; +import { IDIDManagerAddServiceArgs } from 'daf-core'; +import { IDIDManagerCreateArgs } from 'daf-core'; +import { IDIDManagerDeleteArgs } from 'daf-core'; +import { IDIDManagerFindArgs } from 'daf-core'; +import { IDIDManagerGetArgs } from 'daf-core'; +import { IDIDManagerGetByAliasArgs } from 'daf-core'; +import { IDIDManagerGetOrCreateArgs } from 'daf-core'; +import { IDIDManagerRemoveKeyArgs } from 'daf-core'; +import { IDIDManagerRemoveServiceArgs } from 'daf-core'; +import { IDIDManagerSetAliasArgs } from 'daf-core'; +import { IIdentifier } from 'daf-core'; import { IKey } from 'daf-core'; import { IKeyManager } from 'daf-core'; import { IService } from 'daf-core'; // @public -export abstract class AbstractIdentityProvider { +export abstract class AbstractDIDStore { + // (undocumented) + abstract delete(args: { + did: string; + }): Promise; + // (undocumented) + abstract get(args: { + did: string; + }): Promise; + // (undocumented) + abstract get(args: { + alias: string; + provider: string; + }): Promise; + // (undocumented) + abstract import(args: IIdentifier): Promise; + // (undocumented) + abstract list(args: { + alias?: string; + provider?: string; + }): Promise; +} + +// @public +export abstract class AbstractIdentifierProvider { // (undocumented) abstract addKey(args: { - identity: IIdentity; + identifier: IIdentifier; key: IKey; options?: any; }, context: IAgentContext): Promise; // (undocumented) abstract addService(args: { - identity: IIdentity; + identifier: IIdentifier; service: IService; options?: any; }, context: IAgentContext): Promise; // (undocumented) - abstract createIdentity(args: { + abstract createIdentifier(args: { kms?: string; alias?: string; options?: any; - }, context: IAgentContext): Promise>; + }, context: IAgentContext): Promise>; // (undocumented) - abstract deleteIdentity(args: IIdentity, context: IAgentContext): Promise; + abstract deleteIdentifier(args: IIdentifier, context: IAgentContext): Promise; // (undocumented) abstract removeKey(args: { - identity: IIdentity; + identifier: IIdentifier; kid: string; options?: any; }, context: IAgentContext): Promise; // (undocumented) abstract removeService(args: { - identity: IIdentity; + identifier: IIdentifier; id: string; options?: any; }, context: IAgentContext): Promise; } // @public -export abstract class AbstractIdentityStore { - // (undocumented) - abstract delete(args: { - did: string; - }): Promise; - // (undocumented) - abstract get(args: { - did: string; - }): Promise; - // (undocumented) - abstract get(args: { - alias: string; - provider: string; - }): Promise; - // (undocumented) - abstract import(args: IIdentity): Promise; - // (undocumented) - abstract list(args: { - alias?: string; - provider?: string; - }): Promise; -} - -// @public -export class IdentityManager implements IAgentPlugin { +export class DIDManager implements IAgentPlugin { constructor(options: { - providers: Record; + providers: Record; defaultProvider: string; - store: AbstractIdentityStore; + store: AbstractDIDStore; }); // (undocumented) - identityManagerAddKey({ did, key, options }: IIdentityManagerAddKeyArgs, context: IAgentContext): Promise; + didManagerAddKey({ did, key, options }: IDIDManagerAddKeyArgs, context: IAgentContext): Promise; // (undocumented) - identityManagerAddService({ did, service, options }: IIdentityManagerAddServiceArgs, context: IAgentContext): Promise; + didManagerAddService({ did, service, options }: IDIDManagerAddServiceArgs, context: IAgentContext): Promise; // (undocumented) - identityManagerCreateIdentity(args: IIdentityManagerCreateIdentityArgs, context: IAgentContext): Promise; + didManagerCreate(args: IDIDManagerCreateArgs, context: IAgentContext): Promise; // (undocumented) - identityManagerDeleteIdentity({ did }: IIdentityManagerDeleteIdentityArgs, context: IAgentContext): Promise; + didManagerDelete({ did }: IDIDManagerDeleteArgs, context: IAgentContext): Promise; // (undocumented) - identityManagerGetIdentities(args: IIdentityManagerGetIdentitiesArgs): Promise; + didManagerFind(args: IDIDManagerFindArgs): Promise; // (undocumented) - identityManagerGetIdentity({ did }: IIdentityManagerGetIdentityArgs): Promise; + didManagerGet({ did }: IDIDManagerGetArgs): Promise; // (undocumented) - identityManagerGetIdentityByAlias({ alias, provider, }: IIdentityManagerGetIdentityByAliasArgs): Promise; + didManagerGetByAlias({ alias, provider }: IDIDManagerGetByAliasArgs): Promise; // (undocumented) - identityManagerGetOrCreateIdentity({ provider, alias, kms, options }: IIdentityManagerGetOrCreateIdentityArgs, context: IAgentContext): Promise; + didManagerGetOrCreate({ provider, alias, kms, options }: IDIDManagerGetOrCreateArgs, context: IAgentContext): Promise; // (undocumented) - identityManagerGetProviders(): Promise; + didManagerGetProviders(): Promise; // (undocumented) - identityManagerImportIdentity(identity: IIdentity, context: IAgentContext): Promise; + didManagerImport(identifier: IIdentifier, context: IAgentContext): Promise; // (undocumented) - identityManagerRemoveKey({ did, kid, options }: IIdentityManagerRemoveKeyArgs, context: IAgentContext): Promise; + didManagerRemoveKey({ did, kid, options }: IDIDManagerRemoveKeyArgs, context: IAgentContext): Promise; // (undocumented) - identityManagerRemoveService({ did, id, options }: IIdentityManagerRemoveServiceArgs, context: IAgentContext): Promise; + didManagerRemoveService({ did, id, options }: IDIDManagerRemoveServiceArgs, context: IAgentContext): Promise; // (undocumented) - identityManagerSetAlias({ did, alias }: IIdentityManagerSetAliasArgs, context: IAgentContext): Promise; - readonly methods: IIdentityManager; + didManagerSetAlias({ did, alias }: IDIDManagerSetAliasArgs, context: IAgentContext): Promise; + readonly methods: IDIDManager; // (undocumented) readonly schema: any; } diff --git a/packages/daf-identity-manager/src/abstract-identifier-provider.ts b/packages/daf-identity-manager/src/abstract-identifier-provider.ts new file mode 100644 index 000000000..491f450b3 --- /dev/null +++ b/packages/daf-identity-manager/src/abstract-identifier-provider.ts @@ -0,0 +1,29 @@ +import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from 'daf-core' + +/** + * An abstract class for the {@link daf-identity-manager#DIDManager} identifier providers + * @public + */ +export abstract class AbstractIdentifierProvider { + abstract createIdentifier( + args: { kms?: string; alias?: string; options?: any }, + context: IAgentContext, + ): Promise> + abstract deleteIdentifier(args: IIdentifier, context: IAgentContext): Promise + abstract addKey( + args: { identifier: IIdentifier; key: IKey; options?: any }, + context: IAgentContext, + ): Promise + abstract removeKey( + args: { identifier: IIdentifier; kid: string; options?: any }, + context: IAgentContext, + ): Promise + abstract addService( + args: { identifier: IIdentifier; service: IService; options?: any }, + context: IAgentContext, + ): Promise + abstract removeService( + args: { identifier: IIdentifier; id: string; options?: any }, + context: IAgentContext, + ): Promise +} diff --git a/packages/daf-identity-manager/src/abstract-identifier-store.ts b/packages/daf-identity-manager/src/abstract-identifier-store.ts new file mode 100644 index 000000000..5e2683a14 --- /dev/null +++ b/packages/daf-identity-manager/src/abstract-identifier-store.ts @@ -0,0 +1,13 @@ +import { IIdentifier } from 'daf-core' + +/** + * An abstract class for the {@link daf-identity-manager#DIDManager} identifier store + * @public + */ +export abstract class AbstractDIDStore { + abstract import(args: IIdentifier): Promise + abstract get(args: { did: string }): Promise + abstract get(args: { alias: string; provider: string }): Promise + abstract delete(args: { did: string }): Promise + abstract list(args: { alias?: string; provider?: string }): Promise +} diff --git a/packages/daf-identity-manager/src/abstract-identity-provider.ts b/packages/daf-identity-manager/src/abstract-identity-provider.ts deleted file mode 100644 index cbc57a8ac..000000000 --- a/packages/daf-identity-manager/src/abstract-identity-provider.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { IIdentity, IKey, IService, IAgentContext, IKeyManager } from 'daf-core' - -/** - * An abstract class for the {@link daf-identity-manager#IdentityManager} identity providers - * @public - */ -export abstract class AbstractIdentityProvider { - abstract createIdentity( - args: { kms?: string; alias?: string; options?: any }, - context: IAgentContext, - ): Promise> - abstract deleteIdentity(args: IIdentity, context: IAgentContext): Promise - abstract addKey( - args: { identity: IIdentity; key: IKey; options?: any }, - context: IAgentContext, - ): Promise - abstract removeKey( - args: { identity: IIdentity; kid: string; options?: any }, - context: IAgentContext, - ): Promise - abstract addService( - args: { identity: IIdentity; service: IService; options?: any }, - context: IAgentContext, - ): Promise - abstract removeService( - args: { identity: IIdentity; id: string; options?: any }, - context: IAgentContext, - ): Promise -} diff --git a/packages/daf-identity-manager/src/abstract-identity-store.ts b/packages/daf-identity-manager/src/abstract-identity-store.ts deleted file mode 100644 index 0dcc2d717..000000000 --- a/packages/daf-identity-manager/src/abstract-identity-store.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { IIdentity } from 'daf-core' - -/** - * An abstract class for the {@link daf-identity-manager#IdentityManager} identity store - * @public - */ -export abstract class AbstractIdentityStore { - abstract import(args: IIdentity): Promise - abstract get(args: { did: string }): Promise - abstract get(args: { alias: string; provider: string }): Promise - abstract delete(args: { did: string }): Promise - abstract list(args: { alias?: string; provider?: string }): Promise -} diff --git a/packages/daf-identity-manager/src/id-manager.ts b/packages/daf-identity-manager/src/id-manager.ts new file mode 100644 index 000000000..216d840e6 --- /dev/null +++ b/packages/daf-identity-manager/src/id-manager.ts @@ -0,0 +1,217 @@ +import { AbstractIdentifierProvider } from './abstract-identifier-provider' +import { + IAgentPlugin, + IIdentifier, + IAgentContext, + IDIDManager, + IKeyManager, + IDIDManagerGetArgs, + IDIDManagerCreateArgs, + IDIDManagerGetByAliasArgs, + IDIDManagerGetOrCreateArgs, + IDIDManagerDeleteArgs, + IDIDManagerAddKeyArgs, + IDIDManagerRemoveKeyArgs, + IDIDManagerAddServiceArgs, + IDIDManagerRemoveServiceArgs, + IDIDManagerFindArgs, + IDIDManagerSetAliasArgs, + schema, +} from 'daf-core' +import { AbstractDIDStore } from './abstract-identifier-store' + +/** + * Agent plugin that implements {@link daf-core#IDIDManager} interface + * @public + */ +export class DIDManager implements IAgentPlugin { + /** + * Plugin methods + * @public + */ + readonly methods: IDIDManager + readonly schema = schema.IDIDManager + + private providers: Record + private defaultProvider: string + private store: AbstractDIDStore + + constructor(options: { + providers: Record + defaultProvider: string + store: AbstractDIDStore + }) { + this.providers = options.providers + this.defaultProvider = options.defaultProvider + this.store = options.store + this.methods = { + didManagerGetProviders: this.didManagerGetProviders.bind(this), + didManagerFind: this.didManagerFind.bind(this), + didManagerGet: this.didManagerGet.bind(this), + didManagerGetByAlias: this.didManagerGetByAlias.bind(this), + didManagerCreate: this.didManagerCreate.bind(this), + didManagerSetAlias: this.didManagerSetAlias.bind(this), + didManagerGetOrCreate: this.didManagerGetOrCreate.bind(this), + didManagerImport: this.didManagerImport.bind(this), + didManagerDelete: this.didManagerDelete.bind(this), + didManagerAddKey: this.didManagerAddKey.bind(this), + didManagerRemoveKey: this.didManagerRemoveKey.bind(this), + didManagerAddService: this.didManagerAddService.bind(this), + didManagerRemoveService: this.didManagerRemoveService.bind(this), + } + } + + private getProvider(name: string): AbstractIdentifierProvider { + const provider = this.providers[name] + if (!provider) throw Error('Identifier provider does not exist: ' + name) + return provider + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerGetProviders} */ + async didManagerGetProviders(): Promise { + return Object.keys(this.providers) + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerFind} */ + async didManagerFind(args: IDIDManagerFindArgs): Promise { + return this.store.list(args) + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerGet} */ + async didManagerGet({ did }: IDIDManagerGetArgs): Promise { + return this.store.get({ did }) + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerGetByAlias} */ + async didManagerGetByAlias({ alias, provider }: IDIDManagerGetByAliasArgs): Promise { + const providerName = provider || this.defaultProvider + return this.store.get({ alias, provider: providerName }) + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerCreate} */ + async didManagerCreate( + args: IDIDManagerCreateArgs, + context: IAgentContext, + ): Promise { + const providerName = args?.provider || this.defaultProvider + if (args?.alias !== undefined) { + let existingIdentifier + try { + existingIdentifier = await this.store.get({ alias: args.alias, provider: providerName }) + } catch (e) {} + if (existingIdentifier) { + throw Error(`Identifier with alias: ${args.alias}, provider: ${providerName} already exists`) + } + } + const identifierProvider = this.getProvider(providerName) + const partialIdentifier = await identifierProvider.createIdentifier( + { kms: args?.kms, alias: args?.alias, options: args?.options }, + context, + ) + const identifier: IIdentifier = { ...partialIdentifier, provider: providerName } + if (args?.alias) { + identifier.alias = args.alias + } + await this.store.import(identifier) + return identifier + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerGetOrCreate} */ + async didManagerGetOrCreate( + { provider, alias, kms, options }: IDIDManagerGetOrCreateArgs, + context: IAgentContext, + ): Promise { + try { + const providerName = provider || this.defaultProvider + const identifier = await this.store.get({ alias, provider: providerName }) + return identifier + } catch { + return this.didManagerCreate({ provider, alias, kms, options }, context) + } + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerSetAlias} */ + async didManagerSetAlias( + { did, alias }: IDIDManagerSetAliasArgs, + context: IAgentContext, + ): Promise { + const identifier = await this.store.get({ did }) + identifier.alias = alias + return await this.store.import(identifier) + } + /** {@inheritDoc daf-core#IDIDManager.didManagerImport} */ + async didManagerImport(identifier: IIdentifier, context: IAgentContext): Promise { + for (const key of identifier.keys) { + await context.agent.keyManagerImport(key) + } + await this.store.import(identifier) + return identifier + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerDelete} */ + async didManagerDelete( + { did }: IDIDManagerDeleteArgs, + context: IAgentContext, + ): Promise { + const identifier = await this.store.get({ did }) + const provider = this.getProvider(identifier.provider) + await provider.deleteIdentifier(identifier, context) + if (identifier.services.length > 0) { + identifier.services = [] + await this.store.import(identifier) + } + return this.store.delete({ did }) + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerAddKey} */ + async didManagerAddKey( + { did, key, options }: IDIDManagerAddKeyArgs, + context: IAgentContext, + ): Promise { + const identifier = await this.store.get({ did }) + const provider = this.getProvider(identifier.provider) + const result = await provider.addKey({ identifier, key, options }, context) + identifier.keys.push(key) + await this.store.import(identifier) + return result + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerRemoveKey} */ + async didManagerRemoveKey( + { did, kid, options }: IDIDManagerRemoveKeyArgs, + context: IAgentContext, + ): Promise { + const identifier = await this.store.get({ did }) + const provider = this.getProvider(identifier.provider) + const result = await provider.removeKey({ identifier, kid, options }, context) + identifier.keys = identifier.keys.filter((k) => k.kid !== kid) + await this.store.import(identifier) + return result + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerAddService} */ + async didManagerAddService( + { did, service, options }: IDIDManagerAddServiceArgs, + context: IAgentContext, + ): Promise { + const identifier = await this.store.get({ did }) + const provider = this.getProvider(identifier.provider) + const result = await provider.addService({ identifier, service, options }, context) + identifier.services.push(service) + await this.store.import(identifier) + return result + } + + /** {@inheritDoc daf-core#IDIDManager.didManagerRemoveService} */ + async didManagerRemoveService( + { did, id, options }: IDIDManagerRemoveServiceArgs, + context: IAgentContext, + ): Promise { + const identifier = await this.store.get({ did }) + const provider = this.getProvider(identifier.provider) + const result = await provider.removeService({ identifier, id, options }, context) + identifier.services = identifier.services.filter((s) => s.id !== id) + await this.store.import(identifier) + return result + } +} diff --git a/packages/daf-identity-manager/src/identity-manager.ts b/packages/daf-identity-manager/src/identity-manager.ts deleted file mode 100644 index 006a4cbfb..000000000 --- a/packages/daf-identity-manager/src/identity-manager.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { AbstractIdentityProvider } from './abstract-identity-provider' -import { - IAgentPlugin, - IIdentity, - IAgentContext, - IIdentityManager, - IKeyManager, - IIdentityManagerGetIdentityArgs, - IIdentityManagerCreateIdentityArgs, - IIdentityManagerGetIdentityByAliasArgs, - IIdentityManagerGetOrCreateIdentityArgs, - IIdentityManagerDeleteIdentityArgs, - IIdentityManagerAddKeyArgs, - IIdentityManagerRemoveKeyArgs, - IIdentityManagerAddServiceArgs, - IIdentityManagerRemoveServiceArgs, - IIdentityManagerGetIdentitiesArgs, - IIdentityManagerSetAliasArgs, - schema, -} from 'daf-core' -import { AbstractIdentityStore } from './abstract-identity-store' - -/** - * Agent plugin that implements {@link daf-core#IIdentityManager} interface - * @public - */ -export class IdentityManager implements IAgentPlugin { - /** - * Plugin methods - * @public - */ - readonly methods: IIdentityManager - readonly schema = schema.IIdentityManager - - private providers: Record - private defaultProvider: string - private store: AbstractIdentityStore - - constructor(options: { - providers: Record - defaultProvider: string - store: AbstractIdentityStore - }) { - this.providers = options.providers - this.defaultProvider = options.defaultProvider - this.store = options.store - this.methods = { - identityManagerGetProviders: this.identityManagerGetProviders.bind(this), - identityManagerGetIdentities: this.identityManagerGetIdentities.bind(this), - identityManagerGetIdentity: this.identityManagerGetIdentity.bind(this), - identityManagerGetIdentityByAlias: this.identityManagerGetIdentityByAlias.bind(this), - identityManagerCreateIdentity: this.identityManagerCreateIdentity.bind(this), - identityManagerSetAlias: this.identityManagerSetAlias.bind(this), - identityManagerGetOrCreateIdentity: this.identityManagerGetOrCreateIdentity.bind(this), - identityManagerImportIdentity: this.identityManagerImportIdentity.bind(this), - identityManagerDeleteIdentity: this.identityManagerDeleteIdentity.bind(this), - identityManagerAddKey: this.identityManagerAddKey.bind(this), - identityManagerRemoveKey: this.identityManagerRemoveKey.bind(this), - identityManagerAddService: this.identityManagerAddService.bind(this), - identityManagerRemoveService: this.identityManagerRemoveService.bind(this), - } - } - - private getProvider(name: string): AbstractIdentityProvider { - const provider = this.providers[name] - if (!provider) throw Error('Identity provider does not exist: ' + name) - return provider - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerGetProviders} */ - async identityManagerGetProviders(): Promise { - return Object.keys(this.providers) - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerGetIdentities} */ - async identityManagerGetIdentities(args: IIdentityManagerGetIdentitiesArgs): Promise { - return this.store.list(args) - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerGetIdentity} */ - async identityManagerGetIdentity({ did }: IIdentityManagerGetIdentityArgs): Promise { - return this.store.get({ did }) - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerGetIdentityByAlias} */ - async identityManagerGetIdentityByAlias({ - alias, - provider, - }: IIdentityManagerGetIdentityByAliasArgs): Promise { - const providerName = provider || this.defaultProvider - return this.store.get({ alias, provider: providerName }) - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerCreateIdentity} */ - async identityManagerCreateIdentity( - args: IIdentityManagerCreateIdentityArgs, - context: IAgentContext, - ): Promise { - const providerName = args?.provider || this.defaultProvider - if (args?.alias !== undefined) { - let existingIdentity - try { - existingIdentity = await this.store.get({ alias: args.alias, provider: providerName }) - } catch (e) {} - if (existingIdentity) { - throw Error(`Identity with alias: ${args.alias}, provider: ${providerName} already exists`) - } - } - const identityProvider = this.getProvider(providerName) - const partialIdentity = await identityProvider.createIdentity( - { kms: args?.kms, alias: args?.alias, options: args?.options }, - context, - ) - const identity: IIdentity = { ...partialIdentity, provider: providerName } - if (args?.alias) { - identity.alias = args.alias - } - await this.store.import(identity) - return identity - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerGetOrCreateIdentity} */ - async identityManagerGetOrCreateIdentity( - { provider, alias, kms, options }: IIdentityManagerGetOrCreateIdentityArgs, - context: IAgentContext, - ): Promise { - try { - const providerName = provider || this.defaultProvider - const identity = await this.store.get({ alias, provider: providerName }) - return identity - } catch { - return this.identityManagerCreateIdentity({ provider, alias, kms, options }, context) - } - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerSetAlias} */ - async identityManagerSetAlias( - { did, alias }: IIdentityManagerSetAliasArgs, - context: IAgentContext, - ): Promise { - const identity = await this.store.get({ did }) - identity.alias = alias - return await this.store.import(identity) - } - /** {@inheritDoc daf-core#IIdentityManager.identityManagerImportIdentity} */ - async identityManagerImportIdentity( - identity: IIdentity, - context: IAgentContext, - ): Promise { - for (const key of identity.keys) { - await context.agent.keyManagerImportKey(key) - } - await this.store.import(identity) - return identity - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerDeleteIdentity} */ - async identityManagerDeleteIdentity( - { did }: IIdentityManagerDeleteIdentityArgs, - context: IAgentContext, - ): Promise { - const identity = await this.store.get({ did }) - const provider = this.getProvider(identity.provider) - await provider.deleteIdentity(identity, context) - if (identity.services.length > 0) { - identity.services = [] - await this.store.import(identity) - } - return this.store.delete({ did }) - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerAddKey} */ - async identityManagerAddKey( - { did, key, options }: IIdentityManagerAddKeyArgs, - context: IAgentContext, - ): Promise { - const identity = await this.store.get({ did }) - const provider = this.getProvider(identity.provider) - const result = await provider.addKey({ identity, key, options }, context) - identity.keys.push(key) - await this.store.import(identity) - return result - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerRemoveKey} */ - async identityManagerRemoveKey( - { did, kid, options }: IIdentityManagerRemoveKeyArgs, - context: IAgentContext, - ): Promise { - const identity = await this.store.get({ did }) - const provider = this.getProvider(identity.provider) - const result = await provider.removeKey({ identity, kid, options }, context) - identity.keys = identity.keys.filter((k) => k.kid !== kid) - await this.store.import(identity) - return result - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerAddService} */ - async identityManagerAddService( - { did, service, options }: IIdentityManagerAddServiceArgs, - context: IAgentContext, - ): Promise { - const identity = await this.store.get({ did }) - const provider = this.getProvider(identity.provider) - const result = await provider.addService({ identity, service, options }, context) - identity.services.push(service) - await this.store.import(identity) - return result - } - - /** {@inheritDoc daf-core#IIdentityManager.identityManagerRemoveService} */ - async identityManagerRemoveService( - { did, id, options }: IIdentityManagerRemoveServiceArgs, - context: IAgentContext, - ): Promise { - const identity = await this.store.get({ did }) - const provider = this.getProvider(identity.provider) - const result = await provider.removeService({ identity, id, options }, context) - identity.services = identity.services.filter((s) => s.id !== id) - await this.store.import(identity) - return result - } -} diff --git a/packages/daf-identity-manager/src/index.ts b/packages/daf-identity-manager/src/index.ts index 171ab127b..9e886f95c 100644 --- a/packages/daf-identity-manager/src/index.ts +++ b/packages/daf-identity-manager/src/index.ts @@ -1,8 +1,8 @@ /** - * Provides a {@link daf-identity-manager#IdentityManager | plugin} for the {@link daf-core#Agent} that implements {@link daf-core#IIdentityManager} interface + * Provides a {@link daf-identity-manager#DIDManager | plugin} for the {@link daf-core#Agent} that implements {@link daf-core#IDIDManager} interface * * @packageDocumentation */ -export { IdentityManager } from './identity-manager' -export { AbstractIdentityProvider } from './abstract-identity-provider' -export { AbstractIdentityStore } from './abstract-identity-store' +export { DIDManager } from './id-manager' +export { AbstractIdentifierProvider } from './abstract-identifier-provider' +export { AbstractDIDStore } from './abstract-identifier-store' diff --git a/packages/daf-key-manager/api/daf-key-manager.api.md b/packages/daf-key-manager/api/daf-key-manager.api.md index 10fbd026c..5cfe7773b 100644 --- a/packages/daf-key-manager/api/daf-key-manager.api.md +++ b/packages/daf-key-manager/api/daf-key-manager.api.md @@ -8,11 +8,11 @@ import { EcdsaSignature } from 'daf-core'; import { IAgentPlugin } from 'daf-core'; import { IKey } from 'daf-core'; import { IKeyManager } from 'daf-core'; -import { IKeyManagerCreateKeyArgs } from 'daf-core'; +import { IKeyManagerCreateArgs } from 'daf-core'; import { IKeyManagerDecryptJWEArgs } from 'daf-core'; -import { IKeyManagerDeleteKeyArgs } from 'daf-core'; +import { IKeyManagerDeleteArgs } from 'daf-core'; import { IKeyManagerEncryptJWEArgs } from 'daf-core'; -import { IKeyManagerGetKeyArgs } from 'daf-core'; +import { IKeyManagerGetArgs } from 'daf-core'; import { IKeyManagerSignEthTXArgs } from 'daf-core'; import { IKeyManagerSignJWTArgs } from 'daf-core'; import { TKeyType } from 'daf-core'; @@ -80,19 +80,19 @@ export class KeyManager implements IAgentPlugin { kms: Record; }); // (undocumented) - keyManagerCreateKey(args: IKeyManagerCreateKeyArgs): Promise; + keyManagerCreate(args: IKeyManagerCreateArgs): Promise; // (undocumented) keyManagerDecryptJWE({ kid, data }: IKeyManagerDecryptJWEArgs): Promise; // (undocumented) - keyManagerDeleteKey({ kid }: IKeyManagerDeleteKeyArgs): Promise; + keyManagerDelete({ kid }: IKeyManagerDeleteArgs): Promise; // (undocumented) keyManagerEncryptJWE({ kid, to, data }: IKeyManagerEncryptJWEArgs): Promise; // (undocumented) - keyManagerGetKey({ kid }: IKeyManagerGetKeyArgs): Promise; + keyManagerGet({ kid }: IKeyManagerGetArgs): Promise; // (undocumented) keyManagerGetKeyManagementSystems(): Promise>; // (undocumented) - keyManagerImportKey(key: IKey): Promise; + keyManagerImport(key: IKey): Promise; // (undocumented) keyManagerSignEthTX({ kid, transaction }: IKeyManagerSignEthTXArgs): Promise; // (undocumented) diff --git a/packages/daf-key-manager/src/key-manager.ts b/packages/daf-key-manager/src/key-manager.ts index c98655771..d3141e085 100644 --- a/packages/daf-key-manager/src/key-manager.ts +++ b/packages/daf-key-manager/src/key-manager.ts @@ -4,9 +4,9 @@ import { IKey, IKeyManager, IAgentPlugin, - IKeyManagerCreateKeyArgs, - IKeyManagerGetKeyArgs, - IKeyManagerDeleteKeyArgs, + IKeyManagerCreateArgs, + IKeyManagerGetArgs, + IKeyManagerDeleteArgs, IKeyManagerEncryptJWEArgs, IKeyManagerDecryptJWEArgs, IKeyManagerSignJWTArgs, @@ -36,10 +36,10 @@ export class KeyManager implements IAgentPlugin { this.kms = options.kms this.methods = { keyManagerGetKeyManagementSystems: this.keyManagerGetKeyManagementSystems.bind(this), - keyManagerCreateKey: this.keyManagerCreateKey.bind(this), - keyManagerGetKey: this.keyManagerGetKey.bind(this), - keyManagerDeleteKey: this.keyManagerDeleteKey.bind(this), - keyManagerImportKey: this.keyManagerImportKey.bind(this), + keyManagerCreate: this.keyManagerCreate.bind(this), + keyManagerGet: this.keyManagerGet.bind(this), + keyManagerDelete: this.keyManagerDelete.bind(this), + keyManagerImport: this.keyManagerImport.bind(this), keyManagerEncryptJWE: this.keyManagerDecryptJWE.bind(this), keyManagerDecryptJWE: this.keyManagerDecryptJWE.bind(this), keyManagerSignJWT: this.keyManagerSignJWT.bind(this), @@ -58,8 +58,8 @@ export class KeyManager implements IAgentPlugin { return Object.keys(this.kms) } - /** {@inheritDoc daf-core#IKeyManager.keyManagerCreateKey} */ - async keyManagerCreateKey(args: IKeyManagerCreateKeyArgs): Promise { + /** {@inheritDoc daf-core#IKeyManager.keyManagerCreate} */ + async keyManagerCreate(args: IKeyManagerCreateArgs): Promise { const kms = this.getKms(args.kms) const partialKey = await kms.createKey({ type: args.type, meta: args.meta }) const key: IKey = { ...partialKey, kms: args.kms } @@ -73,21 +73,21 @@ export class KeyManager implements IAgentPlugin { return key } - /** {@inheritDoc daf-core#IKeyManager.keyManagerGetKey} */ - async keyManagerGetKey({ kid }: IKeyManagerGetKeyArgs): Promise { + /** {@inheritDoc daf-core#IKeyManager.keyManagerGet} */ + async keyManagerGet({ kid }: IKeyManagerGetArgs): Promise { return this.store.get({ kid }) } - /** {@inheritDoc daf-core#IKeyManager.keyManagerDeleteKey} */ - async keyManagerDeleteKey({ kid }: IKeyManagerDeleteKeyArgs): Promise { + /** {@inheritDoc daf-core#IKeyManager.keyManagerDelete} */ + async keyManagerDelete({ kid }: IKeyManagerDeleteArgs): Promise { const key = await this.store.get({ kid }) const kms = this.getKms(key.kms) await kms.deleteKey({ kid }) return this.store.delete({ kid }) } - /** {@inheritDoc daf-core#IKeyManager.keyManagerImportKey} */ - async keyManagerImportKey(key: IKey): Promise { + /** {@inheritDoc daf-core#IKeyManager.keyManagerImport} */ + async keyManagerImport(key: IKey): Promise { return this.store.import(key) } diff --git a/packages/daf-selective-disclosure/api/daf-selective-disclosure.api.md b/packages/daf-selective-disclosure/api/daf-selective-disclosure.api.md index 5be98394e..f1cc5ebd9 100644 --- a/packages/daf-selective-disclosure/api/daf-selective-disclosure.api.md +++ b/packages/daf-selective-disclosure/api/daf-selective-disclosure.api.md @@ -9,7 +9,7 @@ import { IAgentContext } from 'daf-core'; import { IAgentPlugin } from 'daf-core'; import { ICredentialIssuer } from 'daf-w3c'; import { IDataStoreORM } from 'daf-typeorm'; -import { IIdentityManager } from 'daf-core'; +import { IDIDManager } from 'daf-core'; import { IKeyManager } from 'daf-core'; import { IMessageHandler } from 'daf-core'; import { IPluginMethodMap } from 'daf-core'; @@ -68,9 +68,9 @@ export interface IPresentationValidationResult { // @beta export interface ISelectiveDisclosure extends IPluginMethodMap { // (undocumented) - createProfilePresentation(args: ICreateProfileCredentialsArgs, context: IAgentContext): Promise; + createProfilePresentation(args: ICreateProfileCredentialsArgs, context: IAgentContext): Promise; // (undocumented) - createSelectiveDisclosureRequest(args: ICreateSelectiveDisclosureRequestArgs, context: IAgentContext): Promise; + createSelectiveDisclosureRequest(args: ICreateSelectiveDisclosureRequestArgs, context: IAgentContext): Promise; // (undocumented) getVerifiableCredentialsForSdr(args: IGetVerifiableCredentialsForSdrArgs, context: IAgentContext): Promise>; // (undocumented) @@ -119,8 +119,8 @@ export class SdrMessageHandler extends AbstractMessageHandler { // @beta export class SelectiveDisclosure implements IAgentPlugin { constructor(); - createProfilePresentation(args: ICreateProfileCredentialsArgs, context: IAgentContext): Promise; - createSelectiveDisclosureRequest(args: ICreateSelectiveDisclosureRequestArgs, context: IAgentContext): Promise; + createProfilePresentation(args: ICreateProfileCredentialsArgs, context: IAgentContext): Promise; + createSelectiveDisclosureRequest(args: ICreateSelectiveDisclosureRequestArgs, context: IAgentContext): Promise; getVerifiableCredentialsForSdr(args: IGetVerifiableCredentialsForSdrArgs, context: IAgentContext): Promise; // (undocumented) readonly methods: ISelectiveDisclosure; diff --git a/packages/daf-selective-disclosure/plugin.schema.json b/packages/daf-selective-disclosure/plugin.schema.json index ec13564f7..b5813db01 100644 --- a/packages/daf-selective-disclosure/plugin.schema.json +++ b/packages/daf-selective-disclosure/plugin.schema.json @@ -97,7 +97,7 @@ "verifiableCredential", "proof" ], - "description": "Verifiable Presentation {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "VerifiableCredential": { "type": "object", @@ -174,7 +174,7 @@ "credentialSubject", "proof" ], - "description": "Verifiable Credential {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "ICreateSelectiveDisclosureRequestArgs": { "type": "object", diff --git a/packages/daf-selective-disclosure/src/action-handler.ts b/packages/daf-selective-disclosure/src/action-handler.ts index 193f9d0ad..3f5aba686 100644 --- a/packages/daf-selective-disclosure/src/action-handler.ts +++ b/packages/daf-selective-disclosure/src/action-handler.ts @@ -1,6 +1,6 @@ import { IAgentContext, - IIdentityManager, + IDIDManager, IKeyManager, IAgentPlugin, VerifiablePresentation, @@ -58,15 +58,15 @@ export class SelectiveDisclosure implements IAgentPlugin { */ async createSelectiveDisclosureRequest( args: ICreateSelectiveDisclosureRequestArgs, - context: IAgentContext, + context: IAgentContext, ): Promise { try { - const identity = await context.agent.identityManagerGetIdentity({ did: args.data.issuer }) + const identifier = await context.agent.didManagerGet({ did: args.data.issuer }) const data: Partial = args.data delete data.issuer - Debug('daf:selective-disclosure:create-sdr')('Signing SDR with', identity.did) + Debug('daf:selective-disclosure:create-sdr')('Signing SDR with', identifier.did) - const key = identity.keys.find((k) => k.type === 'Secp256k1') + const key = identifier.keys.find((k) => k.type === 'Secp256k1') if (!key) throw Error('Signing key not found') const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) const jwt = await createJWT( @@ -77,7 +77,7 @@ export class SelectiveDisclosure implements IAgentPlugin { { signer, alg: 'ES256K-R', - issuer: identity.did, + issuer: identifier.did, }, ) return jwt @@ -218,21 +218,21 @@ export class SelectiveDisclosure implements IAgentPlugin { */ async createProfilePresentation( args: ICreateProfileCredentialsArgs, - context: IAgentContext, + context: IAgentContext, ): Promise { - const identity = await context.agent.identityManagerGetIdentity({ did: args.holder }) + const identifier = await context.agent.didManagerGet({ did: args.holder }) const credentials = [] if (args.name) { const credential = await context.agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential', 'Profile'], issuanceDate: new Date().toISOString(), credentialSubject: { - id: identity.did, + id: identifier.did, name: args.name, }, }, @@ -245,12 +245,12 @@ export class SelectiveDisclosure implements IAgentPlugin { if (args.picture) { const credential = await context.agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential', 'Profile'], issuanceDate: new Date().toISOString(), credentialSubject: { - id: identity.did, + id: identifier.did, picture: args.picture, }, }, @@ -263,12 +263,12 @@ export class SelectiveDisclosure implements IAgentPlugin { if (args.url) { const credential = await context.agent.createVerifiableCredential({ credential: { - issuer: { id: identity.did }, + issuer: { id: identifier.did }, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential', 'Profile'], issuanceDate: new Date().toISOString(), credentialSubject: { - id: identity.did, + id: identifier.did, url: args.url, }, }, @@ -281,7 +281,7 @@ export class SelectiveDisclosure implements IAgentPlugin { const profile = await context.agent.createVerifiablePresentation({ presentation: { verifier: args.holder ? [args.holder] : [], - holder: identity.did, + holder: identifier.did, '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiablePresentation', 'Profile'], issuanceDate: new Date().toISOString(), @@ -295,7 +295,7 @@ export class SelectiveDisclosure implements IAgentPlugin { await context.agent.sendMessageDIDCommAlpha1({ save: args.save, data: { - from: identity.did, + from: identifier.did, to: args.verifier, type: 'jwt', body: profile.proof.jwt, diff --git a/packages/daf-selective-disclosure/src/types.ts b/packages/daf-selective-disclosure/src/types.ts index ed928b16b..a906de893 100644 --- a/packages/daf-selective-disclosure/src/types.ts +++ b/packages/daf-selective-disclosure/src/types.ts @@ -1,6 +1,6 @@ import { IAgentContext, - IIdentityManager, + IDIDManager, IKeyManager, IPluginMethodMap, VerifiableCredential, @@ -215,7 +215,7 @@ export interface ICreateProfileCredentialsArgs { export interface ISelectiveDisclosure extends IPluginMethodMap { createSelectiveDisclosureRequest( args: ICreateSelectiveDisclosureRequestArgs, - context: IAgentContext, + context: IAgentContext, ): Promise getVerifiableCredentialsForSdr( args: IGetVerifiableCredentialsForSdrArgs, @@ -227,6 +227,6 @@ export interface ISelectiveDisclosure extends IPluginMethodMap { ): Promise createProfilePresentation( args: ICreateProfileCredentialsArgs, - context: IAgentContext, + context: IAgentContext, ): Promise } diff --git a/packages/daf-typeorm/api/daf-typeorm.api.md b/packages/daf-typeorm/api/daf-typeorm.api.md index 5a4306700..2c0346333 100644 --- a/packages/daf-typeorm/api/daf-typeorm.api.md +++ b/packages/daf-typeorm/api/daf-typeorm.api.md @@ -4,7 +4,7 @@ ```ts -import { AbstractIdentityStore } from 'daf-identity-manager'; +import { AbstractDIDStore } from 'daf-identity-manager'; import { AbstractKeyStore } from 'daf-key-manager'; import { AbstractSecretBox } from 'daf-key-manager'; import { BaseEntity } from 'typeorm'; @@ -17,7 +17,7 @@ import { IDataStoreGetVerifiablePresentationArgs } from 'daf-core'; import { IDataStoreSaveMessageArgs } from 'daf-core'; import { IDataStoreSaveVerifiableCredentialArgs } from 'daf-core'; import { IDataStoreSaveVerifiablePresentationArgs } from 'daf-core'; -import { IIdentity } from 'daf-core'; +import { IIdentifier } from 'daf-core'; import { IKey } from 'daf-core'; import { IMessage } from 'daf-core'; import { IPluginMethodMap } from 'daf-core'; @@ -41,9 +41,9 @@ export class Claim extends BaseEntity { // (undocumented) issuanceDate: Date; // (undocumented) - issuer: Identity; + issuer: Identifier; // (undocumented) - subject?: Identity; + subject?: Identifier; // (undocumented) type: string; // (undocumented) @@ -65,7 +65,7 @@ class Credential_2 extends BaseEntity { // (undocumented) issuanceDate: Date; // (undocumented) - issuer: Identity; + issuer: Identifier; // (undocumented) messages: Message[]; // (undocumented) @@ -74,7 +74,7 @@ class Credential_2 extends BaseEntity { // (undocumented) get raw(): VerifiableCredential; // (undocumented) - subject?: Identity; + subject?: Identifier; // (undocumented) type: string[]; } @@ -106,12 +106,12 @@ export class DataStore implements IAgentPlugin { export class DataStoreORM implements IAgentPlugin { constructor(dbConnection: Promise); // Warning: (ae-forgotten-export) The symbol "IContext" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "PartialIdentity" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "PartialIdentifier" needs to be exported by the entry point index.d.ts // // (undocumented) - dataStoreORMGetIdentities(args: FindArgs, context: IContext): Promise; + dataStoreORMGetIdentifiers(args: FindArgs, context: IContext): Promise; // (undocumented) - dataStoreORMGetIdentitiesCount(args: FindArgs, context: IContext): Promise; + dataStoreORMGetIdentifiersCount(args: FindArgs, context: IContext): Promise; // (undocumented) dataStoreORMGetMessages(args: FindArgs, context: IContext): Promise; // (undocumented) @@ -135,7 +135,29 @@ export class DataStoreORM implements IAgentPlugin { } // @public (undocumented) -export const Entities: (typeof Key | typeof Identity | typeof Service | typeof Claim | typeof Credential_2 | typeof Presentation | typeof Message)[]; +export class DIDStore extends AbstractDIDStore { + constructor(dbConnection: Promise); + // (undocumented) + delete({ did }: { + did: string; + }): Promise; + // (undocumented) + get({ did, alias, provider, }: { + did: string; + alias: string; + provider: string; + }): Promise; + // (undocumented) + import(args: IIdentifier): Promise; + // (undocumented) + list(args: { + alias?: string; + provider?: string; + }): Promise; +} + +// @public (undocumented) +export const Entities: (typeof Key | typeof Identifier | typeof Service | typeof Claim | typeof Credential_2 | typeof Presentation | typeof Message)[]; // @public (undocumented) export interface FindArgs { @@ -156,7 +178,7 @@ export type FindClaimsArgs = FindArgs; export type FindCredentialsArgs = FindArgs; // @public (undocumented) -export type FindIdentitiesArgs = FindArgs; +export type FindIdentifiersArgs = FindArgs; // @public (undocumented) export type FindMessagesArgs = FindArgs; @@ -167,9 +189,9 @@ export type FindPresentationsArgs = FindArgs; // @public (undocumented) export interface IDataStoreORM extends IPluginMethodMap { // (undocumented) - dataStoreORMGetIdentities(args: FindIdentitiesArgs, context: IContext): Promise>; + dataStoreORMGetIdentifiers(args: FindIdentifiersArgs, context: IContext): Promise>; // (undocumented) - dataStoreORMGetIdentitiesCount(args: FindIdentitiesArgs, context: IContext): Promise; + dataStoreORMGetIdentifiersCount(args: FindIdentifiersArgs, context: IContext): Promise; // (undocumented) dataStoreORMGetMessages(args: FindMessagesArgs, context: IContext): Promise>; // (undocumented) @@ -189,7 +211,7 @@ export interface IDataStoreORM extends IPluginMethodMap { } // @public (undocumented) -export class Identity extends BaseEntity { +export class Identifier extends BaseEntity { // (undocumented) alias?: string; // (undocumented) @@ -229,32 +251,10 @@ export class Identity extends BaseEntity { updateDate: Date; } -// @public (undocumented) -export class IdentityStore extends AbstractIdentityStore { - constructor(dbConnection: Promise); - // (undocumented) - delete({ did }: { - did: string; - }): Promise; - // (undocumented) - get({ did, alias, provider }: { - did: string; - alias: string; - provider: string; - }): Promise; - // (undocumented) - import(args: IIdentity): Promise; - // (undocumented) - list(args: { - alias?: string; - provider?: string; - }): Promise; -} - // @public (undocumented) export class Key extends BaseEntity { // (undocumented) - identity: Identity; + identifier: Identifier; // (undocumented) kid: string; // (undocumented) @@ -300,7 +300,7 @@ export class Message extends BaseEntity { // (undocumented) expiresAt?: Date; // (undocumented) - from?: Identity; + from?: Identifier; // (undocumented) id: string; // (undocumented) @@ -320,7 +320,7 @@ export class Message extends BaseEntity { // (undocumented) threadId?: string; // (undocumented) - to?: Identity; + to?: Identifier; // (undocumented) type: string; // (undocumented) @@ -357,7 +357,7 @@ export class Presentation extends BaseEntity { // (undocumented) hash: string; // (undocumented) - holder: Identity; + holder: Identifier; // (undocumented) id?: String; // (undocumented) @@ -370,7 +370,7 @@ export class Presentation extends BaseEntity { // (undocumented) type: string[]; // (undocumented) - verifier?: Identity[]; + verifier?: Identifier[]; } // @public (undocumented) @@ -383,7 +383,7 @@ export class Service extends BaseEntity { // (undocumented) id: string; // (undocumented) - identity: Identity; + identifier: Identifier; // (undocumented) serviceEndpoint: string; // (undocumented) @@ -397,7 +397,7 @@ export type TClaimsColumns = 'context' | 'credentialType' | 'type' | 'value' | ' export type TCredentialColumns = 'context' | 'type' | 'id' | 'issuer' | 'subject' | 'expirationDate' | 'issuanceDate'; // @public (undocumented) -export type TIdentitiesColumns = 'did' | 'alias' | 'provider'; +export type TIdentifiersColumns = 'did' | 'alias' | 'provider'; // @public (undocumented) export type TMessageColumns = 'from' | 'to' | 'id' | 'createdAt' | 'expiresAt' | 'threadId' | 'type' | 'raw' | 'replyTo' | 'replyUrl'; diff --git a/packages/daf-typeorm/plugin.schema.json b/packages/daf-typeorm/plugin.schema.json index 7b16f53a4..2c48c5231 100644 --- a/packages/daf-typeorm/plugin.schema.json +++ b/packages/daf-typeorm/plugin.schema.json @@ -2,22 +2,22 @@ "IDataStoreORM": { "components": { "schemas": { - "FindIdentitiesArgs": { - "$ref": "#/components/schemas/FindArgs-TIdentitiesColumns" + "FindIdentifiersArgs": { + "$ref": "#/components/schemas/FindArgs-TIdentifiersColumns" }, - "FindArgs-TIdentitiesColumns": { + "FindArgs-TIdentifiersColumns": { "type": "object", "properties": { "where": { "type": "array", "items": { - "$ref": "#/components/schemas/Where-TIdentitiesColumns" + "$ref": "#/components/schemas/Where-TIdentifiersColumns" } }, "order": { "type": "array", "items": { - "$ref": "#/components/schemas/Order-TIdentitiesColumns" + "$ref": "#/components/schemas/Order-TIdentifiersColumns" } }, "take": { @@ -28,11 +28,11 @@ } } }, - "Where-TIdentitiesColumns": { + "Where-TIdentifiersColumns": { "type": "object", "properties": { "column": { - "$ref": "#/components/schemas/TIdentitiesColumns" + "$ref": "#/components/schemas/TIdentifiersColumns" }, "value": { "type": "array", @@ -63,7 +63,7 @@ "column" ] }, - "TIdentitiesColumns": { + "TIdentifiersColumns": { "type": "string", "enum": [ "did", @@ -71,11 +71,11 @@ "provider" ] }, - "Order-TIdentitiesColumns": { + "Order-TIdentifiersColumns": { "type": "object", "properties": { "column": { - "$ref": "#/components/schemas/TIdentitiesColumns" + "$ref": "#/components/schemas/TIdentifiersColumns" }, "direction": { "type": "string", @@ -90,7 +90,7 @@ "direction" ] }, - "PartialIdentity": { + "PartialIdentifier": { "type": "object", "properties": { "did": { @@ -99,11 +99,11 @@ }, "alias": { "type": "string", - "description": "Optional. Identity alias. Can be used to reference an object in an external system" + "description": "Optional. Identifier alias. Can be used to reference an object in an external system" }, "provider": { "type": "string", - "description": "Identity provider name" + "description": "Identifier provider name" }, "controllerKeyId": { "type": "string", @@ -201,7 +201,7 @@ "type", "serviceEndpoint" ], - "description": "Identity service" + "description": "Identifier service" }, "FindMessagesArgs": { "$ref": "#/components/schemas/FindArgs-TMessageColumns" @@ -482,7 +482,7 @@ "credentialSubject", "proof" ], - "description": "Verifiable Credential {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "VerifiablePresentation": { "type": "object", @@ -540,7 +540,7 @@ "verifiableCredential", "proof" ], - "description": "Verifiable Presentation {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "FindCredentialsArgs": { "$ref": "#/components/schemas/FindArgs-TCredentialColumns" @@ -853,22 +853,22 @@ } }, "methods": { - "dataStoreORMGetIdentities": { + "dataStoreORMGetIdentifiers": { "description": "", "arguments": { - "$ref": "#/components/schemas/FindIdentitiesArgs" + "$ref": "#/components/schemas/FindIdentifiersArgs" }, "returnType": { "type": "array", "items": { - "$ref": "#/components/schemas/PartialIdentity" + "$ref": "#/components/schemas/PartialIdentifier" } } }, - "dataStoreORMGetIdentitiesCount": { + "dataStoreORMGetIdentifiersCount": { "description": "", "arguments": { - "$ref": "#/components/schemas/FindIdentitiesArgs" + "$ref": "#/components/schemas/FindIdentifiersArgs" }, "returnType": { "type": "number" diff --git a/packages/daf-typeorm/src/__tests__/data-store-orm.test.ts b/packages/daf-typeorm/src/__tests__/data-store-orm.test.ts index b99eb773d..fbd925518 100644 --- a/packages/daf-typeorm/src/__tests__/data-store-orm.test.ts +++ b/packages/daf-typeorm/src/__tests__/data-store-orm.test.ts @@ -7,7 +7,7 @@ import { TCredentialColumns, TMessageColumns, TPresentationColumns, - TIdentitiesColumns, + TIdentifiersColumns, } from '../types' import { DataStore } from '../data-store' import { Entities } from '../index' @@ -190,7 +190,7 @@ describe('daf-typeorm entities', () => { expect(count).toBe(4) }) - test('with auth it only gets messages for the authorized identity', async () => { + test('with auth it only gets messages for the authorized identifier', async () => { const args: FindArgs = { where: [ { @@ -389,12 +389,12 @@ describe('daf-typeorm entities', () => { expect(presentations[0].verifiablePresentation.verifiableCredential[0].id).toEqual('vc6') }) - it('should query identities', async () => { + it('should query identifiers', async () => { const agent = makeAgent() - const identities = await agent.dataStoreORMGetIdentities() - expect(identities.length).toEqual(4) + const identifiers = await agent.dataStoreORMGetIdentifiers() + expect(identifiers.length).toEqual(4) - const count = await agent.dataStoreORMGetIdentitiesCount() + const count = await agent.dataStoreORMGetIdentifiersCount() expect(count).toEqual(4) }) }) diff --git a/packages/daf-typeorm/src/__tests__/entities.test.ts b/packages/daf-typeorm/src/__tests__/entities.test.ts index 726b60ecb..8ff92bf47 100644 --- a/packages/daf-typeorm/src/__tests__/entities.test.ts +++ b/packages/daf-typeorm/src/__tests__/entities.test.ts @@ -2,7 +2,7 @@ import { VerifiableCredential, VerifiablePresentation } from 'daf-core' import { Credential, createCredentialEntity } from '../entities/credential' import { Presentation, createPresentationEntity } from '../entities/presentation' import { createConnection, Connection, In, Raw, FindConditions } from 'typeorm' -import { Identity, Key, Message, Claim } from '../index' +import { Identifier, Key, Message, Claim } from '../index' import { Entities } from '../index' import { blake2bHex } from 'blakejs' import fs from 'fs' @@ -30,13 +30,13 @@ describe('daf-core', () => { fs.unlinkSync(databaseFile) }) - it('Saves identity to DB', async () => { - const identity = new Identity() - identity.did = 'did:test:123' - await identity.save() + it('Saves identifier to DB', async () => { + const identifier = new Identifier() + identifier.did = 'did:test:123' + await identifier.save() - const fromDb = await Identity.findOne(identity.did) - expect(fromDb?.did).toEqual(identity.did) + const fromDb = await Identifier.findOne(identifier.did) + expect(fromDb?.did).toEqual(identifier.did) }) it('Saves credential with claims', async () => { @@ -124,9 +124,9 @@ describe('daf-core', () => { await vp2.save() const m = new Message() - m.from = new Identity() + m.from = new Identifier() m.from.did = did1 - m.to = new Identity() + m.to = new Identifier() m.to.did = did2 m.type = 'mock' m.raw = 'mock' @@ -182,17 +182,17 @@ describe('daf-core', () => { expect(fromDb?.type).toEqual('custom') }) - it('enforces unique alias/provider for an identity', async () => { - const identity = new Identity() - identity.did = 'did:test:123' - identity.alias = 'test' - identity.provider = 'testProvider' - const id1Result = await identity.save() - - const identity2 = new Identity() - identity2.did = 'did:test:456' - identity2.alias = 'test' - identity2.provider = 'testProvider' - await expect(identity2.save()).rejects.toThrowError() + it('enforces unique alias/provider for an identifier', async () => { + const identifier = new Identifier() + identifier.did = 'did:test:123' + identifier.alias = 'test' + identifier.provider = 'testProvider' + const id1Result = await identifier.save() + + const identifier2 = new Identifier() + identifier2.did = 'did:test:456' + identifier2.alias = 'test' + identifier2.provider = 'testProvider' + await expect(identifier2.save()).rejects.toThrowError() }) }) diff --git a/packages/daf-typeorm/src/data-store-orm.ts b/packages/daf-typeorm/src/data-store-orm.ts index b564a362d..39b80bb1b 100644 --- a/packages/daf-typeorm/src/data-store-orm.ts +++ b/packages/daf-typeorm/src/data-store-orm.ts @@ -4,13 +4,13 @@ import { VerifiableCredential, VerifiablePresentation, IPluginMethodMap, - IIdentity, + IIdentifier, } from 'daf-core' import { Message, createMessage } from './entities/message' import { Claim } from './entities/claim' import { Credential } from './entities/credential' import { Presentation } from './entities/presentation' -import { Identity } from './entities/identity' +import { Identifier } from './entities/identifier' import { Connection, Not, @@ -33,7 +33,7 @@ import { TCredentialColumns, TMessageColumns, TPresentationColumns, - TIdentitiesColumns, + TIdentifiersColumns, FindArgs, } from './types' @@ -53,16 +53,16 @@ export interface UniqueVerifiablePresentation { verifiablePresentation: VerifiablePresentation } -export type FindIdentitiesArgs = FindArgs +export type FindIdentifiersArgs = FindArgs export type FindMessagesArgs = FindArgs export type FindClaimsArgs = FindArgs export type FindCredentialsArgs = FindArgs export type FindPresentationsArgs = FindArgs -export type PartialIdentity = Partial +export type PartialIdentifier = Partial export interface IDataStoreORM extends IPluginMethodMap { - dataStoreORMGetIdentities(args: FindIdentitiesArgs, context: IContext): Promise> - dataStoreORMGetIdentitiesCount(args: FindIdentitiesArgs, context: IContext): Promise + dataStoreORMGetIdentifiers(args: FindIdentifiersArgs, context: IContext): Promise> + dataStoreORMGetIdentifiersCount(args: FindIdentifiersArgs, context: IContext): Promise dataStoreORMGetMessages(args: FindMessagesArgs, context: IContext): Promise> dataStoreORMGetMessagesCount(args: FindMessagesArgs, context: IContext): Promise dataStoreORMGetVerifiableCredentialsByClaims( @@ -91,8 +91,8 @@ export class DataStoreORM implements IAgentPlugin { this.dbConnection = dbConnection this.methods = { - dataStoreORMGetIdentities: this.dataStoreORMGetIdentities.bind(this), - dataStoreORMGetIdentitiesCount: this.dataStoreORMGetIdentitiesCount.bind(this), + dataStoreORMGetIdentifiers: this.dataStoreORMGetIdentifiers.bind(this), + dataStoreORMGetIdentifiersCount: this.dataStoreORMGetIdentifiersCount.bind(this), dataStoreORMGetMessages: this.dataStoreORMGetMessages.bind(this), dataStoreORMGetMessagesCount: this.dataStoreORMGetMessagesCount.bind(this), dataStoreORMGetVerifiableCredentialsByClaims: this.dataStoreORMGetVerifiableCredentialsByClaims.bind( @@ -110,48 +110,48 @@ export class DataStoreORM implements IAgentPlugin { } } - // Identities + // Identifiers - private async identitiesQuery( - args: FindArgs, + private async identifiersQuery( + args: FindArgs, context: IContext, - ): Promise> { + ): Promise> { const where = createWhereObject(args) let qb = (await this.dbConnection) - .getRepository(Identity) - .createQueryBuilder('identity') - .leftJoinAndSelect('identity.keys', 'keys') - .leftJoinAndSelect('identity.services', 'services') + .getRepository(Identifier) + .createQueryBuilder('identifier') + .leftJoinAndSelect('identifier.keys', 'keys') + .leftJoinAndSelect('identifier.services', 'services') .where(where) qb = decorateQB(qb, 'message', args) return qb } - async dataStoreORMGetIdentities( - args: FindArgs, + async dataStoreORMGetIdentifiers( + args: FindArgs, context: IContext, - ): Promise { - const identities = await (await this.identitiesQuery(args, context)).getMany() - return identities.map((i) => { - const identity: PartialIdentity = i - if (identity.controllerKeyId === null) { - delete identity.controllerKeyId + ): Promise { + const identifiers = await (await this.identifiersQuery(args, context)).getMany() + return identifiers.map((i) => { + const identifier: PartialIdentifier = i + if (identifier.controllerKeyId === null) { + delete identifier.controllerKeyId } - if (identity.alias === null) { - delete identity.alias + if (identifier.alias === null) { + delete identifier.alias } - if (identity.provider === null) { - delete identity.provider + if (identifier.provider === null) { + delete identifier.provider } - return identity + return identifier }) } - async dataStoreORMGetIdentitiesCount( - args: FindArgs, + async dataStoreORMGetIdentifiersCount( + args: FindArgs, context: IContext, ): Promise { - return await (await this.identitiesQuery(args, context)).getCount() + return await (await this.identifiersQuery(args, context)).getCount() } // Messages @@ -376,7 +376,7 @@ function addVerifierQuery(input: FindArgs, qb: SelectQueryBuilder): Se function createWhereObject( input: FindArgs< - TMessageColumns | TClaimsColumns | TCredentialColumns | TPresentationColumns | TIdentitiesColumns + TMessageColumns | TClaimsColumns | TCredentialColumns | TPresentationColumns | TIdentifiersColumns >, ): any { if (input?.where) { diff --git a/packages/daf-typeorm/src/entities/claim.ts b/packages/daf-typeorm/src/entities/claim.ts index 9b2fe612b..5e9bcc3d0 100644 --- a/packages/daf-typeorm/src/entities/claim.ts +++ b/packages/daf-typeorm/src/entities/claim.ts @@ -1,5 +1,5 @@ import { Entity, Column, BaseEntity, ManyToOne, PrimaryColumn } from 'typeorm' -import { Identity } from './identity' +import { Identifier } from './identifier' import { Credential } from './credential' @Entity() @@ -8,17 +8,17 @@ export class Claim extends BaseEntity { //@ts-ignore hash: string - @ManyToOne((type) => Identity, (identity) => identity.issuedClaims, { + @ManyToOne((type) => Identifier, (identifier) => identifier.issuedClaims, { eager: true, }) //@ts-ignore - issuer: Identity + issuer: Identifier - @ManyToOne((type) => Identity, (identity) => identity.receivedClaims, { + @ManyToOne((type) => Identifier, (identifier) => identifier.receivedClaims, { eager: true, nullable: true, }) - subject?: Identity + subject?: Identifier @ManyToOne((type) => Credential, (credential) => credential.claims) //@ts-ignore diff --git a/packages/daf-typeorm/src/entities/credential.ts b/packages/daf-typeorm/src/entities/credential.ts index aadf0e673..5e6356a04 100644 --- a/packages/daf-typeorm/src/entities/credential.ts +++ b/packages/daf-typeorm/src/entities/credential.ts @@ -1,7 +1,7 @@ import { VerifiableCredential } from 'daf-core' import { blake2bHex } from 'blakejs' import { Entity, Column, BaseEntity, ManyToOne, PrimaryColumn, OneToMany, ManyToMany } from 'typeorm' -import { Identity } from './identity' +import { Identifier } from './identifier' import { Message } from './message' import { Presentation } from './presentation' import { Claim } from './claim' @@ -25,20 +25,20 @@ export class Credential extends BaseEntity { return this._raw } - @ManyToOne((type) => Identity, (identity) => identity.issuedCredentials, { + @ManyToOne((type) => Identifier, (identifier) => identifier.issuedCredentials, { cascade: ['insert'], eager: true, }) //@ts-ignore - issuer: Identity + issuer: Identifier // Subject can be null https://w3c.github.io/vc-data-model/#credential-uniquely-identifies-a-subject - @ManyToOne((type) => Identity, (identity) => identity.receivedCredentials, { + @ManyToOne((type) => Identifier, (identifier) => identifier.receivedCredentials, { cascade: ['insert'], eager: true, nullable: true, }) - subject?: Identity + subject?: Identifier @Column({ nullable: true }) id?: string @@ -87,12 +87,12 @@ export const createCredentialEntity = (vc: VerifiableCredential): Credential => credential.expirationDate = new Date(vc.expirationDate) } - const issuer = new Identity() + const issuer = new Identifier() issuer.did = vc.issuer.id credential.issuer = issuer if (vc.credentialSubject.id) { - const subject = new Identity() + const subject = new Identifier() subject.did = vc.credentialSubject.id credential.subject = subject } diff --git a/packages/daf-typeorm/src/entities/identity.ts b/packages/daf-typeorm/src/entities/identifier.ts similarity index 90% rename from packages/daf-typeorm/src/entities/identity.ts rename to packages/daf-typeorm/src/entities/identifier.ts index 8d826e14f..c77945cc0 100644 --- a/packages/daf-typeorm/src/entities/identity.ts +++ b/packages/daf-typeorm/src/entities/identifier.ts @@ -19,7 +19,7 @@ import { Connection } from 'typeorm' @Entity() @Index(['alias', 'provider'], { unique: true }) -export class Identity extends BaseEntity { +export class Identifier extends BaseEntity { @PrimaryColumn() //@ts-ignore did: string @@ -44,11 +44,11 @@ export class Identity extends BaseEntity { //@ts-ignore controllerKeyId: string - @OneToMany((type) => Key, (key) => key.identity) + @OneToMany((type) => Key, (key) => key.identifier) //@ts-ignore keys: Key[] - @OneToMany((type) => Service, (service) => service.identity, { + @OneToMany((type) => Service, (service) => service.identifier, { cascade: true, }) //@ts-ignore @@ -89,7 +89,7 @@ export class Identity extends BaseEntity { /** * Convenience method * - * const name = await identity.getLatestClaimValue({type: 'name'}) + * const name = await identifier.getLatestClaimValue({type: 'name'}) * * @param where */ diff --git a/packages/daf-typeorm/src/entities/key.ts b/packages/daf-typeorm/src/entities/key.ts index 349fd7fcf..cb4af3640 100644 --- a/packages/daf-typeorm/src/entities/key.ts +++ b/packages/daf-typeorm/src/entities/key.ts @@ -1,5 +1,5 @@ import { Entity, Column, PrimaryColumn, BaseEntity, ManyToOne } from 'typeorm' -import { Identity } from './identity' +import { Identifier } from './identifier' export type KeyType = 'Ed25519' | 'Secp256k1' @@ -27,7 +27,7 @@ export class Key extends BaseEntity { @Column({ type: 'simple-json', nullable: true }) meta?: object | null - @ManyToOne((type) => Identity, (identity) => identity.keys) + @ManyToOne((type) => Identifier, (identifier) => identifier.keys) //@ts-ignore - identity: Identity + identifier: Identifier } diff --git a/packages/daf-typeorm/src/entities/message.ts b/packages/daf-typeorm/src/entities/message.ts index 9c2df90a2..f7f372a79 100644 --- a/packages/daf-typeorm/src/entities/message.ts +++ b/packages/daf-typeorm/src/entities/message.ts @@ -12,7 +12,7 @@ import { } from 'typeorm' import { blake2bHex } from 'blakejs' import { IMessage } from 'daf-core' -import { Identity } from './identity' +import { Identifier } from './identifier' import { Presentation, createPresentationEntity } from './presentation' import { Credential, createCredentialEntity } from './credential' @@ -61,7 +61,7 @@ export class Message extends BaseEntity { @Column('simple-json', { nullable: true }) data?: object | null - // https://github.com/decentralized-identity/didcomm-messaging/blob/41f35f992275dd71d459504d14eb8d70b4185533/jwm.md#jwm-profile + // https://github.com/decentralized-identifier/didcomm-messaging/blob/41f35f992275dd71d459504d14eb8d70b4185533/jwm.md#jwm-profile @Column('simple-array', { nullable: true }) replyTo?: string[] @@ -69,19 +69,19 @@ export class Message extends BaseEntity { @Column({ nullable: true }) replyUrl?: string - @ManyToOne((type) => Identity, (identity) => identity.sentMessages, { + @ManyToOne((type) => Identifier, (identifier) => identifier.sentMessages, { nullable: true, cascade: ['insert'], eager: true, }) - from?: Identity + from?: Identifier - @ManyToOne((type) => Identity, (identity) => identity.receivedMessages, { + @ManyToOne((type) => Identifier, (identifier) => identifier.receivedMessages, { nullable: true, cascade: ['insert'], eager: true, }) - to?: Identity + to?: Identifier @Column('simple-json', { nullable: true }) metaData?: MetaData[] | null @@ -124,13 +124,13 @@ export const createMessageEntity = (args: IMessage): Message => { } if (args.from) { - const from = new Identity() + const from = new Identifier() from.did = args.from message.from = from } if (args.to) { - const to = new Identity() + const to = new Identifier() to.did = args.to message.to = to } diff --git a/packages/daf-typeorm/src/entities/presentation.ts b/packages/daf-typeorm/src/entities/presentation.ts index 355f36856..bab9f833c 100644 --- a/packages/daf-typeorm/src/entities/presentation.ts +++ b/packages/daf-typeorm/src/entities/presentation.ts @@ -10,7 +10,7 @@ import { BeforeInsert, ManyToMany, } from 'typeorm' -import { Identity } from './identity' +import { Identifier } from './identifier' import { Message } from './message' import { Credential, createCredentialEntity } from './credential' @@ -33,21 +33,21 @@ export class Presentation extends BaseEntity { return this._raw } - @ManyToOne((type) => Identity, (identity) => identity.issuedPresentations, { + @ManyToOne((type) => Identifier, (identifier) => identifier.issuedPresentations, { cascade: ['insert'], eager: true, }) //@ts-ignore - holder: Identity + holder: Identifier - @ManyToMany((type) => Identity, (identity) => identity.receivedPresentations, { + @ManyToMany((type) => Identifier, (identifier) => identifier.receivedPresentations, { cascade: ['insert'], eager: true, nullable: true, }) @JoinTable() //@ts-ignore - verifier?: Identity[] + verifier?: Identifier[] @Column({ nullable: true }) id?: String @@ -93,12 +93,12 @@ export const createPresentationEntity = (vp: VerifiablePresentation): Presentati presentation.expirationDate = new Date(vp.expirationDate) } - const holder = new Identity() + const holder = new Identifier() holder.did = vp.holder presentation.holder = holder presentation.verifier = vp.verifier?.map((verifierDid) => { - const id = new Identity() + const id = new Identifier() id.did = verifierDid return id }) diff --git a/packages/daf-typeorm/src/entities/service.ts b/packages/daf-typeorm/src/entities/service.ts index bb0a702a7..c96487987 100644 --- a/packages/daf-typeorm/src/entities/service.ts +++ b/packages/daf-typeorm/src/entities/service.ts @@ -1,5 +1,5 @@ import { Entity, Column, PrimaryColumn, BaseEntity, ManyToOne } from 'typeorm' -import { Identity } from './identity' +import { Identifier } from './identifier' @Entity() export class Service extends BaseEntity { @@ -18,7 +18,7 @@ export class Service extends BaseEntity { @Column({ nullable: true }) description?: string - @ManyToOne((type) => Identity, (identity) => identity.services) + @ManyToOne((type) => Identifier, (identifier) => identifier.services) //@ts-ignore - identity: Identity + identifier: Identifier } diff --git a/packages/daf-typeorm/src/identifier/did-store.ts b/packages/daf-typeorm/src/identifier/did-store.ts new file mode 100644 index 000000000..1ed8bfc10 --- /dev/null +++ b/packages/daf-typeorm/src/identifier/did-store.ts @@ -0,0 +1,122 @@ +import { IIdentifier } from 'daf-core' +import { AbstractDIDStore } from 'daf-identity-manager' +import { Identifier } from '../entities/identifier' +import { Key } from '../entities/key' +import { Service } from '../entities/service' +import { Connection, IsNull, Not } from 'typeorm' + +import Debug from 'debug' +const debug = Debug('daf:typeorm:identifier-store') + +export class DIDStore extends AbstractDIDStore { + constructor(private dbConnection: Promise) { + super() + } + + async get({ + did, + alias, + provider, + }: { + did: string + alias: string + provider: string + }): Promise { + let where = {} + if (did !== undefined && alias === undefined) { + where = { did } + } else if (did === undefined && alias !== undefined && provider !== undefined) { + where = { alias, provider } + } else { + throw Error('[daf:typeorm:identifier-store] Get requires did or (alias and provider)') + } + + const identifier = await (await this.dbConnection).getRepository(Identifier).findOne({ + where, + relations: ['keys', 'services'], + }) + + if (!identifier) throw Error('Identifier not found') + const result: IIdentifier = { + did: identifier.did, + controllerKeyId: identifier.controllerKeyId, + provider: identifier.provider, + services: identifier.services, + keys: identifier.keys.map((k) => ({ + kid: k.kid, + type: k.type, + kms: k.kms, + publicKeyHex: k.publicKeyHex, + })), + } + if (identifier.alias) { + result.alias = identifier.alias + } + return result + } + + async delete({ did }: { did: string }) { + const identifier = await (await this.dbConnection).getRepository(Identifier).findOne(did) + if (!identifier) throw Error('Identifier not found') + debug('Deleting', did) + await (await this.dbConnection).getRepository(Identifier).remove(identifier) + + return true + } + + async import(args: IIdentifier) { + const identifier = new Identifier() + identifier.did = args.did + if (args.controllerKeyId) { + identifier.controllerKeyId = args.controllerKeyId + } + identifier.provider = args.provider + if (args.alias) { + identifier.alias = args.alias + } + + identifier.keys = [] + for (const argsKey of args.keys) { + const key = new Key() + key.kid = argsKey.kid + key.publicKeyHex = argsKey.publicKeyHex + key.privateKeyHex = argsKey.privateKeyHex + key.kms = argsKey.kms + key.meta = argsKey.meta + identifier.keys.push(key) + } + + identifier.services = [] + for (const argsService of args.services) { + const service = new Service() + service.id = argsService.id + service.type = argsService.type + service.serviceEndpoint = argsService.serviceEndpoint + service.description = argsService.description + identifier.services.push(service) + } + + await (await this.dbConnection).getRepository(Identifier).save(identifier) + + debug('Saving', args.did) + return true + } + + async list(args: { alias?: string; provider?: string }): Promise { + const where: any = { provider: args?.provider || Not(IsNull()) } + if (args?.alias) { + where['alias'] = args.alias + } + const identifiers = await (await this.dbConnection).getRepository(Identifier).find({ + where, + relations: ['keys', 'services'], + }) + return identifiers.map((identifier) => { + const i = identifier + if (i.alias === null) { + delete i.alias + } + return i + }) + } +} diff --git a/packages/daf-typeorm/src/identity/key-store.ts b/packages/daf-typeorm/src/identifier/key-store.ts similarity index 100% rename from packages/daf-typeorm/src/identity/key-store.ts rename to packages/daf-typeorm/src/identifier/key-store.ts diff --git a/packages/daf-typeorm/src/identity/identity-store.ts b/packages/daf-typeorm/src/identity/identity-store.ts deleted file mode 100644 index 5630a53b8..000000000 --- a/packages/daf-typeorm/src/identity/identity-store.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { IIdentity } from 'daf-core' -import { AbstractIdentityStore } from 'daf-identity-manager' -import { Identity } from '../entities/identity' -import { Key } from '../entities/key' -import { Service } from '../entities/service' -import { Connection, IsNull, Not } from 'typeorm' - -import Debug from 'debug' -const debug = Debug('daf:typeorm:identity-store') - -export class IdentityStore extends AbstractIdentityStore { - constructor(private dbConnection: Promise) { - super() - } - - async get({ did, alias, provider }: { did: string; alias: string; provider: string }): Promise { - let where = {} - if (did !== undefined && alias === undefined) { - where = { did } - } else if (did === undefined && alias !== undefined && provider !== undefined) { - where = { alias, provider } - } else { - throw Error('[daf:typeorm:identity-store] Get requires did or (alias and provider)') - } - - const identity = await (await this.dbConnection).getRepository(Identity).findOne({ - where, - relations: ['keys', 'services'], - }) - - if (!identity) throw Error('Identity not found') - const result: IIdentity = { - did: identity.did, - controllerKeyId: identity.controllerKeyId, - provider: identity.provider, - services: identity.services, - keys: identity.keys.map((k) => ({ - kid: k.kid, - type: k.type, - kms: k.kms, - publicKeyHex: k.publicKeyHex, - })), - } - if (identity.alias) { - result.alias = identity.alias - } - return result - } - - async delete({ did }: { did: string }) { - const identity = await (await this.dbConnection).getRepository(Identity).findOne(did) - if (!identity) throw Error('Identity not found') - debug('Deleting', did) - await (await this.dbConnection).getRepository(Identity).remove(identity) - - return true - } - - async import(args: IIdentity) { - const identity = new Identity() - identity.did = args.did - if (args.controllerKeyId) { - identity.controllerKeyId = args.controllerKeyId - } - identity.provider = args.provider - if (args.alias) { - identity.alias = args.alias - } - - identity.keys = [] - for (const argsKey of args.keys) { - const key = new Key() - key.kid = argsKey.kid - key.publicKeyHex = argsKey.publicKeyHex - key.privateKeyHex = argsKey.privateKeyHex - key.kms = argsKey.kms - key.meta = argsKey.meta - identity.keys.push(key) - } - - identity.services = [] - for (const argsService of args.services) { - const service = new Service() - service.id = argsService.id - service.type = argsService.type - service.serviceEndpoint = argsService.serviceEndpoint - service.description = argsService.description - identity.services.push(service) - } - - await (await this.dbConnection).getRepository(Identity).save(identity) - - debug('Saving', args.did) - return true - } - - async list(args: { alias?: string; provider?: string }): Promise { - const where: any = { provider: args?.provider || Not(IsNull()) } - if (args?.alias) { - where['alias'] = args.alias - } - const identities = await (await this.dbConnection).getRepository(Identity).find({ - where, - relations: ['keys', 'services'], - }) - return identities.map( identity => { - const i = identity - if (i.alias === null) { - delete i.alias - } - return i - }) - } -} diff --git a/packages/daf-typeorm/src/index.ts b/packages/daf-typeorm/src/index.ts index 393b9340c..2764c66a1 100644 --- a/packages/daf-typeorm/src/index.ts +++ b/packages/daf-typeorm/src/index.ts @@ -1,18 +1,18 @@ /** - * {@link https://typeorm.io/ | TypeORM } backed plugins. {@link daf-core#Agent} {@link daf-typeorm#DataStore | plugin} that implements {@link daf-core#IDataStore } interface. {@link daf-core#Agent} {@link daf-typeorm#DataStoreORM | plugin} that implements {@link daf-typeorm#IDataStoreORM} interface. Provides {@link daf-typeorm#KeyStore} for {@link daf-key-manager#KeyManager} and {@link daf-typeorm#IdentityStore} for {@link daf-identity-manager#IdentityManager} + * {@link https://typeorm.io/ | TypeORM } backed plugins. {@link daf-core#Agent} {@link daf-typeorm#DataStore | plugin} that implements {@link daf-core#IDataStore } interface. {@link daf-core#Agent} {@link daf-typeorm#DataStoreORM | plugin} that implements {@link daf-typeorm#IDataStoreORM} interface. Provides {@link daf-typeorm#KeyStore} for {@link daf-key-manager#KeyManager} and {@link daf-typeorm#DIDStore} for {@link daf-identity-manager#DIDManager} * * @packageDocumentation */ -export { IdentityStore } from './identity/identity-store' -export { KeyStore } from './identity/key-store' +export { DIDStore } from './identifier/did-store' +export { KeyStore } from './identifier/key-store' export { DataStore } from './data-store' export { DataStoreORM, IDataStoreORM, FindClaimsArgs, FindCredentialsArgs, - FindIdentitiesArgs, + FindIdentifiersArgs, FindMessagesArgs, FindPresentationsArgs, UniqueVerifiablePresentation, @@ -20,14 +20,14 @@ export { } from './data-store-orm' export * from './types' import { Key, KeyType } from './entities/key' -import { Identity } from './entities/identity' +import { Identifier } from './entities/identifier' import { Claim } from './entities/claim' import { Credential } from './entities/credential' import { Presentation } from './entities/presentation' import { Service } from './entities/service' import { Message, MetaData } from './entities/message' -export const Entities = [Key, Identity, Message, Claim, Credential, Presentation, Service] -export { KeyType, Key, Identity, Message, Claim, Credential, Presentation, MetaData, Service } +export const Entities = [Key, Identifier, Message, Claim, Credential, Presentation, Service] +export { KeyType, Key, Identifier, Message, Claim, Credential, Presentation, MetaData, Service } export { migrations } from './migrations' const schema = require('../plugin.schema.json') export { schema } diff --git a/packages/daf-typeorm/src/types.ts b/packages/daf-typeorm/src/types.ts index 1ce11c8ed..265734d92 100644 --- a/packages/daf-typeorm/src/types.ts +++ b/packages/daf-typeorm/src/types.ts @@ -27,7 +27,7 @@ export interface FindArgs { skip?: number } -export type TIdentitiesColumns = 'did' | 'alias' | 'provider' +export type TIdentifiersColumns = 'did' | 'alias' | 'provider' export type TMessageColumns = | 'from' diff --git a/packages/daf-url/src/__tests__/message-handler.test.ts b/packages/daf-url/src/__tests__/message-handler.test.ts index c7a46d22f..4b1dd0275 100644 --- a/packages/daf-url/src/__tests__/message-handler.test.ts +++ b/packages/daf-url/src/__tests__/message-handler.test.ts @@ -25,7 +25,7 @@ describe('daf-url', () => { const JWT = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE1NzU5Njc1MzEsInR5cGUiOiJzZHIiLCJ0YWciOiJzZXNzaW9uLTEyMyIsImNsYWltcyI6W3sicmVhc29uIjoiV2UgbmVlZCB5b3VyIG5hbWUiLCJjbGFpbVR5cGUiOiJuYW1lIn1dLCJpc3MiOiJkaWQ6ZXRocjoweDViMmIwMzM1Mzk4NDM2MDFmYjgxZGYxNzA0OTE4NzA0ZmQwMTQxZmEifQ.KoHbpJ5HkLLIw8iEqsu2Jql9m5dbydNy2zO53GKuIbwfPOW842_IPXw2zwVtj0FcEuHUkzhx-bhS28Zhmvkv2gE' const message = new Message({ - raw: 'https://identity.foundation/ssi/?c_i=' + JWT, + raw: 'https://identifier.foundation/ssi/?c_i=' + JWT, metaData: [ { type: 'QRCode', diff --git a/packages/daf-w3c/api/daf-w3c.api.md b/packages/daf-w3c/api/daf-w3c.api.md index 8376f9387..4164b9d55 100644 --- a/packages/daf-w3c/api/daf-w3c.api.md +++ b/packages/daf-w3c/api/daf-w3c.api.md @@ -8,7 +8,7 @@ import { AbstractMessageHandler } from 'daf-message-handler'; import { IAgentContext } from 'daf-core'; import { IAgentPlugin } from 'daf-core'; import { IDataStore } from 'daf-core'; -import { IIdentityManager } from 'daf-core'; +import { IDIDManager } from 'daf-core'; import { IKeyManager } from 'daf-core'; import { IPluginMethodMap } from 'daf-core'; import { IResolver } from 'daf-core'; diff --git a/packages/daf-w3c/plugin.schema.json b/packages/daf-w3c/plugin.schema.json index 56fb67d3c..98381ca6b 100644 --- a/packages/daf-w3c/plugin.schema.json +++ b/packages/daf-w3c/plugin.schema.json @@ -91,7 +91,7 @@ "issuanceDate", "credentialSubject" ], - "description": "W3CCredential {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "W3CCredential {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "EncodingFormat": { "type": "string", @@ -173,7 +173,7 @@ "credentialSubject", "proof" ], - "description": "Verifiable Credential {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "ICreateVerifiablePresentationArgs": { "type": "object", @@ -244,7 +244,7 @@ "verifier", "verifiableCredential" ], - "description": "W3CPresentation {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "W3CPresentation {@link https://github.com/decentralized-identifier/did-jwt-vc}" }, "VerifiablePresentation": { "type": "object", @@ -302,7 +302,7 @@ "verifiableCredential", "proof" ], - "description": "Verifiable Presentation {@link https://github.com/decentralized-identity/did-jwt-vc}" + "description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}" } }, "methods": { diff --git a/packages/daf-w3c/src/__tests__/action-handler.test.ts b/packages/daf-w3c/src/__tests__/action-handler.test.ts index 1bb7cf997..abb8389cb 100644 --- a/packages/daf-w3c/src/__tests__/action-handler.test.ts +++ b/packages/daf-w3c/src/__tests__/action-handler.test.ts @@ -1,7 +1,7 @@ import { W3CCredential, VerifiableCredential, - IIdentity, + IIdentifier, W3CPresentation, VerifiablePresentation, } from 'daf-core' @@ -18,7 +18,7 @@ jest.mock('did-jwt-vc', () => mockDidJwtVc) import { CredentialIssuer, IContext } from '../action-handler' -const mockIdentity1: IIdentity = { +const mockIdentifier1: IIdentifier = { did: 'did:example:111', provider: 'mock', controllerKeyId: 'kid1', @@ -33,7 +33,7 @@ const mockIdentity1: IIdentity = { services: [], } -const mockIdentity2: IIdentity = { +const mockIdentifier2: IIdentifier = { did: 'did:example:222', provider: 'mock', controllerKeyId: 'kid2', @@ -54,9 +54,7 @@ const context: IContext = { availableMethods: jest.fn(), resolveDid: jest.fn(), emit: jest.fn(), - identityManagerGetIdentity: jest - .fn() - .mockImplementation(async (args): Promise => mockIdentity1), + didManagerGet: jest.fn().mockImplementation(async (args): Promise => mockIdentifier1), keyManagerSignJWT: jest.fn().mockImplementation(async (args): Promise => 'mockJWT'), dataStoreSaveVerifiableCredential: jest.fn().mockImplementation(async (args): Promise => true), dataStoreSaveVerifiablePresentation: jest.fn().mockImplementation(async (args): Promise => true), @@ -71,11 +69,11 @@ describe('daf-w3c', () => { const credential: W3CCredential = { '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2020/demo/4342323'], type: ['VerifiableCredential', 'PublicProfile'], - issuer: { id: mockIdentity1.did }, + issuer: { id: mockIdentifier1.did }, issuanceDate: new Date().toISOString(), id: 'vc1', credentialSubject: { - id: mockIdentity2.did, + id: mockIdentifier2.did, name: 'Alice', profilePicture: 'https://example.com/a.png', address: { @@ -94,7 +92,7 @@ describe('daf-w3c', () => { context, ) // TODO Update these after refactoring did-jwt-vc - expect(context.agent.identityManagerGetIdentity).toBeCalledWith({ did: mockIdentity1.did }) + expect(context.agent.didManagerGet).toBeCalledWith({ did: mockIdentifier1.did }) expect(context.agent.dataStoreSaveVerifiableCredential).toBeCalledWith({ verifiableCredential: 'mockCredential', }) @@ -105,11 +103,11 @@ describe('daf-w3c', () => { const credential: VerifiableCredential = { '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential', 'PublicProfile'], - issuer: { id: mockIdentity1.did }, + issuer: { id: mockIdentifier1.did }, issuanceDate: new Date().toISOString(), id: 'vc1', credentialSubject: { - id: mockIdentity2.did, + id: mockIdentifier2.did, name: 'Alice', profilePicture: 'https://example.com/a.png', address: { @@ -125,8 +123,8 @@ describe('daf-w3c', () => { const presentation: W3CPresentation = { '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiablePresentation'], - holder: mockIdentity1.did, - verifier: [mockIdentity2.did], + holder: mockIdentifier1.did, + verifier: [mockIdentifier2.did], issuanceDate: new Date().toISOString(), verifiableCredential: [credential], } @@ -140,7 +138,7 @@ describe('daf-w3c', () => { context, ) - expect(context.agent.identityManagerGetIdentity).toBeCalledWith({ did: mockIdentity1.did }) + expect(context.agent.didManagerGet).toBeCalledWith({ did: mockIdentifier1.did }) expect(context.agent.dataStoreSaveVerifiablePresentation).toBeCalledWith({ verifiablePresentation: 'mockPresentation', }) diff --git a/packages/daf-w3c/src/__tests__/credentialStatus.test.ts b/packages/daf-w3c/src/__tests__/credentialStatus.test.ts index 01a8ca282..331511c11 100644 --- a/packages/daf-w3c/src/__tests__/credentialStatus.test.ts +++ b/packages/daf-w3c/src/__tests__/credentialStatus.test.ts @@ -18,8 +18,8 @@ describe('daf-did-comm', () => { // const mockDid: string = `did:ethr:${signerAddress}` // const mockAgent = { -// identityManager: { -// getIdentity: async (did: string) => ({ +// didManager: { +// getIdentifier: async (did: string) => ({ // did: mockDid, // keyByType: async (type: string) => ({ // signer: () => { diff --git a/packages/daf-w3c/src/action-handler.ts b/packages/daf-w3c/src/action-handler.ts index ae33de1ea..4c395ea68 100644 --- a/packages/daf-w3c/src/action-handler.ts +++ b/packages/daf-w3c/src/action-handler.ts @@ -2,7 +2,7 @@ import { IAgentContext, IAgentPlugin, IResolver, - IIdentityManager, + IDIDManager, IKeyManager, IPluginMethodMap, W3CCredential, @@ -142,7 +142,7 @@ export interface ICredentialIssuer extends IPluginMethodMap { */ export type IContext = IAgentContext< IResolver & - Pick & + Pick & Pick & Pick > @@ -169,15 +169,15 @@ export class CredentialIssuer implements IAgentPlugin { context: IContext, ): Promise { try { - //FIXME: if the identity is not found, the error message should reflect that. - const identity = await context.agent.identityManagerGetIdentity({ did: args.presentation.holder }) + //FIXME: if the identifier is not found, the error message should reflect that. + const identifier = await context.agent.didManagerGet({ did: args.presentation.holder }) //FIXME: `args` should allow picking a key or key type - const key = identity.keys.find((k) => k.type === 'Secp256k1') - if (!key) throw Error('No signing key for ' + identity.did) + const key = identifier.keys.find((k) => k.type === 'Secp256k1') + if (!key) throw Error('No signing key for ' + identifier.did) //FIXME: Throw an `unsupported_format` error if the `args.proofFormat` is not `jwt` const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) - debug('Signing VP with', identity.did) - const jwt = await createVerifiablePresentationJwt(args.presentation, { did: identity.did, signer }) + debug('Signing VP with', identifier.did) + const jwt = await createVerifiablePresentationJwt(args.presentation, { did: identifier.did, signer }) //FIXME: flagging this as a potential privacy leak. debug(jwt) const verifiablePresentation = normalizePresentation(jwt) @@ -197,16 +197,16 @@ export class CredentialIssuer implements IAgentPlugin { context: IContext, ): Promise { try { - //FIXME: if the identity is not found, the error message should reflect that. - const identity = await context.agent.identityManagerGetIdentity({ did: args.credential.issuer.id }) + //FIXME: if the identifier is not found, the error message should reflect that. + const identifier = await context.agent.didManagerGet({ did: args.credential.issuer.id }) //FIXME: `args` should allow picking a key or key type - const key = identity.keys.find((k) => k.type === 'Secp256k1') - if (!key) throw Error('No signing key for ' + identity.did) + const key = identifier.keys.find((k) => k.type === 'Secp256k1') + if (!key) throw Error('No signing key for ' + identifier.did) //FIXME: Throw an `unsupported_format` error if the `args.proofFormat` is not `jwt` const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) - debug('Signing VC with', identity.did) - const jwt = await createVerifiableCredentialJwt(args.credential, { did: identity.did, signer }) + debug('Signing VC with', identifier.did) + const jwt = await createVerifiableCredentialJwt(args.credential, { did: identifier.did, signer }) //FIXME: flagging this as a potential privacy leak. debug(jwt) const verifiableCredential = normalizeCredential(jwt) diff --git a/packages/daf-web-did/api/daf-web-did.api.md b/packages/daf-web-did/api/daf-web-did.api.md index fbe487eb7..5a7f44be7 100644 --- a/packages/daf-web-did/api/daf-web-did.api.md +++ b/packages/daf-web-did/api/daf-web-did.api.md @@ -4,48 +4,48 @@ ```ts -import { AbstractIdentityProvider } from 'daf-identity-manager'; +import { AbstractIdentifierProvider } from 'daf-identity-manager'; import { IAgentContext } from 'daf-core'; -import { IIdentity } from 'daf-core'; +import { IIdentifier } from 'daf-core'; import { IKey } from 'daf-core'; import { IKeyManager } from 'daf-core'; import { IService } from 'daf-core'; // @public -export class WebIdentityProvider extends AbstractIdentityProvider { +export class WebDIDProvider extends AbstractIdentifierProvider { constructor(options: { defaultKms: string; }); // (undocumented) - addKey({ identity, key, options }: { - identity: IIdentity; + addKey({ identifier, key, options }: { + identifier: IIdentifier; key: IKey; options?: any; }, context: IContext): Promise; // (undocumented) - addService({ identity, service, options }: { - identity: IIdentity; + addService({ identifier, service, options }: { + identifier: IIdentifier; service: IService; options?: any; }, context: IContext): Promise; // Warning: (ae-forgotten-export) The symbol "IContext" needs to be exported by the entry point index.d.ts // // (undocumented) - createIdentity({ kms, alias }: { + createIdentifier({ kms, alias }: { kms?: string; alias?: string; - }, context: IContext): Promise>; + }, context: IContext): Promise>; // (undocumented) - deleteIdentity(identity: IIdentity, context: IContext): Promise; + deleteIdentifier(identifier: IIdentifier, context: IContext): Promise; // (undocumented) removeKey(args: { - identity: IIdentity; + identifier: IIdentifier; kid: string; options?: any; }, context: IContext): Promise; // (undocumented) removeService(args: { - identity: IIdentity; + identifier: IIdentifier; id: string; options?: any; }, context: IContext): Promise; diff --git a/packages/daf-web-did/src/identifier-provider.ts b/packages/daf-web-did/src/identifier-provider.ts new file mode 100644 index 000000000..69cdc3946 --- /dev/null +++ b/packages/daf-web-did/src/identifier-provider.ts @@ -0,0 +1,71 @@ +import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from 'daf-core' +import { AbstractIdentifierProvider } from 'daf-identity-manager' + +import Debug from 'debug' +const debug = Debug('daf:web-did:identifier-provider') + +type IContext = IAgentContext + +/** + * {@link daf-identity-manager#DIDManager} identifier provider for `did:web` identifiers + * @public + */ +export class WebDIDProvider extends AbstractIdentifierProvider { + private defaultKms: string + + constructor(options: { defaultKms: string }) { + super() + this.defaultKms = options.defaultKms + } + + async createIdentifier( + { kms, alias }: { kms?: string; alias?: string }, + context: IContext, + ): Promise> { + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) + + const identifier: Omit = { + did: 'did:web:' + alias, + controllerKeyId: key.kid, + keys: [key], + services: [], + } + debug('Created', identifier.did) + return identifier + } + + async deleteIdentifier(identifier: IIdentifier, context: IContext): Promise { + for (const { kid } of identifier.keys) { + await context.agent.keyManagerDelete({ kid }) + } + return true + } + + async addKey( + { identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any }, + context: IContext, + ): Promise { + return { success: true } + } + + async addService( + { identifier, service, options }: { identifier: IIdentifier; service: IService; options?: any }, + context: IContext, + ): Promise { + return { success: true } + } + + async removeKey( + args: { identifier: IIdentifier; kid: string; options?: any }, + context: IContext, + ): Promise { + return { success: true } + } + + async removeService( + args: { identifier: IIdentifier; id: string; options?: any }, + context: IContext, + ): Promise { + return { success: true } + } +} diff --git a/packages/daf-web-did/src/identity-provider.ts b/packages/daf-web-did/src/identity-provider.ts deleted file mode 100644 index 08f5d0974..000000000 --- a/packages/daf-web-did/src/identity-provider.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { IIdentity, IKey, IService, IAgentContext, IKeyManager } from 'daf-core' -import { AbstractIdentityProvider } from 'daf-identity-manager' - -import Debug from 'debug' -const debug = Debug('daf:web-did:identity-provider') - -type IContext = IAgentContext - -/** - * {@link daf-identity-manager#IdentityManager} identity provider for `did:web` identities - * @public - */ -export class WebIdentityProvider extends AbstractIdentityProvider { - private defaultKms: string - - constructor(options: { defaultKms: string }) { - super() - this.defaultKms = options.defaultKms - } - - async createIdentity( - { kms, alias }: { kms?: string; alias?: string }, - context: IContext, - ): Promise> { - const key = await context.agent.keyManagerCreateKey({ kms: kms || this.defaultKms, type: 'Secp256k1' }) - - const identity: Omit = { - did: 'did:web:' + alias, - controllerKeyId: key.kid, - keys: [key], - services: [], - } - debug('Created', identity.did) - return identity - } - - async deleteIdentity(identity: IIdentity, context: IContext): Promise { - for (const { kid } of identity.keys) { - await context.agent.keyManagerDeleteKey({ kid }) - } - return true - } - - async addKey( - { identity, key, options }: { identity: IIdentity; key: IKey; options?: any }, - context: IContext, - ): Promise { - return { success: true } - } - - async addService( - { identity, service, options }: { identity: IIdentity; service: IService; options?: any }, - context: IContext, - ): Promise { - return { success: true } - } - - async removeKey( - args: { identity: IIdentity; kid: string; options?: any }, - context: IContext, - ): Promise { - return { success: true } - } - - async removeService( - args: { identity: IIdentity; id: string; options?: any }, - context: IContext, - ): Promise { - return { success: true } - } -} diff --git a/packages/daf-web-did/src/index.ts b/packages/daf-web-did/src/index.ts index 6516cb0a7..37f563a53 100644 --- a/packages/daf-web-did/src/index.ts +++ b/packages/daf-web-did/src/index.ts @@ -1,6 +1,6 @@ /** - * Provides `did:web` {@link daf-web-did#WebIdentityProvider | identity provider } for the {@link daf-identity-manager#IdentityManager} + * Provides `did:web` {@link daf-web-did#WebDIDProvider | identifier provider } for the {@link daf-identity-manager#DIDManager} * * @packageDocumentation */ -export { WebIdentityProvider } from './identity-provider' +export { WebDIDProvider } from './identifier-provider' diff --git a/scripts/prepare-integration-tests.ts b/scripts/prepare-integration-tests.ts index 06ada9268..dc8584848 100644 --- a/scripts/prepare-integration-tests.ts +++ b/scripts/prepare-integration-tests.ts @@ -41,7 +41,7 @@ for (const inputFolder of inputFolders) { const apiJsonFilePath = './temp/.api.json' const agentPlugins: Record> = { - 'daf-core': ['IResolver', 'IIdentityManager', 'IMessageHandler', 'IDataStore', 'IKeyManager'], + 'daf-core': ['IResolver', 'IDIDManager', 'IMessageHandler', 'IDataStore', 'IKeyManager'], 'daf-w3c': ['ICredentialIssuer'], 'daf-selective-disclosure': ['ISelectiveDisclosure'], 'daf-did-comm': ['IDIDComm'], diff --git a/yarn.lock b/yarn.lock index 3013a86f3..1cd542f9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3509,7 +3509,7 @@ concat-stream@^1.5.0: readable-stream "^2.2.2" typedarray "^0.0.6" -concat-stream@^2.0.0, "concat-stream@github:hugomrdias/concat-stream#feat/smaller": +concat-stream@^2.0.0: version "2.0.0" resolved "https://codeload.github.com/hugomrdias/concat-stream/tar.gz/057bc7b5d6d8df26c8cf00a3f151b6721a0a8034" dependencies: @@ -7343,16 +7343,6 @@ lodash.memoize@4.x: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= -lodash.merge@^4.6.2: - version "4.6.2" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" - integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== - -lodash.partition@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.partition/-/lodash.partition-4.6.0.tgz#a38e46b73469e0420b0da1212e66d414be364ba4" - integrity sha1-o45GtzRp4EILDaEhLmbUFL42S6Q= - lodash.set@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"