move some values to constants for better sharing
This commit is contained in:
parent
58df3e692b
commit
cf22ea2b78
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"appSettings": {
|
"appSettings": {
|
||||||
"rememberedEmailCookieName": "bit.rememberedEmail",
|
|
||||||
"apiUri": "http://localhost:4000"
|
"apiUri": "http://localhost:4000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ angular
|
||||||
.module('bit.accounts')
|
.module('bit.accounts')
|
||||||
|
|
||||||
.controller('accountsLoginController', function ($scope, $rootScope, $cookies, apiService, cryptoService, authService,
|
.controller('accountsLoginController', function ($scope, $rootScope, $cookies, apiService, cryptoService, authService,
|
||||||
$state, appSettings, $analytics) {
|
$state, constants, $analytics) {
|
||||||
$scope.state = $state;
|
$scope.state = $state;
|
||||||
var returnState = $state.params.returnState;
|
var returnState = $state.params.returnState;
|
||||||
var rememberedEmail = $cookies.get(appSettings.rememberedEmailCookieName);
|
var rememberedEmail = $cookies.get(constants.rememberedEmailCookieName);
|
||||||
if (rememberedEmail || $state.params.email) {
|
if (rememberedEmail || $state.params.email) {
|
||||||
$scope.model = {
|
$scope.model = {
|
||||||
email: $state.params.email ? $state.params.email : rememberedEmail,
|
email: $state.params.email ? $state.params.email : rememberedEmail,
|
||||||
|
@ -25,12 +25,12 @@ angular
|
||||||
cookieExpiration.setFullYear(cookieExpiration.getFullYear() + 10);
|
cookieExpiration.setFullYear(cookieExpiration.getFullYear() + 10);
|
||||||
|
|
||||||
$cookies.put(
|
$cookies.put(
|
||||||
appSettings.rememberedEmailCookieName,
|
constants.rememberedEmailCookieName,
|
||||||
model.email,
|
model.email,
|
||||||
{ expires: cookieExpiration });
|
{ expires: cookieExpiration });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$cookies.remove(appSettings.rememberedEmailCookieName);
|
$cookies.remove(constants.rememberedEmailCookieName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (twoFactorProviders && twoFactorProviders.length > 0) {
|
if (twoFactorProviders && twoFactorProviders.length > 0) {
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
angular.module('bit')
|
||||||
|
.constant('constants', {
|
||||||
|
rememberedEmailCookieName: 'bit.rememberedEmail',
|
||||||
|
encType: {
|
||||||
|
AesCbc256_B64: 0,
|
||||||
|
AesCbc128_HmacSha256_B64: 1,
|
||||||
|
AesCbc256_HmacSha256_B64: 2,
|
||||||
|
RsaOaep_Sha256_B64: 3
|
||||||
|
},
|
||||||
|
plans: {
|
||||||
|
free: {
|
||||||
|
basePrice: 0,
|
||||||
|
noAdditionalSeats: true,
|
||||||
|
noPayment: true,
|
||||||
|
upgradeSortOrder: -1
|
||||||
|
},
|
||||||
|
personal: {
|
||||||
|
basePrice: 1,
|
||||||
|
annualBasePrice: 12,
|
||||||
|
baseSeats: 5,
|
||||||
|
seatPrice: 1,
|
||||||
|
annualSeatPrice: 12,
|
||||||
|
maxAdditionalSeats: 5,
|
||||||
|
annualPlanType: 'personalAnnually',
|
||||||
|
upgradeSortOrder: 1
|
||||||
|
},
|
||||||
|
teams: {
|
||||||
|
basePrice: 5,
|
||||||
|
annualBasePrice: 60,
|
||||||
|
monthlyBasePrice: 8,
|
||||||
|
baseSeats: 5,
|
||||||
|
seatPrice: 2,
|
||||||
|
annualSeatPrice: 24,
|
||||||
|
monthlySeatPrice: 2.5,
|
||||||
|
monthPlanType: 'teamsMonthly',
|
||||||
|
annualPlanType: 'teamsAnnually',
|
||||||
|
upgradeSortOrder: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -5,13 +5,14 @@ angular
|
||||||
.directive('letterAvatar', function () {
|
.directive('letterAvatar', function () {
|
||||||
// ref: http://stackoverflow.com/a/16348977/1090359
|
// ref: http://stackoverflow.com/a/16348977/1090359
|
||||||
function stringToColor(str) {
|
function stringToColor(str) {
|
||||||
var hash = 0;
|
var hash = 0,
|
||||||
for (var i = 0; i < str.length; i++) {
|
i = 0;
|
||||||
|
for (i = 0; i < str.length; i++) {
|
||||||
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
var color = '#';
|
var color = '#';
|
||||||
for (var i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
var value = (hash >> (i * 8)) & 0xFF;
|
var value = (hash >> (i * 8)) & 0xFF;
|
||||||
color += ('00' + value.toString(16)).substr(-2);
|
color += ('00' + value.toString(16)).substr(-2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.noSubscription = org.PlanType === 0;
|
$scope.noSubscription = org.PlanType === 0;
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
$scope.plan = {
|
$scope.plan = {
|
||||||
name: org.Plan,
|
name: org.Plan,
|
||||||
type: org.PlanType,
|
type: org.PlanType,
|
||||||
|
@ -103,7 +105,7 @@
|
||||||
|
|
||||||
if (org.Subscription && org.Subscription.Items) {
|
if (org.Subscription && org.Subscription.Items) {
|
||||||
$scope.subscription.items = [];
|
$scope.subscription.items = [];
|
||||||
for (var i = 0; i < org.Subscription.Items.length; i++) {
|
for (i = 0; i < org.Subscription.Items.length; i++) {
|
||||||
$scope.subscription.items.push({
|
$scope.subscription.items.push({
|
||||||
amount: org.Subscription.Items[i].Amount,
|
amount: org.Subscription.Items[i].Amount,
|
||||||
name: org.Subscription.Items[i].Name,
|
name: org.Subscription.Items[i].Name,
|
||||||
|
@ -123,7 +125,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var charges = [];
|
var charges = [];
|
||||||
for (var i = 0; i < org.Charges.length; i++) {
|
for (i = 0; i < org.Charges.length; i++) {
|
||||||
charges.push({
|
charges.push({
|
||||||
date: org.Charges[i].CreatedDate,
|
date: org.Charges[i].CreatedDate,
|
||||||
paymentSource: org.Charges[i].PaymentSource ? org.Charges[i].PaymentSource.Description : '-',
|
paymentSource: org.Charges[i].PaymentSource ? org.Charges[i].PaymentSource.Description : '-',
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
angular
|
angular
|
||||||
.module('bit.services')
|
.module('bit.services')
|
||||||
|
|
||||||
.factory('cryptoService', function ($sessionStorage) {
|
.factory('cryptoService', function ($sessionStorage, constants) {
|
||||||
var _service = {},
|
var _service = {},
|
||||||
_key,
|
_key,
|
||||||
_b64Key,
|
_b64Key,
|
||||||
_privateKey,
|
_privateKey,
|
||||||
_publicKey,
|
_publicKey,
|
||||||
_orgKeys,
|
_orgKeys;
|
||||||
_encType = {
|
|
||||||
AesCbc256_B64: 0,
|
|
||||||
AesCbc128_HmacSha256_B64: 1,
|
|
||||||
AesCbc256_HmacSha256_B64: 2,
|
|
||||||
RsaOaep_Sha256_B64: 3
|
|
||||||
};
|
|
||||||
|
|
||||||
_service.setKey = function (key) {
|
_service.setKey = function (key) {
|
||||||
_key = key;
|
_key = key;
|
||||||
|
@ -261,11 +255,11 @@ angular
|
||||||
var encKey, encType;
|
var encKey, encType;
|
||||||
if (false) {
|
if (false) {
|
||||||
encKey = _service.getEncKey(key);
|
encKey = _service.getEncKey(key);
|
||||||
encType = _encType.AesCbc128_HmacSha256_B64;
|
encType = constants.encType.AesCbc128_HmacSha256_B64;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
encKey = key || _service.getKey();
|
encKey = key || _service.getKey();
|
||||||
encType = _encType.AesCbc256_B64;
|
encType = constants.encType.AesCbc256_B64;
|
||||||
}
|
}
|
||||||
|
|
||||||
plainValueEncoding = plainValueEncoding || 'utf8';
|
plainValueEncoding = plainValueEncoding || 'utf8';
|
||||||
|
@ -281,7 +275,8 @@ angular
|
||||||
var ct = forge.util.encode64(ctBytes);
|
var ct = forge.util.encode64(ctBytes);
|
||||||
var cipherString = iv + '|' + ct;
|
var cipherString = iv + '|' + ct;
|
||||||
|
|
||||||
if (encType === _encType.AesCbc128_HmacSha256_B64 || encType === _encType.AesCbc256_HmacSha256_B64) {
|
if (encType === constants.encType.AesCbc128_HmacSha256_B64 ||
|
||||||
|
encType === constants.encType.AesCbc256_HmacSha256_B64) {
|
||||||
var mac = computeMac(ctBytes, ivBytes);
|
var mac = computeMac(ctBytes, ivBytes);
|
||||||
cipherString = cipherString + '|' + mac;
|
cipherString = cipherString + '|' + mac;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +299,7 @@ angular
|
||||||
var encryptedBytes = publicKey.encrypt(plainValue, 'RSA-OAEP', {
|
var encryptedBytes = publicKey.encrypt(plainValue, 'RSA-OAEP', {
|
||||||
md: forge.md.sha256.create()
|
md: forge.md.sha256.create()
|
||||||
});
|
});
|
||||||
return _encType.RsaOaep_Sha256_B64 + '.' + forge.util.encode64(encryptedBytes);
|
return constants.encType.RsaOaep_Sha256_B64 + '.' + forge.util.encode64(encryptedBytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
_service.decrypt = function (encValue, key, outputEncoding) {
|
_service.decrypt = function (encValue, key, outputEncoding) {
|
||||||
|
@ -324,26 +319,26 @@ angular
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
encType = _encType.AesCbc256_B64;
|
encType = constants.encType.AesCbc256_B64;
|
||||||
encPieces = encValue.split('|');
|
encPieces = encValue.split('|');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (encType) {
|
switch (encType) {
|
||||||
case _encType.AesCbc128_HmacSha256_B64:
|
case constants.encType.AesCbc128_HmacSha256_B64:
|
||||||
if (encPieces.length !== 3) {
|
if (encPieces.length !== 3) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
doMacCheck = true;
|
doMacCheck = true;
|
||||||
encKey = _service.getEncKey(key);
|
encKey = _service.getEncKey(key);
|
||||||
break;
|
break;
|
||||||
case _encType.AesCbc256_HmacSha256_B64:
|
case constants.encType.AesCbc256_HmacSha256_B64:
|
||||||
if (encPieces.length !== 3) {
|
if (encPieces.length !== 3) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
doMacCheck = true;
|
doMacCheck = true;
|
||||||
encKey = _service.getEncKey(key);
|
encKey = _service.getEncKey(key);
|
||||||
break;
|
break;
|
||||||
case _encType.AesCbc256_B64:
|
case constants.encType.AesCbc256_B64:
|
||||||
if (encPieces.length !== 2) {
|
if (encPieces.length !== 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -395,7 +390,7 @@ angular
|
||||||
encPiece;
|
encPiece;
|
||||||
|
|
||||||
if (headerPieces.length === 1) {
|
if (headerPieces.length === 1) {
|
||||||
encType = _encType.RsaOaep_Sha256_B64;
|
encType = constants.encType.RsaOaep_Sha256_B64;
|
||||||
encPiece = headerPieces[0];
|
encPiece = headerPieces[0];
|
||||||
}
|
}
|
||||||
else if (headerPieces.length === 2) {
|
else if (headerPieces.length === 2) {
|
||||||
|
@ -408,7 +403,7 @@ angular
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encType !== _encType.RsaOaep_Sha256_B64) {
|
if (encType !== constants.encType.RsaOaep_Sha256_B64) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
angular.module("bit")
|
angular.module("bit")
|
||||||
.constant("appSettings", {"rememberedEmailCookieName":"bit.rememberedEmail","apiUri":"https://api.bitwarden.com","version":"1.9.1","environment":"Production"});
|
.constant("appSettings", {"apiUri":"https://api.bitwarden.com","version":"1.9.1","environment":"Production"});
|
||||||
|
|
|
@ -2,34 +2,8 @@
|
||||||
.module('bit.settings')
|
.module('bit.settings')
|
||||||
|
|
||||||
.controller('settingsCreateOrganizationController', function ($scope, $state, apiService, cryptoService,
|
.controller('settingsCreateOrganizationController', function ($scope, $state, apiService, cryptoService,
|
||||||
toastr, $analytics, authService, stripe) {
|
toastr, $analytics, authService, stripe, constants) {
|
||||||
$scope.plans = {
|
$scope.plans = constants.plans;
|
||||||
free: {
|
|
||||||
basePrice: 0,
|
|
||||||
noAdditionalSeats: true,
|
|
||||||
noPayment: true
|
|
||||||
},
|
|
||||||
personal: {
|
|
||||||
basePrice: 1,
|
|
||||||
annualBasePrice: 12,
|
|
||||||
baseSeats: 5,
|
|
||||||
seatPrice: 1,
|
|
||||||
annualSeatPrice: 12,
|
|
||||||
maxAdditionalSeats: 5,
|
|
||||||
annualPlanType: 'personalAnnually'
|
|
||||||
},
|
|
||||||
teams: {
|
|
||||||
basePrice: 5,
|
|
||||||
annualBasePrice: 60,
|
|
||||||
monthlyBasePrice: 8,
|
|
||||||
baseSeats: 5,
|
|
||||||
seatPrice: 2,
|
|
||||||
annualSeatPrice: 24,
|
|
||||||
monthlySeatPrice: 2.5,
|
|
||||||
monthPlanType: 'teamsMonthly',
|
|
||||||
annualPlanType: 'teamsAnnually'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.model = {
|
$scope.model = {
|
||||||
plan: 'free',
|
plan: 'free',
|
||||||
|
@ -57,7 +31,7 @@
|
||||||
|
|
||||||
$scope.changedBusiness = function () {
|
$scope.changedBusiness = function () {
|
||||||
if ($scope.model.ownedBusiness) {
|
if ($scope.model.ownedBusiness) {
|
||||||
$scope.model.plan = 'teams'
|
$scope.model.plan = 'teams';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@
|
||||||
|
|
||||||
<script src="app/app.js"></script>
|
<script src="app/app.js"></script>
|
||||||
<script src="app/settings.js"></script>
|
<script src="app/settings.js"></script>
|
||||||
|
<script src="app/constants.js"></script>
|
||||||
<script src="app/config.js"></script>
|
<script src="app/config.js"></script>
|
||||||
<script src="app/apiInterceptor.js"></script>
|
<script src="app/apiInterceptor.js"></script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue