CookieStore.webidl (2159B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://wicg.github.io/cookie-store/#idl-index 8 * 9 * Copyright © 2024 the Contributors to the Cookie Store API Specification, 10 * published by the Web Platform Incubator Community Group under the W3C 11 * Community Contributor License Agreement (CLA). A human-readable summary is 12 * available. 13 */ 14 15 [Exposed=(ServiceWorker,Window), 16 SecureContext, 17 Pref="dom.cookieStore.enabled"] 18 interface CookieStore : EventTarget { 19 [Throws, UseCounter] 20 Promise<CookieListItem?> get(USVString name); 21 [Throws, UseCounter] 22 Promise<CookieListItem?> get(optional CookieStoreGetOptions options = {}); 23 24 [Throws, UseCounter] 25 Promise<CookieList> getAll(USVString name); 26 [Throws, UseCounter] 27 Promise<CookieList> getAll(optional CookieStoreGetOptions options = {}); 28 29 [Throws, UseCounter] 30 Promise<undefined> set(USVString name, USVString value); 31 [Throws, UseCounter] 32 Promise<undefined> set(CookieInit options); 33 34 [Throws, UseCounter] 35 Promise<undefined> delete(USVString name); 36 [Throws, UseCounter] 37 Promise<undefined> delete(CookieStoreDeleteOptions options); 38 39 [Exposed=Window] 40 attribute EventHandler onchange; 41 }; 42 43 dictionary CookieStoreGetOptions { 44 USVString name; 45 USVString url; 46 }; 47 48 enum CookieSameSite { 49 "strict", 50 "lax", 51 "none" 52 }; 53 54 dictionary CookieInit { 55 required USVString name; 56 required USVString value; 57 DOMHighResTimeStamp? expires = null; 58 USVString? domain = null; 59 USVString path = "/"; 60 CookieSameSite sameSite = "strict"; 61 boolean partitioned = false; 62 long long? maxAge = null; 63 }; 64 65 dictionary CookieStoreDeleteOptions { 66 required USVString name; 67 USVString? domain = null; 68 USVString path = "/"; 69 boolean partitioned = false; 70 }; 71 72 dictionary CookieListItem { 73 /* UTF8String semantics match USVString */ 74 75 UTF8String name; 76 UTF8String value; 77 }; 78 79 typedef sequence<CookieListItem> CookieList;