From 31d7aca4d511455e01784c5833b3ceaeab7af59e Mon Sep 17 00:00:00 2001 From: Louis Aussedat Date: Thu, 28 Mar 2024 10:40:01 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A1=20(core):=20Add=20comments=20in=20?= =?UTF-8?q?DefaultApduReceiverService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DefaultApduReceiverService.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/core/src/internal/device-session/service/DefaultApduReceiverService.ts b/packages/core/src/internal/device-session/service/DefaultApduReceiverService.ts index abe0115f9..8cd95ead5 100644 --- a/packages/core/src/internal/device-session/service/DefaultApduReceiverService.ts +++ b/packages/core/src/internal/device-session/service/DefaultApduReceiverService.ts @@ -99,6 +99,12 @@ export class DefaultApduReceiverService implements ApduReceiverService { }); } + /* + * Parse an Uint8Array to a Frame + * Return an error if the frame is not formatted correctly + * + * @param Uint8Array + */ private apduToFrame(apdu: Uint8Array): Either { const channelSize = this._channel.caseOf({ Just: () => CHANNEL_LENGTH, @@ -149,6 +155,11 @@ export class DefaultApduReceiverService implements ApduReceiverService { return Right(frame); } + /* + * Return true if all the datas has been received + * + * @param number + */ private isComplete(dataSize: number): boolean { const totalReceiveLength = this._pendingFrames.reduce( (prev: number, curr: Frame) => prev + curr.getData().length,