Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@edx/cookie-policy-banner

Package Overview
Dependencies
Maintainers
13
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edx/cookie-policy-banner - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

9

build/constants.js

@@ -14,3 +14,4 @@ 'use strict';

var DEFAULT_IETF_TAG = ENGLISH_IETF_TAG;
var STAGE_ENVIRONMENTS = ['acceptance.edx.org', 'dev.edx.org', 'extra.edx.org', 'qa.edx.org', 'stage.edx.org', 'localhost'];
var LOCALHOST = 'localhost';
var STAGE_ENVIRONMENTS = ['acceptance.edx.org', 'dev.edx.org', 'extra.edx.org', 'qa.edx.org', 'stage.edx.org'];

@@ -34,2 +35,4 @@ var LANGUAGE_CODES = Object.freeze([ENGLISH_IETF_TAG, SPANISH_IETF_TAG]);

var COOKIE_POLICY_VIEWED_NAME = 'edx-cookie-policy-viewed';
exports.DEFAULT_IETF_TAG = DEFAULT_IETF_TAG;

@@ -40,2 +43,4 @@ exports.LANGUAGE_CODES = LANGUAGE_CODES;

exports.getPolicyHTML = getPolicyHTML;
exports.STAGE_ENVIRONMENTS = STAGE_ENVIRONMENTS;
exports.STAGE_ENVIRONMENTS = STAGE_ENVIRONMENTS;
exports.LOCALHOST = LOCALHOST;
exports.COOKIE_POLICY_VIEWED_NAME = COOKIE_POLICY_VIEWED_NAME;

@@ -6,3 +6,3 @@ 'use strict';

});
exports.hasViewedCookieBanner = exports.createHasViewedCookieBanner = exports.getLanguageCode = undefined;
exports.isStage = exports.firstMatchingStageEnvironment = exports.isLocalhost = exports.hasViewedCookieBanner = exports.createHasViewedCookieBanner = exports.getLanguageCode = undefined;

@@ -17,10 +17,22 @@ var _universalCookie = require('universal-cookie');

var isStage = function isStage() {
var host = window.location.hostname;
var isLocalhost = function isLocalhost() {
return window.location.hostname.indexOf(_constants.LOCALHOST) >= 0;
};
return _constants.STAGE_ENVIRONMENTS.filter(function (environment) {
return host.indexOf(environment) > -1;
}).length > 0;
var firstMatchingStageEnvironment = function firstMatchingStageEnvironment() {
var matches = _constants.STAGE_ENVIRONMENTS.filter(function (environment) {
return window.location.hostname.indexOf(environment) >= 0;
});
if (matches.length > 0) {
return matches[0];
}
return null;
};
var isStage = function isStage() {
return !!firstMatchingStageEnvironment();
};
var isProduction = function isProduction() {

@@ -51,8 +63,14 @@ var host = window.location.hostname;

if (isLocalhost()) {
return new _universalCookie2.default().set(_constants.COOKIE_POLICY_VIEWED_NAME, true, { domain: _constants.LOCALHOST, path: path, maxAge: maxAge });
}
if (isStage()) {
return new _universalCookie2.default().set('edx-cookie-policy-viewed', true, { domain: '.stage.edx.org', path: path, maxAge: maxAge });
} else if (isProduction()) {
return new _universalCookie2.default().set('edx-cookie-policy-viewed', true, { domain: '.edx.org', path: path, maxAge: maxAge });
return new _universalCookie2.default().set(_constants.COOKIE_POLICY_VIEWED_NAME, true, { domain: '.' + firstMatchingStageEnvironment(), path: path, maxAge: maxAge });
}
if (isProduction()) {
return new _universalCookie2.default().set(_constants.COOKIE_POLICY_VIEWED_NAME, true, { domain: '.edx.org', path: path, maxAge: maxAge });
}
return false;

@@ -62,3 +80,3 @@ };

var hasViewedCookieBanner = function hasViewedCookieBanner() {
var cookie = new _universalCookie2.default().get('edx-cookie-policy-viewed');
var cookie = new _universalCookie2.default().get(_constants.COOKIE_POLICY_VIEWED_NAME);

@@ -70,2 +88,5 @@ return !!cookie;

exports.createHasViewedCookieBanner = createHasViewedCookieBanner;
exports.hasViewedCookieBanner = hasViewedCookieBanner;
exports.hasViewedCookieBanner = hasViewedCookieBanner;
exports.isLocalhost = isLocalhost;
exports.firstMatchingStageEnvironment = firstMatchingStageEnvironment;
exports.isStage = isStage;
{
"name": "@edx/cookie-policy-banner",
"version": "1.1.3",
"version": "1.1.4",
"description": "The edX cookie policy banner component implemented in React.",

@@ -31,3 +31,3 @@ "main": "build/index.js",

"lint": "eslint --ext .jsx,.js .",
"test": "jest --coverage --passWithNoTests",
"test": "jest --coverage --no-cache",
"prepublishOnly": "npm run compile-prod",

@@ -84,2 +84,4 @@ "css": "node-sass src/CookiePolicyBanner/_cookie-policy-banner.scss -o build --importer node_modules/node-sass-import",

"jest": "^22.4.3",
"jest-environment-jsdom": "^22.4.3",
"jest-environment-jsdom-global": "^1.0.3",
"node-sass": "^4.8.3",

@@ -100,4 +102,4 @@ "node-sass-import": "^1.1.1",

"jest": {
"testEnvironment": "node"
"testEnvironment": "jest-environment-jsdom-global"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc