lib updates for login view on desktop

This commit is contained in:
Kyle Spearrin 2018-01-24 23:27:04 -05:00
parent b4257b9ff3
commit e5c1adedff
6 changed files with 47 additions and 27 deletions

View File

@ -1,23 +1,23 @@
export interface TokenService { export abstract class TokenService {
token: string; token: string;
decodedToken: any; decodedToken: any;
refreshToken: string; refreshToken: string;
setTokens(accessToken: string, refreshToken: string): Promise<any>; setTokens: (accessToken: string, refreshToken: string) => Promise<any>;
setToken(token: string): Promise<any>; setToken: (token: string) => Promise<any>;
getToken(): Promise<string>; getToken: () => Promise<string>;
setRefreshToken(refreshToken: string): Promise<any>; setRefreshToken: (refreshToken: string) => Promise<any>;
getRefreshToken(): Promise<string>; getRefreshToken: () => Promise<string>;
setTwoFactorToken(token: string, email: string): Promise<any>; setTwoFactorToken: (token: string, email: string) => Promise<any>;
getTwoFactorToken(email: string): Promise<string>; getTwoFactorToken: (email: string) => Promise<string>;
clearTwoFactorToken(email: string): Promise<any>; clearTwoFactorToken: (email: string) => Promise<any>;
clearToken(): Promise<any>; clearToken: () => Promise<any>;
decodeToken(): any; decodeToken: () => any;
getTokenExpirationDate(): Date; getTokenExpirationDate: () => Date;
tokenSecondsRemaining(offsetSeconds?: number): number; tokenSecondsRemaining: (offsetSeconds?: number) => number;
tokenNeedsRefresh(minutes?: number): boolean; tokenNeedsRefresh: (minutes?: number) => boolean;
getUserId(): string; getUserId: () => string;
getEmail(): string; getEmail: () => string;
getName(): string; getName: () => string;
getPremium(): boolean; getPremium: () => boolean;
getIssuer(): string; getIssuer: () => string;
} }

View File

@ -1,4 +1,4 @@
export interface TotpService { export abstract class TotpService {
getCode(keyb32: string): Promise<string>; getCode: (keyb32: string) => Promise<string>;
isAutoCopyEnabled(): Promise<boolean>; isAutoCopyEnabled: () => Promise<boolean>;
} }

View File

@ -57,4 +57,12 @@ export class CipherView implements View {
return null; return null;
} }
get hasAttachments(): boolean {
return this.attachments && this.attachments.length > 0;
}
get hasFields(): boolean {
return this.fields && this.fields.length > 0;
}
} }

View File

@ -53,7 +53,7 @@ export class LoginView implements View {
get maskedPassword(): string { get maskedPassword(): string {
if (this._maskedPassword == null && this.password != null) { if (this._maskedPassword == null && this.password != null) {
this._maskedPassword = ''; this._maskedPassword = '';
for (var i = 0; i < this.password.length; i++) { for (let i = 0; i < this.password.length; i++) {
this._maskedPassword += '•'; this._maskedPassword += '•';
} }
} }
@ -64,4 +64,16 @@ export class LoginView implements View {
get subTitle(): string { get subTitle(): string {
return this.username; return this.username;
} }
get domainOrUri(): string {
return this.domain != null ? this.domain : this.uri;
}
get isWebsite(): boolean {
return this.uri != null && (this.uri.indexOf('http://') > -1 || this.uri.indexOf('https://') > -1);
}
get canLaunch(): boolean {
return this.uri != null && this.uri.indexOf('://') > -1;
}
} }

View File

@ -2,7 +2,7 @@ import { ConstantsService } from './constants.service';
import { UtilsService } from './utils.service'; import { UtilsService } from './utils.service';
import { StorageService } from '../abstractions/storage.service'; import { StorageService } from '../abstractions/storage.service';
import { TokenService as TokenServiceInterface } from '../abstractions/token.service'; import { TokenService as TokenServiceAbstraction } from '../abstractions/token.service';
const Keys = { const Keys = {
accessToken: 'accessToken', accessToken: 'accessToken',
@ -10,7 +10,7 @@ const Keys = {
twoFactorTokenPrefix: 'twoFactorToken_', twoFactorTokenPrefix: 'twoFactorToken_',
}; };
export class TokenService implements TokenServiceInterface { export class TokenService implements TokenServiceAbstraction {
token: string; token: string;
decodedToken: any; decodedToken: any;
refreshToken: string; refreshToken: string;

View File

@ -1,7 +1,7 @@
import { ConstantsService } from './constants.service'; import { ConstantsService } from './constants.service';
import { StorageService } from '../abstractions/storage.service'; import { StorageService } from '../abstractions/storage.service';
import { TotpService as TotpServiceInterface } from '../abstractions/totp.service'; import { TotpService as TotpServiceAbstraction } from '../abstractions/totp.service';
const b32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; const b32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
@ -10,7 +10,7 @@ const TotpAlgorithm = {
hash: { name: 'SHA-1' }, hash: { name: 'SHA-1' },
}; };
export class TotpService implements TotpServiceInterface { export class TotpService implements TotpServiceAbstraction {
constructor(private storageService: StorageService) { constructor(private storageService: StorageService) {
} }