New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@britannica/cam-utils

Package Overview
Dependencies
Maintainers
5
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@britannica/cam-utils - npm Package Compare versions

Comparing version 4.3.1 to 4.4.0-beta.1

17

dist/cam-utils.cjs.js

@@ -10,2 +10,3 @@ 'use strict';

const CAM_LEGACY_AUTH_COOKIE = 'AuthTokenExpirable2';
const MONEY_SESSION_COOKIE_NAME = 'MendelSession';
/**

@@ -47,13 +48,14 @@ * postMessage event types

/**
* Extract the TLD and SLD of a given hostname. Only works with "britannica.*" domains
* e.g. https://migration.cam.britannica.com.br -> britannica.com.br
* Extract the TLD and SLD of a given hostname. Only works with "*.britannica.*" domains.
* e.g. https://migration.cam.britannica.com.br -> .britannica.com.br
* @param {string} [hostname]
* @returns {string}
*/
function parseDomain(hostname = 'britannica.com') {
if (hostname.indexOf('britannica') === -1) {
function parseDomain(hostname = 'www.britannica.com') {
const cookieDomainPrefix = '.britannica';
if (hostname.indexOf(cookieDomainPrefix) === -1) {
console.warn(`Hostname does not contain "britannica", defaulting to given hostname ${hostname}`);
return hostname;
}
return hostname.substring(hostname.indexOf('britannica'));
return hostname.substring(hostname.indexOf(cookieDomainPrefix));
}

@@ -167,3 +169,5 @@ /**

Object.keys(Cookies.get())
.filter((key) => key.startsWith('CognitoIdentityServiceProvider.') || key === CAM_LEGACY_AUTH_COOKIE)
.filter((key) => key.startsWith('CognitoIdentityServiceProvider.') ||
key === CAM_LEGACY_AUTH_COOKIE ||
key === MONEY_SESSION_COOKIE_NAME)
.forEach((cookie) => Cookies.remove(cookie, { domain: parseDomain() }));

@@ -177,2 +181,3 @@ }

exports.CAM_SIGN_UP_REDIRECT_URL_COOKIE = CAM_SIGN_UP_REDIRECT_URL_COOKIE;
exports.MONEY_SESSION_COOKIE_NAME = MONEY_SESSION_COOKIE_NAME;
exports.clearAuthCookies = clearAuthCookies;

@@ -179,0 +184,0 @@ exports.clearRedirectUrl = clearRedirectUrl;

@@ -8,2 +8,3 @@ import Cookies from 'js-cookie';

const CAM_LEGACY_AUTH_COOKIE = 'AuthTokenExpirable2';
const MONEY_SESSION_COOKIE_NAME = 'MendelSession';
/**

@@ -45,13 +46,14 @@ * postMessage event types

/**
* Extract the TLD and SLD of a given hostname. Only works with "britannica.*" domains
* e.g. https://migration.cam.britannica.com.br -> britannica.com.br
* Extract the TLD and SLD of a given hostname. Only works with "*.britannica.*" domains.
* e.g. https://migration.cam.britannica.com.br -> .britannica.com.br
* @param {string} [hostname]
* @returns {string}
*/
function parseDomain(hostname = 'britannica.com') {
if (hostname.indexOf('britannica') === -1) {
function parseDomain(hostname = 'www.britannica.com') {
const cookieDomainPrefix = '.britannica';
if (hostname.indexOf(cookieDomainPrefix) === -1) {
console.warn(`Hostname does not contain "britannica", defaulting to given hostname ${hostname}`);
return hostname;
}
return hostname.substring(hostname.indexOf('britannica'));
return hostname.substring(hostname.indexOf(cookieDomainPrefix));
}

@@ -165,7 +167,9 @@ /**

Object.keys(Cookies.get())
.filter((key) => key.startsWith('CognitoIdentityServiceProvider.') || key === CAM_LEGACY_AUTH_COOKIE)
.filter((key) => key.startsWith('CognitoIdentityServiceProvider.') ||
key === CAM_LEGACY_AUTH_COOKIE ||
key === MONEY_SESSION_COOKIE_NAME)
.forEach((cookie) => Cookies.remove(cookie, { domain: parseDomain() }));
}
export { CAM_DEFAULT_EXPIRATION_DAYS, CAM_LEGACY_AUTH_COOKIE, CAM_LOGIN_REDIRECT_URL_COOKIE, CAM_LOGOUT_REDIRECT_URL_COOKIE, CAM_SIGN_UP_REDIRECT_URL_COOKIE, Environment, PostMessageEvent, clearAuthCookies, clearRedirectUrl, getAuthConfiguration, getCookie, getProductName, getRedirectUrl, parseDomain, poolConfigurations, setCookie, setRedirectUrl };
export { CAM_DEFAULT_EXPIRATION_DAYS, CAM_LEGACY_AUTH_COOKIE, CAM_LOGIN_REDIRECT_URL_COOKIE, CAM_LOGOUT_REDIRECT_URL_COOKIE, CAM_SIGN_UP_REDIRECT_URL_COOKIE, Environment, MONEY_SESSION_COOKIE_NAME, PostMessageEvent, clearAuthCookies, clearRedirectUrl, getAuthConfiguration, getCookie, getProductName, getRedirectUrl, parseDomain, poolConfigurations, setCookie, setRedirectUrl };
//# sourceMappingURL=cam-utils.esm.js.map

@@ -7,3 +7,3 @@ (function (global, factory) {

/*! js-cookie v3.0.1 | MIT */
/*! js-cookie v3.0.5 | MIT */
/* eslint-disable no-var */

@@ -41,3 +41,3 @@ function assign (target) {

function init (converter, defaultAttributes) {
function set (key, value, attributes) {
function set (name, value, attributes) {
if (typeof document === 'undefined') {

@@ -56,3 +56,3 @@ return

key = encodeURIComponent(key)
name = encodeURIComponent(name)
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)

@@ -84,7 +84,7 @@ .replace(/[()]/g, escape);

return (document.cookie =
key + '=' + converter.write(value, key) + stringifiedAttributes)
name + '=' + converter.write(value, name) + stringifiedAttributes)
}
function get (key) {
if (typeof document === 'undefined' || (arguments.length && !key)) {
function get (name) {
if (typeof document === 'undefined' || (arguments.length && !name)) {
return

@@ -102,6 +102,6 @@ }

try {
var foundKey = decodeURIComponent(parts[0]);
jar[foundKey] = converter.read(value, foundKey);
var found = decodeURIComponent(parts[0]);
jar[found] = converter.read(value, found);
if (key === foundKey) {
if (name === found) {
break

@@ -112,3 +112,3 @@ }

return key ? jar[key] : jar
return name ? jar[name] : jar
}

@@ -118,7 +118,7 @@

{
set: set,
get: get,
remove: function (key, attributes) {
set,
get,
remove: function (name, attributes) {
set(
key,
name,
'',

@@ -151,2 +151,3 @@ assign({}, attributes, {

const CAM_LEGACY_AUTH_COOKIE = 'AuthTokenExpirable2';
const MONEY_SESSION_COOKIE_NAME = 'MendelSession';
/**

@@ -188,13 +189,14 @@ * postMessage event types

/**
* Extract the TLD and SLD of a given hostname. Only works with "britannica.*" domains
* e.g. https://migration.cam.britannica.com.br -> britannica.com.br
* Extract the TLD and SLD of a given hostname. Only works with "*.britannica.*" domains.
* e.g. https://migration.cam.britannica.com.br -> .britannica.com.br
* @param {string} [hostname]
* @returns {string}
*/
function parseDomain(hostname = 'britannica.com') {
if (hostname.indexOf('britannica') === -1) {
function parseDomain(hostname = 'www.britannica.com') {
const cookieDomainPrefix = '.britannica';
if (hostname.indexOf(cookieDomainPrefix) === -1) {
console.warn(`Hostname does not contain "britannica", defaulting to given hostname ${hostname}`);
return hostname;
}
return hostname.substring(hostname.indexOf('britannica'));
return hostname.substring(hostname.indexOf(cookieDomainPrefix));
}

@@ -308,3 +310,5 @@ /**

Object.keys(api.get())
.filter((key) => key.startsWith('CognitoIdentityServiceProvider.') || key === CAM_LEGACY_AUTH_COOKIE)
.filter((key) => key.startsWith('CognitoIdentityServiceProvider.') ||
key === CAM_LEGACY_AUTH_COOKIE ||
key === MONEY_SESSION_COOKIE_NAME)
.forEach((cookie) => api.remove(cookie, { domain: parseDomain() }));

@@ -318,2 +322,3 @@ }

exports.CAM_SIGN_UP_REDIRECT_URL_COOKIE = CAM_SIGN_UP_REDIRECT_URL_COOKIE;
exports.MONEY_SESSION_COOKIE_NAME = MONEY_SESSION_COOKIE_NAME;
exports.clearAuthCookies = clearAuthCookies;

@@ -320,0 +325,0 @@ exports.clearRedirectUrl = clearRedirectUrl;

@@ -15,2 +15,3 @@ import type { CookieAttributes } from 'js-cookie';

export declare const CAM_LEGACY_AUTH_COOKIE = "AuthTokenExpirable2";
export declare const MONEY_SESSION_COOKIE_NAME = "MendelSession";
/**

@@ -34,4 +35,4 @@ * postMessage event types

/**
* Extract the TLD and SLD of a given hostname. Only works with "britannica.*" domains
* e.g. https://migration.cam.britannica.com.br -> britannica.com.br
* Extract the TLD and SLD of a given hostname. Only works with "*.britannica.*" domains.
* e.g. https://migration.cam.britannica.com.br -> .britannica.com.br
* @param {string} [hostname]

@@ -38,0 +39,0 @@ * @returns {string}

{
"name": "@britannica/cam-utils",
"version": "4.3.1",
"version": "4.4.0-beta.1",
"description": "Consumer Account Management (CAM) auth configuration and utilities",

@@ -25,27 +25,27 @@ "repository": "git://github.com/britannica/cam-utils.git",

"dependencies": {
"js-cookie": "3.0.1"
"js-cookie": "3.0.5"
},
"devDependencies": {
"@commitlint/cli": "17.5.1",
"@commitlint/config-conventional": "17.4.4",
"@rollup/plugin-commonjs": "24.0.1",
"@rollup/plugin-node-resolve": "15.0.2",
"@rollup/plugin-typescript": "11.1.0",
"@semantic-release/commit-analyzer": "9.0.2",
"@commitlint/cli": "17.7.2",
"@commitlint/config-conventional": "17.7.0",
"@rollup/plugin-commonjs": "25.0.4",
"@rollup/plugin-node-resolve": "15.2.1",
"@rollup/plugin-typescript": "11.1.4",
"@semantic-release/commit-analyzer": "11.0.0",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "8.0.7",
"@semantic-release/npm": "10.0.2",
"@semantic-release/release-notes-generator": "10.0.3",
"@types/jest": "29.5.0",
"@types/js-cookie": "3.0.3",
"@semantic-release/github": "9.2.1",
"@semantic-release/npm": "11.0.0",
"@semantic-release/release-notes-generator": "12.0.0",
"@types/jest": "29.5.5",
"@types/js-cookie": "3.0.4",
"husky": "8.0.3",
"jest": "29.5.0",
"jest-environment-jsdom": "29.5.0",
"prettier": "2.8.7",
"pretty-quick": "3.1.3",
"rimraf": "4.4.1",
"rollup": "3.20.2",
"ts-jest": "29.1.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"lint-staged": "^14.0.1",
"prettier": "3.0.3",
"rimraf": "5.0.5",
"rollup": "3.29.4",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "5.0.3"
"typescript": "5.2.2"
},

@@ -83,3 +83,6 @@ "commitlint": {

]
},
"lint-staged": {
"*.{ts,js,css,md}": "prettier --write"
}
}

@@ -14,6 +14,6 @@ import {

test('default domain', async () => {
expect(parseDomain()).toBe('britannica.com');
expect(parseDomain()).toBe('.britannica.com');
});
test('britannica.com domains', async () => {
test('britannica domains', async () => {
const tld1 = parseDomain('www.britannica.com');

@@ -24,11 +24,13 @@ const tld2 = parseDomain('kids.britannica.com');

const tld5 = parseDomain('escola.britannica.com.br');
const tld6 = parseDomain('www.britannica.co.jp');
expect(tld1).toBe('britannica.com');
expect(tld2).toBe('britannica.com');
expect(tld3).toBe('britannica.com');
expect(tld4).toBe('britannica.com');
expect(tld5).toBe('britannica.com.br');
expect(tld1).toBe('.britannica.com');
expect(tld2).toBe('.britannica.com');
expect(tld3).toBe('.britannica.com');
expect(tld4).toBe('.britannica.com');
expect(tld5).toBe('.britannica.com.br');
expect(tld6).toBe('.britannica.co.jp');
});
test('non-britannica.com domains', async () => {
test('non-britannica domains', async () => {
const tld1 = parseDomain('www.google.com');

@@ -35,0 +37,0 @@ const tld2 = parseDomain('www.merriam-webster.com');

@@ -17,2 +17,3 @@ import type { CookieAttributes } from 'js-cookie';

export const CAM_LEGACY_AUTH_COOKIE = 'AuthTokenExpirable2';
export const MONEY_SESSION_COOKIE_NAME = 'MendelSession';

@@ -57,4 +58,4 @@ /**

/**
* Extract the TLD and SLD of a given hostname. Only works with "britannica.*" domains
* e.g. https://migration.cam.britannica.com.br -> britannica.com.br
* Extract the TLD and SLD of a given hostname. Only works with "*.britannica.*" domains.
* e.g. https://migration.cam.britannica.com.br -> .britannica.com.br
* @param {string} [hostname]

@@ -64,4 +65,6 @@ * @returns {string}

export function parseDomain(hostname: string = 'britannica.com'): string {
if (hostname.indexOf('britannica') === -1) {
export function parseDomain(hostname: string = 'www.britannica.com'): string {
const cookieDomainPrefix = '.britannica';
if (hostname.indexOf(cookieDomainPrefix) === -1) {
console.warn(`Hostname does not contain "britannica", defaulting to given hostname ${hostname}`);

@@ -72,3 +75,3 @@

return hostname.substring(hostname.indexOf('britannica'));
return hostname.substring(hostname.indexOf(cookieDomainPrefix));
}

@@ -213,4 +216,9 @@

Object.keys(Cookies.get())
.filter((key) => key.startsWith('CognitoIdentityServiceProvider.') || key === CAM_LEGACY_AUTH_COOKIE)
.filter(
(key) =>
key.startsWith('CognitoIdentityServiceProvider.') ||
key === CAM_LEGACY_AUTH_COOKIE ||
key === MONEY_SESSION_COOKIE_NAME
)
.forEach((cookie) => Cookies.remove(cookie, { domain: parseDomain() }));
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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