@ledgerhq/device-mockserver-client 0.0.0-develop-20261116001021 → 0.0.0-develop-20261119000843
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/MockClient.js.map +2 -2
- package/lib/cjs/src/model/Device.js +1 -1
- package/lib/cjs/src/model/Device.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/MockClient.js.map +2 -2
- package/lib/esm/src/model/Device.js +1 -1
- package/lib/esm/src/model/Device.js.map +2 -2
- package/lib/types/src/MockClient.d.ts +5 -0
- package/lib/types/src/MockClient.d.ts.map +1 -1
- package/lib/types/src/model/Device.d.ts +8 -0
- package/lib/types/src/model/Device.d.ts.map +1 -1
- package/lib/types/src/model/SessionExport.d.ts +1 -0
- package/lib/types/src/model/SessionExport.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @ledgerhq/device-mockserver-client
|
|
2
|
+
|
|
3
|
+
The typed client of the [device mock server](https://github.com/LedgerHQ/device-sdk-ts/tree/develop/apps/device-mock-server), a server that emulates Ledger devices for apps built on the Device Management Kit (DMK).
|
|
4
|
+
|
|
5
|
+
Use it from a test or a tool to create a session, add fake devices and APDU mocks, and drive the device screen while an app runs on Speculos. To connect DMK itself to the mock server, use [`@ledgerhq/device-transport-kit-mockserver`](https://www.npmjs.com/package/@ledgerhq/device-transport-kit-mockserver).
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { MockClient } from "@ledgerhq/device-mockserver-client";
|
|
11
|
+
|
|
12
|
+
const client = new MockClient("http://127.0.0.1:9752");
|
|
13
|
+
|
|
14
|
+
// Create a session. Give this token to the DMK transport so that the app
|
|
15
|
+
// and this client see the same devices.
|
|
16
|
+
const token = await client.authenticate();
|
|
17
|
+
|
|
18
|
+
const device = await client.addDevice({
|
|
19
|
+
device_type: "stax",
|
|
20
|
+
firmware_version: "1.9.1",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Make GetAppAndVersion report a locked device.
|
|
24
|
+
await client.addMock(device.id, { prefix: "b0010000", response: "5515" });
|
|
25
|
+
|
|
26
|
+
// ... run the app or the test, then:
|
|
27
|
+
await client.disposeSession();
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Option | Description |
|
|
31
|
+
| ----------- | ------------------------------------------------------------------------------------- |
|
|
32
|
+
| `token` | Join an existing session. Without it, the client creates a session on its first call. |
|
|
33
|
+
| `timeoutMs` | Stop each request after this many milliseconds. No timeout by default. |
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
The [mock server guide](https://github.com/LedgerHQ/device-sdk-ts/tree/develop/apps/device-mock-server#readme) covers:
|
|
38
|
+
|
|
39
|
+
- the hosted instance and how to run the server locally,
|
|
40
|
+
- how to connect a DMK app,
|
|
41
|
+
- every `MockClient` method and the device fields,
|
|
42
|
+
- how mocks match APDUs, with the common error cases,
|
|
43
|
+
- how to run real apps on Speculos and script the device screen,
|
|
44
|
+
- recipes for automated and manual tests.
|
package/lib/cjs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/MockClient.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n bufferToHexaString,\n DmkNetworkClient,\n type DmkRequestConfig,\n} from \"@ledgerhq/device-management-kit\";\nimport { array, type Codec } from \"purify-ts\";\n\nimport {\n authResponseCodec,\n type ConnectionState,\n connectionStateCodec,\n} from \"./model/Auth\";\nimport {\n type CommandResponse,\n commandResponseCodec,\n} from \"./model/CommandResponse\";\nimport { type Device, deviceCodec, type DeviceConfig } from \"./model/Device\";\nimport { type Health, healthCodec } from \"./model/Health\";\nimport { type Mock, mockCodec, type MockConfig } from \"./model/Mock\";\nimport { type Session, sessionCodec } from \"./model/Session\";\nimport { type SessionExport, sessionExportCodec } from \"./model/SessionExport\";\nimport {\n type SpeculosAction,\n type SpeculosButton,\n type SpeculosInstance,\n speculosInstanceCodec,\n} from \"./model/Speculos\";\n\nexport interface MockClientOptions {\n /**\n * An existing mock server session token. When provided the client operates\n * within that session; when omitted the client lazily creates its own session\n * through POST /auth.\n */\n readonly token?: string;\n /** Inject a custom network client (mainly for testing). */\n readonly httpClient?: DmkNetworkClient;\n /** Abort each request after this many milliseconds. Unset means no timeout. */\n readonly timeoutMs?: number;\n}\n\n/**\n * HTTP client for the device mock server.\n *\n * Implements the bearer-token contract: the session is\n * resolved from an `Authorization: Bearer <token>` header rather than a\n * `session_id` header, and sessions, devices and mocks are exposed as REST\n * resources. The token can be injected or self-provisioned via /auth.\n */\nexport class MockClient {\n private readonly client: DmkNetworkClient;\n private readonly timeoutMs?: number;\n private token?: string;\n private authPromise?: Promise<string>;\n\n constructor(baseUrl: string, options: MockClientOptions = {}) {\n this.client =\n options.httpClient ??\n new DmkNetworkClient({ baseUrl: this.normalizeUrl(baseUrl) });\n this.token = options.token;\n this.timeoutMs = options.timeoutMs;\n }\n\n // --- Health ---------------------------------------------------------------\n\n async getHealth(): Promise<Health> {\n const data = await this.client.get(\"health\", this.requestConfig());\n return this.decode(healthCodec, data);\n }\n\n // --- Authentication -------------------------------------------------------\n\n /** Create a session and store the returned bearer token. */\n async authenticate(): Promise<string> {\n const data = await this.client.post(\"auth\", {}, this.requestConfig());\n const token = this.decode(authResponseCodec, data).token;\n this.token = token;\n return token;\n }\n\n /** The current bearer token, if a session has been established. */\n getToken(): string | undefined {\n return this.token;\n }\n\n // --- Devices --------------------------------------------------------------\n\n async listDevices(): Promise<Device[]> {\n const data = await this.client.get(\n \"devices\",\n await this.authRequestConfig(),\n );\n return this.decode(array(deviceCodec), data);\n }\n\n async addDevice(config: DeviceConfig = {}): Promise<Device> {\n const data = await this.client.post(\n \"devices\",\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async getDevice(deviceId: string): Promise<Device> {\n const data = await this.client.get(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async editDevice(deviceId: string, config: DeviceConfig): Promise<Device> {\n const data = await this.client.patch(\n `devices/${deviceId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async deleteDevice(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Connection state -----------------------------------------------------\n\n async connect(deviceId: string): Promise<ConnectionState> {\n const data = await this.client.post(\n `devices/${deviceId}/connect`,\n {},\n await this.authRequestConfig(),\n );\n return this.decode(connectionStateCodec, data);\n }\n\n async disconnect(deviceId: string): Promise<boolean> {\n await this.client.post(\n `devices/${deviceId}/disconnect`,\n {},\n await this.authRequestConfig(),\n );\n return true;\n }\n\n /** Disconnect every device attached to the session. */\n async disconnectAll(): Promise<boolean> {\n const devices = await this.listDevices();\n await Promise.all(\n devices\n .filter((device) => device.connected)\n .map((device) => this.disconnect(device.id)),\n );\n return true;\n }\n\n // --- APDU simulation ------------------------------------------------------\n\n async sendApdu(\n deviceId: string,\n apdu: Uint8Array | string,\n ): Promise<CommandResponse> {\n const hex =\n typeof apdu === \"string\" ? apdu : bufferToHexaString(apdu, false);\n const data = await this.client.post(\n `devices/${deviceId}/apdu`,\n { apdu: hex },\n await this.authRequestConfig(),\n );\n return this.decode(commandResponseCodec, data);\n }\n\n // --- Mocks (device-scoped) ------------------------------------------------\n\n async listMocks(deviceId: string): Promise<Mock[]> {\n const data = await this.client.get(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return this.decode(array(mockCodec), data);\n }\n\n async addMock(deviceId: string, config: MockConfig): Promise<Mock> {\n const data = await this.client.post(\n `devices/${deviceId}/mocks`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async editMock(\n deviceId: string,\n mockId: string,\n config: MockConfig,\n ): Promise<Mock> {\n const data = await this.client.patch(\n `devices/${deviceId}/mocks/${mockId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async deleteMock(deviceId: string, mockId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks/${mockId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n async clearMocks(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Speculos -------------------------------------------------------------\n\n /**\n * Resolve the live Speculos instance backing a device (the one currently\n * proxying its APDUs). Throws if the device has no active instance.\n */\n async getSpeculos(deviceId: string): Promise<SpeculosInstance> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos`,\n await this.authRequestConfig(),\n );\n return this.decode(speculosInstanceCodec, data);\n }\n\n /**\n * Capture the device's current screen as a PNG. Throws with status 409 when\n * the device has no active instance, which is the case whenever no app is\n * running.\n */\n async getScreenshot(deviceId: string): Promise<Blob> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos/screenshot`,\n { ...(await this.authRequestConfig()), responseType: \"blob\" },\n );\n return data as Blob;\n }\n\n /** Actuate a physical button on a button-driven device. */\n async pressButton(\n deviceId: string,\n button: SpeculosButton,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/button/${button}`,\n { action },\n await this.authRequestConfig(),\n );\n }\n\n /** Tap a touchscreen device, in device screen pixels. */\n async touchScreen(\n deviceId: string,\n x: number,\n y: number,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/finger`,\n { action, x, y },\n await this.authRequestConfig(),\n );\n }\n\n // --- Session --------------------------------------------------------------\n\n async getSession(): Promise<Session> {\n const data = await this.client.get(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionCodec, data);\n }\n\n /**\n * Set the BIP39 mnemonic of the Speculos instances the session starts next.\n * Use test mnemonics only: the server keeps the seed in plaintext.\n */\n async setSeed(seed: string): Promise<void> {\n await this.client.put(\n \"sessions/current/seed\",\n { seed },\n await this.authRequestConfig(),\n );\n }\n\n async disposeSession(): Promise<boolean> {\n await this.client.delete(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n this.token = undefined;\n this.authPromise = undefined;\n return true;\n }\n\n // --- Import / Export ------------------------------------------------------\n\n /** Export the session's devices and mocks as a portable snapshot. */\n async exportSession(): Promise<SessionExport> {\n const data = await this.client.get(\n \"export\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n /**\n * Replace the session's devices and mocks with a previously exported\n * snapshot, returning the resulting (normalized) state.\n */\n async importSession(snapshot: SessionExport): Promise<SessionExport> {\n const data = await this.client.post(\n \"import\",\n snapshot,\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n // --- Helpers --------------------------------------------------------------\n\n private decode<T>(codec: Codec<T>, data: unknown): T {\n return codec.decode(data).caseOf({\n Left: (error) => {\n throw new Error(`MockClient: invalid server response (${error})`);\n },\n Right: (value) => value,\n });\n }\n\n private requestConfig(): DmkRequestConfig {\n return { timeoutMs: this.timeoutMs };\n }\n\n private async authRequestConfig(): Promise<DmkRequestConfig> {\n const token = await this.ensureToken();\n return {\n ...this.requestConfig(),\n headers: { Authorization: `Bearer ${token}` },\n };\n }\n\n private ensureToken(): Promise<string> {\n if (this.token) {\n return Promise.resolve(this.token);\n }\n if (!this.authPromise) {\n this.authPromise = this.authenticate();\n }\n return this.authPromise;\n }\n\n private normalizeUrl(baseUrl: string): string {\n return baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CACPC,EAAkC,qBAElCC,EAIO,wBACPC,EAGO,mCACPC,EAA4D,0BAC5DC,EAAyC,0BACzCC,EAAsD,wBACtDC,EAA2C,2BAC3CC,EAAuD,iCACvDC,EAKO,4BAuBA,MAAMX,CAAW,CACL,OACA,UACT,MACA,YAER,YAAYY,EAAiBC,EAA6B,CAAC,EAAG,CAC5D,KAAK,OACHA,EAAQ,YACR,IAAI,mBAAiB,CAAE,QAAS,KAAK,aAAaD,CAAO,CAAE,CAAC,EAC9D,KAAK,MAAQC,EAAQ,MACrB,KAAK,UAAYA,EAAQ,SAC3B,CAIA,MAAM,WAA6B,CACjC,MAAMC,EAAO,MAAM,KAAK,OAAO,IAAI,SAAU,KAAK,cAAc,CAAC,EACjE,OAAO,KAAK,OAAO,cAAaA,CAAI,CACtC,CAKA,MAAM,cAAgC,CACpC,MAAMA,EAAO,MAAM,KAAK,OAAO,KAAK,OAAQ,CAAC,EAAG,KAAK,cAAc,CAAC,EAC9DC,EAAQ,KAAK,OAAO,oBAAmBD,CAAI,EAAE,MACnD,YAAK,MAAQC,EACNA,CACT,CAGA,UAA+B,CAC7B,OAAO,KAAK,KACd,CAIA,MAAM,aAAiC,CACrC,MAAMD,EAAO,MAAM,KAAK,OAAO,IAC7B,UACA,MAAM,KAAK,kBAAkB,CAC/B,EACA,OAAO,KAAK,UAAO,SAAM,aAAW,EAAGA,CAAI,CAC7C,
|
|
4
|
+
"sourcesContent": ["import {\n bufferToHexaString,\n DmkNetworkClient,\n type DmkRequestConfig,\n} from \"@ledgerhq/device-management-kit\";\nimport { array, type Codec } from \"purify-ts\";\n\nimport {\n authResponseCodec,\n type ConnectionState,\n connectionStateCodec,\n} from \"./model/Auth\";\nimport {\n type CommandResponse,\n commandResponseCodec,\n} from \"./model/CommandResponse\";\nimport { type Device, deviceCodec, type DeviceConfig } from \"./model/Device\";\nimport { type Health, healthCodec } from \"./model/Health\";\nimport { type Mock, mockCodec, type MockConfig } from \"./model/Mock\";\nimport { type Session, sessionCodec } from \"./model/Session\";\nimport { type SessionExport, sessionExportCodec } from \"./model/SessionExport\";\nimport {\n type SpeculosAction,\n type SpeculosButton,\n type SpeculosInstance,\n speculosInstanceCodec,\n} from \"./model/Speculos\";\n\nexport interface MockClientOptions {\n /**\n * An existing mock server session token. When provided the client operates\n * within that session; when omitted the client lazily creates its own session\n * through POST /auth.\n */\n readonly token?: string;\n /** Inject a custom network client (mainly for testing). */\n readonly httpClient?: DmkNetworkClient;\n /** Abort each request after this many milliseconds. Unset means no timeout. */\n readonly timeoutMs?: number;\n}\n\n/**\n * HTTP client for the device mock server.\n *\n * Implements the bearer-token contract: the session is\n * resolved from an `Authorization: Bearer <token>` header rather than a\n * `session_id` header, and sessions, devices and mocks are exposed as REST\n * resources. The token can be injected or self-provisioned via /auth.\n */\nexport class MockClient {\n private readonly client: DmkNetworkClient;\n private readonly timeoutMs?: number;\n private token?: string;\n private authPromise?: Promise<string>;\n\n constructor(baseUrl: string, options: MockClientOptions = {}) {\n this.client =\n options.httpClient ??\n new DmkNetworkClient({ baseUrl: this.normalizeUrl(baseUrl) });\n this.token = options.token;\n this.timeoutMs = options.timeoutMs;\n }\n\n // --- Health ---------------------------------------------------------------\n\n async getHealth(): Promise<Health> {\n const data = await this.client.get(\"health\", this.requestConfig());\n return this.decode(healthCodec, data);\n }\n\n // --- Authentication -------------------------------------------------------\n\n /** Create a session and store the returned bearer token. */\n async authenticate(): Promise<string> {\n const data = await this.client.post(\"auth\", {}, this.requestConfig());\n const token = this.decode(authResponseCodec, data).token;\n this.token = token;\n return token;\n }\n\n /** The current bearer token, if a session has been established. */\n getToken(): string | undefined {\n return this.token;\n }\n\n // --- Devices --------------------------------------------------------------\n\n async listDevices(): Promise<Device[]> {\n const data = await this.client.get(\n \"devices\",\n await this.authRequestConfig(),\n );\n return this.decode(array(deviceCodec), data);\n }\n\n /**\n * Attach a device. Pass `config.id` to choose its id, for example to bring\n * back a device you deleted with {@link deleteDevice}: clients that know the\n * device find it again. The server answers `409` if the id is taken.\n */\n async addDevice(config: DeviceConfig = {}): Promise<Device> {\n const data = await this.client.post(\n \"devices\",\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async getDevice(deviceId: string): Promise<Device> {\n const data = await this.client.get(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async editDevice(deviceId: string, config: DeviceConfig): Promise<Device> {\n const data = await this.client.patch(\n `devices/${deviceId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async deleteDevice(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Connection state -----------------------------------------------------\n\n async connect(deviceId: string): Promise<ConnectionState> {\n const data = await this.client.post(\n `devices/${deviceId}/connect`,\n {},\n await this.authRequestConfig(),\n );\n return this.decode(connectionStateCodec, data);\n }\n\n async disconnect(deviceId: string): Promise<boolean> {\n await this.client.post(\n `devices/${deviceId}/disconnect`,\n {},\n await this.authRequestConfig(),\n );\n return true;\n }\n\n /** Disconnect every device attached to the session. */\n async disconnectAll(): Promise<boolean> {\n const devices = await this.listDevices();\n await Promise.all(\n devices\n .filter((device) => device.connected)\n .map((device) => this.disconnect(device.id)),\n );\n return true;\n }\n\n // --- APDU simulation ------------------------------------------------------\n\n async sendApdu(\n deviceId: string,\n apdu: Uint8Array | string,\n ): Promise<CommandResponse> {\n const hex =\n typeof apdu === \"string\" ? apdu : bufferToHexaString(apdu, false);\n const data = await this.client.post(\n `devices/${deviceId}/apdu`,\n { apdu: hex },\n await this.authRequestConfig(),\n );\n return this.decode(commandResponseCodec, data);\n }\n\n // --- Mocks (device-scoped) ------------------------------------------------\n\n async listMocks(deviceId: string): Promise<Mock[]> {\n const data = await this.client.get(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return this.decode(array(mockCodec), data);\n }\n\n async addMock(deviceId: string, config: MockConfig): Promise<Mock> {\n const data = await this.client.post(\n `devices/${deviceId}/mocks`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async editMock(\n deviceId: string,\n mockId: string,\n config: MockConfig,\n ): Promise<Mock> {\n const data = await this.client.patch(\n `devices/${deviceId}/mocks/${mockId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async deleteMock(deviceId: string, mockId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks/${mockId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n async clearMocks(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Speculos -------------------------------------------------------------\n\n /**\n * Resolve the live Speculos instance backing a device (the one currently\n * proxying its APDUs). Throws if the device has no active instance.\n */\n async getSpeculos(deviceId: string): Promise<SpeculosInstance> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos`,\n await this.authRequestConfig(),\n );\n return this.decode(speculosInstanceCodec, data);\n }\n\n /**\n * Capture the device's current screen as a PNG. Throws with status 409 when\n * the device has no active instance, which is the case whenever no app is\n * running.\n */\n async getScreenshot(deviceId: string): Promise<Blob> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos/screenshot`,\n { ...(await this.authRequestConfig()), responseType: \"blob\" },\n );\n return data as Blob;\n }\n\n /** Actuate a physical button on a button-driven device. */\n async pressButton(\n deviceId: string,\n button: SpeculosButton,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/button/${button}`,\n { action },\n await this.authRequestConfig(),\n );\n }\n\n /** Tap a touchscreen device, in device screen pixels. */\n async touchScreen(\n deviceId: string,\n x: number,\n y: number,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/finger`,\n { action, x, y },\n await this.authRequestConfig(),\n );\n }\n\n // --- Session --------------------------------------------------------------\n\n async getSession(): Promise<Session> {\n const data = await this.client.get(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionCodec, data);\n }\n\n /**\n * Set the BIP39 mnemonic of the Speculos instances the session starts next.\n * Use test mnemonics only: the server keeps the seed in plaintext.\n */\n async setSeed(seed: string): Promise<void> {\n await this.client.put(\n \"sessions/current/seed\",\n { seed },\n await this.authRequestConfig(),\n );\n }\n\n async disposeSession(): Promise<boolean> {\n await this.client.delete(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n this.token = undefined;\n this.authPromise = undefined;\n return true;\n }\n\n // --- Import / Export ------------------------------------------------------\n\n /** Export the session's devices and mocks as a portable snapshot. */\n async exportSession(): Promise<SessionExport> {\n const data = await this.client.get(\n \"export\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n /**\n * Replace the session's devices and mocks with a previously exported\n * snapshot, returning the resulting (normalized) state.\n */\n async importSession(snapshot: SessionExport): Promise<SessionExport> {\n const data = await this.client.post(\n \"import\",\n snapshot,\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n // --- Helpers --------------------------------------------------------------\n\n private decode<T>(codec: Codec<T>, data: unknown): T {\n return codec.decode(data).caseOf({\n Left: (error) => {\n throw new Error(`MockClient: invalid server response (${error})`);\n },\n Right: (value) => value,\n });\n }\n\n private requestConfig(): DmkRequestConfig {\n return { timeoutMs: this.timeoutMs };\n }\n\n private async authRequestConfig(): Promise<DmkRequestConfig> {\n const token = await this.ensureToken();\n return {\n ...this.requestConfig(),\n headers: { Authorization: `Bearer ${token}` },\n };\n }\n\n private ensureToken(): Promise<string> {\n if (this.token) {\n return Promise.resolve(this.token);\n }\n if (!this.authPromise) {\n this.authPromise = this.authenticate();\n }\n return this.authPromise;\n }\n\n private normalizeUrl(baseUrl: string): string {\n return baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n }\n}\n"],
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GAE9B,KAAK,cACR,KAAK,YAAc,KAAK,aAAa,GAEhC,KAAK,YACd,CAEQ,aAAaH,EAAyB,CAC5C,OAAOA,EAAQ,SAAS,GAAG,EAAIA,EAAU,GAAGA,CAAO,GACrD,CACF",
|
|
6
6
|
"names": ["MockClient_exports", "__export", "MockClient", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_Auth", "import_CommandResponse", "import_Device", "import_Health", "import_Mock", "import_Session", "import_SessionExport", "import_Speculos", "baseUrl", "options", "data", "token", "config", "deviceId", "devices", "device", "apdu", "hex", "mockId", "button", "action", "x", "y", "seed", "snapshot", "codec", "error", "value"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var g=(o,n)=>{for(var a in n)i(o,a,{get:n[a],enumerable:!0})},m=(o,n,a,
|
|
1
|
+
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var g=(o,n)=>{for(var a in n)i(o,a,{get:n[a],enumerable:!0})},m=(o,n,a,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of y(n))!l.call(o,r)&&r!==a&&i(o,r,{get:()=>n[r],enumerable:!(d=p(n,r))||d.enumerable});return o};var v=o=>m(i({},"__esModule",{value:!0}),o);var _={};g(_,{catalogAppCodec:()=>s,deviceAppCodec:()=>t,deviceCodec:()=>f,deviceConfigCodec:()=>C});module.exports=v(_);var e=require("purify-ts"),c=require("./Mock");const t=e.Codec.interface({name:e.string,version:e.string,hash:(0,e.optional)(e.string)}),s=e.Codec.interface({hash:e.string,name:e.string,version:e.string}),f=e.Codec.interface({id:e.string,name:e.string,device_type:e.string,connectivity_type:e.string,firmware_version:(0,e.optional)(e.string),apps:(0,e.optional)((0,e.array)(t)),masks:(0,e.optional)((0,e.array)(e.number)),connected:(0,e.optional)(e.boolean),onboarded:(0,e.optional)(e.boolean),language:(0,e.optional)(e.string)}),C=e.Codec.interface({id:(0,e.optional)(e.string),name:(0,e.optional)(e.string),device_type:(0,e.optional)(e.string),connectivity_type:(0,e.optional)(e.string),firmware_version:(0,e.optional)(e.string),apps:(0,e.optional)((0,e.array)(t)),masks:(0,e.optional)((0,e.array)(e.number)),mocks:(0,e.optional)((0,e.array)(c.mockConfigCodec)),catalog:(0,e.optional)((0,e.array)(s)),onboarded:(0,e.optional)(e.boolean),language:(0,e.optional)(e.string)});0&&(module.exports={catalogAppCodec,deviceAppCodec,deviceCodec,deviceConfigCodec});
|
|
2
2
|
//# sourceMappingURL=Device.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/model/Device.ts"],
|
|
4
|
-
"sourcesContent": ["import { array, boolean, Codec, number, optional, string } from \"purify-ts\";\n\nimport { type MockConfig, mockConfigCodec } from \"./Mock\";\n\nexport type DeviceConnectivityType = \"USB\" | \"BLE\";\n\nexport interface DeviceApp {\n readonly name: string;\n readonly version: string;\n readonly hash?: string;\n}\n\nexport const deviceAppCodec = Codec.interface({\n name: string,\n version: string,\n hash: optional(string),\n});\n\n/**\n * An installable app known to the mock \"app store\", keyed by its install\n * `hash`. The secure-channel install flow resolves the hash sent by DMK to one\n * of these entries to learn which app is being installed.\n */\nexport interface CatalogApp {\n readonly hash: string;\n readonly name: string;\n readonly version: string;\n}\n\nexport const catalogAppCodec = Codec.interface({\n hash: string,\n name: string,\n version: string,\n});\n\n/**\n * A mocked device attached to a session.\n *\n * The device exposes rich metadata (firmware\n * version, installed applications, memory masks) so DMK can build a realistic\n * device session.\n */\nexport interface Device {\n readonly id: string;\n readonly name: string;\n /** DeviceModelId enum value, e.g. \"nanoX\", \"stax\", \"flex\". */\n readonly device_type: string;\n readonly connectivity_type: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n readonly connected?: boolean;\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation (the device reports itself\n * as not onboarded and auto-advances through the onboarding steps as it is\n * polled).\n */\n readonly onboarded?: boolean;\n /**\n * The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). Omitted\n * means the device runs on its built-in English, as one with no pack\n * installed does. Installing a pack over the wire sets it.\n */\n readonly language?: string;\n}\n\nexport const deviceCodec = Codec.interface({\n id: string,\n name: string,\n device_type: string,\n connectivity_type: string,\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n connected: optional(boolean),\n onboarded: optional(boolean),\n language: optional(string),\n});\n\n/**\n * Payload used to attach (POST /devices) or edit (PATCH /devices/:id) a device.\n */\nexport interface DeviceConfig {\n readonly name?: string;\n readonly device_type?: string;\n readonly connectivity_type?: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n /** Device-scoped APDU mocks, used when attaching (POST) or importing a device. */\n readonly mocks?: MockConfig[];\n /** Installable apps the mock \"app store\" can resolve from an install hash. */\n readonly catalog?: CatalogApp[];\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation.\n */\n readonly onboarded?: boolean;\n /** The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). */\n readonly language?: string;\n}\n\nexport const deviceConfigCodec = Codec.interface({\n name: optional(string),\n device_type: optional(string),\n connectivity_type: optional(string),\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n mocks: optional(array(mockConfigCodec)),\n catalog: optional(array(catalogAppCodec)),\n onboarded: optional(boolean),\n language: optional(string),\n});\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,mBAAAC,EAAA,gBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAgE,qBAEhEC,EAAiD,kBAU1C,MAAML,EAAiB,QAAM,UAAU,CAC5C,KAAM,SACN,QAAS,SACT,QAAM,YAAS,QAAM,CACvB,CAAC,EAaYD,EAAkB,QAAM,UAAU,CAC7C,KAAM,SACN,KAAM,SACN,QAAS,QACX,CAAC,EAkCYE,EAAc,QAAM,UAAU,CACzC,GAAI,SACJ,KAAM,SACN,YAAa,SACb,kBAAmB,SACnB,oBAAkB,YAAS,QAAM,EACjC,QAAM,eAAS,SAAMD,CAAc,CAAC,EACpC,SAAO,eAAS,SAAM,QAAM,CAAC,EAC7B,aAAW,YAAS,SAAO,EAC3B,aAAW,YAAS,SAAO,EAC3B,YAAU,YAAS,QAAM,CAC3B,CAAC,
|
|
4
|
+
"sourcesContent": ["import { array, boolean, Codec, number, optional, string } from \"purify-ts\";\n\nimport { type MockConfig, mockConfigCodec } from \"./Mock\";\n\nexport type DeviceConnectivityType = \"USB\" | \"BLE\";\n\nexport interface DeviceApp {\n readonly name: string;\n readonly version: string;\n readonly hash?: string;\n}\n\nexport const deviceAppCodec = Codec.interface({\n name: string,\n version: string,\n hash: optional(string),\n});\n\n/**\n * An installable app known to the mock \"app store\", keyed by its install\n * `hash`. The secure-channel install flow resolves the hash sent by DMK to one\n * of these entries to learn which app is being installed.\n */\nexport interface CatalogApp {\n readonly hash: string;\n readonly name: string;\n readonly version: string;\n}\n\nexport const catalogAppCodec = Codec.interface({\n hash: string,\n name: string,\n version: string,\n});\n\n/**\n * A mocked device attached to a session.\n *\n * The device exposes rich metadata (firmware\n * version, installed applications, memory masks) so DMK can build a realistic\n * device session.\n */\nexport interface Device {\n readonly id: string;\n readonly name: string;\n /** DeviceModelId enum value, e.g. \"nanoX\", \"stax\", \"flex\". */\n readonly device_type: string;\n readonly connectivity_type: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n readonly connected?: boolean;\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation (the device reports itself\n * as not onboarded and auto-advances through the onboarding steps as it is\n * polled).\n */\n readonly onboarded?: boolean;\n /**\n * The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). Omitted\n * means the device runs on its built-in English, as one with no pack\n * installed does. Installing a pack over the wire sets it.\n */\n readonly language?: string;\n}\n\nexport const deviceCodec = Codec.interface({\n id: string,\n name: string,\n device_type: string,\n connectivity_type: string,\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n connected: optional(boolean),\n onboarded: optional(boolean),\n language: optional(string),\n});\n\n/**\n * Payload used to attach (POST /devices) or edit (PATCH /devices/:id) a device.\n */\nexport interface DeviceConfig {\n /**\n * The id of a new device: 1 to 64 letters, digits, `-` or `_`. Omitted means\n * the server picks a random UUID. `POST /devices` and `POST /import` read it;\n * `PATCH /devices/:id` ignores it. Delete a device, then attach it again with\n * the same id, to make a known device go away and come back.\n */\n readonly id?: string;\n readonly name?: string;\n readonly device_type?: string;\n readonly connectivity_type?: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n /** Device-scoped APDU mocks, used when attaching (POST) or importing a device. */\n readonly mocks?: MockConfig[];\n /** Installable apps the mock \"app store\" can resolve from an install hash. */\n readonly catalog?: CatalogApp[];\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation.\n */\n readonly onboarded?: boolean;\n /** The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). */\n readonly language?: string;\n}\n\nexport const deviceConfigCodec = Codec.interface({\n id: optional(string),\n name: optional(string),\n device_type: optional(string),\n connectivity_type: optional(string),\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n mocks: optional(array(mockConfigCodec)),\n catalog: optional(array(catalogAppCodec)),\n onboarded: optional(boolean),\n language: optional(string),\n});\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,mBAAAC,EAAA,gBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAgE,qBAEhEC,EAAiD,kBAU1C,MAAML,EAAiB,QAAM,UAAU,CAC5C,KAAM,SACN,QAAS,SACT,QAAM,YAAS,QAAM,CACvB,CAAC,EAaYD,EAAkB,QAAM,UAAU,CAC7C,KAAM,SACN,KAAM,SACN,QAAS,QACX,CAAC,EAkCYE,EAAc,QAAM,UAAU,CACzC,GAAI,SACJ,KAAM,SACN,YAAa,SACb,kBAAmB,SACnB,oBAAkB,YAAS,QAAM,EACjC,QAAM,eAAS,SAAMD,CAAc,CAAC,EACpC,SAAO,eAAS,SAAM,QAAM,CAAC,EAC7B,aAAW,YAAS,SAAO,EAC3B,aAAW,YAAS,SAAO,EAC3B,YAAU,YAAS,QAAM,CAC3B,CAAC,EAgCYE,EAAoB,QAAM,UAAU,CAC/C,MAAI,YAAS,QAAM,EACnB,QAAM,YAAS,QAAM,EACrB,eAAa,YAAS,QAAM,EAC5B,qBAAmB,YAAS,QAAM,EAClC,oBAAkB,YAAS,QAAM,EACjC,QAAM,eAAS,SAAMF,CAAc,CAAC,EACpC,SAAO,eAAS,SAAM,QAAM,CAAC,EAC7B,SAAO,eAAS,SAAM,iBAAe,CAAC,EACtC,WAAS,eAAS,SAAMD,CAAe,CAAC,EACxC,aAAW,YAAS,SAAO,EAC3B,YAAU,YAAS,QAAM,CAC3B,CAAC",
|
|
6
6
|
"names": ["Device_exports", "__export", "catalogAppCodec", "deviceAppCodec", "deviceCodec", "deviceConfigCodec", "__toCommonJS", "import_purify_ts", "import_Mock"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/MockClient.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n bufferToHexaString,\n DmkNetworkClient,\n type DmkRequestConfig,\n} from \"@ledgerhq/device-management-kit\";\nimport { array, type Codec } from \"purify-ts\";\n\nimport {\n authResponseCodec,\n type ConnectionState,\n connectionStateCodec,\n} from \"./model/Auth\";\nimport {\n type CommandResponse,\n commandResponseCodec,\n} from \"./model/CommandResponse\";\nimport { type Device, deviceCodec, type DeviceConfig } from \"./model/Device\";\nimport { type Health, healthCodec } from \"./model/Health\";\nimport { type Mock, mockCodec, type MockConfig } from \"./model/Mock\";\nimport { type Session, sessionCodec } from \"./model/Session\";\nimport { type SessionExport, sessionExportCodec } from \"./model/SessionExport\";\nimport {\n type SpeculosAction,\n type SpeculosButton,\n type SpeculosInstance,\n speculosInstanceCodec,\n} from \"./model/Speculos\";\n\nexport interface MockClientOptions {\n /**\n * An existing mock server session token. When provided the client operates\n * within that session; when omitted the client lazily creates its own session\n * through POST /auth.\n */\n readonly token?: string;\n /** Inject a custom network client (mainly for testing). */\n readonly httpClient?: DmkNetworkClient;\n /** Abort each request after this many milliseconds. Unset means no timeout. */\n readonly timeoutMs?: number;\n}\n\n/**\n * HTTP client for the device mock server.\n *\n * Implements the bearer-token contract: the session is\n * resolved from an `Authorization: Bearer <token>` header rather than a\n * `session_id` header, and sessions, devices and mocks are exposed as REST\n * resources. The token can be injected or self-provisioned via /auth.\n */\nexport class MockClient {\n private readonly client: DmkNetworkClient;\n private readonly timeoutMs?: number;\n private token?: string;\n private authPromise?: Promise<string>;\n\n constructor(baseUrl: string, options: MockClientOptions = {}) {\n this.client =\n options.httpClient ??\n new DmkNetworkClient({ baseUrl: this.normalizeUrl(baseUrl) });\n this.token = options.token;\n this.timeoutMs = options.timeoutMs;\n }\n\n // --- Health ---------------------------------------------------------------\n\n async getHealth(): Promise<Health> {\n const data = await this.client.get(\"health\", this.requestConfig());\n return this.decode(healthCodec, data);\n }\n\n // --- Authentication -------------------------------------------------------\n\n /** Create a session and store the returned bearer token. */\n async authenticate(): Promise<string> {\n const data = await this.client.post(\"auth\", {}, this.requestConfig());\n const token = this.decode(authResponseCodec, data).token;\n this.token = token;\n return token;\n }\n\n /** The current bearer token, if a session has been established. */\n getToken(): string | undefined {\n return this.token;\n }\n\n // --- Devices --------------------------------------------------------------\n\n async listDevices(): Promise<Device[]> {\n const data = await this.client.get(\n \"devices\",\n await this.authRequestConfig(),\n );\n return this.decode(array(deviceCodec), data);\n }\n\n async addDevice(config: DeviceConfig = {}): Promise<Device> {\n const data = await this.client.post(\n \"devices\",\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async getDevice(deviceId: string): Promise<Device> {\n const data = await this.client.get(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async editDevice(deviceId: string, config: DeviceConfig): Promise<Device> {\n const data = await this.client.patch(\n `devices/${deviceId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async deleteDevice(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Connection state -----------------------------------------------------\n\n async connect(deviceId: string): Promise<ConnectionState> {\n const data = await this.client.post(\n `devices/${deviceId}/connect`,\n {},\n await this.authRequestConfig(),\n );\n return this.decode(connectionStateCodec, data);\n }\n\n async disconnect(deviceId: string): Promise<boolean> {\n await this.client.post(\n `devices/${deviceId}/disconnect`,\n {},\n await this.authRequestConfig(),\n );\n return true;\n }\n\n /** Disconnect every device attached to the session. */\n async disconnectAll(): Promise<boolean> {\n const devices = await this.listDevices();\n await Promise.all(\n devices\n .filter((device) => device.connected)\n .map((device) => this.disconnect(device.id)),\n );\n return true;\n }\n\n // --- APDU simulation ------------------------------------------------------\n\n async sendApdu(\n deviceId: string,\n apdu: Uint8Array | string,\n ): Promise<CommandResponse> {\n const hex =\n typeof apdu === \"string\" ? apdu : bufferToHexaString(apdu, false);\n const data = await this.client.post(\n `devices/${deviceId}/apdu`,\n { apdu: hex },\n await this.authRequestConfig(),\n );\n return this.decode(commandResponseCodec, data);\n }\n\n // --- Mocks (device-scoped) ------------------------------------------------\n\n async listMocks(deviceId: string): Promise<Mock[]> {\n const data = await this.client.get(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return this.decode(array(mockCodec), data);\n }\n\n async addMock(deviceId: string, config: MockConfig): Promise<Mock> {\n const data = await this.client.post(\n `devices/${deviceId}/mocks`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async editMock(\n deviceId: string,\n mockId: string,\n config: MockConfig,\n ): Promise<Mock> {\n const data = await this.client.patch(\n `devices/${deviceId}/mocks/${mockId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async deleteMock(deviceId: string, mockId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks/${mockId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n async clearMocks(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Speculos -------------------------------------------------------------\n\n /**\n * Resolve the live Speculos instance backing a device (the one currently\n * proxying its APDUs). Throws if the device has no active instance.\n */\n async getSpeculos(deviceId: string): Promise<SpeculosInstance> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos`,\n await this.authRequestConfig(),\n );\n return this.decode(speculosInstanceCodec, data);\n }\n\n /**\n * Capture the device's current screen as a PNG. Throws with status 409 when\n * the device has no active instance, which is the case whenever no app is\n * running.\n */\n async getScreenshot(deviceId: string): Promise<Blob> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos/screenshot`,\n { ...(await this.authRequestConfig()), responseType: \"blob\" },\n );\n return data as Blob;\n }\n\n /** Actuate a physical button on a button-driven device. */\n async pressButton(\n deviceId: string,\n button: SpeculosButton,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/button/${button}`,\n { action },\n await this.authRequestConfig(),\n );\n }\n\n /** Tap a touchscreen device, in device screen pixels. */\n async touchScreen(\n deviceId: string,\n x: number,\n y: number,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/finger`,\n { action, x, y },\n await this.authRequestConfig(),\n );\n }\n\n // --- Session --------------------------------------------------------------\n\n async getSession(): Promise<Session> {\n const data = await this.client.get(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionCodec, data);\n }\n\n /**\n * Set the BIP39 mnemonic of the Speculos instances the session starts next.\n * Use test mnemonics only: the server keeps the seed in plaintext.\n */\n async setSeed(seed: string): Promise<void> {\n await this.client.put(\n \"sessions/current/seed\",\n { seed },\n await this.authRequestConfig(),\n );\n }\n\n async disposeSession(): Promise<boolean> {\n await this.client.delete(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n this.token = undefined;\n this.authPromise = undefined;\n return true;\n }\n\n // --- Import / Export ------------------------------------------------------\n\n /** Export the session's devices and mocks as a portable snapshot. */\n async exportSession(): Promise<SessionExport> {\n const data = await this.client.get(\n \"export\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n /**\n * Replace the session's devices and mocks with a previously exported\n * snapshot, returning the resulting (normalized) state.\n */\n async importSession(snapshot: SessionExport): Promise<SessionExport> {\n const data = await this.client.post(\n \"import\",\n snapshot,\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n // --- Helpers --------------------------------------------------------------\n\n private decode<T>(codec: Codec<T>, data: unknown): T {\n return codec.decode(data).caseOf({\n Left: (error) => {\n throw new Error(`MockClient: invalid server response (${error})`);\n },\n Right: (value) => value,\n });\n }\n\n private requestConfig(): DmkRequestConfig {\n return { timeoutMs: this.timeoutMs };\n }\n\n private async authRequestConfig(): Promise<DmkRequestConfig> {\n const token = await this.ensureToken();\n return {\n ...this.requestConfig(),\n headers: { Authorization: `Bearer ${token}` },\n };\n }\n\n private ensureToken(): Promise<string> {\n if (this.token) {\n return Promise.resolve(this.token);\n }\n if (!this.authPromise) {\n this.authPromise = this.authenticate();\n }\n return this.authPromise;\n }\n\n private normalizeUrl(baseUrl: string): string {\n return baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,sBAAAA,EACA,oBAAAC,MAEK,kCACP,OAAS,SAAAC,MAAyB,YAElC,OACE,qBAAAC,EAEA,wBAAAC,MACK,eACP,OAEE,wBAAAC,MACK,0BACP,OAAsB,eAAAC,MAAsC,iBAC5D,OAAsB,eAAAC,MAAmB,iBACzC,OAAoB,aAAAC,MAAkC,eACtD,OAAuB,gBAAAC,MAAoB,kBAC3C,OAA6B,sBAAAC,MAA0B,wBACvD,OAIE,yBAAAC,MACK,mBAuBA,MAAMC,CAAW,CACL,OACA,UACT,MACA,YAER,YAAYC,EAAiBC,EAA6B,CAAC,EAAG,CAC5D,KAAK,OACHA,EAAQ,YACR,IAAIb,EAAiB,CAAE,QAAS,KAAK,aAAaY,CAAO,CAAE,CAAC,EAC9D,KAAK,MAAQC,EAAQ,MACrB,KAAK,UAAYA,EAAQ,SAC3B,CAIA,MAAM,WAA6B,CACjC,MAAMC,EAAO,MAAM,KAAK,OAAO,IAAI,SAAU,KAAK,cAAc,CAAC,EACjE,OAAO,KAAK,OAAOR,EAAaQ,CAAI,CACtC,CAKA,MAAM,cAAgC,CACpC,MAAMA,EAAO,MAAM,KAAK,OAAO,KAAK,OAAQ,CAAC,EAAG,KAAK,cAAc,CAAC,EAC9DC,EAAQ,KAAK,OAAOb,EAAmBY,CAAI,EAAE,MACnD,YAAK,MAAQC,EACNA,CACT,CAGA,UAA+B,CAC7B,OAAO,KAAK,KACd,CAIA,MAAM,aAAiC,CACrC,MAAMD,EAAO,MAAM,KAAK,OAAO,IAC7B,UACA,MAAM,KAAK,kBAAkB,CAC/B,EACA,OAAO,KAAK,OAAOb,EAAMI,CAAW,EAAGS,CAAI,CAC7C,
|
|
4
|
+
"sourcesContent": ["import {\n bufferToHexaString,\n DmkNetworkClient,\n type DmkRequestConfig,\n} from \"@ledgerhq/device-management-kit\";\nimport { array, type Codec } from \"purify-ts\";\n\nimport {\n authResponseCodec,\n type ConnectionState,\n connectionStateCodec,\n} from \"./model/Auth\";\nimport {\n type CommandResponse,\n commandResponseCodec,\n} from \"./model/CommandResponse\";\nimport { type Device, deviceCodec, type DeviceConfig } from \"./model/Device\";\nimport { type Health, healthCodec } from \"./model/Health\";\nimport { type Mock, mockCodec, type MockConfig } from \"./model/Mock\";\nimport { type Session, sessionCodec } from \"./model/Session\";\nimport { type SessionExport, sessionExportCodec } from \"./model/SessionExport\";\nimport {\n type SpeculosAction,\n type SpeculosButton,\n type SpeculosInstance,\n speculosInstanceCodec,\n} from \"./model/Speculos\";\n\nexport interface MockClientOptions {\n /**\n * An existing mock server session token. When provided the client operates\n * within that session; when omitted the client lazily creates its own session\n * through POST /auth.\n */\n readonly token?: string;\n /** Inject a custom network client (mainly for testing). */\n readonly httpClient?: DmkNetworkClient;\n /** Abort each request after this many milliseconds. Unset means no timeout. */\n readonly timeoutMs?: number;\n}\n\n/**\n * HTTP client for the device mock server.\n *\n * Implements the bearer-token contract: the session is\n * resolved from an `Authorization: Bearer <token>` header rather than a\n * `session_id` header, and sessions, devices and mocks are exposed as REST\n * resources. The token can be injected or self-provisioned via /auth.\n */\nexport class MockClient {\n private readonly client: DmkNetworkClient;\n private readonly timeoutMs?: number;\n private token?: string;\n private authPromise?: Promise<string>;\n\n constructor(baseUrl: string, options: MockClientOptions = {}) {\n this.client =\n options.httpClient ??\n new DmkNetworkClient({ baseUrl: this.normalizeUrl(baseUrl) });\n this.token = options.token;\n this.timeoutMs = options.timeoutMs;\n }\n\n // --- Health ---------------------------------------------------------------\n\n async getHealth(): Promise<Health> {\n const data = await this.client.get(\"health\", this.requestConfig());\n return this.decode(healthCodec, data);\n }\n\n // --- Authentication -------------------------------------------------------\n\n /** Create a session and store the returned bearer token. */\n async authenticate(): Promise<string> {\n const data = await this.client.post(\"auth\", {}, this.requestConfig());\n const token = this.decode(authResponseCodec, data).token;\n this.token = token;\n return token;\n }\n\n /** The current bearer token, if a session has been established. */\n getToken(): string | undefined {\n return this.token;\n }\n\n // --- Devices --------------------------------------------------------------\n\n async listDevices(): Promise<Device[]> {\n const data = await this.client.get(\n \"devices\",\n await this.authRequestConfig(),\n );\n return this.decode(array(deviceCodec), data);\n }\n\n /**\n * Attach a device. Pass `config.id` to choose its id, for example to bring\n * back a device you deleted with {@link deleteDevice}: clients that know the\n * device find it again. The server answers `409` if the id is taken.\n */\n async addDevice(config: DeviceConfig = {}): Promise<Device> {\n const data = await this.client.post(\n \"devices\",\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async getDevice(deviceId: string): Promise<Device> {\n const data = await this.client.get(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async editDevice(deviceId: string, config: DeviceConfig): Promise<Device> {\n const data = await this.client.patch(\n `devices/${deviceId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(deviceCodec, data);\n }\n\n async deleteDevice(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Connection state -----------------------------------------------------\n\n async connect(deviceId: string): Promise<ConnectionState> {\n const data = await this.client.post(\n `devices/${deviceId}/connect`,\n {},\n await this.authRequestConfig(),\n );\n return this.decode(connectionStateCodec, data);\n }\n\n async disconnect(deviceId: string): Promise<boolean> {\n await this.client.post(\n `devices/${deviceId}/disconnect`,\n {},\n await this.authRequestConfig(),\n );\n return true;\n }\n\n /** Disconnect every device attached to the session. */\n async disconnectAll(): Promise<boolean> {\n const devices = await this.listDevices();\n await Promise.all(\n devices\n .filter((device) => device.connected)\n .map((device) => this.disconnect(device.id)),\n );\n return true;\n }\n\n // --- APDU simulation ------------------------------------------------------\n\n async sendApdu(\n deviceId: string,\n apdu: Uint8Array | string,\n ): Promise<CommandResponse> {\n const hex =\n typeof apdu === \"string\" ? apdu : bufferToHexaString(apdu, false);\n const data = await this.client.post(\n `devices/${deviceId}/apdu`,\n { apdu: hex },\n await this.authRequestConfig(),\n );\n return this.decode(commandResponseCodec, data);\n }\n\n // --- Mocks (device-scoped) ------------------------------------------------\n\n async listMocks(deviceId: string): Promise<Mock[]> {\n const data = await this.client.get(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return this.decode(array(mockCodec), data);\n }\n\n async addMock(deviceId: string, config: MockConfig): Promise<Mock> {\n const data = await this.client.post(\n `devices/${deviceId}/mocks`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async editMock(\n deviceId: string,\n mockId: string,\n config: MockConfig,\n ): Promise<Mock> {\n const data = await this.client.patch(\n `devices/${deviceId}/mocks/${mockId}`,\n config,\n await this.authRequestConfig(),\n );\n return this.decode(mockCodec, data);\n }\n\n async deleteMock(deviceId: string, mockId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks/${mockId}`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n async clearMocks(deviceId: string): Promise<boolean> {\n await this.client.delete(\n `devices/${deviceId}/mocks`,\n await this.authRequestConfig(),\n );\n return true;\n }\n\n // --- Speculos -------------------------------------------------------------\n\n /**\n * Resolve the live Speculos instance backing a device (the one currently\n * proxying its APDUs). Throws if the device has no active instance.\n */\n async getSpeculos(deviceId: string): Promise<SpeculosInstance> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos`,\n await this.authRequestConfig(),\n );\n return this.decode(speculosInstanceCodec, data);\n }\n\n /**\n * Capture the device's current screen as a PNG. Throws with status 409 when\n * the device has no active instance, which is the case whenever no app is\n * running.\n */\n async getScreenshot(deviceId: string): Promise<Blob> {\n const data = await this.client.get(\n `devices/${deviceId}/speculos/screenshot`,\n { ...(await this.authRequestConfig()), responseType: \"blob\" },\n );\n return data as Blob;\n }\n\n /** Actuate a physical button on a button-driven device. */\n async pressButton(\n deviceId: string,\n button: SpeculosButton,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/button/${button}`,\n { action },\n await this.authRequestConfig(),\n );\n }\n\n /** Tap a touchscreen device, in device screen pixels. */\n async touchScreen(\n deviceId: string,\n x: number,\n y: number,\n action: SpeculosAction = \"press-and-release\",\n ): Promise<void> {\n await this.client.post(\n `devices/${deviceId}/speculos/finger`,\n { action, x, y },\n await this.authRequestConfig(),\n );\n }\n\n // --- Session --------------------------------------------------------------\n\n async getSession(): Promise<Session> {\n const data = await this.client.get(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionCodec, data);\n }\n\n /**\n * Set the BIP39 mnemonic of the Speculos instances the session starts next.\n * Use test mnemonics only: the server keeps the seed in plaintext.\n */\n async setSeed(seed: string): Promise<void> {\n await this.client.put(\n \"sessions/current/seed\",\n { seed },\n await this.authRequestConfig(),\n );\n }\n\n async disposeSession(): Promise<boolean> {\n await this.client.delete(\n \"sessions/current\",\n await this.authRequestConfig(),\n );\n this.token = undefined;\n this.authPromise = undefined;\n return true;\n }\n\n // --- Import / Export ------------------------------------------------------\n\n /** Export the session's devices and mocks as a portable snapshot. */\n async exportSession(): Promise<SessionExport> {\n const data = await this.client.get(\n \"export\",\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n /**\n * Replace the session's devices and mocks with a previously exported\n * snapshot, returning the resulting (normalized) state.\n */\n async importSession(snapshot: SessionExport): Promise<SessionExport> {\n const data = await this.client.post(\n \"import\",\n snapshot,\n await this.authRequestConfig(),\n );\n return this.decode(sessionExportCodec, data);\n }\n\n // --- Helpers --------------------------------------------------------------\n\n private decode<T>(codec: Codec<T>, data: unknown): T {\n return codec.decode(data).caseOf({\n Left: (error) => {\n throw new Error(`MockClient: invalid server response (${error})`);\n },\n Right: (value) => value,\n });\n }\n\n private requestConfig(): DmkRequestConfig {\n return { timeoutMs: this.timeoutMs };\n }\n\n private async authRequestConfig(): Promise<DmkRequestConfig> {\n const token = await this.ensureToken();\n return {\n ...this.requestConfig(),\n headers: { Authorization: `Bearer ${token}` },\n };\n }\n\n private ensureToken(): Promise<string> {\n if (this.token) {\n return Promise.resolve(this.token);\n }\n if (!this.authPromise) {\n this.authPromise = this.authenticate();\n }\n return this.authPromise;\n }\n\n private normalizeUrl(baseUrl: string): string {\n return baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,sBAAAA,EACA,oBAAAC,MAEK,kCACP,OAAS,SAAAC,MAAyB,YAElC,OACE,qBAAAC,EAEA,wBAAAC,MACK,eACP,OAEE,wBAAAC,MACK,0BACP,OAAsB,eAAAC,MAAsC,iBAC5D,OAAsB,eAAAC,MAAmB,iBACzC,OAAoB,aAAAC,MAAkC,eACtD,OAAuB,gBAAAC,MAAoB,kBAC3C,OAA6B,sBAAAC,MAA0B,wBACvD,OAIE,yBAAAC,MACK,mBAuBA,MAAMC,CAAW,CACL,OACA,UACT,MACA,YAER,YAAYC,EAAiBC,EAA6B,CAAC,EAAG,CAC5D,KAAK,OACHA,EAAQ,YACR,IAAIb,EAAiB,CAAE,QAAS,KAAK,aAAaY,CAAO,CAAE,CAAC,EAC9D,KAAK,MAAQC,EAAQ,MACrB,KAAK,UAAYA,EAAQ,SAC3B,CAIA,MAAM,WAA6B,CACjC,MAAMC,EAAO,MAAM,KAAK,OAAO,IAAI,SAAU,KAAK,cAAc,CAAC,EACjE,OAAO,KAAK,OAAOR,EAAaQ,CAAI,CACtC,CAKA,MAAM,cAAgC,CACpC,MAAMA,EAAO,MAAM,KAAK,OAAO,KAAK,OAAQ,CAAC,EAAG,KAAK,cAAc,CAAC,EAC9DC,EAAQ,KAAK,OAAOb,EAAmBY,CAAI,EAAE,MACnD,YAAK,MAAQC,EACNA,CACT,CAGA,UAA+B,CAC7B,OAAO,KAAK,KACd,CAIA,MAAM,aAAi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EAAM,OAAOf,CAAI,EAAE,OAAO,CAC/B,KAAOgB,GAAU,CACf,MAAM,IAAI,MAAM,wCAAwCA,CAAK,GAAG,CAClE,EACA,MAAQC,GAAUA,CACpB,CAAC,CACH,CAEQ,eAAkC,CACxC,MAAO,CAAE,UAAW,KAAK,SAAU,CACrC,CAEA,MAAc,mBAA+C,CAC3D,MAAMhB,EAAQ,MAAM,KAAK,YAAY,EACrC,MAAO,CACL,GAAG,KAAK,cAAc,EACtB,QAAS,CAAE,cAAe,UAAUA,CAAK,EAAG,CAC9C,CACF,CAEQ,aAA+B,CACrC,OAAI,KAAK,MACA,QAAQ,QAAQ,KAAK,KAAK,GAE9B,KAAK,cACR,KAAK,YAAc,KAAK,aAAa,GAEhC,KAAK,YACd,CAEQ,aAAaH,EAAyB,CAC5C,OAAOA,EAAQ,SAAS,GAAG,EAAIA,EAAU,GAAGA,CAAO,GACrD,CACF",
|
|
6
6
|
"names": ["bufferToHexaString", "DmkNetworkClient", "array", "authResponseCodec", "connectionStateCodec", "commandResponseCodec", "deviceCodec", "healthCodec", "mockCodec", "sessionCodec", "sessionExportCodec", "speculosInstanceCodec", "MockClient", "baseUrl", "options", "data", "token", "config", "deviceId", "devices", "device", "apdu", "hex", "mockId", "button", "action", "x", "y", "seed", "snapshot", "codec", "error", "value"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{array as o,boolean as a,Codec as r,number as i,optional as e,string as n}from"purify-ts";import{mockConfigCodec as
|
|
1
|
+
import{array as o,boolean as a,Codec as r,number as i,optional as e,string as n}from"purify-ts";import{mockConfigCodec as d}from"./Mock";const t=r.interface({name:n,version:n,hash:e(n)}),c=r.interface({hash:n,name:n,version:n}),y=r.interface({id:n,name:n,device_type:n,connectivity_type:n,firmware_version:e(n),apps:e(o(t)),masks:e(o(i)),connected:e(a),onboarded:e(a),language:e(n)}),l=r.interface({id:e(n),name:e(n),device_type:e(n),connectivity_type:e(n),firmware_version:e(n),apps:e(o(t)),masks:e(o(i)),mocks:e(o(d)),catalog:e(o(c)),onboarded:e(a),language:e(n)});export{c as catalogAppCodec,t as deviceAppCodec,y as deviceCodec,l as deviceConfigCodec};
|
|
2
2
|
//# sourceMappingURL=Device.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/model/Device.ts"],
|
|
4
|
-
"sourcesContent": ["import { array, boolean, Codec, number, optional, string } from \"purify-ts\";\n\nimport { type MockConfig, mockConfigCodec } from \"./Mock\";\n\nexport type DeviceConnectivityType = \"USB\" | \"BLE\";\n\nexport interface DeviceApp {\n readonly name: string;\n readonly version: string;\n readonly hash?: string;\n}\n\nexport const deviceAppCodec = Codec.interface({\n name: string,\n version: string,\n hash: optional(string),\n});\n\n/**\n * An installable app known to the mock \"app store\", keyed by its install\n * `hash`. The secure-channel install flow resolves the hash sent by DMK to one\n * of these entries to learn which app is being installed.\n */\nexport interface CatalogApp {\n readonly hash: string;\n readonly name: string;\n readonly version: string;\n}\n\nexport const catalogAppCodec = Codec.interface({\n hash: string,\n name: string,\n version: string,\n});\n\n/**\n * A mocked device attached to a session.\n *\n * The device exposes rich metadata (firmware\n * version, installed applications, memory masks) so DMK can build a realistic\n * device session.\n */\nexport interface Device {\n readonly id: string;\n readonly name: string;\n /** DeviceModelId enum value, e.g. \"nanoX\", \"stax\", \"flex\". */\n readonly device_type: string;\n readonly connectivity_type: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n readonly connected?: boolean;\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation (the device reports itself\n * as not onboarded and auto-advances through the onboarding steps as it is\n * polled).\n */\n readonly onboarded?: boolean;\n /**\n * The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). Omitted\n * means the device runs on its built-in English, as one with no pack\n * installed does. Installing a pack over the wire sets it.\n */\n readonly language?: string;\n}\n\nexport const deviceCodec = Codec.interface({\n id: string,\n name: string,\n device_type: string,\n connectivity_type: string,\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n connected: optional(boolean),\n onboarded: optional(boolean),\n language: optional(string),\n});\n\n/**\n * Payload used to attach (POST /devices) or edit (PATCH /devices/:id) a device.\n */\nexport interface DeviceConfig {\n readonly name?: string;\n readonly device_type?: string;\n readonly connectivity_type?: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n /** Device-scoped APDU mocks, used when attaching (POST) or importing a device. */\n readonly mocks?: MockConfig[];\n /** Installable apps the mock \"app store\" can resolve from an install hash. */\n readonly catalog?: CatalogApp[];\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation.\n */\n readonly onboarded?: boolean;\n /** The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). */\n readonly language?: string;\n}\n\nexport const deviceConfigCodec = Codec.interface({\n name: optional(string),\n device_type: optional(string),\n connectivity_type: optional(string),\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n mocks: optional(array(mockConfigCodec)),\n catalog: optional(array(catalogAppCodec)),\n onboarded: optional(boolean),\n language: optional(string),\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,SAAAA,EAAO,WAAAC,EAAS,SAAAC,EAAO,UAAAC,EAAQ,YAAAC,EAAU,UAAAC,MAAc,YAEhE,OAA0B,mBAAAC,MAAuB,SAU1C,MAAMC,EAAiBL,EAAM,UAAU,CAC5C,KAAMG,EACN,QAASA,EACT,KAAMD,EAASC,CAAM,CACvB,CAAC,EAaYG,EAAkBN,EAAM,UAAU,CAC7C,KAAMG,EACN,KAAMA,EACN,QAASA,CACX,CAAC,EAkCYI,EAAcP,EAAM,UAAU,CACzC,GAAIG,EACJ,KAAMA,EACN,YAAaA,EACb,kBAAmBA,EACnB,iBAAkBD,EAASC,CAAM,EACjC,KAAMD,EAASJ,EAAMO,CAAc,CAAC,EACpC,MAAOH,EAASJ,EAAMG,CAAM,CAAC,EAC7B,UAAWC,EAASH,CAAO,EAC3B,UAAWG,EAASH,CAAO,EAC3B,SAAUG,EAASC,CAAM,CAC3B,CAAC,
|
|
4
|
+
"sourcesContent": ["import { array, boolean, Codec, number, optional, string } from \"purify-ts\";\n\nimport { type MockConfig, mockConfigCodec } from \"./Mock\";\n\nexport type DeviceConnectivityType = \"USB\" | \"BLE\";\n\nexport interface DeviceApp {\n readonly name: string;\n readonly version: string;\n readonly hash?: string;\n}\n\nexport const deviceAppCodec = Codec.interface({\n name: string,\n version: string,\n hash: optional(string),\n});\n\n/**\n * An installable app known to the mock \"app store\", keyed by its install\n * `hash`. The secure-channel install flow resolves the hash sent by DMK to one\n * of these entries to learn which app is being installed.\n */\nexport interface CatalogApp {\n readonly hash: string;\n readonly name: string;\n readonly version: string;\n}\n\nexport const catalogAppCodec = Codec.interface({\n hash: string,\n name: string,\n version: string,\n});\n\n/**\n * A mocked device attached to a session.\n *\n * The device exposes rich metadata (firmware\n * version, installed applications, memory masks) so DMK can build a realistic\n * device session.\n */\nexport interface Device {\n readonly id: string;\n readonly name: string;\n /** DeviceModelId enum value, e.g. \"nanoX\", \"stax\", \"flex\". */\n readonly device_type: string;\n readonly connectivity_type: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n readonly connected?: boolean;\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation (the device reports itself\n * as not onboarded and auto-advances through the onboarding steps as it is\n * polled).\n */\n readonly onboarded?: boolean;\n /**\n * The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). Omitted\n * means the device runs on its built-in English, as one with no pack\n * installed does. Installing a pack over the wire sets it.\n */\n readonly language?: string;\n}\n\nexport const deviceCodec = Codec.interface({\n id: string,\n name: string,\n device_type: string,\n connectivity_type: string,\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n connected: optional(boolean),\n onboarded: optional(boolean),\n language: optional(string),\n});\n\n/**\n * Payload used to attach (POST /devices) or edit (PATCH /devices/:id) a device.\n */\nexport interface DeviceConfig {\n /**\n * The id of a new device: 1 to 64 letters, digits, `-` or `_`. Omitted means\n * the server picks a random UUID. `POST /devices` and `POST /import` read it;\n * `PATCH /devices/:id` ignores it. Delete a device, then attach it again with\n * the same id, to make a known device go away and come back.\n */\n readonly id?: string;\n readonly name?: string;\n readonly device_type?: string;\n readonly connectivity_type?: string;\n readonly firmware_version?: string;\n readonly apps?: DeviceApp[];\n readonly masks?: number[];\n /** Device-scoped APDU mocks, used when attaching (POST) or importing a device. */\n readonly mocks?: MockConfig[];\n /** Installable apps the mock \"app store\" can resolve from an install hash. */\n readonly catalog?: CatalogApp[];\n /**\n * Whether the device is onboarded. Omitted/`true` reports a normal onboarded\n * device; `false` starts the onboarding simulation.\n */\n readonly onboarded?: boolean;\n /** The installed language pack, by name (`\"french\"`, `\"german\"`, \u2026). */\n readonly language?: string;\n}\n\nexport const deviceConfigCodec = Codec.interface({\n id: optional(string),\n name: optional(string),\n device_type: optional(string),\n connectivity_type: optional(string),\n firmware_version: optional(string),\n apps: optional(array(deviceAppCodec)),\n masks: optional(array(number)),\n mocks: optional(array(mockConfigCodec)),\n catalog: optional(array(catalogAppCodec)),\n onboarded: optional(boolean),\n language: optional(string),\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,SAAAA,EAAO,WAAAC,EAAS,SAAAC,EAAO,UAAAC,EAAQ,YAAAC,EAAU,UAAAC,MAAc,YAEhE,OAA0B,mBAAAC,MAAuB,SAU1C,MAAMC,EAAiBL,EAAM,UAAU,CAC5C,KAAMG,EACN,QAASA,EACT,KAAMD,EAASC,CAAM,CACvB,CAAC,EAaYG,EAAkBN,EAAM,UAAU,CAC7C,KAAMG,EACN,KAAMA,EACN,QAASA,CACX,CAAC,EAkCYI,EAAcP,EAAM,UAAU,CACzC,GAAIG,EACJ,KAAMA,EACN,YAAaA,EACb,kBAAmBA,EACnB,iBAAkBD,EAASC,CAAM,EACjC,KAAMD,EAASJ,EAAMO,CAAc,CAAC,EACpC,MAAOH,EAASJ,EAAMG,CAAM,CAAC,EAC7B,UAAWC,EAASH,CAAO,EAC3B,UAAWG,EAASH,CAAO,EAC3B,SAAUG,EAASC,CAAM,CAC3B,CAAC,EAgCYK,EAAoBR,EAAM,UAAU,CAC/C,GAAIE,EAASC,CAAM,EACnB,KAAMD,EAASC,CAAM,EACrB,YAAaD,EAASC,CAAM,EAC5B,kBAAmBD,EAASC,CAAM,EAClC,iBAAkBD,EAASC,CAAM,EACjC,KAAMD,EAASJ,EAAMO,CAAc,CAAC,EACpC,MAAOH,EAASJ,EAAMG,CAAM,CAAC,EAC7B,MAAOC,EAASJ,EAAMM,CAAe,CAAC,EACtC,QAASF,EAASJ,EAAMQ,CAAe,CAAC,EACxC,UAAWJ,EAASH,CAAO,EAC3B,SAAUG,EAASC,CAAM,CAC3B,CAAC",
|
|
6
6
|
"names": ["array", "boolean", "Codec", "number", "optional", "string", "mockConfigCodec", "deviceAppCodec", "catalogAppCodec", "deviceCodec", "deviceConfigCodec"]
|
|
7
7
|
}
|
|
@@ -39,6 +39,11 @@ export declare class MockClient {
|
|
|
39
39
|
/** The current bearer token, if a session has been established. */
|
|
40
40
|
getToken(): string | undefined;
|
|
41
41
|
listDevices(): Promise<Device[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Attach a device. Pass `config.id` to choose its id, for example to bring
|
|
44
|
+
* back a device you deleted with {@link deleteDevice}: clients that know the
|
|
45
|
+
* device find it again. The server answers `409` if the id is taken.
|
|
46
|
+
*/
|
|
42
47
|
addDevice(config?: DeviceConfig): Promise<Device>;
|
|
43
48
|
getDevice(deviceId: string): Promise<Device>;
|
|
44
49
|
editDevice(deviceId: string, config: DeviceConfig): Promise<Device>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockClient.d.ts","sourceRo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,GAAG,OAAO,CAAC,OAAO,CAAC;IAUpD;;;OAGG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQ9D;;;;OAIG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD,2DAA2D;IACrD,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,MAAM,GAAE,cAAoC,GAC3C,OAAO,CAAC,IAAI,CAAC;IAQhB,yDAAyD;IACnD,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,GAAE,cAAoC,GAC3C,OAAO,CAAC,IAAI,CAAC;IAUV,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAQpC;;;OAGG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAYxC,qEAAqE;IAC/D,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAQ7C;;;OAGG;IACG,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAWpE,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,aAAa;YAIP,iBAAiB;IAQ/B,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -77,6 +77,13 @@ export declare const deviceCodec: Codec<{
|
|
|
77
77
|
* Payload used to attach (POST /devices) or edit (PATCH /devices/:id) a device.
|
|
78
78
|
*/
|
|
79
79
|
export interface DeviceConfig {
|
|
80
|
+
/**
|
|
81
|
+
* The id of a new device: 1 to 64 letters, digits, `-` or `_`. Omitted means
|
|
82
|
+
* the server picks a random UUID. `POST /devices` and `POST /import` read it;
|
|
83
|
+
* `PATCH /devices/:id` ignores it. Delete a device, then attach it again with
|
|
84
|
+
* the same id, to make a known device go away and come back.
|
|
85
|
+
*/
|
|
86
|
+
readonly id?: string;
|
|
80
87
|
readonly name?: string;
|
|
81
88
|
readonly device_type?: string;
|
|
82
89
|
readonly connectivity_type?: string;
|
|
@@ -96,6 +103,7 @@ export interface DeviceConfig {
|
|
|
96
103
|
readonly language?: string;
|
|
97
104
|
}
|
|
98
105
|
export declare const deviceConfigCodec: Codec<{
|
|
106
|
+
id: string | undefined;
|
|
99
107
|
name: string | undefined;
|
|
100
108
|
device_type: string | undefined;
|
|
101
109
|
connectivity_type: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../../../src/model/Device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,EAA4B,MAAM,WAAW,CAAC;AAE5E,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,QAAQ,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,KAAK,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,cAAc;;;;EAIzB,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe;;;;EAI1B,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC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;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;EAY5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionExport.d.ts","sourceRoot":"","sources":["../../../../src/model/SessionExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,UAAU,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;CAClC;AAED,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"SessionExport.d.ts","sourceRoot":"","sources":["../../../../src/model/SessionExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,UAAU,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;CAClC;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;EAE7B,CAAC"}
|