2023-03-10 08:11:11 -05:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2018-08-15 10:54:15 -04:00
|
|
|
|
public static class Constants
|
|
|
|
|
|
{
|
|
|
|
|
|
public const int BypassFiltersEventId = 12482444;
|
2023-10-30 08:40:06 -05:00
|
|
|
|
public const int FailedSecretVerificationDelay = 2000;
|
2021-08-04 09:00:30 +10:00
|
|
|
|
|
|
|
|
|
|
// File size limits - give 1 MB extra for cushion.
|
|
|
|
|
|
// Note: if request size limits are changed, 'client_max_body_size'
|
|
|
|
|
|
// in nginx/proxy.conf may also need to be updated accordingly.
|
|
|
|
|
|
public const long FileSize101mb = 101L * 1024L * 1024L;
|
|
|
|
|
|
public const long FileSize501mb = 501L * 1024L * 1024L;
|
2023-01-18 13:16:57 -05:00
|
|
|
|
public const string DatabaseFieldProtectorPurpose = "DatabaseFieldProtection";
|
|
|
|
|
|
public const string DatabaseFieldProtectedPrefix = "P|";
|
2023-05-15 07:38:41 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Default number of days an organization has to apply an updated license to their self-hosted installation after
|
|
|
|
|
|
/// their subscription has expired.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public const int OrganizationSelfHostSubscriptionGracePeriodDays = 60;
|
2023-09-28 08:45:13 -04:00
|
|
|
|
|
2023-10-17 18:17:13 +02:00
|
|
|
|
public const string Fido2KeyCipherMinimumVersion = "2023.10.0";
|
2024-11-05 20:25:06 +01:00
|
|
|
|
public const string SSHKeyCipherMinimumVersion = "2024.12.0";
|
2023-10-17 18:17:13 +02:00
|
|
|
|
|
2023-11-20 15:55:31 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Used by IdentityServer to identify our own provider.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public const string IdentityProvider = "bitwarden";
|
2023-12-20 22:54:45 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Date identifier used in ProviderService to determine if a provider was created before Nov 6, 2023.
|
|
|
|
|
|
/// If true, the organization plan assigned to that provider is updated to a 2020 plan.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static readonly DateTime ProviderCreatedPriorNov62023 = new DateTime(2023, 11, 6);
|
2024-02-13 20:28:14 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// When you set the ProrationBehavior to create_prorations,
|
|
|
|
|
|
/// Stripe will automatically create prorations for any changes made to the subscription,
|
|
|
|
|
|
/// such as changing the plan, adding or removing quantities, or applying discounts.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public const string CreateProrations = "create_prorations";
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// When you set the ProrationBehavior to always_invoice,
|
|
|
|
|
|
/// Stripe will always generate an invoice when a subscription update occurs,
|
|
|
|
|
|
/// regardless of whether there is a proration or not.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public const string AlwaysInvoice = "always_invoice";
|
2018-08-15 10:54:15 -04:00
|
|
|
|
}
|
2020-08-26 14:12:04 -04:00
|
|
|
|
|
2023-12-05 17:21:46 +01:00
|
|
|
|
public static class AuthConstants
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly RangeConstant PBKDF2_ITERATIONS = new(600_000, 2_000_000, 600_000);
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly RangeConstant ARGON2_ITERATIONS = new(2, 10, 3);
|
|
|
|
|
|
public static readonly RangeConstant ARGON2_MEMORY = new(15, 1024, 64);
|
|
|
|
|
|
public static readonly RangeConstant ARGON2_PARALLELISM = new(1, 16, 4);
|
2024-12-17 08:59:39 -08:00
|
|
|
|
public static readonly string NewDeviceVerificationExceptionCacheKeyFormat = "NewDeviceVerificationException_{0}";
|
2023-12-05 17:21:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class RangeConstant
|
|
|
|
|
|
{
|
|
|
|
|
|
public int Default { get; }
|
|
|
|
|
|
public int Min { get; }
|
|
|
|
|
|
public int Max { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public RangeConstant(int min, int max, int defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
Default = defaultValue;
|
|
|
|
|
|
Min = min;
|
|
|
|
|
|
Max = max;
|
|
|
|
|
|
|
|
|
|
|
|
if (Min > Max)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException($"{Min} is larger than {Max}.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!InsideRange(defaultValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentOutOfRangeException($"{Default} is outside allowed range of {Min}-{Max}.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool InsideRange(int number)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Min <= number && number <= Max;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-26 14:12:04 -04:00
|
|
|
|
public static class TokenPurposes
|
|
|
|
|
|
{
|
|
|
|
|
|
public const string LinkSso = "LinkSso";
|
|
|
|
|
|
}
|
2021-01-11 11:03:46 -05:00
|
|
|
|
|
|
|
|
|
|
public static class AuthenticationSchemes
|
|
|
|
|
|
{
|
|
|
|
|
|
public const string BitwardenExternalCookieAuthenticationScheme = "bw.external";
|
2018-08-15 10:54:15 -04:00
|
|
|
|
}
|
2023-03-07 13:46:52 -05:00
|
|
|
|
|
|
|
|
|
|
public static class FeatureFlagKeys
|
|
|
|
|
|
{
|
2025-01-23 00:04:08 +10:00
|
|
|
|
/* Admin Console Team */
|
|
|
|
|
|
public const string ProviderClientVaultPrivacyBanner = "ac-2833-provider-client-vault-privacy-banner";
|
|
|
|
|
|
public const string AccountDeprovisioning = "pm-10308-account-deprovisioning";
|
|
|
|
|
|
public const string VerifiedSsoDomainEndpoint = "pm-12337-refactor-sso-details-endpoint";
|
|
|
|
|
|
public const string IntegrationPage = "pm-14505-admin-console-integration-page";
|
2025-01-27 10:59:46 +00:00
|
|
|
|
public const string DeviceApprovalRequestAdminNotifications = "pm-15637-device-approval-request-admin-notifications";
|
2025-01-23 00:04:08 +10:00
|
|
|
|
|
2024-05-06 08:49:18 -04:00
|
|
|
|
public const string ReturnErrorOnExistingKeypair = "return-error-on-existing-keypair";
|
2024-05-24 10:13:17 -05:00
|
|
|
|
public const string UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection";
|
2023-10-31 11:06:02 -04:00
|
|
|
|
public const string ItemShare = "item-share";
|
2024-01-24 10:13:00 -08:00
|
|
|
|
public const string DuoRedirect = "duo-redirect";
|
2024-04-17 10:09:53 +01:00
|
|
|
|
public const string AC2101UpdateTrialInitiationEmail = "AC-2101-update-trial-initiation-email";
|
2024-04-02 13:21:40 -04:00
|
|
|
|
public const string AC1795_UpdatedSubscriptionStatusSection = "AC-1795_updated-subscription-status-section";
|
2024-04-30 12:43:12 -04:00
|
|
|
|
public const string EmailVerification = "email-verification";
|
2024-07-02 17:03:36 -04:00
|
|
|
|
public const string EmailVerificationDisableTimingDelays = "email-verification-disable-timing-delays";
|
2024-05-03 13:16:57 -07:00
|
|
|
|
public const string ExtensionRefresh = "extension-refresh";
|
2024-05-07 12:30:48 -07:00
|
|
|
|
public const string RestrictProviderAccess = "restrict-provider-access";
|
2024-07-10 16:01:26 +02:00
|
|
|
|
public const string PM4154BulkEncryptionService = "PM-4154-bulk-encryption-service";
|
2024-05-14 09:45:50 -04:00
|
|
|
|
public const string VaultBulkManagementAction = "vault-bulk-management-action";
|
2024-05-24 16:51:32 +01:00
|
|
|
|
public const string MemberAccessReport = "ac-2059-member-access-report";
|
2024-06-17 09:52:17 -05:00
|
|
|
|
public const string InlineMenuFieldQualification = "inline-menu-field-qualification";
|
2024-06-25 12:16:53 -04:00
|
|
|
|
public const string TwoFactorComponentRefactor = "two-factor-component-refactor";
|
2024-07-15 12:20:44 -05:00
|
|
|
|
public const string InlineMenuPositioningImprovements = "inline-menu-positioning-improvements";
|
2024-07-23 15:45:03 -04:00
|
|
|
|
public const string DeviceTrustLogging = "pm-8285-device-trust-logging";
|
2024-11-05 20:25:06 +01:00
|
|
|
|
public const string SSHKeyItemVaultItem = "ssh-key-vault-item";
|
|
|
|
|
|
public const string SSHAgent = "ssh-agent";
|
2024-11-20 10:24:29 -08:00
|
|
|
|
public const string SSHVersionCheckQAOverride = "ssh-version-check-qa-override";
|
2024-07-25 07:51:23 -07:00
|
|
|
|
public const string AuthenticatorTwoFactorToken = "authenticator-2fa-token";
|
2024-08-14 10:44:22 -04:00
|
|
|
|
public const string IdpAutoSubmitLogin = "idp-auto-submit-login";
|
2024-07-30 10:19:36 -04:00
|
|
|
|
public const string UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh";
|
2024-08-05 12:04:23 -05:00
|
|
|
|
public const string GenerateIdentityFillScriptRefactor = "generate-identity-fill-script-refactor";
|
2024-08-07 10:42:00 -05:00
|
|
|
|
public const string DelayFido2PageScriptInitWithinMv2 = "delay-fido2-page-script-init-within-mv2";
|
2024-08-13 14:54:34 -05:00
|
|
|
|
public const string NativeCarouselFlow = "native-carousel-flow";
|
|
|
|
|
|
public const string NativeCreateAccountFlow = "native-create-account-flow";
|
2024-08-21 22:04:08 -05:00
|
|
|
|
public const string NotificationBarAddLoginImprovements = "notification-bar-add-login-improvements";
|
2025-01-08 18:36:18 -05:00
|
|
|
|
public const string BlockBrowserInjectionsByDomain = "block-browser-injections-by-domain";
|
2025-01-14 15:47:35 -05:00
|
|
|
|
public const string NotificationRefresh = "notification-refresh";
|
2024-08-30 16:19:18 -04:00
|
|
|
|
public const string PersistPopupView = "persist-popup-view";
|
2024-09-05 16:25:53 -04:00
|
|
|
|
public const string CipherKeyEncryption = "cipher-key-encryption";
|
2024-09-04 13:43:59 -04:00
|
|
|
|
public const string EnableNewCardCombinedExpiryAutofill = "enable-new-card-combined-expiry-autofill";
|
2024-09-06 09:33:51 -04:00
|
|
|
|
public const string StorageReseedRefactor = "storage-reseed-refactor";
|
2024-09-27 19:39:44 +01:00
|
|
|
|
public const string TrialPayment = "PM-8163-trial-payment";
|
2024-10-03 08:30:02 -04:00
|
|
|
|
public const string RemoveServerVersionHeader = "remove-server-version-header";
|
2024-10-23 18:10:50 +02:00
|
|
|
|
public const string PM12275_MultiOrganizationEnterprises = "pm-12275-multi-organization-enterprises";
|
2024-10-23 18:01:23 +02:00
|
|
|
|
public const string GeneratorToolsModernization = "generator-tools-modernization";
|
2024-10-26 09:43:27 -07:00
|
|
|
|
public const string NewDeviceVerification = "new-device-verification";
|
2024-11-05 13:06:05 -05:00
|
|
|
|
public const string RiskInsightsCriticalApplication = "pm-14466-risk-insights-critical-application";
|
2024-11-07 14:30:29 -05:00
|
|
|
|
public const string NewDeviceVerificationTemporaryDismiss = "new-device-temporary-dismiss";
|
|
|
|
|
|
public const string NewDeviceVerificationPermanentDismiss = "new-device-permanent-dismiss";
|
2024-11-11 13:07:21 -08:00
|
|
|
|
public const string SecurityTasks = "security-tasks";
|
2024-11-19 17:37:01 +01:00
|
|
|
|
public const string DisableFreeFamiliesSponsorship = "PM-12274-disable-free-families-sponsorship";
|
2024-11-28 09:49:09 +01:00
|
|
|
|
public const string MacOsNativeCredentialSync = "macos-native-credential-sync";
|
2024-12-04 11:19:10 -06:00
|
|
|
|
public const string PM9111ExtensionPersistAddEditForm = "pm-9111-extension-persist-add-edit-form";
|
2024-12-04 14:42:12 -05:00
|
|
|
|
public const string InlineMenuTotp = "inline-menu-totp";
|
2024-12-05 09:31:14 -05:00
|
|
|
|
public const string SelfHostLicenseRefactor = "pm-11516-self-host-license-refactor";
|
2024-12-16 12:01:09 -06:00
|
|
|
|
public const string PrivateKeyRegeneration = "pm-12241-private-key-regeneration";
|
2024-12-16 16:18:33 -05:00
|
|
|
|
public const string AuthenticatorSynciOS = "enable-authenticator-sync-ios";
|
|
|
|
|
|
public const string AuthenticatorSyncAndroid = "enable-authenticator-sync-android";
|
2024-12-26 14:50:23 -05:00
|
|
|
|
public const string AppReviewPrompt = "app-review-prompt";
|
2024-12-31 18:06:29 +01:00
|
|
|
|
public const string ResellerManagedOrgAlert = "PM-15814-alert-owners-of-reseller-managed-orgs";
|
2025-01-22 14:14:59 +01:00
|
|
|
|
public const string Argon2Default = "argon2-default";
|
2025-01-03 09:14:07 -06:00
|
|
|
|
public const string UsePricingService = "use-pricing-service";
|
2025-01-06 16:22:03 -05:00
|
|
|
|
public const string RecordInstallationLastActivityDate = "installation-last-activity-date";
|
2025-01-21 16:32:30 -05:00
|
|
|
|
public const string EnablePasswordManagerSyncAndroid = "enable-password-manager-sync-android";
|
|
|
|
|
|
public const string EnablePasswordManagerSynciOS = "enable-password-manager-sync-ios";
|
2025-01-27 17:01:28 -05:00
|
|
|
|
public const string AccountDeprovisioningBanner = "pm-17120-account-deprovisioning-admin-console-banner";
|
2024-08-30 16:45:38 -04:00
|
|
|
|
|
2023-03-10 08:11:11 -05:00
|
|
|
|
public static List<string> GetAllKeys()
|
|
|
|
|
|
{
|
|
|
|
|
|
return typeof(FeatureFlagKeys).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
|
|
|
|
|
|
.Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(string))
|
|
|
|
|
|
.Select(x => (string)x.GetRawConstantValue())
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
}
|
2023-09-01 07:06:21 -04:00
|
|
|
|
|
|
|
|
|
|
public static Dictionary<string, string> GetLocalOverrideFlagValues()
|
|
|
|
|
|
{
|
|
|
|
|
|
// place overriding values when needed locally (offline), or return null
|
|
|
|
|
|
return new Dictionary<string, string>()
|
|
|
|
|
|
{
|
2024-04-12 21:40:43 +10:00
|
|
|
|
{ DuoRedirect, "true" },
|
2023-09-01 07:06:21 -04:00
|
|
|
|
};
|
|
|
|
|
|
}
|
2023-03-07 13:46:52 -05:00
|
|
|
|
}
|