@@ -10,7 +10,7 @@ import type {
10
10
RequestProofOptions ,
11
11
} from './models/ServiceOptions'
12
12
import type { RetrievedCredentials } from './protocol/v1/models'
13
- import type { ProofRecord } from './repository'
13
+ import type { ProofRecord , ProofRepository } from './repository'
14
14
import type { PresentationRecordType } from './repository/PresentationExchangeRecord'
15
15
16
16
import { ConsoleLogger , LogLevel } from '../../logger'
@@ -22,7 +22,14 @@ const logger = new ConsoleLogger(LogLevel.debug)
22
22
* - stores records
23
23
* - returns records & messages
24
24
*/
25
+
25
26
export abstract class ProofService {
27
+ private proofRepository : ProofRepository
28
+
29
+ public constructor ( proofRepository : ProofRepository ) {
30
+ this . proofRepository = proofRepository
31
+ }
32
+
26
33
abstract getVersion ( ) : ProofProtocolVersion
27
34
28
35
/**
@@ -101,7 +108,45 @@ export abstract class ProofService {
101
108
throw Error ( 'Not Implemented' )
102
109
}
103
110
104
- public getById ( proofRecordId : string ) : Promise < ProofRecord > {
111
+ /**
112
+ * Retrieve all proof records
113
+ *
114
+ * @returns List containing all proof records
115
+ */
116
+ public async getAll ( ) : Promise < ProofRecord [ ] > {
117
+ return this . proofRepository . getAll ( )
118
+ }
119
+
120
+ /**
121
+ * Retrieve a proof record by id
122
+ *
123
+ * @param proofRecordId The proof record id
124
+ * @throws {RecordNotFoundError } If no record is found
125
+ * @return The proof record
126
+ *
127
+ */
128
+ public async getById ( proofRecordId : string ) : Promise < ProofRecord > {
105
129
return this . proofRepository . getById ( proofRecordId )
106
130
}
131
+
132
+ /**
133
+ * Retrieve a proof record by id
134
+ *
135
+ * @param proofRecordId The proof record id
136
+ * @return The proof record or null if not found
137
+ *
138
+ */
139
+ public async findById ( proofRecordId : string ) : Promise < ProofRecord | null > {
140
+ return this . proofRepository . findById ( proofRecordId )
141
+ }
142
+
143
+ /**
144
+ * Delete a proof record by id
145
+ *
146
+ * @param proofId the proof record id
147
+ */
148
+ public async deleteById ( proofId : string ) {
149
+ const proofRecord = await this . getById ( proofId )
150
+ return this . proofRepository . delete ( proofRecord )
151
+ }
107
152
}
0 commit comments