1.0.1 • Published 5 years ago

tpc-checker v1.0.1

Weekly downloads
234
License
ISC
Repository
gitlab
Last release
5 years ago

A simple module to check if user browsers have third party cookies enabled.

Usage

Host the contents of the public folder in a publicly, externally accessible, HTTPS enabled place. Then install the package, and require it in your client code using your bundler of choice to use the function.

The checkTPC function takes the URL to wherever you're hosting the public folder, and an optional timeout in ms. It returns a promise that resolves true or false if TPCs are supported or not, and rejects if the check times out.

checkTPC(url: string, timeout?: number): Promise<boolean>

Example

import checkTPC from 'tpc-checker';

checkTPC(
	'https://wherever.you.put.public.contents/', // wherever you put the contents of /public
	5e3 // check timeout (5 seconds)
)
.then((supported)=>{
	if(supported){
		// third party cookies are working
	} else {
		// third party cookies are not supported
	}
})
.catch((error)=>{
	// check timed out
});