Skip to content

Commit

Permalink
✨ (core): Add Command interface
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed Apr 15, 2024
1 parent 42c5005 commit ad3bff9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/api/command/Command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Apdu } from "@api/apdu/model/Apdu";

export interface Command<Params, T> {
getApdu(params?: Params): Apdu;
parseResponse(responseApdu: Apdu): T;
}
12 changes: 12 additions & 0 deletions packages/core/src/internal/device-session/model/Session.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { v4 as uuidv4 } from "uuid";

import { Command } from "@api/command/Command";
import { InternalConnectedDevice } from "@internal/usb/model/InternalConnectedDevice";

export type SessionId = string;
Expand Down Expand Up @@ -32,4 +33,15 @@ export class Session {
sendApdu(_args: Uint8Array) {
return this._connectedDevice.sendApdu(_args);
}

executeCommand<Params, T>(
_params: Params,
_command: Command<Params, T>,
): Promise<T> {
// const apdu = command.getApdu(params);
// do some magic with apdu
// const response = command.parseResponse();
// return response;
throw new Error("Method not implemented.");
}
}

0 comments on commit ad3bff9

Please sign in to comment.