Skip to content

Commit

Permalink
Merge pull request #178 from Sphereon-Opensource/feature/VDX-318
Browse files Browse the repository at this point in the history
feature/VDX-318
  • Loading branch information
BtencateSphereon authored Feb 7, 2024
2 parents cb3333d + ac6aac7 commit 4e098c8
Show file tree
Hide file tree
Showing 9 changed files with 500 additions and 189 deletions.
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@
"@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.15.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.15.0",
"@sphereon/ssi-sdk.contact-manager": "0.18.1-next.4",
"@sphereon/ssi-sdk.core": "0.18.1-next.4",
"@sphereon/ssi-sdk.data-store": "0.18.1-next.4",
"@sphereon/ssi-sdk.issuance-branding": "0.18.1-next.4",
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.18.1-next.4",
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.18.1-next.4",
"@sphereon/ssi-types": "0.18.1-next.4",
"@sphereon/ssi-sdk.contact-manager": "0.18.2-next.9",
"@sphereon/ssi-sdk.core": "0.18.2-next.9",
"@sphereon/ssi-sdk.data-store": "0.18.2-next.9",
"@sphereon/ssi-sdk.issuance-branding": "0.18.2-next.9",
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.18.2-next.9",
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.18.2-next.9",
"@sphereon/ssi-types": "0.18.2-next.9",
"@sphereon/ssi-sdk.event-logger": "0.18.2-next.9",
"@sphereon/ui-components.core": "0.1.3-unstable.88",
"@sphereon/ui-components.ssi-react-native": "0.1.3-unstable.88",
"@transmute/lds-ecdsa-secp256k1-recovery2020": "^0.0.7",
Expand All @@ -72,6 +73,7 @@
"@veramo/did-resolver": "4.2.0",
"@veramo/kms-local": "4.2.0",
"@veramo/utils": "4.2.0",
"@veramo/remote-client": "4.2.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"assert": "^1.1.1",
Expand Down Expand Up @@ -241,13 +243,13 @@
"ajv": "^8.12.0",
"@sphereon/isomorphic-argon2": "1.0.1",
"@sphereon/did-auth-siop": "0.5.0-unstable.7",
"@sphereon/ssi-types": "0.18.1-next.4",
"@sphereon/ssi-sdk.core": "0.18.1-next.4",
"@sphereon/ssi-types": "0.18.2-next.9",
"@sphereon/ssi-sdk.core": "0.18.2-next.9",
"@sphereon/ssi-sdk.data-store": "0.18.2-next.9",
"@sphereon/ssi-sdk.contact-manager": "0.18.2-next.9",
"@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.15.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.15.0",
"@sphereon/ssi-sdk.data-store": "0.18.1-next.4",
"@sphereon/ssi-sdk.contact-manager": "0.18.1-next.4",
"@sphereon/oid4vci-client": "0.7.3",
"@sphereon/oid4vci-common": "0.7.3",
"@sphereon/pex": "2.2.1-unstable.0",
Expand Down
4 changes: 2 additions & 2 deletions src/@config/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DataStoreContactEntities, DataStoreIssuanceBrandingEntities, DataStoreMigrations} from '@sphereon/ssi-sdk.data-store';
import {DataStoreEntities, DataStoreMigrations} from '@sphereon/ssi-sdk.data-store';
import {Entities as VeramoDataStoreEntities, migrations as VeramoDataStoreMigrations} from '@veramo/data-store';
import * as driver from 'expo-sqlite';
import {ExpoConnectionOptions} from 'typeorm/driver/expo/ExpoConnectionOptions';
Expand All @@ -10,7 +10,7 @@ const sqliteConfig: ExpoConnectionOptions = {
type: 'expo',
database: 'sphereon-wallet.sqlite',
driver,
entities: [...VeramoDataStoreEntities, ...DataStoreContactEntities, ...DataStoreIssuanceBrandingEntities],
entities: [...VeramoDataStoreEntities, ...DataStoreEntities],
migrations: [...VeramoDataStoreMigrations, ...DataStoreMigrations],
migrationsRun: false, // We run migrations from code to ensure proper ordering with Redux
synchronize: false, // We do not enable synchronize, as we use migrations from code
Expand Down
134 changes: 65 additions & 69 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import {JwkDIDProvider} from '@sphereon/ssi-sdk-ext.did-provider-jwk';
import {getDidJwkResolver} from '@sphereon/ssi-sdk-ext.did-resolver-jwk';
import {SphereonKeyManager} from '@sphereon/ssi-sdk-ext.key-manager';
import {SphereonKeyManagementSystem} from '@sphereon/ssi-sdk-ext.kms-local';
import {ContactManager, IContactManager} from '@sphereon/ssi-sdk.contact-manager';
import {ContactStore, IssuanceBrandingStore} from '@sphereon/ssi-sdk.data-store';
import {IIssuanceBranding, IssuanceBranding} from '@sphereon/ssi-sdk.issuance-branding';
import {DidAuthSiopOpAuthenticator, IDidAuthSiopOpAuthenticator} from '@sphereon/ssi-sdk.siopv2-oid4vp-op-auth';
import {ContactManager} from '@sphereon/ssi-sdk.contact-manager';
import {ContactStore, EventLoggerStore, IssuanceBrandingStore} from '@sphereon/ssi-sdk.data-store';
import {IssuanceBranding} from '@sphereon/ssi-sdk.issuance-branding';
import {LoggingEventType} from '@sphereon/ssi-sdk.core';
import {DidAuthSiopOpAuthenticator} from '@sphereon/ssi-sdk.siopv2-oid4vp-op-auth';
import {
CredentialHandlerLDLocal,
ICredentialHandlerLDLocal,
MethodNames,
SphereonEd25519Signature2018,
SphereonEd25519Signature2020,
SphereonJsonWebSignature2020,
} from '@sphereon/ssi-sdk.vc-handler-ld-local';
import {createAgent, ICredentialPlugin, IDataStore, IDataStoreORM, IDIDManager, IKeyManager, IResolver} from '@veramo/core';
import {CredentialPlugin, ICredentialIssuer} from '@veramo/credential-w3c';
import {createAgent, IAgentPlugin, TAgent} from '@veramo/core';
import {CredentialPlugin} from '@veramo/credential-w3c';
import {DataStore, DataStoreORM, DIDStore, KeyStore, PrivateKeyStore} from '@veramo/data-store';
import {DIDManager} from '@veramo/did-manager';
import {DIDManager, AbstractIdentifierProvider} from '@veramo/did-manager';
import {EthrDIDProvider} from '@veramo/did-provider-ethr';
import {getDidIonResolver, IonDIDProvider} from '@veramo/did-provider-ion';
import {getDidKeyResolver, KeyDIDProvider} from '@veramo/did-provider-key';
Expand All @@ -28,14 +28,14 @@ import {OrPromise} from '@veramo/utils';
import {Resolver} from 'did-resolver';
import {DataSource} from 'typeorm';
import {getResolver as webDIDResolver} from 'web-did-resolver';

import {DID_PREFIX, DIF_UNIRESOLVER_RESOLVE_URL, SPHEREON_UNIRESOLVER_RESOLVE_URL} from '../@config/constants';
import {EventLogger} from '@sphereon/ssi-sdk.event-logger';
import {DID_PREFIX, DIF_UNIRESOLVER_RESOLVE_URL} from '../@config/constants';
import {LdContexts} from '../@config/credentials';
import {DB_CONNECTION_NAME, DB_ENCRYPTION_KEY} from '../@config/database';
import {getDbConnection} from '../services/databaseService';
import {KeyManagementSystemEnum, SupportedDidMethodEnum} from '../types';
import {AgentTypes, KeyManagementSystemEnum, SupportedDidMethodEnum} from '../types';

export const didResolver = new Resolver({
export const didResolver: Resolver = new Resolver({
...getUniResolver(SupportedDidMethodEnum.DID_ETHR, {
resolveUrl: DIF_UNIRESOLVER_RESOLVE_URL,
}),
Expand All @@ -45,9 +45,11 @@ export const didResolver = new Resolver({
...getDidJwkResolver(),
});

export const didMethodsSupported = Object.keys(didResolver['registry']).map(method => method.toLowerCase().replace('did:', ''));
export const didMethodsSupported: Array<string> = Object.keys(didResolver['registry']).map((method: string) =>
method.toLowerCase().replace('did:', ''),
);

export const didProviders = {
export const didProviders: Record<string, AbstractIdentifierProvider> = {
[`${DID_PREFIX}:${SupportedDidMethodEnum.DID_ETHR}`]: new EthrDIDProvider({
defaultKms: KeyManagementSystemEnum.LOCAL,
network: 'goerli',
Expand All @@ -66,61 +68,55 @@ export const didProviders = {
const dbConnection: OrPromise<DataSource> = getDbConnection(DB_CONNECTION_NAME);
const privateKeyStore: PrivateKeyStore = new PrivateKeyStore(dbConnection, new SecretBox(DB_ENCRYPTION_KEY));

const agent = createAgent<
IDIDManager &
IKeyManager &
IDataStore &
IDataStoreORM &
IResolver &
IDidAuthSiopOpAuthenticator &
IContactManager &
ICredentialPlugin &
ICredentialIssuer &
ICredentialHandlerLDLocal &
IIssuanceBranding
>({
plugins: [
new DataStore(dbConnection),
new DataStoreORM(dbConnection),
new SphereonKeyManager({
store: new KeyStore(dbConnection),
kms: {
local: new SphereonKeyManagementSystem(privateKeyStore),
},
}),
new DIDManager({
store: new DIDStore(dbConnection),
defaultProvider: `${DID_PREFIX}:${SupportedDidMethodEnum.DID_KEY}`,
providers: didProviders,
}),
new DIDResolverPlugin({
resolver: didResolver,
}),
new DidAuthSiopOpAuthenticator(),
new ContactManager({
store: new ContactStore(dbConnection),
}),
new IssuanceBranding({
store: new IssuanceBrandingStore(dbConnection),
}),
new CredentialPlugin(),
new CredentialHandlerLDLocal({
contextMaps: [LdContexts],
suites: [
new SphereonEd25519Signature2018(),
new SphereonEd25519Signature2020(),
// new SphereonBbsBlsSignature2020(),
new SphereonJsonWebSignature2020(),
],
bindingOverrides: new Map([
['verifyCredentialLD', MethodNames.verifyCredentialLDLocal],
['verifyPresentationLD', MethodNames.verifyPresentationLDLocal],
['createVerifiableCredentialLD', MethodNames.createVerifiableCredentialLDLocal],
['createVerifiablePresentationLD', MethodNames.createVerifiablePresentationLDLocal],
]),
keyStore: privateKeyStore,
}),
],
const agentPlugins: Array<IAgentPlugin> = [
new DataStore(dbConnection),
new DataStoreORM(dbConnection),
new SphereonKeyManager({
store: new KeyStore(dbConnection),
kms: {
local: new SphereonKeyManagementSystem(privateKeyStore),
},
}),
new DIDManager({
store: new DIDStore(dbConnection),
defaultProvider: `${DID_PREFIX}:${SupportedDidMethodEnum.DID_KEY}`,
providers: didProviders,
}),
new DIDResolverPlugin({
resolver: didResolver,
}),
new DidAuthSiopOpAuthenticator(),
new ContactManager({
store: new ContactStore(dbConnection),
}),
new IssuanceBranding({
store: new IssuanceBrandingStore(dbConnection),
}),
new CredentialPlugin(),
new CredentialHandlerLDLocal({
contextMaps: [LdContexts],
suites: [
new SphereonEd25519Signature2018(),
new SphereonEd25519Signature2020(),
// new SphereonBbsBlsSignature2020(),
new SphereonJsonWebSignature2020(),
],
bindingOverrides: new Map([
['verifyCredentialLD', MethodNames.verifyCredentialLDLocal],
['verifyPresentationLD', MethodNames.verifyPresentationLDLocal],
['createVerifiableCredentialLD', MethodNames.createVerifiableCredentialLDLocal],
['createVerifiablePresentationLD', MethodNames.createVerifiablePresentationLDLocal],
]),
keyStore: privateKeyStore,
}),
new EventLogger({
eventTypes: [LoggingEventType.AUDIT],
store: new EventLoggerStore(dbConnection),
}),
];

const agent: TAgent<AgentTypes> = createAgent<AgentTypes>({
plugins: agentPlugins,
});

export const didManagerCreate = agent.didManagerCreate;
Expand Down
Loading

0 comments on commit 4e098c8

Please sign in to comment.