Skip to content

Commit

Permalink
chore: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Jul 26, 2024
1 parent 13ab0df commit b2dacd0
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 46 deletions.
94 changes: 73 additions & 21 deletions packages/agent/src/database/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Entities as VeramoDataStoreEntities, migrations as VeramoDataStoreMigrations } from '@veramo/data-store'
import {Entities as VeramoDataStoreEntities, migrations as VeramoDataStoreMigrations} from '@veramo/data-store'
import {
DB_CACHE_ENABLED,
DB_DATABASE_NAME,
Expand All @@ -13,11 +13,25 @@ import {
DB_USE_SSL,
DB_USERNAME,
} from '../environment'
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions'
import { TlsOptions } from 'tls'
import { DataStoreEntities, DataStoreMigrations } from '@sphereon/ssi-sdk.data-store'
import { WebWalletMigrations } from './migrations'
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
import {PostgresConnectionOptions} from 'typeorm/driver/postgres/PostgresConnectionOptions'
import {TlsOptions} from 'tls'
import {DataStoreEntities, DataStoreMigrations} from '@sphereon/ssi-sdk.data-store'
import {WebWalletMigrations} from './migrations'
import {SqliteConnectionOptions} from 'typeorm/driver/sqlite/SqliteConnectionOptions'
import {
DataStoreContactEntities, DataStoreDigitalCredentialEntities, DataStoreEventLoggerEntities,
DataStoreIssuanceBrandingEntities, DataStoreMachineStateEntities, DataStorePresentationDefinitionEntities,
DataStoreStatusListEntities,
} from '@sphereon/ssi-sdk.data-store/src'
import {
DataStoreContactMigrations,
DataStoreDigitalCredentialMigrations,
DataStoreEventLoggerMigrations,
DataStoreIssuanceBrandingMigrations,
DataStoreMachineStateMigrations,
DataStorePresentationDefinitionMigrations,
DataStoreStatusListMigrations,
} from '@sphereon/ssi-sdk.data-store/src/migrations/generic'

if (!process.env.DB_ENCRYPTION_KEY) {
console.warn(
Expand All @@ -32,11 +46,11 @@ const enableSSL = DB_USE_SSL === 'true' || DB_URL?.includes('sslmode=require')

let ssl: TlsOptions | boolean = enableSSL
? {
...(DB_SSL_CA && { ca: DB_SSL_CA }),
...(DB_SSL_ALLOW_SELF_SIGNED && {
rejectUnauthorized: DB_SSL_ALLOW_SELF_SIGNED === 'false',
}),
}
...(DB_SSL_CA && {ca: DB_SSL_CA}),
...(DB_SSL_ALLOW_SELF_SIGNED && {
rejectUnauthorized: DB_SSL_ALLOW_SELF_SIGNED === 'false',
}),
}
: false
if (enableSSL && Object.keys(ssl).length === 0) {
ssl = true
Expand All @@ -48,8 +62,27 @@ if (enableSSL && Object.keys(ssl).length === 0) {
const sqliteConfig: SqliteConnectionOptions = {
type: 'sqlite',
database: DB_URL!,
entities: [...VeramoDataStoreEntities],
migrations: [...VeramoDataStoreMigrations],
entities: [
...VeramoDataStoreEntities,
...DataStoreContactEntities,
...DataStoreIssuanceBrandingEntities,
...DataStoreStatusListEntities,
...DataStoreEventLoggerEntities,
...DataStoreDigitalCredentialEntities,
...DataStoreMachineStateEntities,
...DataStorePresentationDefinitionEntities,
],
migrations: [
...VeramoDataStoreMigrations,
...DataStoreContactMigrations,
...DataStoreIssuanceBrandingMigrations,
...DataStoreStatusListMigrations,
...DataStoreEventLoggerMigrations,
...DataStoreDigitalCredentialMigrations,
...DataStoreMachineStateMigrations,
...DataStorePresentationDefinitionMigrations,
...WebWalletMigrations,
],
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 All @@ -62,17 +95,36 @@ const sqliteConfig: SqliteConnectionOptions = {
*/
const postgresConfig: PostgresConnectionOptions = validatePostgresOptions({
type: 'postgres',
...(DB_URL && { url: DB_URL }),
...(DB_HOST && { host: DB_HOST }),
...(DB_PORT && { port: Number.parseInt(DB_PORT) }),
...(DB_USERNAME && { username: DB_USERNAME }),
...(DB_PASSWORD && { password: DB_PASSWORD }),
...(DB_SCHEMA && { schema: DB_SCHEMA }),
...(DB_URL && {url: DB_URL}),
...(DB_HOST && {host: DB_HOST}),
...(DB_PORT && {port: Number.parseInt(DB_PORT)}),
...(DB_USERNAME && {username: DB_USERNAME}),
...(DB_PASSWORD && {password: DB_PASSWORD}),
...(DB_SCHEMA && {schema: DB_SCHEMA}),
ssl,
database: DB_DATABASE_NAME,
cache: DB_CACHE_ENABLED !== 'false',
entities: [...VeramoDataStoreEntities, ...DataStoreEntities],
migrations: [...VeramoDataStoreMigrations, ...DataStoreMigrations, ...WebWalletMigrations],
entities: [
...VeramoDataStoreEntities,
...DataStoreContactEntities,
...DataStoreIssuanceBrandingEntities,
...DataStoreStatusListEntities,
...DataStoreEventLoggerEntities,
...DataStoreDigitalCredentialEntities,
...DataStoreMachineStateEntities,
...DataStorePresentationDefinitionEntities,
],
migrations: [
...VeramoDataStoreMigrations,
...DataStoreContactMigrations,
...DataStoreIssuanceBrandingMigrations,
...DataStoreStatusListMigrations,
...DataStoreEventLoggerMigrations,
...DataStoreDigitalCredentialMigrations,
...DataStoreMachineStateMigrations,
...DataStorePresentationDefinitionMigrations,
...WebWalletMigrations,
],
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
6 changes: 3 additions & 3 deletions packages/web-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.28.1-next.39",
"@sphereon/ssi-sdk.w3c-vc-api-issuer-rest-client": "0.28.1-next.39",
"@sphereon/ssi-types": "0.28.1-next.39",
"@sphereon/ui-components.core": "0.2.1-unstable.92",
"@sphereon/ui-components.credential-branding": "0.2.1-unstable.92",
"@sphereon/ui-components.ssi-react": "0.2.1-unstable.92",
"@sphereon/ui-components.core": "0.2.1-next.94",
"@sphereon/ui-components.credential-branding": "0.2.1-next.94",
"@sphereon/ui-components.ssi-react": "0.2.1-next.94",
"web-did-resolver": "^2.0.27",
"@supabase/postgrest-js": "1.15.2",
"@supabase/storage-js": "2.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CredentialsList: FC<Props> = (props: Props): ReactElement => {
},
sorters: [
{
field: 'createdAt', // We don't we have a field 'issuanceDate' in the db anymore, so sort on createdAt
field: 'validFrom', // We don't we have a field 'issuanceDate' in the db anymore, so sort on validFrom
order: 'asc',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const credentialDataProvider = (): DataProvider => ({
},
getOne: async <TData extends BaseRecord = BaseRecord>({resource, id, meta}: GetOneParams): Promise<GetOneResponse<TData>> => {
assertResource(resource)
console.log('== meta', meta)
if (meta === undefined || meta.variables === undefined || !('credentialRole' in meta.variables)) {
return Promise.reject(Error('credentialRole not found in meta query'))
}
Expand Down Expand Up @@ -149,6 +148,6 @@ export const credentialDataProvider = (): DataProvider => ({

getApiUrl: (): string => {
// TODO implement
return 'some api url'
throw Error("Not implemented")
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,6 @@ export const identifiersDataProvider = (): DataProvider => ({
},
getApiUrl: (): string => {
// TODO CWALL-244 implement
return 'some api url'
throw Error("Not implemented")
},
})
2 changes: 1 addition & 1 deletion packages/web-wallet/src/dataProviders/keysDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ export const keysDataProvider = (): DataProvider => ({
},
getApiUrl: (): string => {
// TODO CWALL-242 implement
return 'some api url'
throw Error("Not implemented")
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ export const presentationDefinitionDataProvider = (): DataProvider => ({

getApiUrl: (): string => {
// TODO CWALL-234 implement
return 'some api url'
throw Error("Not implemented")
},
})
2 changes: 1 addition & 1 deletion packages/web-wallet/src/types/credential/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class CredentialTableItem {
const subjectPartyIdentity = credential.subjectCorrelationId ? getMatchingIdentity(parties, credential.subjectCorrelationId) : undefined
const subjectParty = subjectPartyIdentity ? subjectPartyIdentity.party : undefined

const issuanceDateStr = formatDate(credential.createdAt as unknown as string) // FIXME use other REST client
const issuanceDateStr = formatDate(credential.validFrom as unknown as string) // FIXME use other REST client
const expirationDateStr = formatDate(credential.validUntil as unknown as string) // FIXME use other REST client

const vc = JSON.parse(credential.uniformDocument ?? credential.rawDocument) as IVerifiableCredential // TODO create function for this in CredentialMapper
Expand Down
29 changes: 14 additions & 15 deletions pnpm-lock.yaml

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

0 comments on commit b2dacd0

Please sign in to comment.