1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-26 17:08:33 +01:00

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;
decodedToken: any;
refreshToken: string;
setTokens(accessToken: string, refreshToken: string): Promise<any>;
setToken(token: string): Promise<any>;
getToken(): Promise<string>;
setRefreshToken(refreshToken: string): Promise<any>;
getRefreshToken(): Promise<string>;
setTwoFactorToken(token: string, email: string): Promise<any>;
getTwoFactorToken(email: string): Promise<string>;
clearTwoFactorToken(email: string): Promise<any>;
clearToken(): Promise<any>;
decodeToken(): any;
getTokenExpirationDate(): Date;
tokenSecondsRemaining(offsetSeconds?: number): number;
tokenNeedsRefresh(minutes?: number): boolean;
getUserId(): string;
getEmail(): string;
getName(): string;
getPremium(): boolean;
getIssuer(): string;
setTokens: (accessToken: string, refreshToken: string) => Promise<any>;
setToken: (token: string) => Promise<any>;
getToken: () => Promise<string>;
setRefreshToken: (refreshToken: string) => Promise<any>;
getRefreshToken: () => Promise<string>;
setTwoFactorToken: (token: string, email: string) => Promise<any>;
getTwoFactorToken: (email: string) => Promise<string>;
clearTwoFactorToken: (email: string) => Promise<any>;
clearToken: () => Promise<any>;
decodeToken: () => any;
getTokenExpirationDate: () => Date;
tokenSecondsRemaining: (offsetSeconds?: number) => number;
tokenNeedsRefresh: (minutes?: number) => boolean;
getUserId: () => string;
getEmail: () => string;
getName: () => string;
getPremium: () => boolean;
getIssuer: () => string;
}

View File

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

View File

@ -57,4 +57,12 @@ export class CipherView implements View {
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 {
if (this._maskedPassword == null && this.password != null) {
this._maskedPassword = '';
for (var i = 0; i < this.password.length; i++) {
for (let i = 0; i < this.password.length; i++) {
this._maskedPassword += '•';
}
}
@ -64,4 +64,16 @@ export class LoginView implements View {
get subTitle(): string {
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 { StorageService } from '../abstractions/storage.service';
import { TokenService as TokenServiceInterface } from '../abstractions/token.service';
import { TokenService as TokenServiceAbstraction } from '../abstractions/token.service';
const Keys = {
accessToken: 'accessToken',
@ -10,7 +10,7 @@ const Keys = {
twoFactorTokenPrefix: 'twoFactorToken_',
};
export class TokenService implements TokenServiceInterface {
export class TokenService implements TokenServiceAbstraction {
token: string;
decodedToken: any;
refreshToken: string;

View File

@ -1,7 +1,7 @@
import { ConstantsService } from './constants.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';
@ -10,7 +10,7 @@ const TotpAlgorithm = {
hash: { name: 'SHA-1' },
};
export class TotpService implements TotpServiceInterface {
export class TotpService implements TotpServiceAbstraction {
constructor(private storageService: StorageService) {
}