Skip to content

Commit

Permalink
refactor: Rename Identity to Identifier (#308)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
simonas-notcat authored Dec 17, 2020
1 parent 3ec73b9 commit 7812e51
Show file tree
Hide file tree
Showing 84 changed files with 2,018 additions and 2,046 deletions.
40 changes: 20 additions & 20 deletions __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
createAgent,
TAgent,
IIdentityManager,
IDIDManager,
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 { 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,
Expand All @@ -27,7 +27,7 @@ import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium/src'
import {
Entities,
KeyStore,
IdentityStore,
DIDStore,
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 didManager from './shared/didManager'
import messageHandler from './shared/messageHandler'

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

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

agent = createAgent<
IIdentityManager &
IDIDManager &
IKeyManager &
IDataStore &
IDataStoreORM &
Expand All @@ -98,42 +98,42 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
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),
Expand Down Expand Up @@ -171,6 +171,6 @@ describe('Local integration tests', () => {
saveClaims(testContext)
documentationExamples(testContext)
keyManager(testContext)
identityManager(testContext)
didManager(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,
IDIDManager,
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 { 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,
Expand All @@ -29,7 +29,7 @@ import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium/src'
import {
Entities,
KeyStore,
IdentityStore,
DIDStore,
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 didManager from './shared/didManager'
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 &
IDIDManager &
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 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: [
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)
didManager(testContext)
messageHandler(testContext)
})
Loading

0 comments on commit 7812e51

Please sign in to comment.