mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
private keys, rsa dec, org keys w/ login dec
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var CipherResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.organizationId = response.OrganizationId;
|
||||
this.folderId = response.FolderId;
|
||||
this.type = response.Type;
|
||||
this.favorite = response.Favorite;
|
||||
@@ -15,6 +16,7 @@ var FolderResponse = function (response) {
|
||||
|
||||
var LoginResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.organizationId = response.OrganizationId;
|
||||
this.folderId = response.FolderId;
|
||||
this.name = response.Name;
|
||||
this.uri = response.Uri;
|
||||
@@ -36,6 +38,22 @@ var ProfileResponse = function (response) {
|
||||
this.masterPasswordHint = response.MasterPasswordHint;
|
||||
this.culture = response.Culture;
|
||||
this.twoFactorEnabled = response.TwoFactorEnabled;
|
||||
|
||||
this.organizations = [];
|
||||
if (response.Organizations) {
|
||||
for (var i = 0; i < response.Organizations.length; i++) {
|
||||
this.organizations.push(new ProfileOrganizationResponse(response.Organizations[i]));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ProfileOrganizationResponse = function (response) {
|
||||
this.id = response.Id;
|
||||
this.name = response.Name;
|
||||
this.key = response.Key;
|
||||
this.status = response.Status;
|
||||
this.type = response.Type;
|
||||
this.enabled = response.Enabled;
|
||||
};
|
||||
|
||||
var IdentityTokenResponse = function (response) {
|
||||
@@ -44,7 +62,7 @@ var IdentityTokenResponse = function (response) {
|
||||
this.refreshToken = response.refresh_token;
|
||||
this.tokenType = response.token_type;
|
||||
|
||||
// TODO: extras
|
||||
this.privateKey = response.PrivateKey;
|
||||
};
|
||||
|
||||
var ListResponse = function (data) {
|
||||
|
||||
@@ -17,6 +17,7 @@ var FolderData = function (response, userId) {
|
||||
|
||||
var LoginData = function (response, userId) {
|
||||
this.id = response.id;
|
||||
this.organizationId = response.organizationId;
|
||||
this.folderId = response.folderId;
|
||||
this.userId = userId;
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ var CipherString = function () {
|
||||
|
||||
var Login = function (obj, alreadyEncrypted) {
|
||||
this.id = obj.id ? obj.id : null;
|
||||
this.organizationId = obj.organizationId ? obj.organizationId : null;
|
||||
this.folderId = obj.folderId ? obj.folderId : null;
|
||||
this.favorite = obj.favorite ? true : false;
|
||||
|
||||
@@ -118,41 +119,41 @@ var Folder = function (obj, alreadyEncrypted) {
|
||||
};
|
||||
|
||||
!function () {
|
||||
CipherString.prototype.decrypt = function (callback) {
|
||||
var deferred = Q.defer();
|
||||
|
||||
if (!this.decryptedValue) {
|
||||
var cryptoService = chrome.extension.getBackgroundPage().cryptoService;
|
||||
cryptoService.decrypt(this).then(function (decValue) {
|
||||
this.decryptedValue = decValue;
|
||||
deferred.resolve(this.decryptedValue);
|
||||
}, function () {
|
||||
this.decryptedValue = '[error: cannot decrypt]';
|
||||
deferred.resolve(this.decryptedValue);
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback(this.decryptedValue);
|
||||
CipherString.prototype.decrypt = function (orgId) {
|
||||
if (this.decryptedValue) {
|
||||
var deferred = Q.defer();
|
||||
deferred.resolve(this.decryptedValue);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
var self = this;
|
||||
var cryptoService = chrome.extension.getBackgroundPage().cryptoService;
|
||||
return cryptoService.getOrgKey(orgId).then(function (orgKey) {
|
||||
return cryptoService.decrypt(self, orgKey);
|
||||
}).then(function (decValue) {
|
||||
self.decryptedValue = decValue;
|
||||
return self.decryptedValue;
|
||||
}).catch(function () {
|
||||
self.decryptedValue = '[error: cannot decrypt]';
|
||||
return self.decryptedValue;
|
||||
});
|
||||
};
|
||||
|
||||
Login.prototype.decrypt = function () {
|
||||
var self = this;
|
||||
var model = {
|
||||
id: self.id,
|
||||
organizationId: self.organizationId,
|
||||
folderId: self.folderId,
|
||||
favorite: self.favorite
|
||||
};
|
||||
|
||||
var deferred = Q.defer();
|
||||
|
||||
self.name.decrypt().then(function (val) {
|
||||
self.name.decrypt(self.organizationId).then(function (val) {
|
||||
model.name = val;
|
||||
if (self.uri) {
|
||||
return self.uri.decrypt();
|
||||
return self.uri.decrypt(self.organizationId);
|
||||
}
|
||||
return null;
|
||||
}).then(function (val) {
|
||||
@@ -162,19 +163,19 @@ var Folder = function (obj, alreadyEncrypted) {
|
||||
model.domain = utilsService.getDomain(val);
|
||||
|
||||
if (self.username) {
|
||||
return self.username.decrypt();
|
||||
return self.username.decrypt(self.organizationId);
|
||||
}
|
||||
return null;
|
||||
}).then(function (val) {
|
||||
model.username = val;
|
||||
if (self.password) {
|
||||
return self.password.decrypt();
|
||||
return self.password.decrypt(self.organizationId);
|
||||
}
|
||||
return null;
|
||||
}).then(function (val) {
|
||||
model.password = val;
|
||||
if (self.notes) {
|
||||
return self.notes.decrypt();
|
||||
return self.notes.decrypt(self.organizationId);
|
||||
}
|
||||
return null;
|
||||
}).then(function (val) {
|
||||
|
||||
Reference in New Issue
Block a user