lightning-browser-extension icon indicating copy to clipboard operation
lightning-browser-extension copied to clipboard

[Feature] Include an auto-lock feature that locks Alby after a certain amount of time

Open brihuang99 opened this issue 1 year ago • 5 comments

Feature description

As of right now, the web extension for Alby does not have an auto-locking feature. Users have to manually open the extension and select 'Lock'. For users who desire an increased sense of security and to follow practices of other hot wallets, providing an auto-locking feature that will lock Alby after a specified amount of time may prove to be useful.

Describe the solution

Front-end

Screenshot_20230802_101118

I believe that a good place in the UI for this feature would be adding a row under 'Settings' and giving users a drop down with some time intervals (1 minute, 5 minutes, 10 minutes, etc.)

I can provide a basic mock up for this later today.

Back-end

There would need to be a function for Alby to track the amount of time that has passed and then execute the locking of the wallet. Maybe create a JavaScript Date object?

Describe alternatives

No response

Additional context

No response

Are you working on this?

Yes

brihuang99 avatar Aug 02 '23 14:08 brihuang99

Here are the designs:

Default

Screenshot_20230802_144414

Drop down options

Screenshot_20230802_144428

New option selected

Screenshot_20230802_144440

I think there could be a number of time intervals to provide. Here's the Figma link for reference.

P.S. I also noticed that right now in prod, the drop down arrow does not invert when the field is opened; that should be something to fix, though minor.

brihuang99 avatar Aug 02 '23 18:08 brihuang99

Hi, I would like to work on this, can you please assign this to me?

pushp1997 avatar Oct 04 '23 19:10 pushp1997

Hi @pushp1997 , thanks for offering. Go ahead!

rolznz avatar Oct 05 '23 07:10 rolznz

Hi @rolznz

Just a doubt, I am thinking to do it in this way:

let autoLockTimeout: NodeJS.Timeout | undefined;

function startAutoLockTimer(timeoutMinutes: number): void {
  const auth = useAccount();
  const timeoutMilliseconds = timeoutMinutes * 60 * 1000;
  autoLockTimeout = setTimeout(async () => {
    auth.lock(() => {
      window.close();
    });
  }, timeoutMilliseconds);
}

/**
 * Get the active auto lock preference and start the background process to lock the app
 */
export function setAutoLock(): void {
  api.getSettings().then((settings) => {
    // check if settings theme selection is system (this is the default)
    if (settings.autoLock === "1_min") {
      startAutoLockTimer(1);
    } else if (settings.autoLock === "5_mins") {
      startAutoLockTimer(5);
    } else if (settings.autoLock === "10_mins") {
      startAutoLockTimer(10);
    } else if (settings.autoLock === "30_mins") {
      startAutoLockTimer(30);
    } else {
      // settings.autoLock === "off"
      clearTimeout(autoLockTimeout);
    }
  });
}

Where should I keep this global variable autoLockTimeout? I am keeping the setAutoLock() in src/app/utils/index.ts and will call it from SettingsContext.tsx.

pushp1997 avatar Oct 18 '23 22:10 pushp1997

@pavanjoshi914 could you review this one?

rolznz avatar Oct 19 '23 16:10 rolznz