diff --git a/examples/expressjs-ethr/src/framework.ts b/examples/expressjs-ethr/src/framework.ts index 5254fc495..afdf7a559 100644 --- a/examples/expressjs-ethr/src/framework.ts +++ b/examples/expressjs-ethr/src/framework.ts @@ -6,8 +6,8 @@ import { JwtMessageHandler } from 'daf-did-jwt' import * as EthrDid from 'daf-ethr-did' import * as DafLibSodium from 'daf-libsodium' import { W3cMessageHandler, W3cActionHandler } from 'daf-w3c' -import { SdrMessageHandler, SdrActionHandler} from 'daf-selective-disclosure' -import { DIDCommMessageHandler, DIDCommActionHandler} from 'daf-did-comm' +import { SdrMessageHandler, SdrActionHandler } from 'daf-selective-disclosure' +import { DIDCommMessageHandler, DIDCommActionHandler } from 'daf-did-comm' import { UrlMessageHandler } from 'daf-url' import { createConnection } from 'typeorm' import { DataStore } from 'daf-data-store' @@ -25,10 +25,18 @@ if (process.env.DAF_UNIVERSAL_RESOLVER_URL) { }) } +const dbConnection = createConnection({ + type: 'sqlite', + database: './database.sqlite', + synchronize: true, + logging: false, + entities: [...Daf.Entities], +}) + const identityProviders = [ new EthrDid.IdentityProvider({ - identityStore: new Daf.IdentityStore('rinkeby-ethr'), - kms: new DafLibSodium.KeyManagementSystem(new Daf.KeyStore()), + identityStore: new Daf.IdentityStore('rinkeby-ethr', dbConnection), + kms: new DafLibSodium.KeyManagementSystem(new Daf.KeyStore(dbConnection)), network: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId, }), @@ -43,26 +51,13 @@ messageHandler .setNext(new SdrMessageHandler()) const actionHandler = new DIDCommActionHandler() -actionHandler - .setNext(new W3cActionHandler()) - .setNext(new SdrActionHandler()) +actionHandler.setNext(new W3cActionHandler()).setNext(new SdrActionHandler()) export const agent = new Daf.Agent({ + dbConnection, identityProviders, serviceControllers, didResolver, messageHandler, actionHandler, }) - -export const initializeDb = async () => { - await createConnection({ - type: 'sqlite', - database: './database.sqlite', - synchronize: true, - logging: false, - entities: [...Daf.Entities], - }) -} - -export const dataStore = new DataStore() diff --git a/examples/expressjs-ethr/src/index.ts b/examples/expressjs-ethr/src/index.ts index 2ffdfc123..b3448e974 100644 --- a/examples/expressjs-ethr/src/index.ts +++ b/examples/expressjs-ethr/src/index.ts @@ -3,14 +3,13 @@ import * as Daf from 'daf-core' import * as SD from 'daf-selective-disclosure' import * as W3C from 'daf-w3c' import { app, server, io, sessionStore } from './server' -import { agent, dataStore, initializeDb } from './framework' +import { agent } from './framework' import { getIdentity, setServiceEndpoint } from './identity' if (!process.env.HOST) throw Error('Environment variable HOST not set') if (!process.env.PORT) throw Error('Environment variable PORT not set') async function main() { - await initializeDb() const identity = await getIdentity() const messagingEndpoint = '/handle-message' @@ -69,8 +68,7 @@ async function main() { req.session.views = req.session.views ? req.session.views + 1 : 1 const { did, views } = req.session - const name = await dataStore.shortId(did) - res.render('home', { did, views, name }) + res.render('home', { did, views }) }) app.get('/history', requireLogin, async (req, res) => { @@ -80,8 +78,9 @@ async function main() { req.session.views = req.session.views ? req.session.views + 1 : 1 const { did, views } = req.session - const name = await dataStore.shortId(did) - const messages = await dataStore.findMessages({ sender: did }) + const messages = await (await agent.dbConnection) + .getRepository(Daf.Message) + .find({ where: { from: did } }) console.log(messages) res.render('history', { did, views, name, messages }) }) @@ -120,7 +119,6 @@ async function main() { req.session.views = req.session.views ? req.session.views + 1 : 1 const { did, views } = req.session - const name = await dataStore.shortId(did) // Sign verifiable credential const nameJwt = await agent.handleAction({ diff --git a/examples/expressjs-ethr/views/history.handlebars b/examples/expressjs-ethr/views/history.handlebars index 66e30dcf1..28dd26037 100644 --- a/examples/expressjs-ethr/views/history.handlebars +++ b/examples/expressjs-ethr/views/history.handlebars @@ -3,13 +3,10 @@

DID

{{did}}

-

Name

-

{{name}}

- - + @@ -18,10 +15,10 @@ {{#each messages}} - {{~/each}} diff --git a/examples/expressjs-ethr/views/home.handlebars b/examples/expressjs-ethr/views/home.handlebars index ef1004b8e..62dced161 100644 --- a/examples/expressjs-ethr/views/home.handlebars +++ b/examples/expressjs-ethr/views/home.handlebars @@ -2,6 +2,3 @@

DID

{{did}}

- -

Name

-

{{name}}

diff --git a/examples/expressjs-ethr/yarn.lock b/examples/expressjs-ethr/yarn.lock index 66bfacfe2..f60629d0e 100644 --- a/examples/expressjs-ethr/yarn.lock +++ b/examples/expressjs-ethr/yarn.lock @@ -613,51 +613,51 @@ cross-fetch@^3.0.4: node-fetch "2.6.0" whatwg-fetch "3.0.0" -daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" debug "^4.1.1" events "^3.0.0" typeorm "^0.2.24" -daf-data-store@../../packages/daf-data-store, daf-data-store@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-data-store@../../packages/daf-data-store, daf-data-store@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" sql-bricks-sqlite "^0.1.0" daf-did-comm@../../packages/daf-did-comm: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" uuid "^3.3.3" -daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" did-resolver "^1.1.0" daf-ethr-did@../../packages/daf-ethr-did: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" ethjs-provider-signer "^0.1.4" ethr-did "^1.1.0" js-sha3 "^0.8.0" daf-libsodium@../../packages/daf-libsodium: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: base-58 "^0.0.1" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" elliptic "^6.5.2" @@ -680,28 +680,29 @@ daf-resolver@../../packages/daf-resolver: web-did-resolver "^1.2.0" daf-selective-disclosure@../../packages/daf-selective-disclosure: - version "4.0.0-beta.15" + version "4.0.0-beta.41" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-data-store "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-data-store "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" + typeorm "^0.2.24" daf-url@../../packages/daf-url: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" url-parse "^1.4.7" daf-w3c@../../packages/daf-w3c: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt-vc "^0.1.3" did-resolver "^1.1.0" diff --git a/examples/id-hub/src/index.ts b/examples/id-hub/src/index.ts index 98dc4401a..5f77b0c7e 100644 --- a/examples/id-hub/src/index.ts +++ b/examples/id-hub/src/index.ts @@ -12,11 +12,18 @@ const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c' let didResolver = new DafResolver({ infuraProjectId }) const messageHandler = new JwtMessageHandler() -messageHandler - .setNext(new W3cMessageHandler()) - .setNext(new SdrMessageHandler()) +messageHandler.setNext(new W3cMessageHandler()).setNext(new SdrMessageHandler()) + +const dbConnection = createConnection({ + type: 'sqlite', + database: './database.sqlite', + synchronize: true, + logging: false, + entities: [...Daf.Entities], +}) export const agent = new Daf.Agent({ + dbConnection, identityProviders: [], serviceControllers: [], didResolver, @@ -43,14 +50,6 @@ agent.on(Daf.EventTypes.savedMessage, async (message: Daf.Message) => { }) const main = async () => { - const c = await createConnection({ - type: 'sqlite', - database: './database.sqlite', - synchronize: true, - logging: false, - entities: [...Daf.Entities], - }) - const info = await server.listen() console.log(`🚀 Server ready at ${info.url}`) } diff --git a/examples/id-hub/yarn.lock b/examples/id-hub/yarn.lock index f55f7b4a8..809c00622 100644 --- a/examples/id-hub/yarn.lock +++ b/examples/id-hub/yarn.lock @@ -861,28 +861,28 @@ cross-fetch@^3.0.4: node-fetch "2.6.0" whatwg-fetch "3.0.0" -daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" debug "^4.1.1" events "^3.0.0" typeorm "^0.2.24" -daf-data-store@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" - resolved "https://registry.yarnpkg.com/daf-data-store/-/daf-data-store-4.0.0-beta.15.tgz#47bdb81fcec83c6a18c20299f2326922ce02697a" - integrity sha512-5vyyYzdqYq4nC841xoVm62AKom6z1YPulJUBo28P95Y2JPUjOmN2+LBnMd4ZPc73Kt3ix0kUCUdZmgebZL+Nhg== +daf-data-store@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" + resolved "https://registry.yarnpkg.com/daf-data-store/-/daf-data-store-4.0.0-beta.39.tgz#e328aa8b5583a07a2e279f5e3da0df65721b31ff" + integrity sha512-DaOeBUZo5l9Dlg2vrFLuxCMMqZGofkFK7q72tmOMdTDUkKfP0BtacB4wmr5PeTSDOtJosKcHI3uVAHI4Ksq0Wg== dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" sql-bricks-sqlite "^0.1.0" -daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" did-resolver "^1.1.0" @@ -897,21 +897,22 @@ daf-resolver@../../packages/daf-resolver: web-did-resolver "^1.2.0" daf-selective-disclosure@../../packages/daf-selective-disclosure: - version "4.0.0-beta.15" + version "4.0.0-beta.41" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-data-store "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-data-store "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" + typeorm "^0.2.24" daf-w3c@../../packages/daf-w3c: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt-vc "^0.1.3" did-resolver "^1.1.0" diff --git a/examples/react-app/src/App.tsx b/examples/react-app/src/App.tsx index c25687e49..b1d35d168 100644 --- a/examples/react-app/src/App.tsx +++ b/examples/react-app/src/App.tsx @@ -55,7 +55,8 @@ const App: React.FC = () => { try { const credentialSubject: any = {} - ;(credentialSubject['id'] = receiver), (credentialSubject[claimType] = claimValue) + credentialSubject['id'] = receiver + credentialSubject[claimType] = claimValue const credential = await agent.handleAction({ type: W3c.ActionTypes.signCredentialJwt, diff --git a/examples/react-app/yarn.lock b/examples/react-app/yarn.lock index e7d00e276..c72763aff 100644 --- a/examples/react-app/yarn.lock +++ b/examples/react-app/yarn.lock @@ -3556,36 +3556,36 @@ d@1, d@^1.0.1: es5-ext "^0.10.50" type "^1.0.1" -daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" debug "^4.1.1" events "^3.0.0" typeorm "^0.2.24" -daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" did-resolver "^1.1.0" daf-ethr-did@../../packages/daf-ethr-did: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" ethjs-provider-signer "^0.1.4" ethr-did "^1.1.0" js-sha3 "^0.8.0" daf-libsodium@../../packages/daf-libsodium: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: base-58 "^0.0.1" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" elliptic "^6.5.2" @@ -3593,9 +3593,9 @@ daf-libsodium@../../packages/daf-libsodium: libsodium-wrappers "^0.7.6" daf-local-storage@../../packages/daf-local-storage: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" daf-resolver@../../packages/daf-resolver: @@ -3608,7 +3608,7 @@ daf-resolver@../../packages/daf-resolver: web-did-resolver "^1.2.0" daf-trust-graph@../../packages/daf-trust-graph: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: apollo-cache-inmemory "^1.6.3" apollo-client "^2.6.4" @@ -3617,7 +3617,7 @@ daf-trust-graph@../../packages/daf-trust-graph: apollo-link-ws "^1.0.19" apollo-utilities "^1.3.2" cross-fetch "^3.0.4" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" graphql "^14.0.0" @@ -3625,11 +3625,11 @@ daf-trust-graph@../../packages/daf-trust-graph: subscriptions-transport-ws "^0.9.0" daf-w3c@../../packages/daf-w3c: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt-vc "^0.1.3" did-resolver "^1.1.0" diff --git a/examples/react-graphql/client/src/gql/queries.ts b/examples/react-graphql/client/src/gql/queries.ts index 6654da5d8..e9ef50aca 100644 --- a/examples/react-graphql/client/src/gql/queries.ts +++ b/examples/react-graphql/client/src/gql/queries.ts @@ -7,13 +7,13 @@ export const credential = gql` rowId iss { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } sub { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } jwt nbf @@ -31,9 +31,9 @@ export const identity = gql` query identity($did: ID!) { identity(did: $did) { did - type - shortId - profileImage + provider + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } } ` @@ -43,10 +43,10 @@ export const allIdentities = gql` identities { isManaged did - shortId + shortId: shortDid firstName lastName - profileImage + profileImage: latestClaimValue(type: "profileImage") } } ` @@ -60,8 +60,8 @@ export const managedIdentities = gql` managedIdentities { did type - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } } ` @@ -77,8 +77,8 @@ export const queryMessage = gql` iss { did { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } url } @@ -90,13 +90,13 @@ export const queryMessage = gql` rowId iss { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } sub { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } jwt fields { @@ -108,13 +108,13 @@ export const queryMessage = gql` } sender { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } receiver { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } } } @@ -133,15 +133,15 @@ export const allMessages = gql` timestamp sender { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } sdr(sub: $activeDid) { iss { did { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } url } @@ -153,13 +153,13 @@ export const allMessages = gql` rowId iss { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } sub { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } jwt fields { @@ -171,21 +171,21 @@ export const allMessages = gql` } receiver { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } vc { rowId hash iss { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } sub { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } fields { type diff --git a/examples/react-graphql/client/src/queries.ts b/examples/react-graphql/client/src/queries.ts index 2722eb68f..04379461f 100644 --- a/examples/react-graphql/client/src/queries.ts +++ b/examples/react-graphql/client/src/queries.ts @@ -7,11 +7,11 @@ export const credential = gql` rowId iss { did - shortId + shortId: shortDid } sub { did - shortId + shortId: shortDid } jwt nbf @@ -30,7 +30,7 @@ export const identity = gql` identity(did: $did) { did provider - shortId + shortId: shortDid } } ` @@ -44,8 +44,8 @@ export const managedIdentities = gql` managedIdentities { did provider - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } } ` @@ -106,26 +106,26 @@ export const allMessages = gql` timestamp sender { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } receiver { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } vc { rowId hash iss { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } sub { did - shortId - profileImage + shortId: shortDid + profileImage: latestClaimValue(type: "profileImage") } fields { type diff --git a/examples/react-graphql/server/index.ts b/examples/react-graphql/server/index.ts index b4a0fa1f0..2c4f0b2af 100644 --- a/examples/react-graphql/server/index.ts +++ b/examples/react-graphql/server/index.ts @@ -18,10 +18,18 @@ const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c' let didResolver = new DafResolver({ infuraProjectId }) +const dbConnection = createConnection({ + type: 'sqlite', + database: './database.sqlite', + synchronize: true, + logging: false, + entities: [...Daf.Entities], +}) + const identityProviders = [ new DafEthrDid.IdentityProvider({ - kms: new DafLibSodium.KeyManagementSystem(new Daf.KeyStore()), - identityStore: new Daf.IdentityStore('rinkeby-ethr'), + kms: new DafLibSodium.KeyManagementSystem(new Daf.KeyStore(dbConnection)), + identityStore: new Daf.IdentityStore('rinkeby-ethr', dbConnection), network: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId, }), @@ -38,6 +46,7 @@ const actionHandler = new TrustGraphActionHandler() actionHandler.setNext(new W3cActionHandler()).setNext(new SdrActionHandler()) export const agent = new Daf.Agent({ + dbConnection, identityProviders, serviceControllers, didResolver, @@ -77,14 +86,6 @@ const server = new ApolloServer({ }) const main = async () => { - await createConnection({ - type: 'sqlite', - database: './database.sqlite', - synchronize: true, - logging: false, - entities: [...Daf.Entities], - }) - await agent.setupServices() await agent.listen() const info = await server.listen() diff --git a/examples/react-graphql/server/yarn.lock b/examples/react-graphql/server/yarn.lock index 7bbeadb3b..98caab9f8 100644 --- a/examples/react-graphql/server/yarn.lock +++ b/examples/react-graphql/server/yarn.lock @@ -867,8 +867,8 @@ cross-fetch@^3.0.4: node-fetch "2.6.0" whatwg-fetch "3.0.0" -daf-core@../../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-core@../../../packages/daf-core, daf-core@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" debug "^4.1.1" @@ -876,35 +876,35 @@ daf-core@../../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: typeorm "^0.2.24" daf-data-store@../../../packages/daf-data-store: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" sql-bricks-sqlite "^0.1.0" -daf-did-jwt@../../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-did-jwt@../../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" did-resolver "^1.1.0" daf-ethr-did@../../../packages/daf-ethr-did: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" ethjs-provider-signer "^0.1.4" ethr-did "^1.1.0" js-sha3 "^0.8.0" daf-libsodium@../../../packages/daf-libsodium: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: base-58 "^0.0.1" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" elliptic "^6.5.2" @@ -921,7 +921,7 @@ daf-resolver@../../../packages/daf-resolver: web-did-resolver "^1.2.0" daf-trust-graph@../../../packages/daf-trust-graph: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: apollo-cache-inmemory "^1.6.3" apollo-client "^2.6.4" @@ -930,7 +930,7 @@ daf-trust-graph@../../../packages/daf-trust-graph: apollo-link-ws "^1.0.19" apollo-utilities "^1.3.2" cross-fetch "^3.0.4" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" graphql "^14.0.0" @@ -938,11 +938,11 @@ daf-trust-graph@../../../packages/daf-trust-graph: subscriptions-transport-ws "^0.9.0" daf-w3c@../../../packages/daf-w3c: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt-vc "^0.1.3" did-resolver "^1.1.0" diff --git a/examples/rest-api/index.ts b/examples/rest-api/index.ts index e42a40340..f07e73601 100644 --- a/examples/rest-api/index.ts +++ b/examples/rest-api/index.ts @@ -1,8 +1,6 @@ import express from 'express' const app = express() const port = process.env.PORT || 8080 -import { Entities } from 'daf-core' -import { createConnection } from 'typeorm' import { agent } from './setup' @@ -53,12 +51,4 @@ app.post('/handle-message', express.text({ type: '*/*' }), async (req, res) => { } }) -createConnection({ - type: 'sqlite', - database: './database.sqlite', - synchronize: true, - logging: true, - entities: Entities, -}).then(() => { - app.listen(port, () => console.log(`Server running at http://localhost:${port}`)) -}) +app.listen(port, () => console.log(`Server running at http://localhost:${port}`)) diff --git a/examples/rest-api/setup.ts b/examples/rest-api/setup.ts index 1984db0b6..01dbd1a83 100644 --- a/examples/rest-api/setup.ts +++ b/examples/rest-api/setup.ts @@ -5,6 +5,7 @@ import { W3cActionHandler, W3cMessageHandler } from 'daf-w3c' import { JwtMessageHandler } from 'daf-did-jwt' import { DIDCommActionHandler, DIDCommMessageHandler } from 'daf-did-comm' import { DafResolver } from 'daf-resolver' +import { createConnection } from 'typeorm' import Debug from 'debug' Debug.enable('*') @@ -20,11 +21,20 @@ const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c' const didResolver = new DafResolver({ infuraProjectId }) +const dbConnection = createConnection({ + type: 'sqlite', + database: './database.sqlite', + synchronize: true, + logging: true, + entities: Daf.Entities, +}) + export const agent = new Daf.Agent({ + dbConnection, identityProviders: [ new DafEthr.IdentityProvider({ - kms: new DafLibSodium.KeyManagementSystem(new Daf.KeyStore()), - identityStore: new Daf.IdentityStore('rinkeby-ethr'), + kms: new DafLibSodium.KeyManagementSystem(new Daf.KeyStore(dbConnection)), + identityStore: new Daf.IdentityStore('rinkeby-ethr', dbConnection), network: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId, }), diff --git a/examples/rest-api/yarn.lock b/examples/rest-api/yarn.lock index 3e17fc8e6..5bf66062c 100644 --- a/examples/rest-api/yarn.lock +++ b/examples/rest-api/yarn.lock @@ -435,8 +435,8 @@ crypto-random-string@^1.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= -daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" debug "^4.1.1" @@ -444,34 +444,34 @@ daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: typeorm "^0.2.24" daf-did-comm@../../packages/daf-did-comm: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" uuid "^3.3.3" -daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" did-resolver "^1.1.0" daf-ethr-did@../../packages/daf-ethr-did: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" ethjs-provider-signer "^0.1.4" ethr-did "^1.1.0" js-sha3 "^0.8.0" daf-libsodium@../../packages/daf-libsodium: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: base-58 "^0.0.1" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" elliptic "^6.5.2" @@ -488,11 +488,11 @@ daf-resolver@../../packages/daf-resolver: web-did-resolver "^1.2.0" daf-w3c@../../packages/daf-w3c: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt-vc "^0.1.3" did-resolver "^1.1.0" diff --git a/examples/send-vc/index.ts b/examples/send-vc/index.ts index f14d236ab..df9f9c8bd 100644 --- a/examples/send-vc/index.ts +++ b/examples/send-vc/index.ts @@ -1,19 +1,9 @@ -import { AbstractIdentity, EventTypes, Entities, Message, Credential } from 'daf-core' +import { AbstractIdentity, EventTypes, Message, Credential } from 'daf-core' import { ActionSendDIDComm, ActionTypes } from 'daf-did-comm' import { ActionSignW3cVc, ActionTypes as W3cActionTypes } from 'daf-w3c' import { agent } from './setup' -import { createConnection } from 'typeorm' async function main() { - // Create database connection - await createConnection({ - type: 'sqlite', - database: 'database.sqlite', - synchronize: true, - logging: true, - entities: Entities, - }) - // Getting existing identity or creating a new one let identity: AbstractIdentity const identities = await agent.identityManager.getIdentities() diff --git a/examples/send-vc/setup.ts b/examples/send-vc/setup.ts index 37b06eaa3..544c9615c 100644 --- a/examples/send-vc/setup.ts +++ b/examples/send-vc/setup.ts @@ -1,9 +1,21 @@ +import { Entities } from 'daf-core' +import { createConnection } from 'typeorm' + +// Create database connection +const dbConnection = createConnection({ + type: 'sqlite', + database: 'database.sqlite', + synchronize: true, + logging: true, + entities: Entities, +}) + // We will be using 'did:ethr' identities import { IdentityProvider } from 'daf-ethr-did' // Storing serialized key pairs in the file system import { KeyStore } from 'daf-core' -const keyStore = new KeyStore() +const keyStore = new KeyStore(dbConnection) // KeyManagementSystem is responsible for managing encryption and signing keys import { KeyManagementSystem } from 'daf-libsodium' @@ -11,7 +23,7 @@ const kms = new KeyManagementSystem(keyStore) // Storing serialized identities in the file system import { IdentityStore } from 'daf-core' -const identityStore = new IdentityStore('rinkeby-ethr') +const identityStore = new IdentityStore('rinkeby-ethr', dbConnection) // Infura is being used to access Ethereum blockchain. https://infura.io const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c' @@ -40,9 +52,7 @@ import { DIDCommActionHandler } from 'daf-did-comm' import { TrustGraphActionHandler } from 'daf-trust-graph' import { W3cActionHandler } from 'daf-w3c' const actionHandler = new W3cActionHandler() -actionHandler - .setNext(new DIDCommActionHandler()) - .setNext(new TrustGraphActionHandler()) +actionHandler.setNext(new DIDCommActionHandler()).setNext(new TrustGraphActionHandler()) // Initializing the Core by injecting dependencies import { Agent } from 'daf-core' diff --git a/examples/send-vc/yarn.lock b/examples/send-vc/yarn.lock index 5eeefb375..9911b9218 100644 --- a/examples/send-vc/yarn.lock +++ b/examples/send-vc/yarn.lock @@ -479,8 +479,8 @@ cross-fetch@^3.0.4: node-fetch "2.6.0" whatwg-fetch "3.0.0" -daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" debug "^4.1.1" @@ -488,40 +488,40 @@ daf-core@../../packages/daf-core, daf-core@^4.0.0-beta.15+00f0d2f: typeorm "^0.2.24" daf-did-comm@../../packages/daf-did-comm: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" uuid "^3.3.3" -daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.15+00f0d2f: - version "4.0.0-beta.15" +daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^4.0.0-beta.39+63dd12d: + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" did-resolver "^1.1.0" daf-ethr-did@../../packages/daf-ethr-did: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" ethjs-provider-signer "^0.1.4" ethr-did "^1.1.0" js-sha3 "^0.8.0" daf-fs@../../packages/daf-fs: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" daf-libsodium@../../packages/daf-libsodium: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: base-58 "^0.0.1" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" elliptic "^6.5.2" @@ -538,7 +538,7 @@ daf-resolver@../../packages/daf-resolver: web-did-resolver "^1.2.0" daf-trust-graph@../../packages/daf-trust-graph: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: apollo-cache-inmemory "^1.6.3" apollo-client "^2.6.4" @@ -547,7 +547,7 @@ daf-trust-graph@../../packages/daf-trust-graph: apollo-link-ws "^1.0.19" apollo-utilities "^1.3.2" cross-fetch "^3.0.4" - daf-core "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt "^4.0.0" graphql "^14.0.0" @@ -555,11 +555,11 @@ daf-trust-graph@../../packages/daf-trust-graph: subscriptions-transport-ws "^0.9.0" daf-w3c@../../packages/daf-w3c: - version "4.0.0-beta.15" + version "4.0.0-beta.39" dependencies: blakejs "^1.1.0" - daf-core "^4.0.0-beta.15+00f0d2f" - daf-did-jwt "^4.0.0-beta.15+00f0d2f" + daf-core "^4.0.0-beta.39+63dd12d" + daf-did-jwt "^4.0.0-beta.39+63dd12d" debug "^4.1.1" did-jwt-vc "^0.1.3" did-resolver "^1.1.0"
TimestampIssuance Date Type Sender Receiver
{{timestamp}} + {{issuanceDate}} {{type}} - {{sender.did}} - {{receiver.did}} + {{from.did}} + {{to.did}}