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}...`,
|
`Evaluating getLogWithPagination transaction with pageSize: ${pageSize}, bookmark: ${bookmark}...`,
|
||||||
);
|
);
|
||||||
const resultBytes = await this.contract.evaluateTransaction(
|
const resultBytes = await this.contract.evaluateTransaction(
|
||||||
'getLogWithPagination',
|
'getLogsWithPagination',
|
||||||
pageSize.toString(),
|
pageSize.toString(),
|
||||||
bookmark,
|
bookmark,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,12 @@ async function bootstrap() {
|
||||||
const configService = app.get(ConfigService);
|
const configService = app.get(ConfigService);
|
||||||
app.setGlobalPrefix('api/');
|
app.setGlobalPrefix('api/');
|
||||||
app.enableCors({
|
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,
|
credentials: true,
|
||||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
||||||
allowedHeaders: 'Content-Type, Accept, X-CSRF-Token',
|
allowedHeaders: 'Content-Type, Accept, X-CSRF-Token',
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,6 @@ export class AuditController {
|
||||||
createAuditTrail() {
|
createAuditTrail() {
|
||||||
this.auditService.storeAuditTrail();
|
this.auditService.storeAuditTrail();
|
||||||
return { message: 'Proses audit trail dijalankan', status: 'STARTED' };
|
return { message: 'Proses audit trail dijalankan', status: 'STARTED' };
|
||||||
// return interval(1000).pipe(
|
|
||||||
// map(
|
|
||||||
// (_) =>
|
|
||||||
// ({ data: { message: 'Audit trail in progress...' } }) as MessageEvent,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Sse('stream')
|
@Sse('stream')
|
||||||
|
|
|
||||||
|
|
@ -130,23 +130,22 @@ export class AuditService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const records = (
|
const records = (
|
||||||
// await Promise.all(
|
await Promise.all(
|
||||||
// logs.map((logEntry, index) =>
|
logs.map((logEntry, index) =>
|
||||||
// this.buildAuditRecord(logEntry, index),
|
this.buildAuditRecord(logEntry, index),
|
||||||
// ),
|
),
|
||||||
// )
|
)
|
||||||
// ).filter((record): record is AuditRecordPayload => record !== null);
|
).filter((record): record is AuditRecordPayload => record !== null);
|
||||||
|
|
||||||
const records: AuditRecordPayload[] = [];
|
// const records: AuditRecordPayload[] = [];
|
||||||
for (let index = 0; index < logs.length; index++) {
|
// for (let index = 0; index < logs.length; index++) {
|
||||||
const record = await this.buildAuditRecord(logs[index], index);
|
// const record = await this.buildAuditRecord(logs[index], index);
|
||||||
if (record !== null) {
|
// if (record !== null) {
|
||||||
records.push(record);
|
// records.push(record);
|
||||||
}
|
// }
|
||||||
// Wait 1 second before processing next item
|
// await new Promise((resolve) => setTimeout(resolve, 250));
|
||||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
if (records.length > 0) {
|
if (records.length > 0) {
|
||||||
await this.prisma.$transaction(
|
await this.prisma.$transaction(
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
export class LogProofDto {
|
export class LogProofDto {
|
||||||
@IsNotEmpty({ message: 'Proof wajib diisi' })
|
@IsNotEmpty({ message: 'Proof wajib diisi' })
|
||||||
@IsObject({ message: 'Proof harus berupa objek' })
|
@IsObject({ message: 'Proof harus berupa objek' })
|
||||||
proofHash: any;
|
proof: any;
|
||||||
|
|
||||||
@IsNotEmpty({ message: 'ID Visit wajib diisi' })
|
@IsNotEmpty({ message: 'ID Visit wajib diisi' })
|
||||||
@IsString({ message: 'ID Visit harus berupa string' })
|
@IsString({ message: 'ID Visit harus berupa string' })
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import {
|
import {
|
||||||
|
BadRequestException,
|
||||||
Injectable,
|
Injectable,
|
||||||
InternalServerErrorException,
|
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
@ -62,14 +62,24 @@ export class ProofService {
|
||||||
|
|
||||||
// const { proof, publicSignals } = await this.generateProof();
|
// const { proof, publicSignals } = await this.generateProof();
|
||||||
|
|
||||||
const { proof, publicSignals } = await groth16.fullProve(
|
let result: any;
|
||||||
{
|
|
||||||
age: age,
|
try {
|
||||||
threshold: 18,
|
result = await groth16.fullProve(
|
||||||
},
|
{
|
||||||
this.wasmPath,
|
age: age,
|
||||||
this.zkeyPath,
|
threshold: 18,
|
||||||
);
|
},
|
||||||
|
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 {
|
return {
|
||||||
proof: proof,
|
proof: proof,
|
||||||
|
|
@ -80,7 +90,7 @@ export class ProofService {
|
||||||
async logVerificationProof(logProofDto: LogProofDto) {
|
async logVerificationProof(logProofDto: LogProofDto) {
|
||||||
const payload = {
|
const payload = {
|
||||||
id_visit: logProofDto.id_visit || null,
|
id_visit: logProofDto.id_visit || null,
|
||||||
proofHash: logProofDto.proofHash || null,
|
proofHash: logProofDto.proof || null,
|
||||||
proofResult: logProofDto.proofResult || null,
|
proofResult: logProofDto.proofResult || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -447,7 +447,7 @@ onBeforeUnmount(() => {
|
||||||
Proses audit sedang berjalan...
|
Proses audit sedang berjalan...
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-gray-600">
|
<p class="text-sm text-gray-600">
|
||||||
{{ progres + 1 }} data telah diperiksa
|
{{ progres }} data telah diperiksa
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user