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

@kth/cortina-block

Package Overview
Dependencies
Maintainers
8
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kth/cortina-block - npm Package Compare versions

Comparing version 6.1.4 to 6.2.0

2

dist/fetch-blocks.d.ts
import { BlocksConfig, BlocksObject, SupportedLang } from '.';
export declare const fetchAllBlocks: (blocksConfig: BlocksConfig, blockApiUrl: string, lang: SupportedLang, headers?: Headers) => Promise<BlocksObject>;
export declare const fetchAllBlocks: (blocksConfig: BlocksConfig, blockApiUrl: string, lang: SupportedLang, headers?: Headers, useStyle10?: boolean) => Promise<BlocksObject>;

@@ -23,7 +23,8 @@ "use strict";

// Fetch all Cortina blocks from API.
const fetchAllBlocks = async (blocksConfig, blockApiUrl, lang, headers) => {
const fetchAllBlocks = async (blocksConfig, blockApiUrl, lang, headers, useStyle10) => {
const blockView = useStyle10 ? 'style10' : 'style9';
const allblocks = [];
for (const blockName in blocksConfig) {
const blockId = blocksConfig[blockName];
allblocks.push({ blockName, url: `${blockApiUrl}${blockId}?&l=${lang}` });
allblocks.push({ blockName, url: `${blockApiUrl}${blockId}?l=${lang}&v=${blockView}` });
}

@@ -30,0 +31,0 @@ return Promise.all(allblocks.map(block => fetchBlock(block.url, headers, block.blockName)))

import { NextFunction, Request } from 'express';
import { Config, RedisConfig, SupportedLang, BlocksObject, BlocksConfig, Redis } from './types';
export * from './types';
export declare function cortina(blockApiUrl: string, headers: Headers | undefined, language: SupportedLang, shouldSkipCookieScripts: boolean, blocksConfigIn?: BlocksConfig, redisConfig?: RedisConfig, redisClient?: Redis): Promise<{
export declare function cortina(blockApiUrl: string, headers: Headers | undefined, language: SupportedLang, shouldSkipCookieScripts: boolean, blocksConfigIn?: BlocksConfig, redisConfig?: RedisConfig, redisClient?: Redis, useStyle10?: boolean): Promise<{
[blockName: string]: string;

@@ -6,0 +6,0 @@ }>;

@@ -29,3 +29,3 @@ "use strict";

// Gets HTML blocks from Cortina using promises.
function cortina(blockApiUrl, headers, language, shouldSkipCookieScripts, blocksConfigIn, redisConfig, redisClient) {
function cortina(blockApiUrl, headers, language, shouldSkipCookieScripts, blocksConfigIn, redisConfig, redisClient, useStyle10) {
const blocksConfig = { ...config_1.defaultBlocksConfig, ...blocksConfigIn };

@@ -40,5 +40,6 @@ if (shouldSkipCookieScripts) {

if (!redisConfig || !redisClient) {
return (0, fetch_blocks_1.fetchAllBlocks)(blocksConfig, blockApiUrl, language, headers);
return (0, fetch_blocks_1.fetchAllBlocks)(blocksConfig, blockApiUrl, language, headers, useStyle10);
}
const { redisKey, redisExpire } = config_1.redisItemSettings;
const { redisKey: redisKeyBase, redisExpire } = config_1.redisItemSettings;
const redisKey = redisKeyBase + (useStyle10 ? 'style10_' : 'style9_');
// Try to get from Redis otherwise get from web service then cache result

@@ -52,7 +53,7 @@ // in Redis using redisKey. If Redis connection fails, call API

}
return (0, fetch_blocks_1.fetchAllBlocks)(blocksConfig, blockApiUrl, language, headers).then(cortinaBlocks => (0, redis_utils_1.setRedisItem)(redisClient, redisKey, redisExpire, language, cortinaBlocks));
return (0, fetch_blocks_1.fetchAllBlocks)(blocksConfig, blockApiUrl, language, headers, useStyle10).then(cortinaBlocks => (0, redis_utils_1.setRedisItem)(redisClient, redisKey, redisExpire, language, cortinaBlocks));
})
.catch(err => {
log_1.default.error('Redis failed:', err.message, err.code);
return (0, fetch_blocks_1.fetchAllBlocks)(blocksConfig, blockApiUrl, language, headers);
return (0, fetch_blocks_1.fetchAllBlocks)(blocksConfig, blockApiUrl, language, headers, useStyle10);
});

@@ -105,3 +106,3 @@ }

}
return cortina(config.blockApiUrl, config.headers, lang, shouldSkipCookieScripts, config.blocksConfig, redisConfig, redisClient)
return cortina(config.blockApiUrl, config.headers, lang, shouldSkipCookieScripts, config.blocksConfig, redisConfig, redisClient, config.useStyle10)
.then(blocks => {

@@ -108,0 +109,0 @@ // @ts-ignore

@@ -16,2 +16,3 @@ export type Config = {

skipCookieScriptsInDev?: boolean;
useStyle10?: boolean;
};

@@ -18,0 +19,0 @@ export type RedisConfig = {

{
"name": "@kth/cortina-block",
"version": "6.1.4",
"version": "6.2.0",
"description": "Node.js module for fetching Cortina blocks and optionally cache using Redis.",

@@ -18,3 +18,3 @@ "main": "dist/index.js",

"build": "npm ci && tsc",
"prepare": "if [ -f ./node_modules/.bin/husky ]; then husky install; fi"
"prepare": "husky"
},

@@ -40,3 +40,3 @@ "repository": {

"jsdom": "^22.1.0",
"kth-node-redis": "^3.2.0"
"kth-node-redis": "^3.3.0"
},

@@ -47,15 +47,15 @@ "peerDependencies": {

"devDependencies": {
"@kth/eslint-config-kth": "^3.1.0",
"@kth/eslint-config-kth": "^3.4.0",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.10",
"@types/jest": "^29.5.12",
"@types/jsdom": "^21.1.6",
"eslint": "^8.54.0",
"eslint-plugin-jest-dom": "^4.0.3",
"express": "^4.18.2",
"husky": "^8.0.3",
"eslint": "^8.57.0",
"eslint-plugin-jest-dom": "^5.2.0",
"express": "^4.19.2",
"husky": "^9.0.11",
"jest": "^29.7.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"ts-jest": "^29.1.1",
"typescript": "^5.3.2"
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"typescript": "^5.4.3"
},

@@ -62,0 +62,0 @@ "prettier": {

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