Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON-LD Signature Support #525

Merged
merged 48 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
59eba11
Commit LD Changes
rado0x54 Apr 7, 2021
dfcd421
tests: started to add integration tests for JSON-LD Integration
rado0x54 Apr 15, 2021
29f3d48
fix: missing deps
simonas-notcat Apr 15, 2021
d8feab7
fix: Fixed failing tests.
rado0x54 Apr 15, 2021
c3be9de
feat: added Secp256k1 support.
rado0x54 Apr 16, 2021
1f61cb6
started implementation of verifyVerifiablePresesntation.
rado0x54 Apr 16, 2021
8be5943
feat: finished EcdsaSecp256k1RecoverySignature2020 and Ed25519Signatu…
rado0x54 Apr 19, 2021
fae2d8b
fixed merge conflicts and added local jsonld contexts.
rado0x54 Apr 19, 2021
1cc995f
feat: added presentation creation and verification.
rado0x54 Apr 19, 2021
07c037d
feat: Demo update and integration test workaround.
rado0x54 Apr 19, 2021
53265ae
fix: added missing KYC context.
rado0x54 Apr 19, 2021
b206074
fix: fixed loading of context files from build.
rado0x54 Apr 19, 2021
36aa8a4
feat: Added profile credential
rado0x54 Apr 19, 2021
2bb983c
feat: sync Demo
rado0x54 Apr 19, 2021
81fdaeb
fix: manually updated plugin.schema.json, to contain newly exposed me…
rado0x54 Apr 19, 2021
29e73f3
feat: allow so send LD Credentials
rado0x54 Apr 22, 2021
3b12f32
feat: enabled presentation creation and verification with EcdsaSecp25…
rado0x54 Apr 20, 2021
4b2123b
fix: fixed save operation for credentials
rado0x54 Apr 22, 2021
51faa1a
feat: Finished message-handler for VCs (LD-Based)
rado0x54 Apr 22, 2021
2babf88
feat: fixed did:key ed25519 signature handling.
rado0x54 Apr 22, 2021
9e85f0a
fix: Update after cherry-picking commits.
rado0x54 May 18, 2021
7084002
chore: resolve technical merge conflicts (with tests still failing)
rado0x54 Jul 8, 2021
e37b4c5
fix: failing test for ed25519 signature. (Transmute Library Update)
rado0x54 Jul 27, 2021
e4feb35
feat: moved LD logic into dedicated module
rado0x54 Aug 2, 2021
d84edf2
fix: fixed tests by binding 'this' correctly to the class function ex…
rado0x54 Aug 2, 2021
9af22d8
feat: Post-Merge fixes.
rado0x54 Aug 2, 2021
69143db
feat: Allow to dynamically load ld-contexts
rado0x54 Aug 3, 2021
5b2313c
feat: included credential context from transmute library
rado0x54 Aug 3, 2021
5bd4c04
feat: added outline for ld signature loader implementation
rado0x54 Aug 4, 2021
0bea9a8
feat: moved all suite-related code into VeramoLDSignature implementat…
rado0x54 Aug 4, 2021
9d6f397
feat: updated default config to new initialization
rado0x54 Aug 4, 2021
bda39f0
fix: removed broken import
rado0x54 Aug 4, 2021
501dcff
feat: add @veramo/utils package
mirceanis Sep 8, 2021
21bb1fd
fix: remove support for Ed25519 LD crypto suites and fix EcdsaSecp256…
mirceanis Sep 8, 2021
6c0317a
fix: refactor after rebase
mirceanis Nov 17, 2021
6cf3b93
feat(credential-w3c): re-add support for Ed25519Signature2018 for JSO…
mirceanis Nov 17, 2021
7145d2b
refactor: isolate ld-suites to individual files
mirceanis Nov 17, 2021
4f55926
refactor(credential-ld): isolate credential-ld as individual package
mirceanis Nov 18, 2021
223c207
refactor(credential-ld): simplify credential-ld initialization API
mirceanis Nov 18, 2021
8c1081b
feat(credential-ld): proper mapping from localKeys to verificationMet…
mirceanis Nov 19, 2021
9c58627
feat(cli): update default config to use CredentialIssuerLD module
mirceanis Nov 22, 2021
d439701
feat(credential-w3c): autoselect presentation audience if it's a mana…
mirceanis Nov 22, 2021
fe4b4cf
feat(cli): add CLI methods to verify credentials and presentations
mirceanis Nov 22, 2021
0050022
feat(core): add common type definitions for credentials and presentat…
mirceanis Nov 23, 2021
aa48b7d
style: reformat code
mirceanis Nov 23, 2021
e449f03
test(utils): add some tests for the utils package
mirceanis Nov 23, 2021
1071b02
style(utils): reformat code
mirceanis Nov 23, 2021
790fb8c
feat(cli): credential UX improvements
simonas-notcat Nov 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coverage
examples
build/**/*
**/build
docs
report
*.json
Expand Down
28 changes: 18 additions & 10 deletions __tests__/initial.migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@
* TypeORM migrations were available (before Veramo 3.0.0)
*/

import { createAgent, TAgent, IDIDManager, IResolver, IKeyManager, IDataStore } from '../packages/core/src'
import {
createAgent,
IDataStore,
IDIDManager,
IKeyManager,
IResolver,
TAgent,
VerifiableCredential,
} from '../packages/core/src'
import { DIDResolverPlugin } from '../packages/did-resolver/src'
import { EthrDIDProvider } from '../packages/did-provider-ethr/src'
import { WebDIDProvider } from '../packages/did-provider-web/src'
import { KeyDIDProvider } from '../packages/did-provider-key/src'
import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src'
import { DIDComm, IDIDComm } from '../packages/did-comm/src'
import { KeyManagementSystem, SecretBox } from '../packages/kms-local/src'
import {
Entities,
IDataStoreORM,
DataStore,
DataStoreORM,
KeyStore,
DIDStore,
Entities,
IDataStoreORM,
KeyStore,
migrations,
PrivateKeyStore,
} from '../packages/data-store/src'
import { getDidKeyResolver } from '../packages/did-provider-key/src'
import { KeyManager } from '../packages/key-manager/src'
import { DIDManager } from '../packages/did-manager/src'
import { FakeDidProvider, FakeDidResolver } from './utils/fake-did'

import { createConnection, Connection, ConnectionOptions } from 'typeorm'
import { Connection, ConnectionOptions, createConnection } from 'typeorm'
import { Resolver } from 'did-resolver'
import { getResolver as ethrDidResolver } from 'ethr-did-resolver'
import { getResolver as webDidResolver } from 'web-did-resolver'
import fs from 'fs'
import * as fs from 'fs'

jest.setTimeout(30000)

Expand Down Expand Up @@ -196,10 +203,11 @@ describe('database initial migration tests', () => {
})

it('reads a presentation by hash', async () => {
const cred = await agent.dataStoreGetVerifiablePresentation({
const presentation = await agent.dataStoreGetVerifiablePresentation({
hash: '4cfe965596a0d343ff2cc02afd32068bced34caa2b1e7e3f253b23e420de106b58a613f06f55d9d9cbbdbe0b0f051a45d44404020b123c58f0ee48bdaeafdc90',
})
expect(cred?.verifiableCredential?.[0]?.credentialSubject?.name).toEqual('Alice')
const cred0: VerifiableCredential = presentation?.verifiableCredential?.[0] as VerifiableCredential
expect(cred0.credentialSubject?.name).toEqual('Alice')
})

it('reads existing messages', async () => {
Expand Down
67 changes: 41 additions & 26 deletions __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,68 @@
/**
* This runs a suite of ./shared tests using an agent configured for local operations,
* using a SQLite db for storage of credentials, presentations, messages as well as keys and DIDs.
*
*
* This suite also runs a ganache local blockchain to run through some examples of DIDComm using did:ethr identifiers.
*/

import {
createAgent,
TAgent,
IAgentOptions,
IDataStore,
IDIDManager,
IResolver,
IKeyManager,
IDataStore,
IMessageHandler,
IAgentOptions,
IResolver,
TAgent,
} from '../packages/core/src'
import { MessageHandler } from '../packages/message-handler/src'
import { KeyManager } from '../packages/key-manager/src'
import { DIDManager, AliasDiscoveryProvider } from '../packages/did-manager/src'
import { AliasDiscoveryProvider, DIDManager } from '../packages/did-manager/src'
import { DIDResolverPlugin } from '../packages/did-resolver/src'
import { JwtMessageHandler } from '../packages/did-jwt/src'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from '../packages/credential-w3c/src'
import {
CredentialIssuerLD,
ICredentialIssuerLD,
LdDefaultContexts,
VeramoEcdsaSecp256k1RecoverySignature2020,
VeramoEd25519Signature2018,
} from '../packages/credential-ld/src'
import { EthrDIDProvider } from '../packages/did-provider-ethr/src'
import { WebDIDProvider } from '../packages/did-provider-web/src'
import { KeyDIDProvider } from '../packages/did-provider-key/src'
import { DIDComm, DIDCommMessageHandler, IDIDComm, DIDCommHttpTransport } from '../packages/did-comm/src'
import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src'
import { DIDComm, DIDCommHttpTransport, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src'
import {
SelectiveDisclosure,
ISelectiveDisclosure,
SdrMessageHandler,
SelectiveDisclosure,
} from '../packages/selective-disclosure/src'
import { KeyManagementSystem, SecretBox } from '../packages/kms-local/src'
import { IDIDDiscovery, DIDDiscovery } from '../packages/did-discovery/src'
import { getDidKeyResolver } from '../packages/did-provider-key/src'
import { DIDDiscovery, IDIDDiscovery } from '../packages/did-discovery/src'

import {
Entities,
KeyStore,
DIDStore,
IDataStoreORM,
DataStore,
DataStoreORM,
ProfileDiscoveryProvider,
PrivateKeyStore,
DIDStore,
Entities,
IDataStoreORM,
KeyStore,
migrations,
PrivateKeyStore,
ProfileDiscoveryProvider,
} from '../packages/data-store/src'
import { createConnection, Connection } from 'typeorm'

import { FakeDidProvider, FakeDidResolver } from './utils/fake-did'

import { Connection, createConnection } from 'typeorm'
import { createGanacheProvider } from './utils/ganache-provider'
import { Resolver } from 'did-resolver'
import { getResolver as ethrDidResolver } from 'ethr-did-resolver'
import { getResolver as webDidResolver } from 'web-did-resolver'
import fs from 'fs'

jest.setTimeout(30000)

import { contexts as credential_contexts } from '@transmute/credentials-context'
import * as fs from 'fs'
// Shared tests
import verifiableData from './shared/verifiableData'
import verifiableDataJWT from './shared/verifiableDataJWT'
import verifiableDataLD from './shared/verifiableDataLD'
import handleSdrMessage from './shared/handleSdrMessage'
import resolveDid from './shared/resolveDid'
import webDidFlow from './shared/webDidFlow'
Expand All @@ -71,6 +76,8 @@ import didDiscovery from './shared/didDiscovery'
import dbInitOptions from './shared/dbInitOptions'
import didCommWithEthrDidFlow from './shared/didCommWithEthrDidFlow'

jest.setTimeout(30000)

const infuraProjectId = '3586660d179141e3801c3895de1c2eba'
const secretKey = '29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c'

Expand All @@ -83,14 +90,16 @@ let agent: TAgent<
IMessageHandler &
IDIDComm &
ICredentialIssuer &
ICredentialIssuerLD &
ISelectiveDisclosure &
IDIDDiscovery
>
let dbConnection: Promise<Connection>
let databaseFile: string

const setup = async (options?: IAgentOptions): Promise<boolean> => {
databaseFile = options?.context?.databaseFile || `./tmp/local-database-${Math.random().toPrecision(5)}.sqlite`
databaseFile =
options?.context?.databaseFile || `./tmp/local-database-${Math.random().toPrecision(5)}.sqlite`
dbConnection = createConnection({
name: options?.context?.['dbName'] || 'test',
type: 'sqlite',
Expand All @@ -115,6 +124,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
IMessageHandler &
IDIDComm &
ICredentialIssuer &
ICredentialIssuerLD &
ISelectiveDisclosure &
IDIDDiscovery
>({
Expand Down Expand Up @@ -198,6 +208,10 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDComm([new DIDCommHttpTransport()]),
new CredentialIssuer(),
new CredentialIssuerLD({
contextMaps: [LdDefaultContexts, credential_contexts as any],
suites: [new VeramoEcdsaSecp256k1RecoverySignature2020(), new VeramoEd25519Signature2018()],
}),
new SelectiveDisclosure(),
new DIDDiscovery({
providers: [new AliasDiscoveryProvider(), new ProfileDiscoveryProvider()],
Expand Down Expand Up @@ -228,7 +242,8 @@ const getAgent = () => agent
const testContext = { getAgent, setup, tearDown }

describe('Local integration tests', () => {
verifiableData(testContext)
verifiableDataJWT(testContext)
verifiableDataLD(testContext)
handleSdrMessage(testContext)
resolveDid(testContext)
webDidFlow(testContext)
Expand Down
50 changes: 32 additions & 18 deletions __tests__/localMemoryStoreAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
/**
* This runs a suite of ./shared tests using an agent configured for local operations,
* using a SQLite db for storage of credentials and an in-memory store for keys and DIDs.
*
*
*/
import {
createAgent,
TAgent,
IAgentOptions,
IDataStore,
IDIDManager,
IResolver,
IKeyManager,
IDataStore,
IMessageHandler,
IAgentOptions,
IResolver,
TAgent,
} from '../packages/core/src'
import { MessageHandler } from '../packages/message-handler/src'
import { KeyManager, MemoryKeyStore, MemoryPrivateKeyStore } from '../packages/key-manager/src'
import { DIDManager, MemoryDIDStore } from '../packages/did-manager/src'
import { createConnection, Connection } from 'typeorm'
import { Connection, createConnection } from 'typeorm'
import { DIDResolverPlugin } from '../packages/did-resolver/src'
import { JwtMessageHandler } from '../packages/did-jwt/src'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from '../packages/credential-w3c/src'
import {
CredentialIssuerLD,
ICredentialIssuerLD,
LdDefaultContexts,
VeramoEcdsaSecp256k1RecoverySignature2020,
VeramoEd25519Signature2018,
} from '../packages/credential-ld/src'
import { EthrDIDProvider } from '../packages/did-provider-ethr/src'
import { WebDIDProvider } from '../packages/did-provider-web/src'
import { KeyDIDProvider } from '../packages/did-provider-key/src'
import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src'
import {
SelectiveDisclosure,
ISelectiveDisclosure,
SdrMessageHandler,
SelectiveDisclosure,
} from '../packages/selective-disclosure/src'
import { KeyManagementSystem } from '../packages/kms-local/src'
import { Entities, IDataStoreORM, DataStore, DataStoreORM, migrations } from '../packages/data-store/src'
import { getDidKeyResolver } from '../packages/did-provider-key/src'
import { DataStore, DataStoreORM, Entities, IDataStoreORM, migrations } from '../packages/data-store/src'
import { FakeDidProvider, FakeDidResolver } from './utils/fake-did'

import { Resolver } from 'did-resolver'
import { getResolver as ethrDidResolver } from 'ethr-did-resolver'
import { getResolver as webDidResolver } from 'web-did-resolver'
import fs from 'fs'

jest.setTimeout(30000)

import { contexts as credential_contexts } from '@transmute/credentials-context'
import * as fs from 'fs'
// Shared tests
import verifiableData from './shared/verifiableData'
import verifiableDataJWT from './shared/verifiableDataJWT'
import verifiableDataLD from './shared/verifiableDataLD'
import handleSdrMessage from './shared/handleSdrMessage'
import resolveDid from './shared/resolveDid'
import webDidFlow from './shared/webDidFlow'
Expand All @@ -53,6 +58,8 @@ import didManager from './shared/didManager'
import didCommPacking from './shared/didCommPacking'
import messageHandler from './shared/messageHandler'

jest.setTimeout(30000)

const databaseFile = `./tmp/local-database2-${Math.random().toPrecision(5)}.sqlite`
const infuraProjectId = '3586660d179141e3801c3895de1c2eba'

Expand All @@ -65,6 +72,7 @@ let agent: TAgent<
IMessageHandler &
IDIDComm &
ICredentialIssuer &
ICredentialIssuerLD &
ISelectiveDisclosure
>
let dbConnection: Promise<Connection>
Expand All @@ -76,7 +84,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
database: databaseFile,
synchronize: false,
migrations: migrations,
migrationsRun:true,
migrationsRun: true,
logging: false,
entities: Entities,
})
Expand All @@ -90,6 +98,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
IMessageHandler &
IDIDComm &
ICredentialIssuer &
ICredentialIssuerLD &
ISelectiveDisclosure
>({
...options,
Expand Down Expand Up @@ -156,6 +165,10 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDComm(),
new CredentialIssuer(),
new CredentialIssuerLD({
contextMaps: [LdDefaultContexts, credential_contexts as any],
suites: [new VeramoEcdsaSecp256k1RecoverySignature2020(), new VeramoEd25519Signature2018()],
}),
new SelectiveDisclosure(),
...(options?.plugins || []),
],
Expand All @@ -170,7 +183,7 @@ const tearDown = async (): Promise<boolean> => {
} catch (e) {
// nop
}
try{
try {
fs.unlinkSync(databaseFile)
} catch (e) {
//nop
Expand All @@ -183,7 +196,8 @@ const getAgent = () => agent
const testContext = { getAgent, setup, tearDown }

describe('Local in-memory integration tests', () => {
verifiableData(testContext)
verifiableDataJWT(testContext)
verifiableDataLD(testContext)
handleSdrMessage(testContext)
resolveDid(testContext)
webDidFlow(testContext)
Expand Down
Loading