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
4
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 1.0.0 to 1.1.0

8

CHANGELOG.md

@@ -5,6 +5,12 @@ # Changelog

## [1.0.0](https://github.com/britannica/cam-utils/compare/v0.0.0...v1.0.0) (2020-03-09)
## [1.1.0](https://github.com/britannica/cam-utils/compare/v1.0.0...v1.1.0) (2020-03-10)
### Features
- Add `clearAuthCookies` method ([d53f506](https://github.com/britannica/cam-utils/commit/d53f5063f0903e060393ec7ded73604822d59f54))
## [1.0.0](https://github.com/britannica/cam-utils/compare/v0.0.1...v1.0.0) (2020-03-09)
### ⚠ BREAKING CHANGES
- Bump out of 0.x range

63

dist/cam-utils.cjs.js

@@ -9,7 +9,7 @@ 'use strict';

const CAM_COOKIE_DOMAIN = '.britannica.com';
const CAM_COOKIE_DOMAIN = ".britannica.com";
const CAM_DEFAULT_EXPIRATION_DAYS = 365;
const CAM_CONFIGURATION_COOKIE = 'CAMConfigure';
const CAM_LOGIN_REDIRECT_URL_COOKIE = 'CAMLoginRedirectUrl';
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl';
const CAM_CONFIGURATION_COOKIE = "CAMConfigure";
const CAM_LOGIN_REDIRECT_URL_COOKIE = "CAMLoginRedirectUrl";
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = "CAMSignUpRedirectUrl";

@@ -26,17 +26,26 @@ // --- Auth configuration setter and getter

function setAuthConfiguration({ userPoolId, userPoolWebClientId, secure = false, expires = CAM_DEFAULT_EXPIRATION_DAYS }) {
Cookies.set(CAM_CONFIGURATION_COOKIE, JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split('_').shift(),
cookieStorage: {
function setAuthConfiguration({
userPoolId,
userPoolWebClientId,
secure = false,
expires = CAM_DEFAULT_EXPIRATION_DAYS
}) {
Cookies.set(
CAM_CONFIGURATION_COOKIE,
JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split("_").shift(),
cookieStorage: {
expires,
secure,
domain: CAM_COOKIE_DOMAIN
}
}),
{
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
},
}), {
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
});
domain: CAM_COOKIE_DOMAIN
}
);
}

@@ -53,3 +62,3 @@

if (!configurationCookie) {
console.error('CAM Utils: No configuration cookie set');
console.error("CAM Utils: No configuration cookie set");

@@ -71,3 +80,6 @@ return;

function setRedirectUrl(type, url) {
Cookies.set(type, url, { domain: CAM_COOKIE_DOMAIN, expires: CAM_DEFAULT_EXPIRATION_DAYS });
Cookies.set(type, url, {
domain: CAM_COOKIE_DOMAIN,
expires: CAM_DEFAULT_EXPIRATION_DAYS
});
}

@@ -85,2 +97,14 @@

// Heavy-handed sign out function
/**
* Clear all cognito cookies
*/
function clearAuthCookies() {
Object.keys(Cookies.get())
.filter(key => key.startsWith("CognitoIdentityServiceProvider."))
.forEach(cookie => Cookies.remove(cookie, { domain: CAM_COOKIE_DOMAIN }));
}
exports.CAM_CONFIGURATION_COOKIE = CAM_CONFIGURATION_COOKIE;

@@ -91,2 +115,3 @@ exports.CAM_COOKIE_DOMAIN = CAM_COOKIE_DOMAIN;

exports.CAM_SIGN_UP_REDIRECT_URL_COOKIE = CAM_SIGN_UP_REDIRECT_URL_COOKIE;
exports.clearAuthCookies = clearAuthCookies;
exports.getAuthConfiguration = getAuthConfiguration;

@@ -93,0 +118,0 @@ exports.getRedirectUrl = getRedirectUrl;

import Cookies from 'js-cookie';
const CAM_COOKIE_DOMAIN = '.britannica.com';
const CAM_COOKIE_DOMAIN = ".britannica.com";
const CAM_DEFAULT_EXPIRATION_DAYS = 365;
const CAM_CONFIGURATION_COOKIE = 'CAMConfigure';
const CAM_LOGIN_REDIRECT_URL_COOKIE = 'CAMLoginRedirectUrl';
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl';
const CAM_CONFIGURATION_COOKIE = "CAMConfigure";
const CAM_LOGIN_REDIRECT_URL_COOKIE = "CAMLoginRedirectUrl";
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = "CAMSignUpRedirectUrl";

@@ -19,17 +19,26 @@ // --- Auth configuration setter and getter

function setAuthConfiguration({ userPoolId, userPoolWebClientId, secure = false, expires = CAM_DEFAULT_EXPIRATION_DAYS }) {
Cookies.set(CAM_CONFIGURATION_COOKIE, JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split('_').shift(),
cookieStorage: {
function setAuthConfiguration({
userPoolId,
userPoolWebClientId,
secure = false,
expires = CAM_DEFAULT_EXPIRATION_DAYS
}) {
Cookies.set(
CAM_CONFIGURATION_COOKIE,
JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split("_").shift(),
cookieStorage: {
expires,
secure,
domain: CAM_COOKIE_DOMAIN
}
}),
{
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
},
}), {
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
});
domain: CAM_COOKIE_DOMAIN
}
);
}

@@ -46,3 +55,3 @@

if (!configurationCookie) {
console.error('CAM Utils: No configuration cookie set');
console.error("CAM Utils: No configuration cookie set");

@@ -64,3 +73,6 @@ return;

function setRedirectUrl(type, url) {
Cookies.set(type, url, { domain: CAM_COOKIE_DOMAIN, expires: CAM_DEFAULT_EXPIRATION_DAYS });
Cookies.set(type, url, {
domain: CAM_COOKIE_DOMAIN,
expires: CAM_DEFAULT_EXPIRATION_DAYS
});
}

@@ -78,2 +90,14 @@

export { CAM_CONFIGURATION_COOKIE, CAM_COOKIE_DOMAIN, CAM_DEFAULT_EXPIRATION_DAYS, CAM_LOGIN_REDIRECT_URL_COOKIE, CAM_SIGN_UP_REDIRECT_URL_COOKIE, getAuthConfiguration, getRedirectUrl, setAuthConfiguration, setRedirectUrl };
// Heavy-handed sign out function
/**
* Clear all cognito cookies
*/
function clearAuthCookies() {
Object.keys(Cookies.get())
.filter(key => key.startsWith("CognitoIdentityServiceProvider."))
.forEach(cookie => Cookies.remove(cookie, { domain: CAM_COOKIE_DOMAIN }));
}
export { CAM_CONFIGURATION_COOKIE, CAM_COOKIE_DOMAIN, CAM_DEFAULT_EXPIRATION_DAYS, CAM_LOGIN_REDIRECT_URL_COOKIE, CAM_SIGN_UP_REDIRECT_URL_COOKIE, clearAuthCookies, getAuthConfiguration, getRedirectUrl, setAuthConfiguration, setRedirectUrl };

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

const CAM_COOKIE_DOMAIN = '.britannica.com';
const CAM_COOKIE_DOMAIN = ".britannica.com";
const CAM_DEFAULT_EXPIRATION_DAYS = 365;
const CAM_CONFIGURATION_COOKIE = 'CAMConfigure';
const CAM_LOGIN_REDIRECT_URL_COOKIE = 'CAMLoginRedirectUrl';
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl';
const CAM_CONFIGURATION_COOKIE = "CAMConfigure";
const CAM_LOGIN_REDIRECT_URL_COOKIE = "CAMLoginRedirectUrl";
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = "CAMSignUpRedirectUrl";

@@ -183,17 +183,26 @@ // --- Auth configuration setter and getter

function setAuthConfiguration({ userPoolId, userPoolWebClientId, secure = false, expires = CAM_DEFAULT_EXPIRATION_DAYS }) {
js_cookie.set(CAM_CONFIGURATION_COOKIE, JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split('_').shift(),
cookieStorage: {
function setAuthConfiguration({
userPoolId,
userPoolWebClientId,
secure = false,
expires = CAM_DEFAULT_EXPIRATION_DAYS
}) {
js_cookie.set(
CAM_CONFIGURATION_COOKIE,
JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split("_").shift(),
cookieStorage: {
expires,
secure,
domain: CAM_COOKIE_DOMAIN
}
}),
{
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
},
}), {
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
});
domain: CAM_COOKIE_DOMAIN
}
);
}

@@ -210,3 +219,3 @@

if (!configurationCookie) {
console.error('CAM Utils: No configuration cookie set');
console.error("CAM Utils: No configuration cookie set");

@@ -228,3 +237,6 @@ return;

function setRedirectUrl(type, url) {
js_cookie.set(type, url, { domain: CAM_COOKIE_DOMAIN, expires: CAM_DEFAULT_EXPIRATION_DAYS });
js_cookie.set(type, url, {
domain: CAM_COOKIE_DOMAIN,
expires: CAM_DEFAULT_EXPIRATION_DAYS
});
}

@@ -242,2 +254,14 @@

// Heavy-handed sign out function
/**
* Clear all cognito cookies
*/
function clearAuthCookies() {
Object.keys(js_cookie.get())
.filter(key => key.startsWith("CognitoIdentityServiceProvider."))
.forEach(cookie => js_cookie.remove(cookie, { domain: CAM_COOKIE_DOMAIN }));
}
exports.CAM_CONFIGURATION_COOKIE = CAM_CONFIGURATION_COOKIE;

@@ -248,2 +272,3 @@ exports.CAM_COOKIE_DOMAIN = CAM_COOKIE_DOMAIN;

exports.CAM_SIGN_UP_REDIRECT_URL_COOKIE = CAM_SIGN_UP_REDIRECT_URL_COOKIE;
exports.clearAuthCookies = clearAuthCookies;
exports.getAuthConfiguration = getAuthConfiguration;

@@ -250,0 +275,0 @@ exports.getRedirectUrl = getRedirectUrl;

{
"name": "@britannica/cam-utils",
"version": "1.0.0",
"version": "1.1.0",
"description": "Consumer Account Management (CAM) auth configuration and utilities",

@@ -5,0 +5,0 @@ "repository": "git://github.com/britannica/cam-utils.git",

@@ -1,8 +0,8 @@

import Cookies from 'js-cookie';
import Cookies from "js-cookie";
export const CAM_COOKIE_DOMAIN = '.britannica.com';
export const CAM_COOKIE_DOMAIN = ".britannica.com";
export const CAM_DEFAULT_EXPIRATION_DAYS = 365;
export const CAM_CONFIGURATION_COOKIE = 'CAMConfigure';
export const CAM_LOGIN_REDIRECT_URL_COOKIE = 'CAMLoginRedirectUrl';
export const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl';
export const CAM_CONFIGURATION_COOKIE = "CAMConfigure";
export const CAM_LOGIN_REDIRECT_URL_COOKIE = "CAMLoginRedirectUrl";
export const CAM_SIGN_UP_REDIRECT_URL_COOKIE = "CAMSignUpRedirectUrl";

@@ -19,17 +19,26 @@ // --- Auth configuration setter and getter

export function setAuthConfiguration({ userPoolId, userPoolWebClientId, secure = false, expires = CAM_DEFAULT_EXPIRATION_DAYS }) {
Cookies.set(CAM_CONFIGURATION_COOKIE, JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split('_').shift(),
cookieStorage: {
export function setAuthConfiguration({
userPoolId,
userPoolWebClientId,
secure = false,
expires = CAM_DEFAULT_EXPIRATION_DAYS
}) {
Cookies.set(
CAM_CONFIGURATION_COOKIE,
JSON.stringify({
userPoolId,
userPoolWebClientId,
region: userPoolId.split("_").shift(),
cookieStorage: {
expires,
secure,
domain: CAM_COOKIE_DOMAIN
}
}),
{
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
},
}), {
expires,
secure,
domain: CAM_COOKIE_DOMAIN,
});
domain: CAM_COOKIE_DOMAIN
}
);
}

@@ -46,3 +55,3 @@

if (!configurationCookie) {
console.error('CAM Utils: No configuration cookie set');
console.error("CAM Utils: No configuration cookie set");

@@ -64,3 +73,6 @@ return;

export function setRedirectUrl(type, url) {
Cookies.set(type, url, { domain: CAM_COOKIE_DOMAIN, expires: CAM_DEFAULT_EXPIRATION_DAYS });
Cookies.set(type, url, {
domain: CAM_COOKIE_DOMAIN,
expires: CAM_DEFAULT_EXPIRATION_DAYS
});
}

@@ -78,1 +90,12 @@

// Heavy-handed sign out function
/**
* Clear all cognito cookies
*/
export function clearAuthCookies() {
Object.keys(Cookies.get())
.filter(key => key.startsWith("CognitoIdentityServiceProvider."))
.forEach(cookie => Cookies.remove(cookie, { domain: CAM_COOKIE_DOMAIN }));
}
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