@oddnetworks/oddworks
Advanced tools
Comparing version 3.5.1 to 3.7.0
# Changelog | ||
## 3.7.0 Unstable | ||
- Fixes a bug in the CORS headers middleware | ||
- Report upstream source errors, but return cached content anyway | ||
- Fix redis-search store | ||
- Authorization warns if Authentication failed | ||
- Fix search request parameter handling | ||
## 3.5.0 Unstable | ||
@@ -4,0 +11,0 @@ - Return [401 if channel/platform not active](https://github.com/oddnetworks/oddworks/pull/115) |
@@ -20,2 +20,10 @@ 'use strict'; | ||
return function authorizeMiddleware(req, res, next) { | ||
if (!req.identity) { | ||
debug('missing-identity: req.identity not set, is request-authenticate middleware missing?'); | ||
bus.broadcast( | ||
{level: 'warn', event: 'missing-identity'}, | ||
{message: 'req.identity not set, is request-authenticate middleware missing?', error: null} | ||
); | ||
} | ||
let audience = (req.identity || {}).audience; | ||
@@ -22,0 +30,0 @@ if (!audience) { |
@@ -6,3 +6,3 @@ 'use strict'; | ||
if (req.method === 'OPTIONS') { | ||
res.send(200); | ||
res.sendStatus(200); | ||
req.connection.destroy(); | ||
@@ -9,0 +9,0 @@ } else { |
@@ -16,3 +16,3 @@ 'use strict'; | ||
'X-Requested-With', | ||
'Autorization', | ||
'Authorization', | ||
'Content-Type', | ||
@@ -19,0 +19,0 @@ 'Accept', |
@@ -104,7 +104,7 @@ 'use strict'; | ||
let baseUrl = `${req.protocol}://${req.hostname}`; | ||
const port = req.socket.address().port.toString(); | ||
const port = req.socket.address().port || process.env.PORT; | ||
let defaultPort = false; | ||
if ((req.protocol === 'http' && port === '80') || | ||
(req.protocol === 'https' && port === '443')) { | ||
if ((req.protocol === 'http' && port === 80) || | ||
(req.protocol === 'https' && port === 443)) { | ||
defaultPort = true; | ||
@@ -111,0 +111,0 @@ } |
@@ -14,3 +14,3 @@ 'use strict'; | ||
this.bus | ||
.query({role: 'catalog', cmd: 'search'}, {query: req.query.q}) | ||
.query({role: 'catalog', cmd: 'search'}, {query: req.query.q, channel: req.identity.channel.id, type: req.query.type}) | ||
.then(objects => { | ||
@@ -17,0 +17,0 @@ res.body = objects; |
@@ -78,3 +78,3 @@ 'use strict'; | ||
return checkCache(channel, object).then(resource => { | ||
return checkCache(service.bus, channel, object).then(resource => { | ||
// Update the meta again. | ||
@@ -110,5 +110,17 @@ // TODO: Bring back string interpolation | ||
function checkCache(channel, object) { | ||
function checkCache(bus, channel, object) { | ||
const now = _.now(); | ||
function handleSourceError(err) { | ||
const event = { | ||
code: 'UPSTREAM_FAILURE', | ||
spec: object.spec, | ||
message: 'upstream source failed', | ||
error: err | ||
}; | ||
bus.broadcast({level: 'error'}, event); | ||
return object; | ||
} | ||
// maxAge and staleWhileRevalidate are in seconds (so we multiply by 1000) | ||
@@ -132,3 +144,3 @@ | ||
if (promise) { | ||
return promise; | ||
return promise.catch(handleSourceError); | ||
} | ||
@@ -144,3 +156,3 @@ | ||
// Fetch resource in the background | ||
fetchItemSource(channel, object); | ||
fetchItemSource(channel, object).catch(handleSourceError); | ||
} | ||
@@ -147,0 +159,0 @@ } |
@@ -35,8 +35,4 @@ 'use strict'; | ||
if (!payload.channel || !_.isString(payload.channel)) { | ||
return Promise.reject(new Error('query() payload.channel String is required.')); | ||
} | ||
const typeFilter = payload.type ? [payload.type] : types; | ||
const typeFilter = [payload.type] || types; | ||
const facet = { | ||
@@ -43,0 +39,0 @@ channel: {buckets: [payload.channel]}, |
@@ -30,3 +30,3 @@ 'use strict'; | ||
config.redis = redis; | ||
config.client = redis; | ||
const search = Search.createSearch(config); | ||
@@ -33,0 +33,0 @@ |
{ | ||
"name": "@oddnetworks/oddworks", | ||
"version": "3.5.1", | ||
"version": "3.7.0", | ||
"description": "An extensible media platform for OTT devices.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/oddworks.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3121
140506
54
3