Session
Unofficial
Electron session for managing browser sessions, cookies, cache, network, and extensions.
Note: The upstream static fromPartition(...) and static defaultSession members cannot be expressed as statics on a plain interface, so they are modelled here as instance members.
Import:
import type { Session } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface SessionProperties
| Property | Type | Description | |
|---|---|---|---|
| availableSpellCheckerLanguages | string[] | A list of all the known available spell checker languages. | |
| cookies | ElectronCookies | A Cookies object for this session. | |
| defaultSession | Session | The default session object of the app. | |
| netLog | ElectronNetLog | A NetLog object for this session. | |
| protocol | ElectronProtocol | A Protocol object for this session. | |
| serviceWorkers | ElectronServiceWorkers | A ServiceWorkers object for this session. | |
| spellCheckerEnabled | boolean | Whether the builtin spell checker is enabled. | |
| storagePath | null | string | The absolute file system path where data for this session is persisted on disk, or null for in-memory sessions. | |
| webRequest | ElectronWebRequest | A WebRequest object for this session. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addListener(event, listener) | this | Emitted after an extension is loaded. | |
| addListener(event, listener) | this | Emitted after an extension is loaded and all necessary browser state is initialized. | |
| addListener(event, listener) | this | Emitted after an extension is unloaded. | |
| addListener(event, listener) | this | Emitted when a new HID device becomes available. | |
| addListener(event, listener) | this | Emitted when a HID device has been removed. | |
| addListener(event, listener) | this | Emitted when a render process requests preconnection to a URL. | |
| addListener(event, listener) | this | Emitted when a HID device needs to be selected. | |
| addListener(event, listener) | this | Emitted when a serial port needs to be selected. | |
| addListener(event, listener) | this | Emitted after a new serial port becomes available. | |
| addListener(event, listener) | this | Emitted after a serial port has been removed. | |
| addListener(event, listener) | this | Emitted when a hunspell dictionary file starts downloading. | |
| addListener(event, listener) | this | Emitted when a hunspell dictionary file download fails. | |
| addListener(event, listener) | this | Emitted when a hunspell dictionary file has been successfully downloaded. | |
| addListener(event, listener) | this | Emitted when a hunspell dictionary file has been successfully initialized. | |
| addListener(event, listener) | this | Emitted when Electron is about to download item in webContents. | |
| addWordToSpellCheckerDictionary(word) | boolean | Writes the word to the custom dictionary. Does not work on non-persistent (in-memory) sessions. | |
| allowNTLMCredentialsForDomains(domains) | void | Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication. | |
| clearAuthCache() | Promise<void> | Clears the session's HTTP authentication cache. | |
| clearCache() | Promise<void> | Clears the session's HTTP cache. | |
| clearCodeCaches(options) | Promise<void> | Clears the session's generated JS code caches. | |
| clearHostResolverCache() | Promise<void> | Clears the host resolver cache. | |
| clearStorageData(options?) | Promise<void> | Clears the storage data for the current session. | |
| closeAllConnections() | Promise<void> | Closes all connections, terminating any requests currently in flight. | |
| createInterruptedDownload(options) | void | Allows resuming a cancelled or interrupted download from a previous session. | |
| disableNetworkEmulation() | void | Disables any network emulation already active for the session. | |
| downloadURL(url) | void | Initiates a download of the resource at url. | |
| enableNetworkEmulation(options) | void | Emulates network with the given configuration for the session. | |
| flushStorageData() | void | Writes any unwritten DOMStorage data to disk. | |
| forceReloadProxyConfig() | Promise<void> | Resets all internal states of the proxy service and reapplies the latest proxy configuration. | |
| fromPartition(partition, options?) | Session | Returns a session instance from the partition string, creating one with options if none exists. | |
| getAllExtensions() | ElectronExtension[] | Returns a list of all loaded extensions. | |
| getBlobData(identifier) | Promise<Buffer> | Returns the blob data associated with the given identifier. | |
| getCacheSize() | Promise<number> | Returns the session's current cache size, in bytes. | |
| getExtension(extensionId) | ElectronExtension | Returns the loaded extension with the given ID. | |
| getPreloads() | string[] | Returns an array of paths to preload scripts that have been registered. | |
| getSpellCheckerLanguages() | string[] | Returns an array of language codes the spellchecker is enabled for. | |
| getStoragePath() | void | Returns the absolute file system path where data for this session is persisted on disk. | |
| getUserAgent() | string | Returns the user agent for this session. | |
| isPersistent() | boolean | Returns whether or not this session is a persistent one. | |
| isSpellCheckerEnabled() | boolean | Returns whether the builtin spell checker is enabled. | |
| listWordsInSpellCheckerDictionary() | Promise<string[]> | Returns all words in the app's custom dictionary. | |
| loadExtension(path, options?) | Promise<ElectronExtension> | Loads a Chrome extension from path. | |
| on('extension-loaded', listener) | this | Emitted after an extension is loaded. | |
| on('extension-ready', listener) | this | Emitted after an extension is loaded and all necessary browser state is initialized. | |
| on('extension-unloaded', listener) | this | Emitted after an extension is unloaded. | |
| on('hid-device-added', listener) | this | Emitted when a new HID device becomes available. | |
| on('hid-device-removed', listener) | this | Emitted when a HID device has been removed. | |
| on('preconnect', listener) | this | Emitted when a render process requests preconnection to a URL. | |
| on('select-hid-device', listener) | this | Emitted when a HID device needs to be selected. | |
| on('select-serial-port', listener) | this | Emitted when a serial port needs to be selected. | |
| on('serial-port-added', listener) | this | Emitted after a new serial port becomes available. | |
| on('serial-port-removed', listener) | this | Emitted after a serial port has been removed. | |
| on('spellcheck-dictionary-download-begin', listener) | this | Emitted when a hunspell dictionary file starts downloading. | |
| on('spellcheck-dictionary-download-failure', listener) | this | Emitted when a hunspell dictionary file download fails. | |
| on('spellcheck-dictionary-download-success', listener) | this | Emitted when a hunspell dictionary file has been successfully downloaded. | |
| on('spellcheck-dictionary-initialized', listener) | this | Emitted when a hunspell dictionary file has been successfully initialized. | |
| on('will-download', listener) | this | Emitted when Electron is about to download item in webContents. | |
| once(event, listener) | this | Emitted after an extension is loaded. | |
| once(event, listener) | this | Emitted after an extension is loaded and all necessary browser state is initialized. | |
| once(event, listener) | this | Emitted after an extension is unloaded. | |
| once(event, listener) | this | Emitted when a new HID device becomes available. | |
| once(event, listener) | this | Emitted when a HID device has been removed. | |
| once(event, listener) | this | Emitted when a render process requests preconnection to a URL. | |
| once(event, listener) | this | Emitted when a HID device needs to be selected. | |
| once(event, listener) | this | Emitted when a serial port needs to be selected. | |
| once(event, listener) | this | Emitted after a new serial port becomes available. | |
| once(event, listener) | this | Emitted after a serial port has been removed. | |
| once(event, listener) | this | Emitted when a hunspell dictionary file starts downloading. | |
| once(event, listener) | this | Emitted when a hunspell dictionary file download fails. | |
| once(event, listener) | this | Emitted when a hunspell dictionary file has been successfully downloaded. | |
| once(event, listener) | this | Emitted when a hunspell dictionary file has been successfully initialized. | |
| once(event, listener) | this | Emitted when Electron is about to download item in webContents. | |
| preconnect(options) | void | Preconnects the given number of sockets to an origin. | |
| removeExtension(extensionId) | void | Unloads an extension. | |
| removeListener(event, listener) | this | Removes a previously registered extension-loaded event listener. | |
| removeListener(event, listener) | this | Removes a previously registered extension-ready event listener. | |
| removeListener(event, listener) | this | Removes a previously registered extension-unloaded event listener. | |
| removeListener(event, listener) | this | Removes a previously registered hid-device-added event listener. | |
| removeListener(event, listener) | this | Removes a previously registered hid-device-removed event listener. | |
| removeListener(event, listener) | this | Removes a previously registered preconnect event listener. | |
| removeListener(event, listener) | this | Removes a previously registered select-hid-device event listener. | |
| removeListener(event, listener) | this | Removes a previously registered select-serial-port event listener. | |
| removeListener(event, listener) | this | Removes a previously registered serial-port-added event listener. | |
| removeListener(event, listener) | this | Removes a previously registered serial-port-removed event listener. | |
| removeListener(event, listener) | this | Removes a previously registered spellcheck-dictionary-download-begin event listener. | |
| removeListener(event, listener) | this | Removes a previously registered spellcheck-dictionary-download-failure event listener. | |
| removeListener(event, listener) | this | Removes a previously registered spellcheck-dictionary-download-success event listener. | |
| removeListener(event, listener) | this | Removes a previously registered spellcheck-dictionary-initialized event listener. | |
| removeListener(event, listener) | this | Removes a previously registered will-download event listener. | |
| removeWordFromSpellCheckerDictionary(word) | boolean | Removes the word from the custom dictionary. Does not work on non-persistent (in-memory) sessions. | |
| resolveProxy(url) | Promise<string> | Resolves the proxy information for url. | |
| setBluetoothPairingHandler(handler) | void | Sets a handler to respond to Bluetooth pairing requests. | |
| setCertificateVerifyProc(proc) | void | Sets the certificate verify proc for the session. | |
| setCodeCachePath(path) | void | Sets the directory to store the generated JS code cache for this session. | |
| setDevicePermissionHandler(handler) | void | Sets the handler used to respond to device permission checks for the session. | |
| setDownloadPath(path) | void | Sets the download saving directory. | |
| setPermissionCheckHandler(handler) | void | Sets the handler used to respond to permission checks for the session. | |
| setPermissionRequestHandler(handler) | void | Sets the handler used to respond to permission requests for the session. | |
| setPreloads(preloads) | void | Adds scripts that will be executed on all web contents associated with this session just before normal preload scripts run. | |
| setProxy(config) | Promise<void> | Sets the proxy settings. | |
| setSpellCheckerDictionaryDownloadURL(url) | void | Overrides the URL used to download hunspell dictionaries. | |
| setSpellCheckerEnabled(enable) | void | Sets whether to enable the builtin spell checker. | |
| setSpellCheckerLanguages(languages) | void | Sets the languages the spell checker should check. | |
| setSSLConfig(config) | void | Sets the SSL configuration for the session. | |
| setUserAgent(userAgent, acceptLanguages?) | void | Overrides the user agent and accept languages for this session. |
Links to this page: