enums.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Storage area type for persisting and exchanging data.
  3. * @see https://developer.chrome.com/docs/extensions/reference/storage/#overview
  4. */
  5. export enum StorageEnum {
  6. /**
  7. * Persist data locally against browser restarts. Will be deleted by uninstalling the extension.
  8. * @default
  9. */
  10. Local = 'local',
  11. /**
  12. * Uploads data to the users account in the cloud and syncs to the users browsers on other devices. Limits apply.
  13. */
  14. Sync = 'sync',
  15. /**
  16. * Requires an [enterprise policy](https://www.chromium.org/administrators/configuring-policy-for-extensions) with a
  17. * json schema for company wide config.
  18. */
  19. Managed = 'managed',
  20. /**
  21. * Only persist data until the browser is closed. Recommended for service workers which can shutdown anytime and
  22. * therefore need to restore their state. Set {@link SessionAccessLevelEnum} for permitting content scripts access.
  23. * @implements Chromes [Session Storage](https://developer.chrome.com/docs/extensions/reference/storage/#property-session)
  24. */
  25. Session = 'session',
  26. }
  27. /**
  28. * Global access level requirement for the {@link StorageEnum.Session} Storage Area.
  29. * @implements Chromes [Session Access Level](https://developer.chrome.com/docs/extensions/reference/storage/#method-StorageArea-setAccessLevel)
  30. */
  31. export enum SessionAccessLevelEnum {
  32. /**
  33. * Storage can only be accessed by Extension pages (not Content scripts).
  34. * @default
  35. */
  36. ExtensionPagesOnly = 'TRUSTED_CONTEXTS',
  37. /**
  38. * Storage can be accessed by both Extension pages and Content scripts.
  39. */
  40. ExtensionPagesAndContentScripts = 'TRUSTED_AND_UNTRUSTED_CONTEXTS',
  41. }