@britannica/cam-utils
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -5,2 +5,8 @@ # Changelog | ||
## [2.2.0](https://github.com/britannica/cam-utils/compare/v2.1.0...v2.2.0) (2020-04-20) | ||
### Features | ||
- add setProductName and getProductName functions ([c1cd57d](https://github.com/britannica/cam-utils/commit/c1cd57d9ad7ebb1f10515c19951c1d39dc14f924)) | ||
## [2.1.0](https://github.com/britannica/cam-utils/compare/v2.0.0...v2.1.0) (2020-03-10) | ||
@@ -7,0 +13,0 @@ |
@@ -13,2 +13,3 @@ 'use strict'; | ||
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl'; | ||
const CAM_PRODUCT_NAME_COOKIE = 'CAMProductName'; | ||
@@ -67,4 +68,17 @@ const Environment = { | ||
// Redirect setter and getter | ||
/** | ||
* Generic cookie setting function | ||
* @param {string} cookie | ||
* @param {string} value | ||
*/ | ||
function setCookie(cookie, value) { | ||
Cookies.set(cookie, value, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
} | ||
// --- Redirects --- // | ||
/** | ||
@@ -77,6 +91,3 @@ * Set the redirect url for the given cookie type | ||
function setRedirectUrl(type, url) { | ||
Cookies.set(type, url, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
setCookie(type, url); | ||
} | ||
@@ -103,2 +114,22 @@ | ||
// --- Product name --- // | ||
/** | ||
* Set the name of the product to display within CAM | ||
* @param {string} productName | ||
*/ | ||
function setProductName(productName) { | ||
setCookie(CAM_PRODUCT_NAME_COOKIE, productName); | ||
} | ||
/** | ||
* Retrieve the product name | ||
* @returns {string} | ||
*/ | ||
function getProductName() { | ||
return Cookies.get(CAM_PRODUCT_NAME_COOKIE); | ||
} | ||
// Heavy-handed sign out function | ||
@@ -119,2 +150,3 @@ | ||
exports.CAM_LOGIN_REDIRECT_URL_COOKIE = CAM_LOGIN_REDIRECT_URL_COOKIE; | ||
exports.CAM_PRODUCT_NAME_COOKIE = CAM_PRODUCT_NAME_COOKIE; | ||
exports.CAM_SIGN_UP_REDIRECT_URL_COOKIE = CAM_SIGN_UP_REDIRECT_URL_COOKIE; | ||
@@ -125,3 +157,5 @@ exports.Environment = Environment; | ||
exports.getAuthConfiguration = getAuthConfiguration; | ||
exports.getProductName = getProductName; | ||
exports.getRedirectUrl = getRedirectUrl; | ||
exports.setProductName = setProductName; | ||
exports.setRedirectUrl = setRedirectUrl; |
@@ -7,2 +7,3 @@ import Cookies from 'js-cookie'; | ||
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl'; | ||
const CAM_PRODUCT_NAME_COOKIE = 'CAMProductName'; | ||
@@ -61,4 +62,17 @@ const Environment = { | ||
// Redirect setter and getter | ||
/** | ||
* Generic cookie setting function | ||
* @param {string} cookie | ||
* @param {string} value | ||
*/ | ||
function setCookie(cookie, value) { | ||
Cookies.set(cookie, value, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
} | ||
// --- Redirects --- // | ||
/** | ||
@@ -71,6 +85,3 @@ * Set the redirect url for the given cookie type | ||
function setRedirectUrl(type, url) { | ||
Cookies.set(type, url, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
setCookie(type, url); | ||
} | ||
@@ -97,2 +108,22 @@ | ||
// --- Product name --- // | ||
/** | ||
* Set the name of the product to display within CAM | ||
* @param {string} productName | ||
*/ | ||
function setProductName(productName) { | ||
setCookie(CAM_PRODUCT_NAME_COOKIE, productName); | ||
} | ||
/** | ||
* Retrieve the product name | ||
* @returns {string} | ||
*/ | ||
function getProductName() { | ||
return Cookies.get(CAM_PRODUCT_NAME_COOKIE); | ||
} | ||
// Heavy-handed sign out function | ||
@@ -110,2 +141,2 @@ | ||
export { CAM_COOKIE_DOMAIN, CAM_DEFAULT_EXPIRATION_DAYS, CAM_LOGIN_REDIRECT_URL_COOKIE, CAM_SIGN_UP_REDIRECT_URL_COOKIE, Environment, clearAuthCookies, clearRedirectUrl, getAuthConfiguration, getRedirectUrl, setRedirectUrl }; | ||
export { CAM_COOKIE_DOMAIN, CAM_DEFAULT_EXPIRATION_DAYS, CAM_LOGIN_REDIRECT_URL_COOKIE, CAM_PRODUCT_NAME_COOKIE, CAM_SIGN_UP_REDIRECT_URL_COOKIE, Environment, clearAuthCookies, clearRedirectUrl, getAuthConfiguration, getProductName, getRedirectUrl, setProductName, setRedirectUrl }; |
@@ -170,2 +170,3 @@ (function (global, factory) { | ||
const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl'; | ||
const CAM_PRODUCT_NAME_COOKIE = 'CAMProductName'; | ||
@@ -224,4 +225,17 @@ const Environment = { | ||
// Redirect setter and getter | ||
/** | ||
* Generic cookie setting function | ||
* @param {string} cookie | ||
* @param {string} value | ||
*/ | ||
function setCookie(cookie, value) { | ||
js_cookie.set(cookie, value, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
} | ||
// --- Redirects --- // | ||
/** | ||
@@ -234,6 +248,3 @@ * Set the redirect url for the given cookie type | ||
function setRedirectUrl(type, url) { | ||
js_cookie.set(type, url, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
setCookie(type, url); | ||
} | ||
@@ -260,2 +271,22 @@ | ||
// --- Product name --- // | ||
/** | ||
* Set the name of the product to display within CAM | ||
* @param {string} productName | ||
*/ | ||
function setProductName(productName) { | ||
setCookie(CAM_PRODUCT_NAME_COOKIE, productName); | ||
} | ||
/** | ||
* Retrieve the product name | ||
* @returns {string} | ||
*/ | ||
function getProductName() { | ||
return js_cookie.get(CAM_PRODUCT_NAME_COOKIE); | ||
} | ||
// Heavy-handed sign out function | ||
@@ -276,2 +307,3 @@ | ||
exports.CAM_LOGIN_REDIRECT_URL_COOKIE = CAM_LOGIN_REDIRECT_URL_COOKIE; | ||
exports.CAM_PRODUCT_NAME_COOKIE = CAM_PRODUCT_NAME_COOKIE; | ||
exports.CAM_SIGN_UP_REDIRECT_URL_COOKIE = CAM_SIGN_UP_REDIRECT_URL_COOKIE; | ||
@@ -282,3 +314,5 @@ exports.Environment = Environment; | ||
exports.getAuthConfiguration = getAuthConfiguration; | ||
exports.getProductName = getProductName; | ||
exports.getRedirectUrl = getRedirectUrl; | ||
exports.setProductName = setProductName; | ||
exports.setRedirectUrl = setRedirectUrl; | ||
@@ -285,0 +319,0 @@ |
{ | ||
"name": "@britannica/cam-utils", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Consumer Account Management (CAM) auth configuration and utilities", | ||
@@ -48,7 +48,2 @@ "repository": "git://github.com/britannica/cam-utils.git", | ||
}, | ||
"standard-version": { | ||
"skip": { | ||
"commit": true | ||
} | ||
}, | ||
"husky": { | ||
@@ -55,0 +50,0 @@ "hooks": { |
# @britannica/cam-utils | ||
> Consumer Account Management (CAM) auth configuration and utilities |
@@ -0,0 +0,0 @@ import resolve from '@rollup/plugin-node-resolve'; |
@@ -7,2 +7,3 @@ import Cookies from 'js-cookie'; | ||
export const CAM_SIGN_UP_REDIRECT_URL_COOKIE = 'CAMSignUpRedirectUrl'; | ||
export const CAM_PRODUCT_NAME_COOKIE = 'CAMProductName'; | ||
@@ -61,4 +62,17 @@ export const Environment = { | ||
// Redirect setter and getter | ||
/** | ||
* Generic cookie setting function | ||
* @param {string} cookie | ||
* @param {string} value | ||
*/ | ||
function setCookie(cookie, value) { | ||
Cookies.set(cookie, value, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
} | ||
// --- Redirects --- // | ||
/** | ||
@@ -71,6 +85,3 @@ * Set the redirect url for the given cookie type | ||
export function setRedirectUrl(type, url) { | ||
Cookies.set(type, url, { | ||
domain: CAM_COOKIE_DOMAIN, | ||
expires: CAM_DEFAULT_EXPIRATION_DAYS, | ||
}); | ||
setCookie(type, url); | ||
} | ||
@@ -97,2 +108,22 @@ | ||
// --- Product name --- // | ||
/** | ||
* Set the name of the product to display within CAM | ||
* @param {string} productName | ||
*/ | ||
export function setProductName(productName) { | ||
setCookie(CAM_PRODUCT_NAME_COOKIE, productName); | ||
} | ||
/** | ||
* Retrieve the product name | ||
* @returns {string} | ||
*/ | ||
export function getProductName() { | ||
return Cookies.get(CAM_PRODUCT_NAME_COOKIE); | ||
} | ||
// Heavy-handed sign out function | ||
@@ -99,0 +130,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
22546
643