-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (core) [DSDK-251]: Add new Apdu Receiver Service (#41)
- Loading branch information
Showing
12 changed files
with
655 additions
and
18 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/core/src/internal/device-session/data/ApduResponseConst.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const APDU_RESPONSE_STATUS_CODE_LENGTH = 2; |
8 changes: 4 additions & 4 deletions
8
packages/core/src/internal/device-session/data/FramerConst.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const HEAD_TAG = 0x05; | ||
export const HEAD_TAG_SIZE = 1; | ||
export const CHANNEL_SIZE = 2; | ||
export const INDEX_SIZE = 2; | ||
export const APDU_DATA_SIZE = 2; | ||
export const HEAD_TAG_LENGTH = 1; | ||
export const CHANNEL_LENGTH = 2; | ||
export const INDEX_LENGTH = 2; | ||
export const APDU_DATA_LENGTH_LENGTH = 2; |
22 changes: 22 additions & 0 deletions
22
packages/core/src/internal/device-session/model/ApduResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
type ApduResponseConstructorArgs = { | ||
statusCode: Uint8Array; | ||
data: Uint8Array; | ||
}; | ||
|
||
export class ApduResponse { | ||
protected _statusCode: Uint8Array; | ||
protected _data: Uint8Array; | ||
|
||
constructor({ statusCode, data }: ApduResponseConstructorArgs) { | ||
this._statusCode = statusCode; | ||
this._data = data; | ||
} | ||
|
||
public getStatusCode() { | ||
return this._statusCode; | ||
} | ||
|
||
public getData() { | ||
return this._data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/core/src/internal/device-session/service/ApduReceiverService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Either, Maybe } from "purify-ts"; | ||
|
||
import { ApduResponse } from "@internal/device-session/model/ApduResponse"; | ||
import { ReceiverApduError } from "@internal/device-session/model/Errors"; | ||
|
||
export interface ApduReceiverService { | ||
handleFrame(apdu: Uint8Array): Either<ReceiverApduError, Maybe<ApduResponse>>; | ||
} |
Oops, something went wrong.