diff --git a/src/app/shared/collector/collector.service.ts b/src/app/shared/collector/collector.service.ts index c257f535e..858ecf72b 100644 --- a/src/app/shared/collector/collector.service.ts +++ b/src/app/shared/collector/collector.service.ts @@ -26,14 +26,18 @@ export class CollectorService { async run(assets: Assets, capturedTimestamp: number, source: CameraSource) { const truth = await this.collectTruth(assets, capturedTimestamp); const proof = await Proof.from(this.mediaStore, assets, truth); - await this.generateSignature(proof, source); + proof.cameraSource = source; + await this.generateSignature(proof, proof.cameraSource); proof.isCollected = true; return proof; } + // FIXME: @sultanmyrza get cameraSource from proof.cameraSource instead of passing separately + // TODO: @sultanmyrza remove 2nd parameter and make sure all other places get called accordinglyt async generateSignature(proof: Proof, source: CameraSource) { - const recorder = - CaptureAppWebCryptoApiSignatureProvider.recorderFor(source); + const recorder = CaptureAppWebCryptoApiSignatureProvider.recorderFor( + proof.cameraSource + ); const proofMetadata = await proof.generateProofMetadata(recorder); const { signatures, integritySha } = await this.signProofMetadata( proofMetadata, diff --git a/src/app/shared/repositories/proof/proof.ts b/src/app/shared/repositories/proof/proof.ts index d6425c132..7ef7a175d 100644 --- a/src/app/shared/repositories/proof/proof.ts +++ b/src/app/shared/repositories/proof/proof.ts @@ -34,6 +34,13 @@ export class Proof { integritySha?: string = undefined; + /** + * Since capture cam originally capture photos/videos from camera we set cameraSource to + * CameraSource.Camera by default. If user picks photo/video from galley then cameraSource + * should be changed to CameraSource.Photos + */ + cameraSource: CameraSource = CameraSource.Camera; + get timestamp() { return this.truth.timestamp; } @@ -116,6 +123,7 @@ export class Proof { proof.isCollected = indexedProofView.isCollected ?? false; proof.signatureVersion = indexedProofView.signatureVersion; proof.integritySha = indexedProofView.integritySha; + proof.cameraSource = indexedProofView.cameraSource; return proof; } @@ -285,6 +293,7 @@ export class Proof { diaBackendAssetId: this.diaBackendAssetId, isCollected: this.isCollected, integritySha: this.integritySha, + cameraSource: this.cameraSource, }; } @@ -418,6 +427,7 @@ export interface IndexedProofView extends Tuple { readonly diaBackendAssetId?: string; readonly isCollected?: boolean; readonly integritySha?: string; + readonly cameraSource: CameraSource; } /**