Skip to content

Commit

Permalink
feat: New DID management interfaces
Browse files Browse the repository at this point in the history
BREAKING CHANGE: new interfaces for IdentityManager
 AbstractIdentityController AbstractIdentityProvider
 AbstractIdentityStore AbstractIdentity
AbstractKeyManagementSystem AbstractKey AbstractKeyStore
  • Loading branch information
simonas-notcat committed Feb 17, 2020
1 parent e86fec4 commit 9599e2a
Show file tree
Hide file tree
Showing 77 changed files with 478 additions and 24,512 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ lerna-debug.log

*.tsbuildinfo
identity-store.json
key-store.json
4 changes: 3 additions & 1 deletion examples/expressjs-ethr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"daf-debug": "^1.4.1",
"daf-did-comm": "^1.4.1",
"daf-did-jwt": "^1.4.1",
"daf-ethr-did-fs": "^1.4.1",
"daf-ethr-did": "../daf/packages/daf-ethr-did",
"daf-fs": "../daf/packages/daf-fs",
"daf-libsodium": "../daf/packages/daf-libsodium",
"daf-node-sqlite3": "^1.5.0",
"daf-resolver": "^1.1.0",
"daf-resolver-universal": "^1.1.0",
Expand Down
10 changes: 6 additions & 4 deletions examples/expressjs-ethr/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { DafUniversalResolver } from 'daf-resolver-universal'

import * as Daf from 'daf-core'
import * as DidJwt from 'daf-did-jwt'
import { IdentityProvider } from 'daf-ethr-did-fs'
import * as EthrDid from 'daf-ethr-did'
import * as DafLibSodium from 'daf-libsodium'
import * as DafFs from 'daf-fs'

import * as W3c from 'daf-w3c'
import * as SD from 'daf-selective-disclosure'
Expand All @@ -18,7 +20,6 @@ import ws from 'ws'

const defaultPath = __dirname + '/.daf'

const identityStoreFilename = process.env.DAF_IDENTITY_STORE ?? defaultPath + '/identity-store.json'
const dataStoreFilename = process.env.DAF_DATA_STORE ?? defaultPath + '/data-store.sqlite3'
const infuraProjectId = process.env.DAF_INFURA_ID ?? '5ffc47f65c4042ce847ef66a3fa70d4c'
if (process.env.DAF_TG_URI) TG.ServiceController.defaultUri = process.env.DAF_TG_URI
Expand All @@ -44,8 +45,9 @@ if (process.env.DAF_UNIVERSAL_RESOLVER_URL) {
}

const identityProviders = [
new IdentityProvider({
fileName: identityStoreFilename,
new EthrDid.IdentityProvider({
identityStore: new DafFs.IdentityStore(defaultPath + '/identity-store.json'),
kms: new DafLibSodium.KeyManagementSystem(new DafFs.KeyStore(defaultPath + '/key-store.json')),
network: 'rinkeby',
rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId,
resolver: didResolver,
Expand Down
5 changes: 3 additions & 2 deletions examples/expressjs-ethr/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
{ "path": "../../packages/daf-debug" },
{ "path": "../../packages/daf-did-comm" },
{ "path": "../../packages/daf-did-jwt" },
{ "path": "../../packages/daf-ethr-did-fs" },
{ "path": "../../packages/daf-ethr-did-react-native" },
{ "path": "../../packages/daf-ethr-did" },
{ "path": "../../packages/daf-fs" },
{ "path": "../../packages/daf-libsodium" },
{ "path": "../../packages/daf-node-sqlite3" },
{ "path": "../../packages/daf-resolver" },
{ "path": "../../packages/daf-resolver-universal" },
Expand Down
5 changes: 3 additions & 2 deletions examples/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"daf-core": "^1.4.1",
"daf-debug": "^1.4.1",
"daf-did-jwt": "^1.4.1",
"daf-ethr-did-local-storage": "../daf/packages/daf-ethr-did-local-storage",
"daf-ethr-did-metamask": "../daf/packages/daf-ethr-did-metamask",
"daf-ethr-did": "../daf/packages/daf-ethr-did",
"daf-local-storage": "../daf/packages/daf-local-storage",
"daf-libsodium": "../daf/packages/daf-libsodium",
"daf-resolver-universal": "^1.1.0",
"daf-trust-graph": "^1.4.1",
"daf-w3c": "^1.4.1",
Expand Down
18 changes: 11 additions & 7 deletions examples/react-app/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import * as TG from 'daf-trust-graph'
import * as DBG from 'daf-debug'
import * as DidJwt from 'daf-did-jwt'
import { DafUniversalResolver } from 'daf-resolver-universal'
import * as EthrLocal from 'daf-ethr-did-local-storage'
import * as MM from 'daf-ethr-did-metamask'
import * as EthrDid from 'daf-ethr-did'
import * as DafLocalStorage from 'daf-local-storage'
import * as DafLibSodium from 'daf-libsodium'
// import * as MM from 'daf-ethr-did-metamask'

import Debug from 'debug'
Debug.enable('*')
Expand All @@ -21,17 +23,19 @@ const didResolver = new DafUniversalResolver({ url: 'https://uniresolver.io/1.0/
const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c'

const identityProviders: Daf.AbstractIdentityProvider[] = [
new EthrLocal.IdentityProvider({
new EthrDid.IdentityProvider({
kms: new DafLibSodium.KeyManagementSystem(new DafLocalStorage.KeyStore('localKeys')),
identityStore: new DafLocalStorage.IdentityStore('localIdentities'),
network: 'rinkeby',
rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId,
resolver: didResolver,
}),
]

if (typeof window.ethereum !== 'undefined' && window.ethereum.isMetaMask) {
MM.IdentityProvider.snapId = 'http://localhost:8082/package.json'
identityProviders.push(new MM.IdentityProvider())
}
// if (typeof window.ethereum !== 'undefined' && window.ethereum.isMetaMask) {
// MM.IdentityProvider.snapId = 'http://localhost:8082/package.json'
// identityProviders.push(new MM.IdentityProvider())
// }

export const core = new Daf.Core({
identityProviders,
Expand Down
5 changes: 4 additions & 1 deletion examples/react-graphql/client/src/gql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export const allIdentities = gql`

export const managedIdentities = gql`
query managedIdentities {
managedIdentityTypes
identityProviders {
type
description
}
managedIdentities {
did
type
Expand Down
5 changes: 4 additions & 1 deletion examples/react-graphql/client/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const identity = gql`

export const managedIdentities = gql`
query managedIdentities {
managedIdentityTypes
identityProviders {
type
description
}
managedIdentities {
did
type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,19 @@ const Component = () => {
</tbody>
</Table>
<Box pl={4}>
{managedIdentitiesData?.managedIdentityTypes?.map((type: string) => (
<Button mt={3} mb={3} mr={3} key={type} onClick={() => createIdentity({ variables: { type } })}>
Create {type} DID
</Button>
))}
{managedIdentitiesData?.identityProviders?.map(
(provider: { type: string; description: string }) => (
<Button
mt={3}
mb={3}
mr={3}
key={provider.type}
onClick={() => createIdentity({ variables: { type: provider.type } })}
>
Create {provider.type} DID
</Button>
),
)}
</Box>
</Panel>
</Page>
Expand Down
9 changes: 6 additions & 3 deletions examples/react-graphql/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import * as TG from 'daf-trust-graph'
import * as DBG from 'daf-debug'
import * as URL from 'daf-url'
import { NodeSqlite3 } from 'daf-node-sqlite3'
import { IdentityProvider } from 'daf-ethr-did-fs'
import * as DafEthrDid from 'daf-ethr-did'
import * as DafFs from 'daf-fs'
import * as DafLibSodium from 'daf-libsodium'
import { DafResolver } from 'daf-resolver'
import { ApolloServer } from 'apollo-server'
import merge from 'lodash.merge'
Expand All @@ -19,8 +21,9 @@ const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c'
let didResolver = new DafResolver({ infuraProjectId })

const identityProviders = [
new IdentityProvider({
fileName: './identity-store.json',
new DafEthrDid.IdentityProvider({
kms: new DafLibSodium.KeyManagementSystem(new DafFs.KeyStore('./key-store.json')),
identityStore: new DafFs.IdentityStore('./identity-store.json'),
network: 'rinkeby',
rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId,
resolver: didResolver,
Expand Down
Loading

0 comments on commit 9599e2a

Please sign in to comment.