@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 2.16 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/core/data/cookie.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,MAAM;IAEf;;OAEG;WACW,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAgB7C;;OAEG;WACW,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK7C;;OAEG;WACW,+BAA+B,IAAI,MAAM;IAWvD;;OAEG;WACW,uBAAuB,IAAI,MAAM;IAI/C;;OAEG;WACW,yBAAyB,IAAI,IAAI;CAGlD","file":"cookie.d.ts","sourcesContent":["import { EnvironmentModule } from '../manifest/environment-modules';\r\n\r\n/**\r\n * Cookie class.\r\n */\r\nexport class Cookie {\r\n\r\n /**\r\n * Gets cookie by name.\r\n */\r\n public static get(cookieName: string): string {\r\n const name = cookieName + '=';\r\n const ca = document.cookie.split(';');\r\n for (let i = 0; i < ca.length; i++) {\r\n let c = ca[i];\r\n while (c.charAt(0) === ' ') {\r\n c = c.substring(1);\r\n }\r\n if (c.indexOf(name) === 0) {\r\n return c.substring(name.length, c.length);\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * \"clears\" cookie by name. Setting its expiration date to \"Thu, 01 Jan 1970 00:00:00 GMT\"\r\n */\r\n public static clear(cookieName: string): void {\r\n const dawnOfTime = new Date(0).toUTCString();\r\n document.cookie = `${cookieName}=;expires=${dawnOfTime}`;\r\n }\r\n\r\n /**\r\n * Gets the cross site request forgery token.\r\n */\r\n public static getCrossSiteRequestForgeryToken(): string {\r\n if (EnvironmentModule.isGatewayV200) {\r\n const xsrf = Cookie.get('WAC-XSRF');\r\n if (xsrf) {\r\n return xsrf;\r\n }\r\n }\r\n\r\n return Cookie.get('XSRF-TOKEN');\r\n }\r\n\r\n /**\r\n * Gets the gateway identity token.\r\n */\r\n public static getGatewayIdentityToken(): string {\r\n return Cookie.get('GATEWAY-IDENTITY-TOKEN');\r\n }\r\n\r\n /**\r\n * Clears the gateway identity token.\r\n */\r\n public static clearGatewayIdentityToken(): void {\r\n Cookie.clear('GATEWAY-IDENTITY-TOKEN');\r\n }\r\n}\r\n"]}