feat: add handler for invalid proof at proof service backend because of age doesn't meet proving requirement
This commit is contained in:
parent
bd7f93e826
commit
3903191cdc
|
|
@ -238,7 +238,7 @@ class FabricGateway {
|
|||
`Evaluating getLogWithPagination transaction with pageSize: ${pageSize}, bookmark: ${bookmark}...`,
|
||||
);
|
||||
const resultBytes = await this.contract.evaluateTransaction(
|
||||
'getLogWithPagination',
|
||||
'getLogsWithPagination',
|
||||
pageSize.toString(),
|
||||
bookmark,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,12 @@ async function bootstrap() {
|
|||
const configService = app.get(ConfigService);
|
||||
app.setGlobalPrefix('api/');
|
||||
app.enableCors({
|
||||
origin: 'https://64spbch3-5173.asse.devtunnels.ms',
|
||||
origin: [
|
||||
'https://64spbch3-5173.asse.devtunnels.ms',
|
||||
'https://64spbch3-5174.asse.devtunnels.ms',
|
||||
'http://localhost:5173',
|
||||
'http://localhost:5174',
|
||||
],
|
||||
credentials: true,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
||||
allowedHeaders: 'Content-Type, Accept, X-CSRF-Token',
|
||||
|
|
|
|||
|
|
@ -43,12 +43,6 @@ export class AuditController {
|
|||
createAuditTrail() {
|
||||
this.auditService.storeAuditTrail();
|
||||
return { message: 'Proses audit trail dijalankan', status: 'STARTED' };
|
||||
// return interval(1000).pipe(
|
||||
// map(
|
||||
// (_) =>
|
||||
// ({ data: { message: 'Audit trail in progress...' } }) as MessageEvent,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
@Sse('stream')
|
||||
|
|
|
|||
|
|
@ -130,23 +130,22 @@ export class AuditService {
|
|||
break;
|
||||
}
|
||||
|
||||
// const records = (
|
||||
// await Promise.all(
|
||||
// logs.map((logEntry, index) =>
|
||||
// this.buildAuditRecord(logEntry, index),
|
||||
// ),
|
||||
// )
|
||||
// ).filter((record): record is AuditRecordPayload => record !== null);
|
||||
const records = (
|
||||
await Promise.all(
|
||||
logs.map((logEntry, index) =>
|
||||
this.buildAuditRecord(logEntry, index),
|
||||
),
|
||||
)
|
||||
).filter((record): record is AuditRecordPayload => record !== null);
|
||||
|
||||
const records: AuditRecordPayload[] = [];
|
||||
for (let index = 0; index < logs.length; index++) {
|
||||
const record = await this.buildAuditRecord(logs[index], index);
|
||||
if (record !== null) {
|
||||
records.push(record);
|
||||
}
|
||||
// Wait 1 second before processing next item
|
||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
}
|
||||
// const records: AuditRecordPayload[] = [];
|
||||
// for (let index = 0; index < logs.length; index++) {
|
||||
// const record = await this.buildAuditRecord(logs[index], index);
|
||||
// if (record !== null) {
|
||||
// records.push(record);
|
||||
// }
|
||||
// await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
// }
|
||||
|
||||
if (records.length > 0) {
|
||||
await this.prisma.$transaction(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
export class LogProofDto {
|
||||
@IsNotEmpty({ message: 'Proof wajib diisi' })
|
||||
@IsObject({ message: 'Proof harus berupa objek' })
|
||||
proofHash: any;
|
||||
proof: any;
|
||||
|
||||
@IsNotEmpty({ message: 'ID Visit wajib diisi' })
|
||||
@IsString({ message: 'ID Visit harus berupa string' })
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
|
@ -62,7 +62,10 @@ export class ProofService {
|
|||
|
||||
// const { proof, publicSignals } = await this.generateProof();
|
||||
|
||||
const { proof, publicSignals } = await groth16.fullProve(
|
||||
let result: any;
|
||||
|
||||
try {
|
||||
result = await groth16.fullProve(
|
||||
{
|
||||
age: age,
|
||||
threshold: 18,
|
||||
|
|
@ -70,6 +73,13 @@ export class ProofService {
|
|||
this.wasmPath,
|
||||
this.zkeyPath,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
"Can't generate proof from input based on constraint. Please check the input data and try again.",
|
||||
);
|
||||
}
|
||||
|
||||
const { proof, publicSignals } = result;
|
||||
|
||||
return {
|
||||
proof: proof,
|
||||
|
|
@ -80,7 +90,7 @@ export class ProofService {
|
|||
async logVerificationProof(logProofDto: LogProofDto) {
|
||||
const payload = {
|
||||
id_visit: logProofDto.id_visit || null,
|
||||
proofHash: logProofDto.proofHash || null,
|
||||
proofHash: logProofDto.proof || null,
|
||||
proofResult: logProofDto.proofResult || null,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -447,7 +447,7 @@ onBeforeUnmount(() => {
|
|||
Proses audit sedang berjalan...
|
||||
</p>
|
||||
<p class="text-sm text-gray-600">
|
||||
{{ progres + 1 }} data telah diperiksa
|
||||
{{ progres }} data telah diperiksa
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user