UNPKG

ngx-cookie-service

Version:
1 lines • 29 kB
{"version":3,"file":"ngx-cookie-service.mjs","names":[],"sources":["../../../projects/ngx-cookie-service/src/lib/cookie.config.ts","../../../projects/ngx-cookie-service/src/lib/cookie.service.ts"],"sourcesContent":["import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\nimport type { CookieOptions } from './cookie.service';\n\n/**\n * App-wide default options for {@link CookieService}. Provide them with {@link provideCookieOptions}.\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\nexport const COOKIE_OPTIONS = new InjectionToken<CookieOptions>('ngx-cookie-service default cookie options');\n\n/**\n * Sets default options for every `set()`, `delete()` and `deleteAll()` call of {@link CookieService}.\n *\n * Options passed to a call win over these defaults, and `undefined` values don't override them. A call that passes its own\n * `expires` replaces the default one, so `delete()` always expires the cookie.\n *\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [provideCookieOptions({ path: '/', secure: true, sameSite: 'Strict' })],\n * };\n * ```\n *\n * @param options Default cookie options\n * @returns Providers to add to the application config\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\nexport function provideCookieOptions(options: CookieOptions): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: COOKIE_OPTIONS, useValue: { ...options } }]);\n}\n\n/**\n * A custom encoding for cookie values, used with {@link provideCookieEncoding}.\n *\n * `encode` runs on every value written by `set()`, and `decode` on every value read by `get()` and `getAll()`. Cookie names\n * keep the default encoding. If `decode` throws, the raw value is returned instead.\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\nexport interface CookieCodec {\n encode(value: string, name: string): string;\n decode(value: string, name: string): string;\n}\n\n/**\n * How {@link CookieService} encodes cookie values:\n *\n * - `'uri'` (default): `encodeURIComponent` and `decodeURIComponent`.\n * - `'minimal'`: values made only of characters allowed in a cookie value (RFC 6265 cookie-octets, except `%`) are written\n * as-is, and other values are encoded with `encodeURIComponent`. This is the default of the jshttp `cookie` package used\n * by Express, and keeps values such as JWTs and base64 readable by servers that don't URL-decode cookies.\n * - A {@link CookieCodec} for a custom scheme.\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\nexport type CookieEncoding = 'uri' | 'minimal' | CookieCodec;\n\n/**\n * The cookie value encoding for {@link CookieService}. Provide it with {@link provideCookieEncoding}.\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\nexport const COOKIE_ENCODING = new InjectionToken<CookieEncoding>('ngx-cookie-service cookie value encoding');\n\n/**\n * Sets how {@link CookieService} encodes cookie values when writing them and decodes them when reading.\n *\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [provideCookieEncoding('minimal')],\n * };\n * ```\n *\n * @param encoding `'uri'` (default), `'minimal'`, or a custom {@link CookieCodec}\n * @returns Providers to add to the application config\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\nexport function provideCookieEncoding(encoding: CookieEncoding): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: COOKIE_ENCODING, useValue: encoding }]);\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { DOCUMENT, inject, Injectable, PLATFORM_ID } from '@angular/core';\nimport { COOKIE_ENCODING, COOKIE_OPTIONS, CookieCodec, CookieEncoding } from './cookie.config';\n\nexport type SameSite = 'Lax' | 'None' | 'Strict';\n\nexport interface CookieOptions {\n expires?: number | Date;\n path?: string;\n domain?: string;\n secure?: boolean;\n sameSite?: SameSite;\n partitioned?: boolean;\n}\n\n/**\n * Attributes that identify the cookie to delete. They must match the attributes the cookie was set with.\n */\nexport type DeleteCookieOptions = Omit<CookieOptions, 'expires'>;\n\n/**\n * Cookie options after validation: invalid values are removed and `expires` is always a `Date`.\n */\ntype ValidCookieOptions = Omit<CookieOptions, 'expires'> & { expires?: Date };\n\n/**\n * The `SameSite` values browsers accept, in their canonical spelling.\n */\nconst SAME_SITE_VALUES: readonly SameSite[] = ['Lax', 'Strict', 'None'];\n\n/**\n * RFC 6265 cookie-octets except `%`: values made only of these are written as-is by the `'minimal'` encoding and still\n * decode to themselves. Same pattern as the jshttp `cookie` package (2.x) used by Express.\n */\nconst COOKIE_OCTET_REGEXP = /^[!#$&'()*+\\-./0-9:<=>?@A-Z[\\]^_`a-z{|}~]*$/;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class CookieService {\n private readonly documentIsAccessible: boolean;\n private readonly document = inject<Document>(DOCUMENT);\n private readonly platformId = inject<object>(PLATFORM_ID);\n private readonly defaultOptions: CookieOptions = inject(COOKIE_OPTIONS, { optional: true }) ?? {};\n private readonly codec: CookieCodec = CookieService.toCodec(inject(COOKIE_ENCODING, { optional: true }));\n\n constructor() {\n this.documentIsAccessible = isPlatformBrowser(this.platformId);\n }\n\n /**\n * Get cookie Regular Expression\n *\n * @param name Cookie name\n * @returns property RegExp\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n private static getCookieRegExp(name: string): RegExp {\n const escapedName: string = name.replace(/([[\\]{}()|=;+?,.*^$\\\\])/gi, '\\\\$1');\n\n return new RegExp('(?:^' + escapedName + '|;\\\\s*' + escapedName + ')=(.*?)(?:;|$)');\n }\n\n /**\n * Gets the decoded version of an encoded component of a Uniform Resource Identifier (URI).\n *\n * @param encodedURIComponent A value representing an encoded URI component.\n *\n * @returns The decoded version of an encoded component of a Uniform Resource Identifier (URI).\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n private static safeDecodeURIComponent(encodedURIComponent: string): string {\n try {\n return decodeURIComponent(encodedURIComponent);\n } catch {\n // probably it is not uri encoded. return as is\n return encodedURIComponent;\n }\n }\n\n /**\n * Return `true` if {@link Document} is accessible, otherwise return `false`\n *\n * @param name Cookie name\n * @returns boolean - whether cookie with specified name exists\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n check(name: string): boolean {\n if (!this.documentIsAccessible) {\n return false;\n }\n name = encodeURIComponent(name);\n const regExp = CookieService.getCookieRegExp(name);\n return regExp.test(this.document.cookie);\n }\n\n /**\n * Get cookies by name\n *\n * @param name Cookie name\n * @returns property value\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n get(name: string): string {\n if (this.check(name)) {\n const regExp: RegExp = CookieService.getCookieRegExp(encodeURIComponent(name));\n const result = regExp.exec(this.document.cookie);\n return result?.[1] ? this.decodeValue(result[1], name) : '';\n } else {\n return '';\n }\n }\n\n /**\n * Get all cookies in JSON format\n *\n * @returns all the cookies in json\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n getAll(): Record<string, string> {\n if (!this.documentIsAccessible) {\n return {};\n }\n\n const cookies: Record<string, string> = {};\n const document: Document = this.document;\n\n if (document.cookie && document.cookie !== '') {\n document.cookie.split(';').forEach((currentCookie: string) => {\n const trimmedCookie = currentCookie.trim();\n if (!trimmedCookie) {\n return;\n }\n // Split on the first '=' only, so values containing '=' (e.g. base64 padding) are preserved\n const equalIndex = trimmedCookie.indexOf('=');\n if (equalIndex === -1) {\n // Cookie without value (invalid, but handle gracefully)\n return;\n }\n const cookieName = CookieService.safeDecodeURIComponent(trimmedCookie.substring(0, equalIndex));\n // Browsers list the most specific cookie first when several share a name. Keep that one, as get() does.\n if (Object.hasOwn(cookies, cookieName)) {\n return;\n }\n // defineProperty stores names such as \"__proto__\" as normal entries instead of touching the object's prototype\n Object.defineProperty(cookies, cookieName, {\n value: this.decodeValue(trimmedCookie.substring(equalIndex + 1), cookieName),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n });\n }\n\n return cookies;\n }\n\n /**\n * Set cookie based on provided information\n *\n * @param name Cookie name\n * @param value Cookie value\n * @param expires Number of days until the cookies expires or an actual `Date`\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Secure flag\n * @param partitioned Partitioned flag\n * @param sameSite OWASP same site token `Lax`, `None`, or `Strict`. Defaults to `Lax`\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n set(\n name: string,\n value: string,\n expires?: CookieOptions['expires'],\n path?: CookieOptions['path'],\n domain?: CookieOptions['domain'],\n secure?: CookieOptions['secure'],\n sameSite?: SameSite,\n partitioned?: CookieOptions['partitioned']\n ): void;\n\n /**\n * Set cookie based on provided information\n *\n * Cookie's parameters:\n * <pre>\n * expires Number of days until the cookies expires or an actual `Date`\n * path Cookie path\n * domain Cookie domain\n * secure flag\n * sameSite OWASP same site token `Lax`, `None`, or `Strict`. Defaults to `Lax`\n * </pre>\n *\n * @param name Cookie name\n * @param value Cookie value\n * @param options Body with cookie's params\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n set(name: string, value: string, options?: CookieOptions): void;\n\n set(\n name: string,\n value: string,\n expiresOrOptions?: CookieOptions['expires'] | CookieOptions,\n path?: CookieOptions['path'],\n domain?: CookieOptions['domain'],\n secure?: CookieOptions['secure'],\n sameSite?: SameSite,\n partitioned?: CookieOptions['partitioned']\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n\n // Anything but an options object means the positional form, so no positional argument (e.g. a lone `partitioned`) is dropped\n if (typeof expiresOrOptions !== 'object' || expiresOrOptions === null || expiresOrOptions instanceof Date) {\n const optionsBody = {\n expires: expiresOrOptions as CookieOptions['expires'],\n path,\n domain,\n secure,\n sameSite,\n partitioned,\n };\n\n this.set(name, value, optionsBody);\n return;\n }\n\n // validateOptions() returns a copy, so the defaults applied below don't leak back into the caller's object\n const options = CookieService.validateOptions(name, CookieService.withDefaults(this.defaultOptions, expiresOrOptions));\n if (!options) {\n return;\n }\n\n const encodedValue = this.encodeValue(name, value);\n if (encodedValue === undefined) {\n return;\n }\n\n let cookieString: string = encodeURIComponent(name) + '=' + encodedValue + ';';\n\n if (options.expires) {\n cookieString += 'Expires=' + options.expires.toUTCString() + ';';\n }\n\n if (options.path) {\n cookieString += 'Path=' + options.path + ';';\n }\n\n if (options.domain) {\n cookieString += 'Domain=' + options.domain + ';';\n }\n\n if (options.sameSite === 'None' && !options.secure) {\n options.secure = true;\n console.warn(\n `[ngx-cookie-service] Cookie ${name} was forced with secure flag because sameSite=None.` +\n `More details : https://github.com/stevermeister/ngx-cookie-service/issues/86#issuecomment-597720130`\n );\n }\n if (options.partitioned && !options.secure) {\n options.secure = true;\n console.warn(`[ngx-cookie-service] Cookie ${name} was forced with secure flag because Partitioned cookies must be Secure.`);\n }\n if (options.secure) {\n cookieString += 'Secure;';\n }\n\n if (!options.sameSite) {\n options.sameSite = 'Lax';\n }\n\n cookieString += 'SameSite=' + options.sameSite + ';';\n\n if (options.partitioned) {\n cookieString += 'Partitioned;';\n }\n\n this.document.cookie = cookieString;\n }\n\n /**\n * Delete cookie by name at given path and domain.\n *\n * If `path` is not specified, no `Path` attribute is written and the browser uses its default path: the directory of the URL\n * the page was loaded at (not the current router URL). To delete a cookie that was set with `path: '/'`, pass `'/'` here too.\n *\n * @param name Cookie name\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Cookie secure flag\n * @param sameSite Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n delete(name: string, path?: CookieOptions['path'], domain?: CookieOptions['domain'], secure?: CookieOptions['secure'], sameSite?: SameSite): void;\n\n /**\n * Delete cookie by name. The options must match the attributes the cookie was set with: `path` and `domain` select the\n * cookie, and `partitioned: true` is required to delete a Partitioned cookie.\n *\n * If `path` is not specified, no `Path` attribute is written and the browser uses its default path: the directory of the URL\n * the page was loaded at (not the current router URL). To delete a cookie that was set with `path: '/'`, pass `'/'` here too.\n *\n * @param name Cookie name\n * @param options Cookie attributes: `path`, `domain`, `secure`, `sameSite` and `partitioned`\n *\n * @author: Pavankumar Jadda\n * @since: 22.1.0\n */\n delete(name: string, options?: DeleteCookieOptions): void;\n\n delete(\n name: string,\n pathOrOptions?: CookieOptions['path'] | DeleteCookieOptions,\n domain?: CookieOptions['domain'],\n secure?: CookieOptions['secure'],\n sameSite?: SameSite\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n const options = CookieService.toDeleteOptions(pathOrOptions, domain, secure, sameSite);\n this.set(name, '', { ...options, expires: new Date('Thu, 01 Jan 1970 00:00:01 GMT') });\n }\n\n /**\n * Delete all cookies at given path and domain.\n *\n * If `path` is not specified, the browser's default path is used for each cookie, as described for {@link delete}.\n *\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Is the Cookie secure\n * @param sameSite Is the cookie same site\n *\n * @author: Stepan Suvorov\n * @since: 1.0.0\n */\n deleteAll(path?: CookieOptions['path'], domain?: CookieOptions['domain'], secure?: CookieOptions['secure'], sameSite?: SameSite): void;\n\n /**\n * Delete all cookies that can currently be accessed, using the same attributes for each one.\n *\n * If `path` is not specified, the browser's default path is used for each cookie, as described for {@link delete}.\n *\n * @param options Cookie attributes: `path`, `domain`, `secure`, `sameSite` and `partitioned`\n *\n * @author: Pavankumar Jadda\n * @since: 22.1.0\n */\n deleteAll(options?: DeleteCookieOptions): void;\n\n deleteAll(\n pathOrOptions?: CookieOptions['path'] | DeleteCookieOptions,\n domain?: CookieOptions['domain'],\n secure?: CookieOptions['secure'],\n sameSite?: SameSite\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n\n // Object.keys() rather than for...in with cookies.hasOwnProperty(): a cookie named \"hasOwnProperty\" would shadow that method\n for (const cookieName of Object.keys(this.getAll())) {\n // Call delete() the same way deleteAll() was called, so overrides and spies of the positional form keep working\n if (typeof pathOrOptions === 'object' && pathOrOptions !== null) {\n this.delete(cookieName, pathOrOptions);\n } else {\n this.delete(cookieName, pathOrOptions, domain, secure, sameSite);\n }\n }\n }\n\n /**\n * Built-in `'uri'` encoding: `encodeURIComponent`, decoded with {@link CookieService.safeDecodeURIComponent}.\n */\n private static readonly uriCodec: CookieCodec = {\n encode: (value) => encodeURIComponent(value),\n decode: (value) => CookieService.safeDecodeURIComponent(value),\n };\n\n /**\n * Built-in `'minimal'` encoding: values made only of cookie-octets are written as-is, others use `encodeURIComponent`.\n */\n private static readonly minimalCodec: CookieCodec = {\n encode: (value) => (COOKIE_OCTET_REGEXP.test(value) ? value : encodeURIComponent(value)),\n decode: (value) => CookieService.safeDecodeURIComponent(value),\n };\n\n /**\n * Resolves the encoding provided with {@link provideCookieEncoding} to a codec, defaulting to `'uri'`.\n *\n * @param encoding Provided encoding, or `null` when none was provided\n * @returns The codec to use\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\n private static toCodec(encoding: CookieEncoding | null): CookieCodec {\n if (encoding === 'minimal') {\n return CookieService.minimalCodec;\n }\n if (typeof encoding === 'object' && encoding !== null) {\n return encoding;\n }\n return CookieService.uriCodec;\n }\n\n /**\n * Encodes a cookie value with the configured encoding. Returns `undefined`, with a warning, when the result can't be\n * written safely because it isn't a string or contains `;` or a control character.\n *\n * @param name Cookie name\n * @param value Cookie value\n * @returns The encoded value, or `undefined` to skip the write\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\n private encodeValue(name: string, value: string): string | undefined {\n const encodedValue = this.codec.encode(value, name);\n if (typeof encodedValue !== 'string' || CookieService.hasUnsafeCharacter(encodedValue)) {\n console.warn(`[ngx-cookie-service] Cookie ${name} was skipped because its encoded value isn't a string without \";\" or control characters.`);\n return undefined;\n }\n return encodedValue;\n }\n\n /**\n * Decodes a cookie value with the configured encoding. If a custom `decode` throws, the raw value is returned.\n *\n * @param value Raw cookie value\n * @param name Decoded cookie name\n * @returns The decoded value\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\n private decodeValue(value: string, name: string): string {\n try {\n return this.codec.decode(value, name);\n } catch {\n return value;\n }\n }\n\n /**\n * Merges the app-wide defaults from {@link provideCookieOptions} under the options of one call.\n *\n * Values passed to the call win, and `undefined` or `null` values don't override a default.\n *\n * @param defaults Default cookie options\n * @param options Options passed to the call\n * @returns A new, merged CookieOptions object\n *\n * @author: Pavankumar Jadda\n * @since: 22.2.0\n */\n private static withDefaults(defaults: CookieOptions, options: CookieOptions = {}): CookieOptions {\n const merged: Record<string, unknown> = { ...defaults };\n for (const [key, value] of Object.entries(options)) {\n if (value !== undefined && value !== null) {\n merged[key] = value;\n }\n }\n return merged as CookieOptions;\n }\n\n /**\n * Returns a validated copy of the options, or `undefined` if the cookie must not be written.\n *\n * A `path` or `domain` containing `;` or a control character could inject attributes or change the cookie's scope, so the\n * whole write is skipped. An invalid `expires` is dropped, which makes a session cookie as browsers already did, and an\n * unknown `sameSite` falls back to the `Lax` default. Each case logs a warning. A numeric `expires` (days\n * from now) is converted to a `Date`, and `sameSite` is matched case-insensitively.\n *\n * @param name Cookie name, used in warnings\n * @param options Cookie options\n * @returns A validated copy of the options, or `undefined` to skip the write\n *\n * @author: Pavankumar Jadda\n * @since: 22.1.0\n */\n private static validateOptions(name: string, options: CookieOptions = {}): ValidCookieOptions | undefined {\n const { expires, ...valid }: CookieOptions = options;\n const result: ValidCookieOptions = valid;\n\n for (const attribute of ['path', 'domain'] as const) {\n const attributeValue = result[attribute];\n if (typeof attributeValue === 'string' && CookieService.hasUnsafeCharacter(attributeValue)) {\n console.warn(`[ngx-cookie-service] Cookie ${name} was skipped because its ${attribute} contains \";\" or a control character.`);\n return undefined;\n }\n }\n if (expires) {\n const date = typeof expires === 'number' ? new Date(Date.now() + expires * 1000 * 60 * 60 * 24) : expires;\n if (date instanceof Date && Number.isFinite(date.getTime())) {\n result.expires = date;\n } else {\n console.warn(`[ngx-cookie-service] Cookie ${name}: ignoring invalid expires value \"${String(expires)}\".`);\n }\n }\n if (result.sameSite !== undefined && result.sameSite !== null) {\n const sameSite = SAME_SITE_VALUES.find((value) => value.toLowerCase() === String(result.sameSite).toLowerCase());\n if (sameSite) {\n result.sameSite = sameSite;\n } else {\n console.warn(`[ngx-cookie-service] Cookie ${name}: ignoring invalid sameSite value \"${String(result.sameSite)}\".`);\n delete result.sameSite;\n }\n }\n return result;\n }\n\n /**\n * Whether a cookie attribute value contains `;` or an ASCII control character, which would end the attribute early or\n * corrupt the header.\n *\n * @param value Attribute value\n * @returns `true` if the value is unsafe to write\n *\n * @author: Pavankumar Jadda\n * @since: 22.1.0\n */\n private static hasUnsafeCharacter(value: string): boolean {\n return [...value].some((character) => {\n const code = character.charCodeAt(0);\n return character === ';' || code < 0x20 || code === 0x7f;\n });\n }\n\n /**\n * Builds delete options from either an options object or the positional `path`, `domain`, `secure` and `sameSite` arguments.\n *\n * @param pathOrOptions Either a DeleteCookieOptions object or the cookie path\n * @param domain Cookie domain\n * @param secure Cookie secure flag\n * @param sameSite Cookie sameSite flag\n * @returns A new DeleteCookieOptions object\n *\n * @author: Pavankumar Jadda\n * @since: 22.1.0\n */\n private static toDeleteOptions(\n pathOrOptions?: CookieOptions['path'] | DeleteCookieOptions,\n domain?: CookieOptions['domain'],\n secure?: CookieOptions['secure'],\n sameSite?: SameSite\n ): DeleteCookieOptions {\n if (typeof pathOrOptions === 'object' && pathOrOptions !== null) {\n return { ...pathOrOptions };\n }\n return { path: pathOrOptions, domain, secure, sameSite };\n }\n}\n"],"mappings":";;;AASA,MAAa,iBAAiB,IAAI,eAA8B,2CAA2C;AAoB3G,SAAgB,qBAAqB,SAAsB;CACzD,OAAO,yBAAyB,CAAC;EAAE,SAAS;EAAgB,UAAU,EAAE,GAAG,QAAO;CAAE,CAAE,CAAC;AACzF;AAoCA,MAAa,kBAAkB,IAAI,eAA+B,0CAA0C;AAiB5G,SAAgB,sBAAsB,UAAwB;CAC5D,OAAO,yBAAyB,CAAC;EAAE,SAAS;EAAiB,UAAU;CAAQ,CAAE,CAAC;AACpF;AC1DA,MAAM,mBAAwC;CAAC;CAAO;CAAU;AAAM;AAMtE,MAAM,sBAAsB;AAK5B,IAAa,gBAAb,MAAa,cAAa;CAOxB,cAAA;EALiB,KAAA,WAAW,OAAiB,QAAQ;EACpC,KAAA,aAAa,OAAe,WAAW;EACvC,KAAA,iBAAgC,OAAO,gBAAgB,EAAE,UAAU,KAAI,CAAE,KAAK,CAAA;EAC9E,KAAA,QAAqB,cAAc,QAAQ,OAAO,iBAAiB,EAAE,UAAU,KAAI,CAAE,CAAC;EAGrG,KAAK,uBAAuB,kBAAkB,KAAK,UAAU;CAC/D;CAWQ,OAAO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