services/sync/modules/constants.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 #filter substitution
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 // Process each item in the "constants hash" to add to "global" and give a name
     7 this.EXPORTED_SYMBOLS = [((this[key] = val), key) for ([key, val] in Iterator({
     9 WEAVE_VERSION:                         "@weave_version@",
    11 // Sync Server API version that the client supports.
    12 SYNC_API_VERSION:                      "1.1",
    13 USER_API_VERSION:                      "1.0",
    14 MISC_API_VERSION:                      "1.0",
    16 // Version of the data format this client supports. The data format describes
    17 // how records are packaged; this is separate from the Server API version and
    18 // the per-engine cleartext formats.
    19 STORAGE_VERSION:                       5,
    20 PREFS_BRANCH:                          "services.sync.",
    22 // Host "key" to access Weave Identity in the password manager
    23 PWDMGR_HOST:                           "chrome://weave",
    24 PWDMGR_PASSWORD_REALM:                 "Mozilla Services Password",
    25 PWDMGR_PASSPHRASE_REALM:               "Mozilla Services Encryption Passphrase",
    26 PWDMGR_KEYBUNDLE_REALM:                "Mozilla Services Key Bundles",
    28 // Put in [] because those aren't allowed in a collection name.
    29 DEFAULT_KEYBUNDLE_NAME:                "[default]",
    31 // Our extra input to SHA256-HMAC in generateEntry.
    32 // This includes the full crypto spec; change this when our algo changes.
    33 HMAC_INPUT:                            "Sync-AES_256_CBC-HMAC256",
    35 // Key dimensions.
    36 SYNC_KEY_ENCODED_LENGTH:               26,
    37 SYNC_KEY_DECODED_LENGTH:               16,
    38 SYNC_KEY_HYPHENATED_LENGTH:            31,    // 26 chars, 5 hyphens.
    40 NO_SYNC_NODE_INTERVAL:                 10 * 60 * 1000, // 10 minutes
    42 MAX_ERROR_COUNT_BEFORE_BACKOFF:        3,
    43 MAX_IGNORE_ERROR_COUNT:                5,
    45 // Backoff intervals
    46 MINIMUM_BACKOFF_INTERVAL:              15 * 60 * 1000,      // 15 minutes
    47 MAXIMUM_BACKOFF_INTERVAL:              8 * 60 * 60 * 1000,  // 8 hours 
    49 // HMAC event handling timeout.
    50 // 10 minutes: a compromise between the multi-desktop sync interval
    51 // and the mobile sync interval.
    52 HMAC_EVENT_INTERVAL:                   600000,
    54 // How long to wait between sync attempts if the Master Password is locked.
    55 MASTER_PASSWORD_LOCKED_RETRY_INTERVAL: 15 * 60 * 1000,   // 15 minutes
    57 // Separate from the ID fetch batch size to allow tuning for mobile.
    58 MOBILE_BATCH_SIZE:                     50,
    60 // 50 is hardcoded here because of URL length restrictions.
    61 // (GUIDs can be up to 64 chars long.)
    62 // Individual engines can set different values for their limit if their
    63 // identifiers are shorter.
    64 DEFAULT_GUID_FETCH_BATCH_SIZE:         50,
    65 DEFAULT_MOBILE_GUID_FETCH_BATCH_SIZE:  50,
    67 // Default batch size for applying incoming records.
    68 DEFAULT_STORE_BATCH_SIZE:              1,
    69 HISTORY_STORE_BATCH_SIZE:              50,      // same as MOBILE_BATCH_SIZE
    70 FORMS_STORE_BATCH_SIZE:                50,      // same as MOBILE_BATCH_SIZE
    71 PASSWORDS_STORE_BATCH_SIZE:            50,      // same as MOBILE_BATCH_SIZE
    72 ADDONS_STORE_BATCH_SIZE:               1000000, // process all addons at once
    73 APPS_STORE_BATCH_SIZE:                 50,      // same as MOBILE_BATCH_SIZE
    75 // score thresholds for early syncs
    76 SINGLE_USER_THRESHOLD:                 1000,
    77 MULTI_DEVICE_THRESHOLD:                300,
    79 // Other score increment constants
    80 SCORE_INCREMENT_SMALL:                 1,
    81 SCORE_INCREMENT_MEDIUM:                10,
    83 // Instant sync score increment
    84 SCORE_INCREMENT_XLARGE:                300 + 1, //MULTI_DEVICE_THRESHOLD + 1
    86 // Delay before incrementing global score
    87 SCORE_UPDATE_DELAY:                    100,
    89 // Delay for the back observer debouncer. This is chosen to be longer than any
    90 // observed spurious idle/back events and short enough to pre-empt user activity.
    91 IDLE_OBSERVER_BACK_DELAY:              100,
    93 // Number of records to upload in a single POST (multiple POSTS if exceeded)
    94 // FIXME: Record size limit is 256k (new cluster), so this can be quite large!
    95 // (Bug 569295)
    96 MAX_UPLOAD_RECORDS:                    100,
    97 MAX_HISTORY_UPLOAD:                    5000,
    98 MAX_HISTORY_DOWNLOAD:                  5000,
   100 // Top-level statuses:
   101 STATUS_OK:                             "success.status_ok",
   102 SYNC_FAILED:                           "error.sync.failed",
   103 LOGIN_FAILED:                          "error.login.failed",
   104 SYNC_FAILED_PARTIAL:                   "error.sync.failed_partial",
   105 CLIENT_NOT_CONFIGURED:                 "service.client_not_configured",
   106 STATUS_DISABLED:                       "service.disabled",
   107 MASTER_PASSWORD_LOCKED:                "service.master_password_locked",
   109 // success states
   110 LOGIN_SUCCEEDED:                       "success.login",
   111 SYNC_SUCCEEDED:                        "success.sync",
   112 ENGINE_SUCCEEDED:                      "success.engine",
   114 // login failure status codes:
   115 LOGIN_FAILED_NO_USERNAME:              "error.login.reason.no_username",
   116 LOGIN_FAILED_NO_PASSWORD:              "error.login.reason.no_password2",
   117 LOGIN_FAILED_NO_PASSPHRASE:            "error.login.reason.no_recoverykey",
   118 LOGIN_FAILED_NETWORK_ERROR:            "error.login.reason.network",
   119 LOGIN_FAILED_SERVER_ERROR:             "error.login.reason.server",
   120 LOGIN_FAILED_INVALID_PASSPHRASE:       "error.login.reason.recoverykey",
   121 LOGIN_FAILED_LOGIN_REJECTED:           "error.login.reason.account",
   122 LOGIN_FAILED_NOT_READY:                "error.login.reason.initializing",
   124 // sync failure status codes
   125 METARECORD_DOWNLOAD_FAIL:              "error.sync.reason.metarecord_download_fail",
   126 VERSION_OUT_OF_DATE:                   "error.sync.reason.version_out_of_date",
   127 DESKTOP_VERSION_OUT_OF_DATE:           "error.sync.reason.desktop_version_out_of_date",
   128 SETUP_FAILED_NO_PASSPHRASE:            "error.sync.reason.setup_failed_no_passphrase",
   129 CREDENTIALS_CHANGED:                   "error.sync.reason.credentials_changed",
   130 ABORT_SYNC_COMMAND:                    "aborting sync, process commands said so",
   131 NO_SYNC_NODE_FOUND:                    "error.sync.reason.no_node_found",
   132 OVER_QUOTA:                            "error.sync.reason.over_quota",
   133 PROLONGED_SYNC_FAILURE:                "error.sync.prolonged_failure",
   134 SERVER_MAINTENANCE:                    "error.sync.reason.serverMaintenance",
   136 RESPONSE_OVER_QUOTA:                   "14",
   138 // engine failure status codes
   139 ENGINE_UPLOAD_FAIL:                    "error.engine.reason.record_upload_fail",
   140 ENGINE_DOWNLOAD_FAIL:                  "error.engine.reason.record_download_fail",
   141 ENGINE_UNKNOWN_FAIL:                   "error.engine.reason.unknown_fail",
   142 ENGINE_APPLY_FAIL:                     "error.engine.reason.apply_fail",
   143 ENGINE_METARECORD_DOWNLOAD_FAIL:       "error.engine.reason.metarecord_download_fail",
   144 ENGINE_METARECORD_UPLOAD_FAIL:         "error.engine.reason.metarecord_upload_fail",
   146 JPAKE_ERROR_CHANNEL:                   "jpake.error.channel",
   147 JPAKE_ERROR_NETWORK:                   "jpake.error.network",
   148 JPAKE_ERROR_SERVER:                    "jpake.error.server",
   149 JPAKE_ERROR_TIMEOUT:                   "jpake.error.timeout",
   150 JPAKE_ERROR_INTERNAL:                  "jpake.error.internal",
   151 JPAKE_ERROR_INVALID:                   "jpake.error.invalid",
   152 JPAKE_ERROR_NODATA:                    "jpake.error.nodata",
   153 JPAKE_ERROR_KEYMISMATCH:               "jpake.error.keymismatch",
   154 JPAKE_ERROR_WRONGMESSAGE:              "jpake.error.wrongmessage",
   155 JPAKE_ERROR_USERABORT:                 "jpake.error.userabort",
   156 JPAKE_ERROR_DELAYUNSUPPORTED:          "jpake.error.delayunsupported",
   158 // info types for Service.getStorageInfo
   159 INFO_COLLECTIONS:                      "collections",
   160 INFO_COLLECTION_USAGE:                 "collection_usage",
   161 INFO_COLLECTION_COUNTS:                "collection_counts",
   162 INFO_QUOTA:                            "quota",
   164 // Ways that a sync can be disabled (messages only to be printed in debug log)
   165 kSyncMasterPasswordLocked:             "User elected to leave Master Password locked",
   166 kSyncWeaveDisabled:                    "Weave is disabled",
   167 kSyncNetworkOffline:                   "Network is offline",
   168 kSyncBackoffNotMet:                    "Trying to sync before the server said it's okay",
   169 kFirstSyncChoiceNotMade:               "User has not selected an action for first sync",
   171 // Application IDs
   172 FIREFOX_ID:                            "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
   173 FENNEC_ID:                             "{a23983c0-fd0e-11dc-95ff-0800200c9a66}",
   174 SEAMONKEY_ID:                          "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}",
   175 TEST_HARNESS_ID:                       "xuth@mozilla.org",
   177 MIN_PP_LENGTH:                         12,
   178 MIN_PASS_LENGTH:                       8,
   180 LOG_DATE_FORMAT:                       "%Y-%m-%d %H:%M:%S",
   182 }))];

mercurial