From 4e0fe9b9533addfb846a2e3f7cddd7fe2f9dc7f1 Mon Sep 17 00:00:00 2001 From: jacamera Date: Thu, 12 Mar 2020 19:51:59 -0400 Subject: [PATCH] added SameSiteStatus to chrome.cookies in Chrome package (#43023) * added dictionary {size -> ImageData} option to imageData property * exposed concealed ClassValue type in classnames package * corrections per tslint * moved additional types into namespace * added SameSiteStatus to chrome.cookies * synced up classnames * fixed newline * made sameSite optional in SetDetails * added @since Chrome 51. moniker to sameSite * added sameSite to cookies in sinon-chrome package --- types/chrome/index.d.ts | 13 +++++++++++++ types/sinon-chrome/sinon-chrome-tests.ts | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 016458df3a..3a6bf635a3 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -1266,6 +1266,9 @@ declare namespace chrome.contextMenus { * Permissions: "cookies", host permissions */ declare namespace chrome.cookies { + /** A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set with 'SameSite=None', 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. 'unspecified' corresponds to a cookie set without the SameSite attribute. **/ + export type SameSiteStatus = 'unspecified' | 'no_restriction' | 'lax' | 'strict'; + /** Represents information about an HTTP cookie. */ export interface Cookie { /** The domain of the cookie (e.g. "www.google.com", "example.com"). */ @@ -1288,6 +1291,11 @@ declare namespace chrome.cookies { httpOnly: boolean; /** True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS). */ secure: boolean; + /** + * The cookie's same-site status (i.e. whether the cookie is sent with cross-site requests). + * @since Chrome 51. + */ + sameSite: SameSiteStatus } /** Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a non-incognito window. */ @@ -1334,6 +1342,11 @@ declare namespace chrome.cookies { httpOnly?: boolean; /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */ secure?: boolean; + /** + * Optional. The cookie's same-site status. Defaults to "unspecified", i.e., if omitted, the cookie is set without specifying a SameSite attribute. + * @since Chrome 51. + */ + sameSite?: SameSiteStatus } export interface Details { diff --git a/types/sinon-chrome/sinon-chrome-tests.ts b/types/sinon-chrome/sinon-chrome-tests.ts index ab5f050f52..52b6206a03 100644 --- a/types/sinon-chrome/sinon-chrome-tests.ts +++ b/types/sinon-chrome/sinon-chrome-tests.ts @@ -64,7 +64,8 @@ chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin( secure: false, session: false, storeId: '0', - value: 'COOKIE_VALUE' + value: 'COOKIE_VALUE', + sameSite: 'unspecified' }, { domain: 'other-domain.com', @@ -75,7 +76,8 @@ chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin( secure: false, session: true, storeId: '0', - value: '123' + value: '123', + sameSite: 'unspecified' } ] ));