36 lines
985 B
TypeScript
36 lines
985 B
TypeScript
import {OAuthStorage} from 'angular-oauth2-oidc';
|
|
import {Inject, Injectable} from '@angular/core';
|
|
|
|
@Injectable()
|
|
export class SecureOAuthStorage extends OAuthStorage {
|
|
private storage = {};
|
|
|
|
secureKey(key:string): boolean {
|
|
if(key == "nonce") return false;
|
|
if(key == "PKCI_verifier") return false;
|
|
return true;
|
|
}
|
|
|
|
getItem(key: string): string {
|
|
if(this.secureKey(key)) {
|
|
return this.storage[key];
|
|
} else {
|
|
return window.sessionStorage.getItem(key);
|
|
}
|
|
|
|
};
|
|
removeItem(key: string): void {
|
|
if(this.secureKey(key)) {
|
|
delete this.storage[key];
|
|
} else {
|
|
window.sessionStorage.removeItem(key);
|
|
}
|
|
}
|
|
setItem(key: string, data: string): void {
|
|
if(this.secureKey(key)) {
|
|
this.storage[key]=data;
|
|
} else {
|
|
window.sessionStorage.setItem(key,data);
|
|
}
|
|
}
|
|
} |