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

feature/VDX-247 added a module for contact manager #123

Merged
merged 17 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
53 changes: 29 additions & 24 deletions packages/contact-manager-rest-api/__tests__/RestAPI.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
import { ExpressBuilder, StaticBearerAuth } from '../../ssi-express-support/src'
import { ContactManagerApiServer, IContactManagerAPIEndpointOpts } from '../src'
import { ContactManagerApiServer } from '../src'
import agent from './agent'

const opts: IContactManagerAPIEndpointOpts = {
endpointOpts: {
globalAuth: {
authentication: {
enabled: true,
strategy: 'bearer',
},
},
},
}

StaticBearerAuth.init('bearer')
.withUsers([
{ id: 1, token: '123456', name: 'API User 1' },
{ id: 2, token: 'abcdef', name: 'API User 2' },
])
.connectPassport()
/*
passport.serializeUser(function (user: Express.User, done: (err: any, id?: any) => void) {
done(null, user)
})

passport.deserializeUser(function (user: Express.User, done: (err: any, user?: Express.User | false | null) => void) {
done(null, user)
})
*/

const builder = ExpressBuilder.fromServerOpts({
port: 5000,
hostname: '0.0.0.0',
})
.withMorganLogging({ format: 'dev' })
.withPassportAuth(true)
.withMorganLogging()
// .withSessionOptions({secret: '1234', name: 'oidc-session'})
.withSessionOptions({ secret: '1234', name: 'oidc-session' })

const expressSupport = builder.build({ startListening: true })

new ContactManagerApiServer({ agent, expressSupport, opts })
new ContactManagerApiServer({
opts: {
endpointOpts: {
globalAuth: {
authentication: {
enabled: false,
},
},
partyRead: {
disableGlobalAuth: true
nklomp marked this conversation as resolved.
Show resolved Hide resolved
},
partyWrite: {
disableGlobalAuth: true
},
identityRead: {
disableGlobalAuth: true
},
partyTypeRead: {
disableGlobalAuth: true
}
},
enableFeatures: ['party_read', 'party_write', 'party_type_read', 'identity_read'],
},
expressSupport,
agent,
})
expressSupport.start()
7 changes: 5 additions & 2 deletions packages/contact-manager-rest-api/__tests__/agent.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { createAgent } from '@veramo/core'
import { DataStore, DataStoreORM } from '@veramo/data-store'
import { IRequiredPlugins } from '../src'
import { DB_CONNECTION_NAME, getDbConnection } from './database'
import { DB_CONNECTION_NAME, sqliteConfig } from './database'
import { ContactManager } from '@sphereon/ssi-sdk.contact-manager'
import { ContactStore } from '@sphereon/ssi-sdk.data-store'
import { DataSources } from '@sphereon/ssi-sdk.agent-config'

const dbConnection = getDbConnection(DB_CONNECTION_NAME)
const dbConnection = DataSources.singleInstance()
.addConfig(DB_CONNECTION_NAME, sqliteConfig)
.getDbConnection(DB_CONNECTION_NAME)

const agent = createAgent<IRequiredPlugins>({
plugins: [new DataStore(dbConnection), new DataStoreORM(dbConnection), new ContactManager({ store: new ContactStore(dbConnection) })],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DataStoreContactEntities, DataStoreMigrations } from '@sphereon/ssi-sdk.data-store'
import { DataStoreContactEntities } from '@sphereon/ssi-sdk.data-store'
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
import { DataStoreContactMigrations } from '@sphereon/ssi-sdk.data-store/dist/migrations/generic'

const DB_CONNECTION_NAME = 'default'
const DB_ENCRYPTION_KEY = '29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c'
Expand All @@ -8,7 +9,7 @@ const sqliteConfig: SqliteConnectionOptions = {
type: 'sqlite',
database: '__tests__/database/test.sqlite',
entities: [...DataStoreContactEntities],
migrations: [...DataStoreMigrations],
migrations: [...DataStoreContactMigrations],
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
migrationsTransactionMode: 'each', // protect every migration with a separate transaction
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './config'
export * from './databaseService'
1 change: 1 addition & 0 deletions packages/contact-manager-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"start:dev": "ts-node __tests__/RestAPI.ts"
},
"dependencies": {
"@sphereon/ssi-sdk.agent-config": "workspace:^",
"@sphereon/ssi-express-support": "workspace:^",
"@sphereon/ssi-sdk.contact-manager": "workspace:^",
"@sphereon/ssi-sdk.data-store": "workspace:^",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.