WICG / cookie-store

Asynchronous access to cookies from JavaScript
https://wicg.github.io/cookie-store/
Apache License 2.0
144 stars 35 forks source link

Update `set()` method to use CookieInit #141

Closed ayuishii closed 4 years ago

ayuishii commented 4 years ago

Github Issue: https://github.com/WICG/cookie-store/issues/139

Change set() method to be as follows

Before

Promise<void> set(USVString name, USVString value,
                    optional CookieStoreSetOptions options = {});
Promise<void> set(CookieStoreSetExtraOptions options);

dictionary CookieStoreSetOptions {
  DOMTimeStamp? expires = null;
  USVString? domain = null;
  USVString path = "/";
  CookieSameSite sameSite = "strict";
};

dictionary CookieStoreSetExtraOptions : CookieStoreSetOptions {
  required USVString name;
  required USVString value;
};

After

Promise<void> set(USVString name, USVString value);
Promise<void> set(CookieInit cookieInit);

dictionary CookieInit {
  required USVString name;
  required USVString value;
  USVString? domain = null;
  USVString path = "/";
  DOMTimeStamp? expires = null;
  CookieSameSite sameSite = "strict";
};

Usage examples:

cookieStore.set('cookie-name', 'cookie-value');
cookieStore.set({ name: 'cookie-name', value: 'cookie-value', path: '/' });

Preview | Diff