1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00

typescript models

This commit is contained in:
Kyle Spearrin
2017-11-01 10:27:07 -04:00
parent 4b68163cbd
commit 6086bf5812
40 changed files with 788 additions and 468 deletions

View File

@@ -0,0 +1,46 @@
class TokenRequest {
email: string;
masterPasswordHash: string;
token: string;
provider: number;
remember: boolean;
device?: any;
constructor(email: string, masterPasswordHash: string, provider: number,
token: string, remember: boolean, device?: any) {
this.email = email;
this.masterPasswordHash = masterPasswordHash;
this.token = token;
this.provider = provider;
this.remember = remember;
this.device = device ? device : null;
}
toIdentityToken() {
const obj: any = {
grant_type: 'password',
username: this.email,
password: this.masterPasswordHash,
scope: 'api offline_access',
client_id: 'browser',
};
if (this.device) {
obj.deviceType = this.device.type;
obj.deviceIdentifier = this.device.identifier;
obj.deviceName = this.device.name;
obj.devicePushToken = this.device.pushToken;
}
if (this.token && this.provider !== null && (typeof this.provider !== 'undefined')) {
obj.twoFactorToken = this.token;
obj.twoFactorProvider = this.provider;
obj.twoFactorRemember = this.remember ? '1' : '0';
}
return obj;
}
}
export { TokenRequest };
(window as any).TokenRequest = TokenRequest;