Browse Source

chore: deprecate the 'options' argument to clearAuthCache (#18131)

The network service APIs do not support the fine-grained clearing of the auth cache. In preparation for switching to the network service in 7.x, log a warning that the options argument is deprecated. Ref #17970.

This might not be quite right as we could also potentially expose the new options that are available: namely, start and end time. #17970 does not expose those options, but it would in theory be possible to support them with the existing network service APIs. The current options object does not offer time-based cache clearing.
Jeremy Apthorp 6 years ago
parent
commit
5b7bd56367
2 changed files with 11 additions and 1 deletions
  1. 5 1
      docs/api/session.md
  2. 6 0
      lib/browser/api/session.js

+ 5 - 1
docs/api/session.md

@@ -548,12 +548,16 @@ Clears the session’s HTTP authentication cache.
 
 **[Deprecated Soon](modernization/promisification.md)**
 
-#### `ses.clearAuthCache(options)`
+#### `ses.clearAuthCache(options)` _(deprecated)_
 
 * `options` ([RemovePassword](structures/remove-password.md) | [RemoveClientCertificate](structures/remove-client-certificate.md))
 
 Returns `Promise<void>` - resolves when the session’s HTTP authentication cache has been cleared.
 
+#### `ses.clearAuthCache()`
+
+Returns `Promise<void>` - resolves when the session’s HTTP authentication cache has been cleared.
+
 #### `ses.setPreloads(preloads)`
 
 * `preloads` String[] - An array of absolute path to preload scripts

+ 6 - 0
lib/browser/api/session.js

@@ -31,6 +31,12 @@ Session.prototype.getCacheSize = deprecate.promisify(Session.prototype.getCacheS
 Session.prototype.clearCache = deprecate.promisify(Session.prototype.clearCache)
 Session.prototype.clearAuthCache = deprecate.promisify(Session.prototype.clearAuthCache)
 Session.prototype.getBlobData = deprecate.promisifyMultiArg(Session.prototype.getBlobData)
+Session.prototype.clearAuthCache = ((clearAuthCache) => function (...args) {
+  if (args.length > 0) {
+    deprecate.log(`The 'options' argument to 'clearAuthCache' is deprecated. Beginning with Electron 7, clearAuthCache will clear the entire auth cache unconditionally.`)
+  }
+  return clearAuthCache.apply(this, args)
+})(Session.prototype.clearAuthCache)
 
 Cookies.prototype.flushStore = deprecate.promisify(Cookies.prototype.flushStore)
 Cookies.prototype.get = deprecate.promisify(Cookies.prototype.get)