Skip to content

Commit

Permalink
fix: After dropping DB agent would throw exception as we removed the …
Browse files Browse the repository at this point in the history
…data source
  • Loading branch information
nklomp committed Oct 9, 2024
1 parent 6474f4b commit ab9c1c8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/agent-config/src/dataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,19 @@ export const getDbConnection = async (
return DataSources.singleInstance().getDbConnection(connectionName)
}

export const dropDatabase = async (dbName: string): Promise<void> => {
export const dropDatabase = async (dbName: string, opts?: {removeDataSource?: boolean}): Promise<void> => {
const {removeDataSource = false} = {...opts}
if (!DataSources.singleInstance().has(dbName)) {
return Promise.reject(Error(`No database present with name: ${dbName}`))
}

const connection: DataSource = await getDbConnection(dbName)
await connection.dropDatabase()
DataSources.singleInstance().delete(dbName)
if (removeDataSource) {
DataSources.singleInstance().delete(dbName)
} else if (!connection.isInitialized) {
await connection.initialize()
}
}

/**
Expand Down
19 changes: 19 additions & 0 deletions packages/ssi-types/src/mapper/credential-constraints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CredentialFormat, PresentationFormat } from '../types'

export type CredentialEncoding = 'json' /*includes json-ld*/ | 'jwt' | 'cbor'

export type IssuerAttributeName = 'iss' | 'issuer' | 'issuerAuth'
export type SubjectAttributeName = 'subject' | 'id' | 'deviceMac' | 'TODO'
export type TypeAttributeName = 'type' | 'vct'

export type DataModel = 'W3C_VCDM' | 'IETF_SD_JWT' | 'ISO_MSO_MDOC'

export interface CredentialConstraint {
credentialFormat: CredentialFormat
presentationFormat: PresentationFormat
maxSignatures: number
encoding: CredentialEncoding
dataModel: DataModel
typeAttribute?: TypeAttributeName // optional since mdocs use namespace maps without an explicit type attribute
issuerAttributes: [IssuerAttributeName]
}

0 comments on commit ab9c1c8

Please sign in to comment.