Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vtex-render-session

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vtex-render-session - npm Package Compare versions

Comparing version 1.4.12-beta to 1.5.0

.prettierignore

14

CHANGELOG.md

@@ -10,12 +10,8 @@ # Changelog

## [1.4.12-beta] - 2019-09-06
## [1.5.0] - 2019-09-25
### Changed
- Add more fields to constants.ts, to get more fields from session.
## [1.4.11-beta] - 2019-09-06
## [1.4.1] - 2019-09-24
## [1.4.10-beta] - 2019-09-06
## [1.4.9-beta] - 2019-09-06
## [1.4.8-beta] - 2019-09-06
## [1.4.0] - 2019-07-11

@@ -60,2 +56,2 @@

### Added
- Copy of the code available in the render runtime to a separate bundle to provide session
- Copy of the code available in the render runtime to a separate bundle to provide session

@@ -89,2 +89,39 @@ /******/ (function(modules) { // webpackBootstrap

/***/ "./constants.ts":
/*!**********************!*\
!*** ./constants.ts ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ITEMS = [
"account.id",
"account.accountName",
"store.channel",
"store.countryCode",
"store.cultureInfo",
"store.currencyCode",
"store.currencySymbol",
"store.admin_cultureInfo",
"creditControl.creditAccounts",
"creditControl.deadlines",
"creditControl.minimumInstallmentValue",
"authentication.storeUserId",
"authentication.storeUserEmail",
"profile.firstName",
"profile.document",
"profile.email",
"profile.id",
"profile.isAuthenticated",
"profile.lastName",
"profile.phone",
"public.favoritePickup"
];
/***/ }),
/***/ "./index.ts":

@@ -100,48 +137,23 @@ /*!******************!*\

Object.defineProperty(exports, "__esModule", { value: true });
var constants_1 = __webpack_require__(/*! ./constants */ "./constants.ts");
var delay = function (ms) {
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
};
var supportedLocales = window.__RUNTIME__ && window.__RUNTIME__.culture && window.__RUNTIME__.culture.availableLocales || [];
var rootPath = window.__RUNTIME__ && window.__RUNTIME__.rootPath || '';
var RETRY_STATUSES = [408, 425, 429, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511];
var FETCH_TIMEOUT = 5000;
var canRetry = function (status) { return RETRY_STATUSES.includes(status); };
var ok = function (status) { return 200 <= status && status < 300; };
var fetchWithRetry = function (url, init, maxRetries) {
if (maxRetries === void 0) { maxRetries = 1; }
if (maxRetries === void 0) { maxRetries = 3; }
var status = 500;
var didTimeOut = false;
var callFetch = function (attempt) {
if (attempt === void 0) { attempt = 0; }
return new Promise(function (resolve, reject) {
var timeout = setTimeout(function () {
didTimeOut = true;
reject(new Error('Fetch timed out'));
}, FETCH_TIMEOUT);
fetch(url, init).then(function (response) {
clearTimeout(timeout);
if (!didTimeOut) {
resolve(response);
}
}).catch(function (err) {
if (didTimeOut) {
return;
}
reject(err);
});
}).then(function (response) {
return fetch(url, init).then(function (response) {
status = response.status;
return ok(status)
? { response: response, error: null }
: response.json()
.then(function (error) { return ({ response: response, error: error }); })
.catch(function () { return ({ response: response, error: { message: 'Unable to parse JSON' } }); });
}).then(function (_a) {
var error = _a.error;
if (error) {
throw new Error(error.message || 'Unknown error');
}
return response.json()
.then(function (data) { return ({ response: data, error: null }); });
}).catch(function (error) {
console.error(error);
if (attempt >= maxRetries || !canRetry(status) || didTimeOut) {
return; // no session is fine for now
if (attempt >= maxRetries || !canRetry(status)) {
return { response: null, error: { message: 'Maximum number of attempts achieved' } };
}

@@ -161,3 +173,7 @@ var ms = (Math.pow(2, attempt)) * 500;

}).catch(function (err) { return console.log('Error while patching session with error: ', err); }); };
var sessionPromise = fetchWithRetry("http://localhost:3000", {
var items = (window.location.search ? '&' : '?') + "items=" + constants_1.ITEMS.join(',');
var supportedLocalesSearch = supportedLocales.length > 0
? "&supportedLocales=" + supportedLocales.join(',')
: '';
var sessionPromise = fetchWithRetry(rootPath + "/api/sessions" + window.location.search + items + supportedLocalesSearch, {
body: '{}',

@@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mc3VwcG9ydGVkTG9jYWxlcz0ke3N1cHBvcnRlZExvY2FsZXMuam9pbignLCcpfWBcbiAgOiAnJ1xuXG5jb25zdCBzZXNzaW9uUHJvbWlzZSA9IGZldGNoV2l0aFJldHJ5KGAke3Jvb3RQYXRofS9hcGkvc2Vzc2lvbnMke3dpbmRvdy5sb2NhdGlvbi5zZWFyY2h9JHtpdGVtc30ke3N1cHBvcnRlZExvY2FsZXNTZWFyY2h9YCwge1xuICBib2R5OiAne30nLFxuICBjcmVkZW50aWFsczogJ3NhbWUtb3JpZ2luJyxcbiAgaGVhZGVyczogbmV3IEhlYWRlcnMoeyAnQ29udGVudC1UeXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nIH0pLFxuICBtZXRob2Q6ICdQT1NUJyxcbn0pLmNhdGNoKGVyciA9PiBjb25zb2xlLmxvZygnRXJyb3Igd2hpbGUgbG9hZGluZyBzZXNzaW9uIHdpdGggZXJyb3I6ICcsIGVycikpO1xuXG4od2luZG93IGFzIGFueSkuX19SRU5ERVJfN19TRVNTSU9OX18gPSAod2luZG93IGFzIGFueSkuX19SRU5ERVJfOF9TRVNTSU9OX18gPSB7XG4gIHBhdGNoU2Vzc2lvbixcbiAgc2Vzc2lvblByb21pc2UsXG59XG5cbmV4cG9ydCB7fSJdLCJzb3VyY2VSb290IjoiIn0=

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

!function(e){var n={};function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,n){if(1&n&&(e=r(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)r.d(t,o,function(n){return e[n]}.bind(null,o));return t},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="/",r(r.s=0)}([function(e,n,r){e.exports=r(1)},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=window.__RUNTIME__&&window.__RUNTIME__.rootPath||"",o=[408,425,429,500,501,502,503,504,505,506,507,508,510,511],i=function(e,n,r){void 0===r&&(r=1);var t=500,i=!1,u=function(c){return void 0===c&&(c=0),new Promise(function(r,t){var o=setTimeout(function(){i=!0,t(new Error("Fetch timed out"))},5e3);fetch(e,n).then(function(e){clearTimeout(o),i||r(e)}).catch(function(e){i||t(e)})}).then(function(e){return function(e){return 200<=e&&e<300}(t=e.status)?{response:e,error:null}:e.json().then(function(n){return{response:e,error:n}}).catch(function(){return{response:e,error:{message:"Unable to parse JSON"}}})}).then(function(e){var n=e.error;if(n)throw new Error(n.message||"Unknown error")}).catch(function(e){if(console.error(e),!(c>=r||!function(e){return o.includes(e)}(t)||i))return function(e){return new Promise(function(n){return setTimeout(n,e)})}(500*Math.pow(2,c)).then(function(){return u(++c)})})};return u()},u=i("http://localhost:3000",{body:"{}",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),method:"POST"}).catch(function(e){return console.log("Error while loading session with error: ",e)});window.__RENDER_7_SESSION__=window.__RENDER_8_SESSION__={patchSession:function(e){return i(t+"/api/sessions"+window.location.search,{body:e?JSON.stringify(e):"{}",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),method:"PATCH"}).catch(function(e){return console.log("Error while patching session with error: ",e)})},sessionPromise:u}}]);
!function(e){var n={};function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)t.d(o,r,function(n){return e[n]}.bind(null,r));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/",t(t.s=0)}([function(e,n,t){e.exports=t(1)},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=t(2),r=window.__RUNTIME__&&window.__RUNTIME__.culture&&window.__RUNTIME__.culture.availableLocales||[],i=window.__RUNTIME__&&window.__RUNTIME__.rootPath||"",u=[408,425,429,500,501,502,503,504,505,506,507,508,510,511],c=function(e,n,t){void 0===t&&(t=3);var o=500,r=function(i){return void 0===i&&(i=0),fetch(e,n).then(function(e){return o=e.status,e.json().then(function(e){return{response:e,error:null}})}).catch(function(e){return console.error(e),i>=t||!function(e){return u.includes(e)}(o)?{response:null,error:{message:"Maximum number of attempts achieved"}}:function(e){return new Promise(function(n){return setTimeout(n,e)})}(500*Math.pow(2,i)).then(function(){return r(++i)})})};return r()},s=(window.location.search?"&":"?")+"items="+o.ITEMS.join(","),a=r.length>0?"&supportedLocales="+r.join(","):"",l=c(i+"/api/sessions"+window.location.search+s+a,{body:"{}",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),method:"POST"}).catch(function(e){return console.log("Error while loading session with error: ",e)});window.__RENDER_7_SESSION__=window.__RENDER_8_SESSION__={patchSession:function(e){return c(i+"/api/sessions"+window.location.search,{body:e?JSON.stringify(e):"{}",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json"}),method:"PATCH"}).catch(function(e){return console.log("Error while patching session with error: ",e)})},sessionPromise:l}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.ITEMS=["account.id","account.accountName","store.channel","store.countryCode","store.cultureInfo","store.currencyCode","store.currencySymbol","store.admin_cultureInfo","creditControl.creditAccounts","creditControl.deadlines","creditControl.minimumInstallmentValue","authentication.storeUserId","authentication.storeUserEmail","profile.firstName","profile.document","profile.email","profile.id","profile.isAuthenticated","profile.lastName","profile.phone","public.favoritePickup"]}]);
{
"name": "vtex-render-session",
"version": "1.4.12-beta",
"version": "1.5.0",
"description": "Adds session as external to render runtime",

@@ -5,0 +5,0 @@ "scripts": {

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

import { ITEMS } from './constants'
interface SessionResponse {
response: Response | null,
error: any,
}
const delay = (ms: number): Promise<void> => {

@@ -16,47 +23,21 @@ return new Promise(resolve => setTimeout(resolve, ms))

const supportedLocales = window.__RUNTIME__ && window.__RUNTIME__.culture && window.__RUNTIME__.culture.availableLocales || []
const rootPath = window.__RUNTIME__ && window.__RUNTIME__.rootPath || ''
const RETRY_STATUSES = [ 408, 425, 429, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511 ]
const FETCH_TIMEOUT = 5000
const canRetry = (status: number) => RETRY_STATUSES.includes(status)
const ok = (status: number) => 200 <= status && status < 300
const fetchWithRetry = (url: string, init: RequestInit, maxRetries: number = 1): Promise<void> => {
const fetchWithRetry = (url: string, init: RequestInit, maxRetries: number = 3) => {
let status = 500
let didTimeOut = false
const callFetch = (attempt: number = 0): Promise<void> =>
new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
didTimeOut = true
reject(new Error('Fetch timed out'))
}, FETCH_TIMEOUT)
fetch(url, init).then((response) => {
clearTimeout(timeout)
if (!didTimeOut) {
resolve(response)
}
}).catch((err) => {
if (didTimeOut) {
return
}
reject(err)
})
}).then((response) => {
status = (response as any).status
return ok(status)
? { response, error: null }
: (response as any).json()
.then((error: any) => ({ response, error }))
.catch(() => ({ response, error: { message: 'Unable to parse JSON' } }))
}).then(({ error }: any) => {
if (error) {
throw new Error(error.message || 'Unknown error')
}
const callFetch = (attempt: number = 0): Promise<SessionResponse>=>
fetch(url, init).then((response: Response) => {
status = response.status
return response.json()
.then((data: any) => ({response: data, error: null}))
}).catch((error) => {
console.error(error)
if (attempt >= maxRetries || !canRetry(status) || didTimeOut) {
return // no session is fine for now
if (attempt >= maxRetries || !canRetry(status)) {
return {response: null, error: {message: 'Maximum number of attempts achieved'}} as SessionResponse
}

@@ -79,4 +60,9 @@

const items = `${window.location.search ? '&' : '?'}items=${ITEMS.join(',')}`
const sessionPromise = fetchWithRetry(`http://localhost:3000`, {
const supportedLocalesSearch = supportedLocales.length > 0
? `&supportedLocales=${supportedLocales.join(',')}`
: ''
const sessionPromise = fetchWithRetry(`${rootPath}/api/sessions${window.location.search}${items}${supportedLocalesSearch}`, {
body: '{}',

@@ -93,2 +79,2 @@ credentials: 'same-origin',

export {}
export {}
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