Skip to content

Commit

Permalink
feat(store): update constructor naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ditoglez committed Jun 21, 2024
1 parent 09b8745 commit 20c5dd6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/idos-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ interface PipeCodecArgs<T> {

export class Store {
keyPrefix = "idOS-";
handler: Storage;
device: Storage;
readonly REMEMBER_DURATION_KEY = "storage-expiration";

constructor(handler = window.localStorage) {
this.handler = handler;
constructor(device = window.localStorage) {
this.device = device;
if (this.hasRememberDurationElapsed()) this.reset();
}

Expand Down Expand Up @@ -79,21 +79,21 @@ export class Store {
}

#getLocalStorage(key: string) {
return this.handler.getItem(`${this.keyPrefix}${key}`);
return this.device.getItem(`${this.keyPrefix}${key}`);
}

#setLocalStorage(key: string, value: string) {
return this.handler.setItem(`${this.keyPrefix}${key}`, value);
return this.device.setItem(`${this.keyPrefix}${key}`, value);
}

#removeLocalStorage(key: string) {
return this.handler.removeItem(`${this.keyPrefix}${key}`);
return this.device.removeItem(`${this.keyPrefix}${key}`);
}

reset() {
for (const key of Object.keys(this.handler)) {
for (const key of Object.keys(this.device)) {
if (key === "idOS-credential-id") continue;
if (key.startsWith(this.keyPrefix)) this.handler.removeItem(key);
if (key.startsWith(this.keyPrefix)) this.device.removeItem(key);
}
}
}

0 comments on commit 20c5dd6

Please sign in to comment.