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