Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rename Identity to Identifier #308

Merged
merged 18 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
createAgent,
TAgent,
IIdentityManager,
IIdManager,
IResolver,
IKeyManager,
IDataStore,
Expand All @@ -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 { IdManager } 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 { EthrIdentifierProvider } from '../packages/daf-ethr-did/src'
import { WebIdentifierProvider } from '../packages/daf-web-did/src'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/daf-did-comm/src'
import {
SelectiveDisclosure,
Expand All @@ -27,7 +27,7 @@ import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium/src'
import {
Entities,
KeyStore,
IdentityStore,
IdentifierStore,
IDataStoreORM,
DataStore,
DataStoreORM,
Expand All @@ -47,15 +47,15 @@ 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 idManager from './shared/idManager'
import messageHandler from './shared/messageHandler'

const databaseFile = 'local-database.sqlite'
const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c'
const secretKey = '29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c'

let agent: TAgent<
IIdentityManager &
IIdManager &
IKeyManager &
IDataStore &
IDataStoreORM &
Expand All @@ -77,7 +77,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
})

agent = createAgent<
IIdentityManager &
IIdManager &
IKeyManager &
IDataStore &
IDataStoreORM &
Expand All @@ -98,30 +98,30 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
local: new KeyManagementSystem(),
},
}),
new IdentityManager({
store: new IdentityStore(dbConnection),
new IdManager({
store: new IdentifierStore(dbConnection),
defaultProvider: 'did:ethr:rinkeby',
providers: {
'did:ethr': new EthrIdentityProvider({
'did:ethr': new EthrIdentifierProvider({
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 EthrIdentifierProvider({
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 WebIdentifierProvider({
defaultKms: 'local',
}),
},
}),
new DafResolver({
new DafResolver({
resolver: new Resolver({
ethr: ethrDidResolver({
networks: [
Expand All @@ -130,10 +130,10 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
{ 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),
Expand Down Expand Up @@ -171,6 +171,6 @@ describe('Local integration tests', () => {
saveClaims(testContext)
documentationExamples(testContext)
keyManager(testContext)
identityManager(testContext)
idManager(testContext)
messageHandler(testContext)
})
36 changes: 18 additions & 18 deletions __tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Agent,
IAgent,
createAgent,
IIdentityManager,
IIdManager,
IResolver,
IKeyManager,
IDataStore,
Expand All @@ -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 { IdManager } 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 { EthrIdentifierProvider } from '../packages/daf-ethr-did/src'
import { WebIdentifierProvider } from '../packages/daf-web-did/src'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/daf-did-comm/src'
import {
SelectiveDisclosure,
Expand All @@ -29,7 +29,7 @@ import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium/src'
import {
Entities,
KeyStore,
IdentityStore,
IdentifierStore,
IDataStoreORM,
DataStore,
DataStoreORM,
Expand All @@ -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 idManager from './shared/idManager'
import messageHandler from './shared/messageHandler'

const databaseFile = 'rest-database.sqlite'
Expand All @@ -67,7 +67,7 @@ let restServer: Server

const getAgent = (options?: IAgentOptions) =>
createAgent<
IIdentityManager &
IIdManager &
IKeyManager &
IDataStore &
IDataStoreORM &
Expand All @@ -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(),
}),
],
Expand All @@ -105,30 +105,30 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
local: new KeyManagementSystem(),
},
}),
new IdentityManager({
store: new IdentityStore(dbConnection),
new IdManager({
store: new IdentifierStore(dbConnection),
defaultProvider: 'did:ethr:rinkeby',
providers: {
'did:ethr': new EthrIdentityProvider({
'did:ethr': new EthrIdentifierProvider({
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 EthrIdentifierProvider({
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 WebIdentifierProvider({
defaultKms: 'local',
}),
},
}),
new DafResolver({
new DafResolver({
resolver: new Resolver({
ethr: ethrDidResolver({
networks: [
Expand All @@ -137,10 +137,10 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
{ 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),
Expand Down Expand Up @@ -188,6 +188,6 @@ describe('REST integration tests', () => {
webDidFlow(testContext)
documentationExamples(testContext)
keyManager(testContext)
identityManager(testContext)
idManager(testContext)
messageHandler(testContext)
})
26 changes: 13 additions & 13 deletions __tests__/shared/documentationExamples.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TAgent, IIdentityManager, IDataStore, IMessageHandler } from '../../packages/daf-core/src'
import { TAgent, IIdManager, 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
IIdManager & ICredentialIssuer & IDataStoreORM & IDataStore & IMessageHandler & ISelectiveDisclosure
>

export default (testContext: {
Expand Down Expand Up @@ -48,35 +48,35 @@ export default (testContext: {
})
})

it('daf-core-IIdentityManager-identityManagerCreateIdentity example', async () => {
const identity = await agent.identityManagerCreateIdentity({
it('daf-core-IIdManager-idManagerCreateIdentifier example', async () => {
const identifier = await agent.idManagerCreateIdentifier({
alias: 'alice',
provider: 'did:ethr:rinkeby',
kms: 'local',
})
})

it('daf-core-IIdentityManager-identityManagerGetIdentities example', async () => {
const aliceIdentities = await agent.identityManagerGetIdentities({
it('daf-core-IIdManager-idManagerGetIdentifiers example', async () => {
const aliceIdentifiers = await agent.idManagerGetIdentifiers({
alias: 'alice',
})

const rinkebyIdentities = await agent.identityManagerGetIdentities({
const rinkebyIdentifiers = await agent.idManagerGetIdentifiers({
provider: 'did:ethr:rinkeby',
})
})

it('daf-core-IIdentityManager-identityManagerGetIdentityByAlias example', async () => {
const identity = await agent.identityManagerGetIdentityByAlias({
it('daf-core-IIdManager-idManagerGetIdentifierByAlias example', async () => {
const identifier = await agent.idManagerGetIdentifierByAlias({
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-IIdManager-idManagerSetAlias example', async () => {
const identifier = await agent.idManagerCreateIdentifier()
const result = await agent.idManagerSetAlias({
did: identifier.did,
alias: 'carol',
})
})
Expand Down
Loading