Skip to content

Commit

Permalink
fix: Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Mar 11, 2020
1 parent 88cdd5a commit 9887732
Show file tree
Hide file tree
Showing 6 changed files with 570 additions and 61 deletions.
36 changes: 18 additions & 18 deletions examples/react-app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3556,52 +3556,52 @@ d@1, d@^1.0.1:
es5-ext "^0.10.50"
type "^1.0.1"

daf-core@../../packages/daf-core, daf-core@^2.3.18:
version "2.3.18"
daf-core@../../packages/daf-core, daf-core@^2.3.19:
version "2.3.19"
dependencies:
blakejs "^1.1.0"
debug "^4.1.1"
events "^3.0.0"
typeorm "^0.2.24"

daf-debug@../../packages/daf-debug:
version "2.3.18"
version "2.3.19"
dependencies:
daf-core "^2.3.18"
daf-core "^2.3.19"
debug "^4.1.1"

daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^2.3.18:
version "2.3.18"
daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^2.3.19:
version "2.3.19"
dependencies:
daf-core "^2.3.18"
daf-core "^2.3.19"
debug "^4.1.1"
did-jwt "^4.0.0"
did-resolver "^1.1.0"

daf-ethr-did@../../packages/daf-ethr-did:
version "2.3.18"
version "2.3.19"
dependencies:
daf-core "^2.3.18"
daf-core "^2.3.19"
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 "2.3.18"
version "2.3.19"
dependencies:
base-58 "^0.0.1"
daf-core "^2.3.18"
daf-core "^2.3.19"
debug "^4.1.1"
did-jwt "^4.0.0"
elliptic "^6.5.2"
ethjs-signer "^0.1.1"
libsodium-wrappers "^0.7.6"

daf-local-storage@../../packages/daf-local-storage:
version "2.3.18"
version "2.3.19"
dependencies:
daf-core "^2.3.18"
daf-core "^2.3.19"
debug "^4.1.1"

daf-resolver@../../packages/daf-resolver:
Expand All @@ -3614,7 +3614,7 @@ daf-resolver@../../packages/daf-resolver:
web-did-resolver "^1.2.0"

daf-trust-graph@../../packages/daf-trust-graph:
version "2.3.18"
version "2.3.19"
dependencies:
apollo-cache-inmemory "^1.6.3"
apollo-client "^2.6.4"
Expand All @@ -3623,18 +3623,18 @@ 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 "^2.3.18"
daf-core "^2.3.19"
debug "^4.1.1"
did-jwt "^4.0.0"
graphql "^14.0.0"
graphql-tag "^2.10.1"
subscriptions-transport-ws "^0.9.0"

daf-w3c@../../packages/daf-w3c:
version "2.3.18"
version "2.3.19"
dependencies:
daf-core "^2.3.18"
daf-did-jwt "^2.3.18"
daf-core "^2.3.19"
daf-did-jwt "^2.3.19"
debug "^4.1.1"
did-jwt-vc "^0.1.3"
did-resolver "^1.1.0"
Expand Down
10 changes: 1 addition & 9 deletions examples/react-graphql/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ const main = async () => {
database: './database.sqlite',
synchronize: true,
logging: true,
entities: [
Daf.Key,
Daf.Identity,
Daf.Message,
Daf.MessageMetaData,
Daf.Credential,
Daf.Presentation,
Daf.Claim,
],
entities: Daf.Entities,
})

await core.setupServices()
Expand Down
20 changes: 15 additions & 5 deletions examples/rest-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import express from 'express'
const app = express()
const port = process.env.PORT || 8080
import { Message } from 'daf-core'
import { Message, Entities } from 'daf-core'
import { createConnection } from 'typeorm'

import { core } from './setup'

Expand Down Expand Up @@ -38,16 +39,25 @@ app.post('/handle-action', express.json(), async (req, res) => {
// This endpoint would be published in did doc as a serviceEndpoint
app.post('/handle-message', express.text({ type: '*/*' }), async (req, res) => {
try {
const result = await core.validateMessage(
new Message({ raw: req.body, meta: { type: 'serviceEndpoint', id: 'handle-message' } }),
const message = await core.validateMessage(
new Message({ raw: req.body, meta: { type: 'serviceEndpoint', value: 'handle-message' } }),
)

await message.save()
// now you can store this message or pass through to some webhook

res.json({ id: result.id })
res.json({ id: message.id })
} catch (e) {
res.send(e.message)
}
})

app.listen(port, () => console.log(`Server running at http://localhost:${port}`))
createConnection({
type: 'sqlite',
database: './database.sqlite',
synchronize: true,
logging: true,
entities: Entities,
}).then(() => {
app.listen(port, () => console.log(`Server running at http://localhost:${port}`))
})
4 changes: 2 additions & 2 deletions examples/rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"daf-did-comm": "../../packages/daf-did-comm",
"daf-did-jwt": "../../packages/daf-did-jwt",
"daf-ethr-did": "../../packages/daf-ethr-did",
"daf-fs": "../../packages/daf-fs",
"daf-libsodium": "../../packages/daf-libsodium",
"daf-resolver": "../../packages/daf-resolver",
"daf-w3c": "../../packages/daf-w3c",
"express": "^4.17.1"
"express": "^4.17.1",
"typeorm": "^0.2.24"
}
}
5 changes: 2 additions & 3 deletions examples/rest-api/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Daf from 'daf-core'
import * as DafEthr from 'daf-ethr-did'
import * as DafFs from 'daf-fs'
import * as DafLibSodium from 'daf-libsodium'
import * as W3c from 'daf-w3c'
import * as DBG from 'daf-debug'
Expand All @@ -24,8 +23,8 @@ const didResolver = new DafResolver({ infuraProjectId })
export const core = new Daf.Core({
identityProviders: [
new DafEthr.IdentityProvider({
kms: new DafLibSodium.KeyManagementSystem(new DafFs.KeyStore('./key-store.json')),
identityStore: new DafFs.IdentityStore('./identity-store.json'),
kms: new DafLibSodium.KeyManagementSystem(new Daf.KeyStore()),
identityStore: new Daf.IdentityStore('rinkeby-ethr'),
network: 'rinkeby',
rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId,
}),
Expand Down
Loading

0 comments on commit 9887732

Please sign in to comment.