Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace ValueBox with @appium/strongbox #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import {KEYMAP} from './keys';
import log from './logger';
import {LGRemoteKeys} from './remote/lg-remote-client';
import {LGWSClient} from './remote/lg-socket-client';
// eslint-disable-next-line import/no-unresolved
import {ValueBox} from './remote/valuebox';
import {strongbox} from '@appium/strongbox';
export {KEYS} from './keys';

// this is the ID for the 'Developer' application, which we launch after a session ends to ensure
Expand Down Expand Up @@ -133,9 +132,9 @@ export class WebOSDriver extends BaseDriver {
await installApp(app, appId, deviceName);
}

this.valueBox = ValueBox.create('appium-lg-webos-driver');
this.strongbox = strongbox('appium-lg-webos-driver');
this.socketClient = new LGWSClient({
valueBox: this.valueBox,
strongbox: this.strongbox,
deviceName,
url: `ws://${deviceHost}:${websocketPort}`,
remoteKeyCooldown: keyCooldown,
Expand Down
18 changes: 9 additions & 9 deletions lib/remote/lg-socket-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class LGWSClient {
#remoteKeyCooldown;

/**
* @type {import('./valuebox').ValueWrapper<string>}
* @type {import('@appium/strongbox').Item<string>}
*/
#keystore;

/** @type {import('./valuebox').ValueBox} */
#valueBox;
/** @type {import('@appium/strongbox').Strongbox} */
#strongbox;

/**
* Unique identifier for key based on device name.
Expand All @@ -58,13 +58,13 @@ export class LGWSClient {
*/
constructor({
url,
valueBox,
strongbox,
deviceName,
log = logger.getLogger('LGWsClient'),
saveClientKey = true,
remoteKeyCooldown,
}) {
this.#valueBox = valueBox;
this.#strongbox = strongbox;
this.#url = url;
this.#log = log;
this.#saveClientKey = saveClientKey;
Expand Down Expand Up @@ -175,11 +175,11 @@ export class LGWSClient {
/**
* Gets / initializes the keystore based on the keystore ID
* @see {@linkcode #keystoreId}
* @returns {Promise<import('./valuebox').ValueWrapper<string>>}
* @returns {Promise<import('@appium/strongbox').Item<string>>}
*/
async #getKeystore() {
return (
this.#keystore ?? (this.#keystore = await this.#valueBox.createWrapper(this.#keystoreId))
this.#keystore ?? (this.#keystore = await this.#strongbox.createItem(this.#keystoreId))
);
}

Expand All @@ -192,7 +192,7 @@ export class LGWSClient {
try {
const keystore = await this.#getKeystore();
this.#log.info(
`Trying to read key from file on disk at ${path.join(this.#valueBox.dir, keystore.id)}`
`Trying to read key from file on disk at ${path.join(this.#strongbox.container, this.#keystoreId)}`
);
this.#clientKey = keystore.value;
this.#log.info(`Success: key is '${this.#clientKey}'`);
Expand All @@ -215,7 +215,7 @@ export class LGWSClient {
if (this.#saveClientKey && this.#clientKey !== undefined && this.#clientKey !== origClientKey) {
this.#log.info(`Client key changed, writing it to disk`);
const keystore = await this.#getKeystore();
await keystore.put(this.#clientKey);
await keystore.write(this.#clientKey);
}
return /** @type {string} */ (this.#clientKey);
}
Expand Down