mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
typescript models
This commit is contained in:
@@ -68,72 +68,3 @@ window.CipherRequest = function (cipher) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.FolderRequest = function (folder) {
|
||||
this.name = folder.name ? folder.name.encryptedString : null;
|
||||
};
|
||||
|
||||
window.TokenRequest = function (email, masterPasswordHash, provider, token, remember, device) {
|
||||
this.email = email;
|
||||
this.masterPasswordHash = masterPasswordHash;
|
||||
this.token = token;
|
||||
this.provider = provider;
|
||||
this.remember = remember === true;
|
||||
this.device = null;
|
||||
if (device) {
|
||||
this.device = device;
|
||||
}
|
||||
};
|
||||
|
||||
window.TokenRequest.prototype.toIdentityToken = function () {
|
||||
var obj = {
|
||||
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;
|
||||
};
|
||||
|
||||
window.RegisterRequest = function (email, masterPasswordHash, masterPasswordHint, key) {
|
||||
this.name = null;
|
||||
this.email = email;
|
||||
this.masterPasswordHash = masterPasswordHash;
|
||||
this.masterPasswordHint = masterPasswordHint ? masterPasswordHint : null;
|
||||
this.key = key;
|
||||
};
|
||||
|
||||
window.PasswordHintRequest = function (email) {
|
||||
this.email = email;
|
||||
};
|
||||
|
||||
window.TwoFactorEmailRequest = function (email, masterPasswordHash) {
|
||||
this.email = email;
|
||||
this.masterPasswordHash = masterPasswordHash;
|
||||
};
|
||||
|
||||
window.DeviceTokenRequest = function () {
|
||||
this.pushToken = null;
|
||||
};
|
||||
|
||||
window.DeviceRequest = function (appId, utilsService) {
|
||||
this.type = utilsService.getDeviceType();
|
||||
this.name = utilsService.getBrowser();
|
||||
this.identifier = appId;
|
||||
this.pushToken = null;
|
||||
};
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
window.CipherResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.organizationId = response.OrganizationId;
|
||||
this.folderId = response.FolderId;
|
||||
this.type = response.Type;
|
||||
this.favorite = response.Favorite;
|
||||
this.edit = response.Edit;
|
||||
this.organizationUseTotp = response.OrganizationUseTotp;
|
||||
this.data = response.Data;
|
||||
this.revisionDate = response.RevisionDate;
|
||||
|
||||
if (response.Attachments) {
|
||||
this.attachments = [];
|
||||
for (var i = 0; i < response.Attachments.length; i++) {
|
||||
this.attachments.push(new AttachmentResponse(response.Attachments[i]));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.FolderResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.name = response.Name;
|
||||
this.revisionDate = response.RevisionDate;
|
||||
};
|
||||
|
||||
window.ProfileResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.name = response.Name;
|
||||
this.email = response.Email;
|
||||
this.emailVerified = response.EmailVerified;
|
||||
this.masterPasswordHint = response.MasterPasswordHint;
|
||||
this.premium = response.Premium;
|
||||
this.culture = response.Culture;
|
||||
this.twoFactorEnabled = response.TwoFactorEnabled;
|
||||
this.key = response.Key;
|
||||
this.privateKey = response.PrivateKey;
|
||||
this.securityStamp = response.SecurityStamp;
|
||||
|
||||
this.organizations = [];
|
||||
if (response.Organizations) {
|
||||
for (var i = 0; i < response.Organizations.length; i++) {
|
||||
this.organizations.push(new ProfileOrganizationResponse(response.Organizations[i]));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.KeysResponse = function (response) {
|
||||
this.privateKey = response.PrivateKey;
|
||||
this.publicKey = response.PublicKey;
|
||||
};
|
||||
|
||||
window.ProfileOrganizationResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.name = response.Name;
|
||||
this.useGroups = response.UseGroups;
|
||||
this.useDirectory = response.UseDirectory;
|
||||
this.useTotp = response.UseTotp;
|
||||
this.seats = response.Seats;
|
||||
this.maxCollections = response.MaxCollections;
|
||||
this.maxStorageGb = response.MaxStorageGb;
|
||||
this.key = response.Key;
|
||||
this.status = response.Status;
|
||||
this.type = response.Type;
|
||||
};
|
||||
|
||||
window.AttachmentResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.url = response.Url;
|
||||
this.fileName = response.FileName;
|
||||
this.size = response.Size;
|
||||
this.sizeName = response.SizeName;
|
||||
};
|
||||
|
||||
window.IdentityTokenResponse = function (response) {
|
||||
this.accessToken = response.access_token;
|
||||
this.expiresIn = response.expires_in;
|
||||
this.refreshToken = response.refresh_token;
|
||||
this.tokenType = response.token_type;
|
||||
|
||||
this.privateKey = response.PrivateKey;
|
||||
this.key = response.Key;
|
||||
this.twoFactorToken = response.TwoFactorToken;
|
||||
};
|
||||
|
||||
window.ListResponse = function (data) {
|
||||
this.data = data;
|
||||
};
|
||||
|
||||
window.ErrorResponse = function (response, identityResponse) {
|
||||
var errorModel = null;
|
||||
if (identityResponse && identityResponse === true && response.responseJSON && response.responseJSON.ErrorModel) {
|
||||
errorModel = response.responseJSON.ErrorModel;
|
||||
}
|
||||
else if (response.responseJSON) {
|
||||
errorModel = response.responseJSON;
|
||||
}
|
||||
else if (response.responseText && response.responseText.indexOf('{') === 0) {
|
||||
errorModel = JSON.parse(response.responseText);
|
||||
}
|
||||
|
||||
if (errorModel) {
|
||||
this.message = errorModel.Message;
|
||||
this.validationErrors = errorModel.ValidationErrors;
|
||||
}
|
||||
this.statusCode = response.status;
|
||||
};
|
||||
|
||||
window.DeviceResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.name = response.Name;
|
||||
this.identifier = response.Identifier;
|
||||
this.type = response.Type;
|
||||
this.creationDate = response.CreationDate;
|
||||
};
|
||||
|
||||
window.CipherHistoryResponse = function (response) {
|
||||
this.revised = [];
|
||||
|
||||
var revised = response.Revised;
|
||||
for (var i = 0; i < revised.length; i++) {
|
||||
this.revised.push(new CipherResponse(revised[i]));
|
||||
}
|
||||
|
||||
this.deleted = response.Deleted;
|
||||
};
|
||||
|
||||
window.DomainsResponse = function (response) {
|
||||
var GlobalDomainResponse = function (response) {
|
||||
this.type = response.Type;
|
||||
this.domains = response.Domains;
|
||||
this.excluded = response.Excluded;
|
||||
};
|
||||
|
||||
this.equivalentDomains = response.EquivalentDomains;
|
||||
this.globalEquivalentDomains = [];
|
||||
|
||||
var globalEquivalentDomains = response.GlobalEquivalentDomains;
|
||||
if (!globalEquivalentDomains) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < globalEquivalentDomains.length; i++) {
|
||||
this.globalEquivalentDomains.push(new GlobalDomainResponse(globalEquivalentDomains[i]));
|
||||
}
|
||||
};
|
||||
|
||||
window.SyncResponse = function (response) {
|
||||
if (response.Profile) {
|
||||
this.profile = new ProfileResponse(response.Profile);
|
||||
}
|
||||
|
||||
var i;
|
||||
this.folders = [];
|
||||
if (response.Folders) {
|
||||
for (i = 0; i < response.Folders.length; i++) {
|
||||
this.folders.push(new FolderResponse(response.Folders[i]));
|
||||
}
|
||||
}
|
||||
|
||||
this.ciphers = [];
|
||||
if (response.Ciphers) {
|
||||
for (i = 0; i < response.Ciphers.length; i++) {
|
||||
this.ciphers.push(new CipherResponse(response.Ciphers[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (response.Domains) {
|
||||
this.domains = new DomainsResponse(response.Domains);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user