Skip to content

Commit 2080d8a

Browse files
committed
fix: restrict installation to defined extensions only
1 parent b0037f1 commit 2080d8a

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

src/session/dapp-driver.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,22 @@ export class DappDriver {
204204
* @memberof DappDriver
205205
*/
206206
private static async install(options: BrowserOptions): Promise<void> {
207-
const initCwd: string = process.env.INIT_CWD;
208-
const cwd: string = process.cwd();
209-
const downloadDir: string = `${initCwd || cwd}/${NODE_MODULE_DIR}`;
210-
await DappDriver.Instance.Extension.install(downloadDir, options.extension.version);
207+
try {
208+
switch (options.extension.wallet) {
209+
case METAMASK:
210+
case METAMASK_FLASK:
211+
case RAINBOW:
212+
case ZERION: {
213+
const initCwd: string = process.env.INIT_CWD;
214+
const cwd: string = process.cwd();
215+
const downloadDir: string = `${initCwd || cwd}/${NODE_MODULE_DIR}`;
216+
await DappDriver.Instance.Extension.install(downloadDir, options.extension.version);
217+
break;
218+
}
219+
}
220+
} catch (error) {
221+
throw new Error('Failed to install extension: ' + error);
222+
}
211223
}
212224
/**
213225
*
@@ -220,8 +232,16 @@ export class DappDriver {
220232
*/
221233
private static async loadExtensionModule(options: BrowserOptions): Promise<void> {
222234
try {
223-
const extensionModule = await import(`../${options.extension.wallet}`);
224-
DappDriver.Instance.Extension = extensionModule.default as IWallet;
235+
switch (options.extension.wallet) {
236+
case METAMASK:
237+
case METAMASK_FLASK:
238+
case RAINBOW:
239+
case ZERION: {
240+
const extensionModule = await import(`../${options.extension.wallet}`);
241+
DappDriver.Instance.Extension = extensionModule.default as IWallet;
242+
break;
243+
}
244+
}
225245
} catch (error) {
226246
throw new Error('Failed to load extension module: ' + error);
227247
}

0 commit comments

Comments
 (0)