-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implements wallet auto-lock feature (#678)
- Loading branch information
Showing
8 changed files
with
117 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/adena-extension/src/common/constants/alarm-key.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum AlarmKey { | ||
EXPIRED_PASSWORD = 'EXPIRED_PASSWORD', | ||
} |
32 changes: 30 additions & 2 deletions
32
packages/adena-extension/src/common/provider/memory/memory-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
const EXPIRED_PASSWORD_DURATION_MIN = 5; | ||
|
||
export class MemoryProvider { | ||
private memory: Map<string, any> = new Map(); | ||
private activeConnections = 0; | ||
private expiredPasswordDuration = EXPIRED_PASSWORD_DURATION_MIN; | ||
|
||
public get = <T = any>(key: string): T | null => { | ||
if (!this.memory.get(key)) { | ||
return null; | ||
} | ||
|
||
public get = <T = any>(key: string): T => { | ||
return this.memory.get(key) as T; | ||
}; | ||
|
||
public set = <T = any>(key: string, value: T): void => { | ||
public set = <T = any>(key: string, value: T | null): void => { | ||
this.memory.set(key, value); | ||
}; | ||
|
||
public async init(): Promise<void> { | ||
this.memory = new Map(); | ||
} | ||
|
||
public addConnection(): void { | ||
this.activeConnections++; | ||
} | ||
|
||
public removeConnection(): void { | ||
this.activeConnections--; | ||
} | ||
|
||
public isActive(): boolean { | ||
return this.activeConnections > 0; | ||
} | ||
|
||
public getExpiredPasswordDurationMinutes(): number { | ||
return this.expiredPasswordDuration; | ||
} | ||
|
||
public setExpiredPasswordDurationMinutes(duration: number): void { | ||
this.expiredPasswordDuration = duration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters