Skip to content

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-catalyst-latest';

Signature:

export interface Session

Properties

PropertyTypeDescription
availableSpellCheckerLanguagesstring[]A list of all the known available spell checker languages.
cookiesElectronCookiesA Cookies object for this session.
defaultSessionSessionThe default session object of the app.
netLogElectronNetLogA NetLog object for this session.
protocolElectronProtocolA Protocol object for this session.
serviceWorkersElectronServiceWorkersA ServiceWorkers object for this session.
spellCheckerEnabledbooleanWhether the builtin spell checker is enabled.
storagePathnull | stringThe absolute file system path where data for this session is persisted on disk, or null for in-memory sessions.
webRequestElectronWebRequestA WebRequest object for this session.

Methods

MethodReturnsDescription
addListener(event, listener)thisEmitted after an extension is loaded.
addListener(event, listener)thisEmitted after an extension is loaded and all necessary browser state is initialized.
addListener(event, listener)thisEmitted after an extension is unloaded.
addListener(event, listener)thisEmitted when a new HID device becomes available.
addListener(event, listener)thisEmitted when a HID device has been removed.
addListener(event, listener)thisEmitted when a render process requests preconnection to a URL.
addListener(event, listener)thisEmitted when a HID device needs to be selected.
addListener(event, listener)thisEmitted when a serial port needs to be selected.
addListener(event, listener)thisEmitted after a new serial port becomes available.
addListener(event, listener)thisEmitted after a serial port has been removed.
addListener(event, listener)thisEmitted when a hunspell dictionary file starts downloading.
addListener(event, listener)thisEmitted when a hunspell dictionary file download fails.
addListener(event, listener)thisEmitted when a hunspell dictionary file has been successfully downloaded.
addListener(event, listener)thisEmitted when a hunspell dictionary file has been successfully initialized.
addListener(event, listener)thisEmitted when Electron is about to download item in webContents.
addWordToSpellCheckerDictionary(word)booleanWrites the word to the custom dictionary. Does not work on non-persistent (in-memory) sessions.
allowNTLMCredentialsForDomains(domains)voidDynamically 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.
clearData(options?)Promise<void>Clears various types of browsing data of the session.
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)voidAllows resuming a cancelled or interrupted download from a previous session.
disableNetworkEmulation()voidDisables any network emulation already active for the session.
downloadURL(url)voidInitiates a download of the resource at url.
enableNetworkEmulation(options)voidEmulates network with the given configuration for the session.
flushStorageData()voidWrites 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?)SessionReturns 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)ElectronExtensionReturns 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()voidReturns the absolute file system path where data for this session is persisted on disk.
getUserAgent()stringReturns the user agent for this session.
isPersistent()booleanReturns whether or not this session is a persistent one.
isSpellCheckerEnabled()booleanReturns 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)thisEmitted after an extension is loaded.
on('extension-ready', listener)thisEmitted after an extension is loaded and all necessary browser state is initialized.
on('extension-unloaded', listener)thisEmitted after an extension is unloaded.
on('hid-device-added', listener)thisEmitted when a new HID device becomes available.
on('hid-device-removed', listener)thisEmitted when a HID device has been removed.
on('preconnect', listener)thisEmitted when a render process requests preconnection to a URL.
on('select-hid-device', listener)thisEmitted when a HID device needs to be selected.
on('select-serial-port', listener)thisEmitted when a serial port needs to be selected.
on('serial-port-added', listener)thisEmitted after a new serial port becomes available.
on('serial-port-removed', listener)thisEmitted after a serial port has been removed.
on('spellcheck-dictionary-download-begin', listener)thisEmitted when a hunspell dictionary file starts downloading.
on('spellcheck-dictionary-download-failure', listener)thisEmitted when a hunspell dictionary file download fails.
on('spellcheck-dictionary-download-success', listener)thisEmitted when a hunspell dictionary file has been successfully downloaded.
on('spellcheck-dictionary-initialized', listener)thisEmitted when a hunspell dictionary file has been successfully initialized.
on('will-download', listener)thisEmitted when Electron is about to download item in webContents.
once(event, listener)thisEmitted after an extension is loaded.
once(event, listener)thisEmitted after an extension is loaded and all necessary browser state is initialized.
once(event, listener)thisEmitted after an extension is unloaded.
once(event, listener)thisEmitted when a new HID device becomes available.
once(event, listener)thisEmitted when a HID device has been removed.
once(event, listener)thisEmitted when a render process requests preconnection to a URL.
once(event, listener)thisEmitted when a HID device needs to be selected.
once(event, listener)thisEmitted when a serial port needs to be selected.
once(event, listener)thisEmitted after a new serial port becomes available.
once(event, listener)thisEmitted after a serial port has been removed.
once(event, listener)thisEmitted when a hunspell dictionary file starts downloading.
once(event, listener)thisEmitted when a hunspell dictionary file download fails.
once(event, listener)thisEmitted when a hunspell dictionary file has been successfully downloaded.
once(event, listener)thisEmitted when a hunspell dictionary file has been successfully initialized.
once(event, listener)thisEmitted when Electron is about to download item in webContents.
preconnect(options)voidPreconnects the given number of sockets to an origin.
removeExtension(extensionId)voidUnloads an extension.
removeListener(event, listener)thisRemoves a previously registered extension-loaded event listener.
removeListener(event, listener)thisRemoves a previously registered extension-ready event listener.
removeListener(event, listener)thisRemoves a previously registered extension-unloaded event listener.
removeListener(event, listener)thisRemoves a previously registered hid-device-added event listener.
removeListener(event, listener)thisRemoves a previously registered hid-device-removed event listener.
removeListener(event, listener)thisRemoves a previously registered preconnect event listener.
removeListener(event, listener)thisRemoves a previously registered select-hid-device event listener.
removeListener(event, listener)thisRemoves a previously registered select-serial-port event listener.
removeListener(event, listener)thisRemoves a previously registered serial-port-added event listener.
removeListener(event, listener)thisRemoves a previously registered serial-port-removed event listener.
removeListener(event, listener)thisRemoves a previously registered spellcheck-dictionary-download-begin event listener.
removeListener(event, listener)thisRemoves a previously registered spellcheck-dictionary-download-failure event listener.
removeListener(event, listener)thisRemoves a previously registered spellcheck-dictionary-download-success event listener.
removeListener(event, listener)thisRemoves a previously registered spellcheck-dictionary-initialized event listener.
removeListener(event, listener)thisRemoves a previously registered will-download event listener.
removeWordFromSpellCheckerDictionary(word)booleanRemoves 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)voidSets a handler to respond to Bluetooth pairing requests.
setCertificateVerifyProc(proc)voidSets the certificate verify proc for the session.
setCodeCachePath(path)voidSets the directory to store the generated JS code cache for this session.
setDevicePermissionHandler(handler)voidSets the handler used to respond to device permission checks for the session.
setDownloadPath(path)voidSets the download saving directory.
setPermissionCheckHandler(handler)voidSets the handler used to respond to permission checks for the session.
setPermissionRequestHandler(handler)voidSets the handler used to respond to permission requests for the session.
setPreloads(preloads)voidAdds 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)voidOverrides the URL used to download hunspell dictionaries.
setSpellCheckerEnabled(enable)voidSets whether to enable the builtin spell checker.
setSpellCheckerLanguages(languages)voidSets the languages the spell checker should check.
setSSLConfig(config)voidSets the SSL configuration for the session.
setUserAgent(userAgent, acceptLanguages?)voidOverrides the user agent and accept languages for this session.

Links to this page: