From ff0643644b9f0a9bd70626bfef234f759913432c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Ja=C5=A1ek?= <48070343+dominikjasek@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:23:10 +0200 Subject: [PATCH] Use production domain for cookies on staging (#16) --- CHANGELOG.md | 6 ++++++ dist/signalerjs.min.js | 2 +- package.json | 2 +- src/helpers.js | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ce1495..7249c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2024-07-18 + +### Changed + +- On staging, use production domain `.customink.com` + ## [1.1.0] - 2024-07-18 diff --git a/dist/signalerjs.min.js b/dist/signalerjs.min.js index 345cbf0..15c4c92 100644 --- a/dist/signalerjs.min.js +++ b/dist/signalerjs.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.signalerjs=t():e.signalerjs=t()}(self,(function(){return function(){var e={560:function(e,t,n){var r;!function(o){"use strict";function u(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function c(e,t,n,r,o,c){return u((i=u(u(t,e),u(r,c)))<<(a=o)|i>>>32-a,n);var i,a}function i(e,t,n,r,o,u,i){return c(t&n|~t&r,e,t,o,u,i)}function a(e,t,n,r,o,u,i){return c(t&r|n&~r,e,t,o,u,i)}function f(e,t,n,r,o,u,i){return c(t^n^r,e,t,o,u,i)}function s(e,t,n,r,o,u,i){return c(n^(t|~r),e,t,o,u,i)}function l(e,t){var n,r,o,c,l;e[t>>5]|=128<>>9<<4)]=t;var p=1732584193,d=-271733879,g=-1732584194,y=271733878;for(n=0;n>5]>>>t%32&255);return n}function d(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function y(e){return unescape(encodeURIComponent(e))}function h(e){return function(e){return p(l(d(e),8*e.length))}(y(e))}function v(e,t){return function(e,t){var n,r,o=d(e),u=[],c=[];for(u[15]=c[15]=void 0,o.length>16&&(o=l(o,8*e.length)),n=0;n<16;n+=1)u[n]=909522486^o[n],c[n]=1549556828^o[n];return r=l(u.concat(d(t)),512+8*t.length),p(l(c.concat(r),640))}(y(e),y(t))}function m(e,t,n){return t?n?v(t,e):g(v(t,e)):n?h(e):g(h(e))}void 0===(r=function(){return m}.call(t,n,t,e))||(e.exports=r)}()},360:function(e,t,n){var r;!function(o,u){"use strict";var c=function(e){if("object"!=typeof e.document)throw new Error("Cookies.js requires a `window` with a `document` object");var t=function(e,n,r){return 1===arguments.length?t.get(e):t.set(e,n,r)};return t._document=e.document,t._cacheKeyPrefix="cookey.",t._maxExpireDate=new Date("Fri, 31 Dec 9999 23:59:59 UTC"),t.defaults={path:"/",secure:!1},t.get=function(e){t._cachedDocumentCookie!==t._document.cookie&&t._renewCache();var n=t._cache[t._cacheKeyPrefix+e];return n===u?u:decodeURIComponent(n)},t.set=function(e,n,r){return(r=t._getExtendedOptions(r)).expires=t._getExpiresDate(n===u?-1:r.expires),t._document.cookie=t._generateCookieString(e,n,r),t},t.expire=function(e,n){return t.set(e,u,n)},t._getExtendedOptions=function(e){return{path:e&&e.path||t.defaults.path,domain:e&&e.domain||t.defaults.domain,expires:e&&e.expires||t.defaults.expires,secure:e&&e.secure!==u?e.secure:t.defaults.secure}},t._isValidDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e.getTime())},t._getExpiresDate=function(e,n){if(n=n||new Date,"number"==typeof e?e=e===1/0?t._maxExpireDate:new Date(n.getTime()+1e3*e):"string"==typeof e&&(e=new Date(e)),e&&!t._isValidDate(e))throw new Error("`expires` parameter cannot be converted to a valid Date instance");return e},t._generateCookieString=function(e,t,n){var r=(e=(e=e.replace(/[^#$&+\^`|]/g,encodeURIComponent)).replace(/\(/g,"%28").replace(/\)/g,"%29"))+"="+(t=(t+"").replace(/[^!#$&-+\--:<-\[\]-~]/g,encodeURIComponent));return r+=(n=n||{}).path?";path="+n.path:"",r+=n.domain?";domain="+n.domain:"",(r+=n.expires?";expires="+n.expires.toUTCString():"")+(n.secure?";secure":"")},t._getCacheFromString=function(e){for(var n={},r=e?e.split("; "):[],o=0;o=t?(u=!0,e):void 0}))[0]||null},e.exports=t.default}])}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var u=t[r]={exports:{}};return e[r].call(u.exports,u,u.exports,n),u.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}n.r(r),n.d(r,{default:function(){return b}});var o=n(560),u=n.n(o),c=n(360),i=n.n(c),a=n(789),f=n.n(a);function s(e){var t=Date.now();return new Date(t+864e5*e).toUTCString()}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function p(t){for(var n=1;n2?".".concat(g.slice(1).join(".")):".".concat(d)),expires:s(30)},h=function(e){var t={};return e.map((function(e){t[e]=v(e)})),t},v=function(e){var t=i().get(u()(e));return t?(i().set("feature_".concat(e),t),i().expire(u()(e))):t=i().get("feature_".concat(e)),t},m=function(e){switch(t(e)){case"string":return{expires:e};case"number":return{expires:s(e)};default:return{}}};function b(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.transformCookieOptions||function(e){return e};i().defaults=p(p({},y),n.cookieDefaults);var o=function(){return"string"===t(e)?window.fetch("".concat(e,".json")).then((function(e){return e.json()})).then((function(e){return h(Object.keys(e))})):new Promise((function(t){return t(h(Object.keys(e)))}))},u=function(t){var n=v(t);if(n)return n;var r=e[t],o=f()(r.flags),u=m(r.expires);return a(t,o,u),o},c=function(t){return window.fetch("".concat(e,"/").concat(t,".json")).then((function(e){return e.json()})).then((function(e){var n=m(e.expires);return a(t,e.flag,n),e.flag}))},a=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i().set("feature_".concat(e),t,r(n))};return{featureFlags:o,featureFlag:u,featureFlagFromServer:c,setFeatureFlag:a}}}(),r}()})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.signalerjs=t():e.signalerjs=t()}(self,(function(){return function(){var e={560:function(e,t,n){var r;!function(o){"use strict";function u(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function c(e,t,n,r,o,c){return u((i=u(u(t,e),u(r,c)))<<(a=o)|i>>>32-a,n);var i,a}function i(e,t,n,r,o,u,i){return c(t&n|~t&r,e,t,o,u,i)}function a(e,t,n,r,o,u,i){return c(t&r|n&~r,e,t,o,u,i)}function f(e,t,n,r,o,u,i){return c(t^n^r,e,t,o,u,i)}function s(e,t,n,r,o,u,i){return c(n^(t|~r),e,t,o,u,i)}function l(e,t){var n,r,o,c,l;e[t>>5]|=128<>>9<<4)]=t;var p=1732584193,d=-271733879,g=-1732584194,y=271733878;for(n=0;n>5]>>>t%32&255);return n}function d(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function y(e){return unescape(encodeURIComponent(e))}function h(e){return function(e){return p(l(d(e),8*e.length))}(y(e))}function v(e,t){return function(e,t){var n,r,o=d(e),u=[],c=[];for(u[15]=c[15]=void 0,o.length>16&&(o=l(o,8*e.length)),n=0;n<16;n+=1)u[n]=909522486^o[n],c[n]=1549556828^o[n];return r=l(u.concat(d(t)),512+8*t.length),p(l(c.concat(r),640))}(y(e),y(t))}function m(e,t,n){return t?n?v(t,e):g(v(t,e)):n?h(e):g(h(e))}void 0===(r=function(){return m}.call(t,n,t,e))||(e.exports=r)}()},360:function(e,t,n){var r;!function(o,u){"use strict";var c=function(e){if("object"!=typeof e.document)throw new Error("Cookies.js requires a `window` with a `document` object");var t=function(e,n,r){return 1===arguments.length?t.get(e):t.set(e,n,r)};return t._document=e.document,t._cacheKeyPrefix="cookey.",t._maxExpireDate=new Date("Fri, 31 Dec 9999 23:59:59 UTC"),t.defaults={path:"/",secure:!1},t.get=function(e){t._cachedDocumentCookie!==t._document.cookie&&t._renewCache();var n=t._cache[t._cacheKeyPrefix+e];return n===u?u:decodeURIComponent(n)},t.set=function(e,n,r){return(r=t._getExtendedOptions(r)).expires=t._getExpiresDate(n===u?-1:r.expires),t._document.cookie=t._generateCookieString(e,n,r),t},t.expire=function(e,n){return t.set(e,u,n)},t._getExtendedOptions=function(e){return{path:e&&e.path||t.defaults.path,domain:e&&e.domain||t.defaults.domain,expires:e&&e.expires||t.defaults.expires,secure:e&&e.secure!==u?e.secure:t.defaults.secure}},t._isValidDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e.getTime())},t._getExpiresDate=function(e,n){if(n=n||new Date,"number"==typeof e?e=e===1/0?t._maxExpireDate:new Date(n.getTime()+1e3*e):"string"==typeof e&&(e=new Date(e)),e&&!t._isValidDate(e))throw new Error("`expires` parameter cannot be converted to a valid Date instance");return e},t._generateCookieString=function(e,t,n){var r=(e=(e=e.replace(/[^#$&+\^`|]/g,encodeURIComponent)).replace(/\(/g,"%28").replace(/\)/g,"%29"))+"="+(t=(t+"").replace(/[^!#$&-+\--:<-\[\]-~]/g,encodeURIComponent));return r+=(n=n||{}).path?";path="+n.path:"",r+=n.domain?";domain="+n.domain:"",(r+=n.expires?";expires="+n.expires.toUTCString():"")+(n.secure?";secure":"")},t._getCacheFromString=function(e){for(var n={},r=e?e.split("; "):[],o=0;o=t?(u=!0,e):void 0}))[0]||null},e.exports=t.default}])}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var u=t[r]={exports:{}};return e[r].call(u.exports,u,u.exports,n),u.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}n.r(r),n.d(r,{default:function(){return b}});var o=n(560),u=n.n(o),c=n(360),i=n.n(c),a=n(789),f=n.n(a);function s(e){var t=Date.now();return new Date(t+864e5*e).toUTCString()}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function p(t){for(var n=1;n2?".".concat(g.slice(g.length-2).join(".")):".".concat(d)),expires:s(30)},h=function(e){var t={};return e.map((function(e){t[e]=v(e)})),t},v=function(e){var t=i().get(u()(e));return t?(i().set("feature_".concat(e),t),i().expire(u()(e))):t=i().get("feature_".concat(e)),t},m=function(e){switch(t(e)){case"string":return{expires:e};case"number":return{expires:s(e)};default:return{}}};function b(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.transformCookieOptions||function(e){return e};i().defaults=p(p({},y),n.cookieDefaults);var o=function(){return"string"===t(e)?window.fetch("".concat(e,".json")).then((function(e){return e.json()})).then((function(e){return h(Object.keys(e))})):new Promise((function(t){return t(h(Object.keys(e)))}))},u=function(t){var n=v(t);if(n)return n;var r=e[t],o=f()(r.flags),u=m(r.expires);return a(t,o,u),o},c=function(t){return window.fetch("".concat(e,"/").concat(t,".json")).then((function(e){return e.json()})).then((function(e){var n=m(e.expires);return a(t,e.flag,n),e.flag}))},a=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i().set("feature_".concat(e),t,r(n))};return{featureFlags:o,featureFlag:u,featureFlagFromServer:c,setFeatureFlag:a}}}(),r}()})); \ No newline at end of file diff --git a/package.json b/package.json index 77d448b..a5e4b4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@customink/signalerjs", - "version": "1.1.0", + "version": "1.2.0", "description": "JavaScript A/B testing feature flag library", "main": "dist/signalerjs.min.js", "scripts": { diff --git a/src/helpers.js b/src/helpers.js index 24e3464..d8a60a9 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,7 +1,7 @@ export function defaultDomain(hostname) { const hostArray = hostname.split('.'); return hostArray.length > 2 - ? `.${hostArray.slice(1).join('.')}` + ? `.${hostArray.slice(hostArray.length-2).join('.')}` : `.${hostname}`; }