Skip to content

Commit

Permalink
feat: Experimentation
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Mar 5, 2020
1 parent 7f1c85f commit 134a812
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/send-vc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"version": "2.0.0",
"main": "index.ts",
"scripts": {
"start": "DEBUG=daf:* ts-node index.ts"
"start": "DEBUG=daf:* ts-node index.ts",
"test": "DEBUG=daf:* ts-node test.ts"
},
"dependencies": {
"daf-core": "../../packages/daf-core",
Expand Down
70 changes: 70 additions & 0 deletions examples/send-vc/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
Identity,
Key,
OMessage,
MessageMetaData,
Credential,
Presentation,
CredentialContext,
CredentialType,
PresentationContext,
PresentationType,
Claim,
Action,
} from 'daf-core'
import { core } from './setup'
import { createConnection } from 'typeorm'

const main = async () => {
await createConnection({
// Sqlite
// "type": "sqlite",
// "database": "database.sqlite",

//Postgres
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'simonas',
password: '',
database: 'simonas',

synchronize: false,
logging: true,
entities: [
Key,
Identity,
OMessage,
MessageMetaData,
Credential,
PresentationType,
PresentationContext,
Presentation,
CredentialType,
CredentialContext,
Claim,
Action,
],
})

let identity1: Identity
let identity2: Identity
const identities = await core.identityManager.getIdentities()
if (identities.length > 1) {
identity1 = (identities[0] as any) as Identity
identity2 = (identities[1] as any) as Identity
} else {
const identityProviders = await core.identityManager.getIdentityProviderTypes()
identity1 = ((await core.identityManager.createIdentity(identityProviders[0].type)) as any) as Identity
identity2 = ((await core.identityManager.createIdentity(identityProviders[0].type)) as any) as Identity
}

console.log(identity1)
console.log(identity2)

const vc = new Credential()
vc.issuer = identity1
vc.subject = identity2
}

main().catch(console.log)

0 comments on commit 134a812

Please sign in to comment.