PageRenderTime 25ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/services/sync/modules/constants.js

http://github.com/zpao/v8monkey
JavaScript | 218 lines | 107 code | 36 blank | 75 comment | 1 complexity | 09cfa9809ec5b45251d572ea93a36d2a MD5 | raw file
  1#filter substitution
  2/* ***** BEGIN LICENSE BLOCK *****
  3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4 *
  5 * The contents of this file are subject to the Mozilla Public License Version
  6 * 1.1 (the "License"); you may not use this file except in compliance with
  7 * the License. You may obtain a copy of the License at
  8 * http://www.mozilla.org/MPL/
  9 *
 10 * Software distributed under the License is distributed on an "AS IS" basis,
 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 12 * for the specific language governing rights and limitations under the
 13 * License.
 14 *
 15 * The Original Code is Bookmarks Sync.
 16 *
 17 * The Initial Developer of the Original Code is Mozilla.
 18 * Portions created by the Initial Developer are Copyright (C) 2007
 19 * the Initial Developer. All Rights Reserved.
 20 *
 21 * Contributor(s):
 22 *  Dan Mills <thunder@mozilla.com>
 23 *  Philipp von Weitershausen <philipp@weitershausen.de>
 24 *  Richard Newman <rnewman@mozilla.com>
 25 *
 26 * Alternatively, the contents of this file may be used under the terms of
 27 * either the GNU General Public License Version 2 or later (the "GPL"), or
 28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 29 * in which case the provisions of the GPL or the LGPL are applicable instead
 30 * of those above. If you wish to allow use of your version of this file only
 31 * under the terms of either the GPL or the LGPL, and not to allow others to
 32 * use your version of this file under the terms of the MPL, indicate your
 33 * decision by deleting the provisions above and replace them with the notice
 34 * and other provisions required by the GPL or the LGPL. If you do not delete
 35 * the provisions above, a recipient may use your version of this file under
 36 * the terms of any one of the MPL, the GPL or the LGPL.
 37 *
 38 * ***** END LICENSE BLOCK ***** */
 39
 40// Process each item in the "constants hash" to add to "global" and give a name
 41let EXPORTED_SYMBOLS = [((this[key] = val), key) for ([key, val] in Iterator({
 42
 43WEAVE_CHANNEL:                         "@weave_channel@",
 44WEAVE_VERSION:                         "@weave_version@",
 45
 46// Sync Server API version that the client supports.
 47SYNC_API_VERSION:                      "1.1",
 48USER_API_VERSION:                      "1.0",
 49MISC_API_VERSION:                      "1.0",
 50
 51// Version of the data format this client supports. The data format describes
 52// how records are packaged; this is separate from the Server API version and
 53// the per-engine cleartext formats.
 54STORAGE_VERSION:                       5,
 55
 56UPDATED_DEV_URL:                       "https://services.mozilla.com/sync/updated/?version=@weave_version@&channel=@weave_channel@",
 57UPDATED_REL_URL:                       "http://www.mozilla.com/firefox/sync/updated.html",
 58
 59PREFS_BRANCH:                          "services.sync.",
 60
 61// Host "key" to access Weave Identity in the password manager
 62PWDMGR_HOST:                           "chrome://weave",
 63PWDMGR_PASSWORD_REALM:                 "Mozilla Services Password",
 64PWDMGR_PASSPHRASE_REALM:               "Mozilla Services Encryption Passphrase",
 65PWDMGR_KEYBUNDLE_REALM:                "Mozilla Services Key Bundles",
 66
 67// Put in [] because those aren't allowed in a collection name.
 68DEFAULT_KEYBUNDLE_NAME:                "[default]",
 69
 70// Our extra input to SHA256-HMAC in generateEntry.
 71// This includes the full crypto spec; change this when our algo changes.
 72HMAC_INPUT:                            "Sync-AES_256_CBC-HMAC256",
 73
 74// Key dimensions.
 75SYNC_KEY_ENCODED_LENGTH:               26,
 76SYNC_KEY_DECODED_LENGTH:               16,
 77SYNC_KEY_HYPHENATED_LENGTH:            31,    // 26 chars, 5 hyphens.
 78
 79NO_SYNC_NODE_INTERVAL:                 10 * 60 * 1000, // 10 minutes
 80
 81MAX_ERROR_COUNT_BEFORE_BACKOFF:        3,
 82MAX_IGNORE_ERROR_COUNT:                5,
 83
 84// Backoff intervals
 85MINIMUM_BACKOFF_INTERVAL:              15 * 60 * 1000,      // 15 minutes
 86MAXIMUM_BACKOFF_INTERVAL:              8 * 60 * 60 * 1000,  // 8 hours 
 87
 88// HMAC event handling timeout.
 89// 10 minutes: a compromise between the multi-desktop sync interval
 90// and the mobile sync interval.
 91HMAC_EVENT_INTERVAL:                   600000,
 92
 93// How long to wait between sync attempts if the Master Password is locked.
 94MASTER_PASSWORD_LOCKED_RETRY_INTERVAL: 15 * 60 * 1000,   // 15 minutes
 95
 96// Separate from the ID fetch batch size to allow tuning for mobile.
 97MOBILE_BATCH_SIZE:                     50,
 98
 99// 50 is hardcoded here because of URL length restrictions.
100// (GUIDs can be up to 64 chars long.)
101// Individual engines can set different values for their limit if their
102// identifiers are shorter.
103DEFAULT_GUID_FETCH_BATCH_SIZE:         50,
104DEFAULT_MOBILE_GUID_FETCH_BATCH_SIZE:  50,
105
106// Default batch size for applying incoming records.
107DEFAULT_STORE_BATCH_SIZE:              1,
108HISTORY_STORE_BATCH_SIZE:              50,      // same as MOBILE_BATCH_SIZE
109FORMS_STORE_BATCH_SIZE:                50,      // same as MOBILE_BATCH_SIZE
110PASSWORDS_STORE_BATCH_SIZE:            50,      // same as MOBILE_BATCH_SIZE
111ADDONS_STORE_BATCH_SIZE:               1000000, // process all addons at once
112APPS_STORE_BATCH_SIZE:                 50,      // same as MOBILE_BATCH_SIZE
113
114// score thresholds for early syncs
115SINGLE_USER_THRESHOLD:                 1000,
116MULTI_DEVICE_THRESHOLD:                300,
117
118// Other score increment constants
119SCORE_INCREMENT_SMALL:                 1,
120SCORE_INCREMENT_MEDIUM:                10,
121
122// Instant sync score increment
123SCORE_INCREMENT_XLARGE:                300 + 1, //MULTI_DEVICE_THRESHOLD + 1
124
125// Delay before incrementing global score
126SCORE_UPDATE_DELAY:                    100,
127
128// Delay for the back observer debouncer. This is chosen to be longer than any
129// observed spurious idle/back events and short enough to pre-empt user activity.
130IDLE_OBSERVER_BACK_DELAY:              100,
131
132// Number of records to upload in a single POST (multiple POSTS if exceeded)
133// FIXME: Record size limit is 256k (new cluster), so this can be quite large!
134// (Bug 569295)
135MAX_UPLOAD_RECORDS:                    100,
136MAX_HISTORY_UPLOAD:                    5000,
137MAX_HISTORY_DOWNLOAD:                  5000,
138
139// Top-level statuses:
140STATUS_OK:                             "success.status_ok",
141SYNC_FAILED:                           "error.sync.failed",
142LOGIN_FAILED:                          "error.login.failed",
143SYNC_FAILED_PARTIAL:                   "error.sync.failed_partial",
144CLIENT_NOT_CONFIGURED:                 "service.client_not_configured",
145STATUS_DISABLED:                       "service.disabled",
146MASTER_PASSWORD_LOCKED:                "service.master_password_locked",
147
148// success states
149LOGIN_SUCCEEDED:                       "success.login",
150SYNC_SUCCEEDED:                        "success.sync",
151ENGINE_SUCCEEDED:                      "success.engine",
152
153// login failure status codes:
154LOGIN_FAILED_NO_USERNAME:              "error.login.reason.no_username",
155LOGIN_FAILED_NO_PASSWORD:              "error.login.reason.no_password2",
156LOGIN_FAILED_NO_PASSPHRASE:            "error.login.reason.no_recoverykey",
157LOGIN_FAILED_NETWORK_ERROR:            "error.login.reason.network",
158LOGIN_FAILED_SERVER_ERROR:             "error.login.reason.server",
159LOGIN_FAILED_INVALID_PASSPHRASE:       "error.login.reason.recoverykey",
160LOGIN_FAILED_LOGIN_REJECTED:           "error.login.reason.account",
161
162// sync failure status codes
163METARECORD_DOWNLOAD_FAIL:              "error.sync.reason.metarecord_download_fail",
164VERSION_OUT_OF_DATE:                   "error.sync.reason.version_out_of_date",
165DESKTOP_VERSION_OUT_OF_DATE:           "error.sync.reason.desktop_version_out_of_date",
166SETUP_FAILED_NO_PASSPHRASE:            "error.sync.reason.setup_failed_no_passphrase",
167CREDENTIALS_CHANGED:                   "error.sync.reason.credentials_changed",
168ABORT_SYNC_COMMAND:                    "aborting sync, process commands said so",
169NO_SYNC_NODE_FOUND:                    "error.sync.reason.no_node_found",
170OVER_QUOTA:                            "error.sync.reason.over_quota",
171PROLONGED_SYNC_FAILURE:                "error.sync.prolonged_failure",
172SERVER_MAINTENANCE:                    "error.sync.reason.serverMaintenance",
173
174RESPONSE_OVER_QUOTA:                   "14",
175
176// engine failure status codes
177ENGINE_UPLOAD_FAIL:                    "error.engine.reason.record_upload_fail",
178ENGINE_DOWNLOAD_FAIL:                  "error.engine.reason.record_download_fail",
179ENGINE_UNKNOWN_FAIL:                   "error.engine.reason.unknown_fail",
180ENGINE_APPLY_FAIL:                     "error.engine.reason.apply_fail",
181ENGINE_METARECORD_DOWNLOAD_FAIL:       "error.engine.reason.metarecord_download_fail",
182ENGINE_METARECORD_UPLOAD_FAIL:         "error.engine.reason.metarecord_upload_fail",
183
184JPAKE_ERROR_CHANNEL:                   "jpake.error.channel",
185JPAKE_ERROR_NETWORK:                   "jpake.error.network",
186JPAKE_ERROR_SERVER:                    "jpake.error.server",
187JPAKE_ERROR_TIMEOUT:                   "jpake.error.timeout",
188JPAKE_ERROR_INTERNAL:                  "jpake.error.internal",
189JPAKE_ERROR_INVALID:                   "jpake.error.invalid",
190JPAKE_ERROR_NODATA:                    "jpake.error.nodata",
191JPAKE_ERROR_KEYMISMATCH:               "jpake.error.keymismatch",
192JPAKE_ERROR_WRONGMESSAGE:              "jpake.error.wrongmessage",
193JPAKE_ERROR_USERABORT:                 "jpake.error.userabort",
194JPAKE_ERROR_DELAYUNSUPPORTED:          "jpake.error.delayunsupported",
195
196// info types for Service.getStorageInfo
197INFO_COLLECTIONS:                      "collections",
198INFO_COLLECTION_USAGE:                 "collection_usage",
199INFO_COLLECTION_COUNTS:                "collection_counts",
200INFO_QUOTA:                            "quota",
201
202// Ways that a sync can be disabled (messages only to be printed in debug log)
203kSyncMasterPasswordLocked:             "User elected to leave Master Password locked",
204kSyncWeaveDisabled:                    "Weave is disabled",
205kSyncNetworkOffline:                   "Network is offline",
206kSyncBackoffNotMet:                    "Trying to sync before the server said it's okay",
207kFirstSyncChoiceNotMade:               "User has not selected an action for first sync",
208
209// Application IDs
210FIREFOX_ID:                            "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
211FENNEC_ID:                             "{a23983c0-fd0e-11dc-95ff-0800200c9a66}",
212SEAMONKEY_ID:                          "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}",
213TEST_HARNESS_ID:                       "xuth@mozilla.org",
214
215MIN_PP_LENGTH:                         12,
216MIN_PASS_LENGTH:                       8
217
218}))];