diff --git a/examples/send-vc/package.json b/examples/send-vc/package.json index 7d8958d11..85557ad38 100644 --- a/examples/send-vc/package.json +++ b/examples/send-vc/package.json @@ -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", diff --git a/examples/send-vc/test.ts b/examples/send-vc/test.ts new file mode 100644 index 000000000..82b69e2a7 --- /dev/null +++ b/examples/send-vc/test.ts @@ -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)