Skip to content

Commit

Permalink
fix: Example
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Mar 11, 2020
1 parent 9887732 commit dcf46d6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 196 deletions.
20 changes: 7 additions & 13 deletions examples/send-vc/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { AbstractIdentity, EventTypes, Message, Key, Identity } from 'daf-core'
import { AbstractIdentity, EventTypes, Entities, Message } from 'daf-core'
import { ActionSendJWT } from 'daf-did-comm'
import { ActionSignW3cVc } from 'daf-w3c'
import { core } from './setup'
import { createConnection } from 'typeorm'

async function main() {
// Create database connection
await createConnection({
// "type": "sqlite",
// "database": "database.sqlite",
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'simonas',
password: '',
database: 'simonas',
type: 'sqlite',
database: 'database.sqlite',
synchronize: true,
logging: true,
entities: [Key, Identity],
logging: false,
entities: Entities,
})

// Getting existing identity or creating a new one
Expand All @@ -29,8 +24,6 @@ async function main() {
identity = await core.identityManager.createIdentity(identityProviders[0].type)
}

console.log(identity.did)

// Sign verifiable credential
const vcJwt = await core.handleAction({
type: 'action.sign.w3c.vc',
Expand Down Expand Up @@ -62,6 +55,7 @@ async function main() {
// which can arrive from external services, or by sending it using `action.sendJwt`
core.on(EventTypes.validatedMessage, async (message: Message) => {
console.log('\n\nSuccessfully sent message:', message)
await message.save()
})

main().catch(console.log)
10 changes: 3 additions & 7 deletions examples/send-vc/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@
import { IdentityProvider } from 'daf-ethr-did'

// Storing serialized key pairs in the file system
// import { KeyStore } from 'daf-fs'
// const keyStore = new KeyStore('./key-store.json')
import KeyStore from './key-store'
import { KeyStore } from 'daf-core'
const keyStore = new KeyStore()

// KeyManagementSystem is responsible for managing encryption and signing keys
import { KeyManagementSystem } from 'daf-libsodium'
const kms = new KeyManagementSystem(keyStore)

// Storing serialized identities in the file system
// import { IdentityStore } from 'daf-fs'
// const identityStore = new IdentityStore('./identity-store.json')
import { IdentityStore } from './identity-store'
const identityStore = new IdentityStore()
import { IdentityStore } from 'daf-core'
const identityStore = new IdentityStore('rinkeby-ethr')

// Infura is being used to access Ethereum blockchain. https://infura.io
const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c'
Expand Down
155 changes: 0 additions & 155 deletions examples/send-vc/test.ts

This file was deleted.

42 changes: 21 additions & 21 deletions examples/send-vc/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,63 +479,63 @@ cross-fetch@^3.0.4:
node-fetch "2.6.0"
whatwg-fetch "3.0.0"

daf-core@../../packages/daf-core, daf-core@^2.3.16:
version "2.3.16"
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.16"
version "2.3.19"
dependencies:
daf-core "^2.3.16"
daf-core "^2.3.19"
debug "^4.1.1"

daf-did-comm@../../packages/daf-did-comm:
version "2.3.16"
version "2.3.19"
dependencies:
daf-core "^2.3.16"
daf-core "^2.3.19"
debug "^4.1.1"
uuid "^3.3.3"

daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^2.3.16:
version "2.3.16"
daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^2.3.19:
version "2.3.19"
dependencies:
daf-core "^2.3.16"
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.17"
version "2.3.19"
dependencies:
daf-core "^2.3.16"
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-fs@../../packages/daf-fs:
version "2.3.16"
version "2.3.19"
dependencies:
daf-core "^2.3.16"
daf-core "^2.3.19"
debug "^4.1.1"

daf-libsodium@../../packages/daf-libsodium:
version "2.3.16"
version "2.3.19"
dependencies:
base-58 "^0.0.1"
daf-core "^2.3.16"
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-resolver@../../packages/daf-resolver:
version "2.3.15"
version "2.3.18"
dependencies:
debug "^4.1.1"
did-resolver "^1.1.0"
Expand All @@ -544,7 +544,7 @@ daf-resolver@../../packages/daf-resolver:
web-did-resolver "^1.2.0"

daf-trust-graph@../../packages/daf-trust-graph:
version "2.3.16"
version "2.3.19"
dependencies:
apollo-cache-inmemory "^1.6.3"
apollo-client "^2.6.4"
Expand All @@ -553,18 +553,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.16"
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.16"
version "2.3.19"
dependencies:
daf-core "^2.3.16"
daf-did-jwt "^2.3.16"
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

0 comments on commit dcf46d6

Please sign in to comment.