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

@adobe-mcid/visitor-js-server

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adobe-mcid/visitor-js-server - npm Package Compare versions

Comparing version

to
2.1.0

4

lib/amcv-cookie.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!(i&&_arr.length===i));_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target};/*************************************************************************
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!(i&&_arr.length===i));_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target};/*************************************************************************
* ADOBE CONFIDENTIAL

@@ -32,2 +32,2 @@ * ___________________

*/// Parse into: { settingsDigest: { value: 3213, expire: 0, shouldExpireOnSession: false, hasExpired: false... }}
function isSettingsDigest(a){return a.match(/^[\-0-9]+$/)}function parseSettingsDigest(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(isSettingsDigest(a[0])){var c={value:a[0],hasExpired:!1,shouldExpireOnSession:!1,expire:0};b.settingsDigest=c,a.shift(),1==a.length%2&&a.pop()}return b}function makeAmcvEntry(a){var b=new Date;return _extends({},a,{hasExpired:!!(0<a.expire&&b.getTime()>=1000*a.expire)})}var amcvCookie={pickValues:function pickValues(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],c=amcvCookie.parse(a);return b.reduce(function(d,e){var f=c[e];return f&&(d[e]=f.value),d},{})},parse:function parse(a){if(!a||"T"===a)return{};var b=decodeURIComponent(a).split("|"),c=parseSettingsDigest(b);for(var d=0,e=b.length;d<e;d+=2){var _b$d$split=b[d].split("-"),_b$d$split2=_slicedToArray(_b$d$split,2),f=_b$d$split2[0],_b$d$split2$=_b$d$split2[1],g=_b$d$split2$===void 0?0:_b$d$split2$,h=b[d+1],j=!!(g&&g.includes("s")),k=g?parseInt(g,10):g;c[f]=makeAmcvEntry({value:h,expire:k,shouldExpireOnSession:j})}return c}};exports.default=amcvCookie;module.exports=exports["default"];
function isSettingsDigest(a){return a.match(/^[\-0-9]+$/)}function parseSettingsDigest(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(isSettingsDigest(a[0])){var c={value:a[0],hasExpired:!1,shouldExpireOnSession:!1,expire:0};b.settingsDigest=c,a.shift(),1==a.length%2&&a.pop()}return b}function makeAmcvEntry(a){var b=new Date;return _extends({},a,{hasExpired:!!(0<a.expire&&b.getTime()>=1000*a.expire)})}var amcvCookie={pickValues:function pickValues(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],c=amcvCookie.parse(a);return b.reduce(function(d,e){var f=c[e];return f&&(d[e]=f.value),d},{})},parse:function parse(a){if(!a||"T"===a)return{};for(var b=decodeURIComponent(a).split("|"),c=parseSettingsDigest(b),d=0,e=b.length;d<e;d+=2){var _b$d$split=b[d].split("-"),_b$d$split2=_slicedToArray(_b$d$split,2),f=_b$d$split2[0],_b$d$split2$=_b$d$split2[1],g=_b$d$split2$===void 0?0:_b$d$split2$,h=b[d+1],j=!!(g&&g.includes("s")),k=g?parseInt(g,10):g;c[f]=makeAmcvEntry({value:h,expire:k,shouldExpireOnSession:j})}return c}};exports.default=amcvCookie;module.exports=exports["default"];

@@ -17,2 +17,5 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _visitorJsShared=require("@adobe-mcid/visitor-js-shared"),_amcvCookie=require("./amcv-cookie");function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}/*************************************************************************

* from Adobe Systems Incorporated.
**************************************************************************/var CONSUMER_ID_BASE="payload:",AMCV_PREFIX="AMCV_",ORG_ID_REQUIRED="Org ID is required",CONSUMER_ID_REQUIRED="Consumer ID is required",throwError=function throwError(a){throw new Error(a)},normalizeOrgId=function normalizeOrgId(a){return 0>a.indexOf("@")?a+"@AdobeOrg":a};function Visitor(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:throwError(ORG_ID_REQUIRED),b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,c={},d=normalizeOrgId(a),e=function e(g){return c=Object.assign({},c,g)},f=(0,_visitorJsShared.supplementalDataIDFactory)();this.getVisitorValues=function(){return b?(0,_amcvCookie.pickValues)(b,["MCMID","MCAAMB","MCAAMLH"]):{}},this.getSupplementalDataID=function(){var g=0<arguments.length&&void 0!==arguments[0]?arguments[0]:throwError(CONSUMER_ID_REQUIRED),h=f.getID(""+CONSUMER_ID_BASE+g),i=f.getState();return e({sdid:i}),h},this.setCustomerIDs=function(){var g=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};e({customerIDs:g})},this.getState=function(){return _defineProperty({},d,c)},this.getCookieName=function(){return AMCV_PREFIX+d}}Visitor.AuthState=_visitorJsShared.AuthState;exports.default=Visitor;module.exports=exports["default"];
**************************************************************************/var CONSUMER_ID_BASE="payload:",AMCV_PREFIX="AMCV_",ORG_ID_REQUIRED="Org ID is required",CONSUMER_ID_REQUIRED="Consumer ID is required",ADOBE_MC_SDID="adobe_mc_sdid",SDID_PARAM_EXPIRY=30,throwError=function throwError(a){throw new Error(a)},normalizeOrgId=function normalizeOrgId(a){return 0>a.indexOf("@")?a+"@AdobeOrg":a};function Visitor(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:throwError(ORG_ID_REQUIRED),b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,c={},d=normalizeOrgId(a),e=function e(l){return c=Object.assign({},c,l)},f=(0,_visitorJsShared.supplementalDataIDFactory)(),g=function g(l,m){var n=new RegExp("[\\?&#]"+m+"=([^&#]*)"),o=n.exec(l);if(o&&o.length)return decodeURIComponent(o[1])},h=function h(l){// Parse '|' delimited k=v pairs into an object.
var m=l.split("|");return m.reduce(function(n,o){var p=o.split("=");return n[p[0]]=decodeURIComponent(p[1]),n},{})},i=function i(){return Math.round(new Date().getTime()/1000)},k=function(j){return function(r){var s=r||global.location.href;try{var t=g(s,j);if(t)return h(t)}catch(u){// Fail silently.
}}}(ADOBE_MC_SDID);this.getVisitorValues=function(){return b?(0,_amcvCookie.pickValues)(b,["MCMID","MCAAMB","MCAAMLH"]):{}},this.getSupplementalDataID=function(){var l=0<arguments.length&&void 0!==arguments[0]?arguments[0]:throwError(CONSUMER_ID_REQUIRED),m=f.getID(""+CONSUMER_ID_BASE+l),n=f.getState();return e({sdid:n}),m},this.attemptToPopulateSdidFromUrl=function(l){var m=k(l),n=1000000000,o=f.getState();// expired
m&&m.TS&&(n=i()-m.TS),m&&m.SDID&&m.MCORGID===d&&n<SDID_PARAM_EXPIRY&&(o.supplementalDataIDCurrent=m.SDID,o.supplementalDataIDCurrentConsumed.SDID_URL_PARAM=!0,e({sdid:o}))},this.setCustomerIDs=function(){var l=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};e({customerIDs:l})},this.getState=function(){return _defineProperty({},d,c)},this.getCookieName=function(){return AMCV_PREFIX+d}}Visitor.AuthState=_visitorJsShared.AuthState;exports.default=Visitor;module.exports=exports["default"];
{
"name": "@adobe-mcid/visitor-js-server",
"version": "2.0.0",
"version": "2.1.0",
"description": "Server compatible Visitor ID service",

@@ -13,3 +13,3 @@ "main": "lib/Visitor.js",

"build": "babel src --out-dir lib",
"prepublish": "npm run build && autochecker 4.4.2 5.10.1 6.2.2"
"prepublish": "npm run build && autochecker 6.2.2 6.17.1"
},

@@ -16,0 +16,0 @@ "pre-commit": [

@@ -10,2 +10,3 @@ # Visitor JS - Server Side

- getSupplementalDataID(sdidConsumerID): String
- attemptToPopulateSdidFromUrl(redirectURL)
- setCustomerIDs(object: customerIDs)

@@ -68,3 +69,3 @@ - getState() : State { OrgID: { sdid, customerIDs }

// 2. Instantiate Visitor instance
const visitor = new Visitor("<orgId>", amcvCookie);
const visitor = new Visitor("<orgId>", amcvCookie);

@@ -76,3 +77,21 @@ //3. Retrieve SDID

```
## `attemptToPopulateSdidFromUrl(redirectURL)`
This method looks for an `adobe_mc_sdid` param in the URL. If found, parse it and look for SDID and CONSUMER, and try to set those IDs as supplemental Data IDs.
```javascript
// 1. Retrieve the AMCV cookie from the request.
var cookies = cookie.parse(req.headers.cookie || "");
var cookieName = visitor.getCookieName();
var amcvCookie = cookies[cookieName];
// 2. Instantiate Visitor instance
const visitor = new Visitor("<orgId>", amcvCookie);
//3. Attempt to populate SDIDs from
visitor.attemptToPopulateSdidFromUrl(redirectURL);
...
```
## `getState`

@@ -79,0 +98,0 @@