
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
A middleware layer between a service and a client. The service could be an in-process library, a file, an external web service, anything. Any time the results from a resource call can be cached, you can use ASC as a proxy to that resource.
ASC is a tiered caching middleware that sits between your application and cacheable services. It allows you to define multiple caching layers that ASC will automatically manage and update as needed. The name "ASC" stands for Asynchronous Self-Updating Cache.
npm install asc
import ASC from 'asc';
// Create a cache instance for string keys and number values
const cache = new ASC<string, number>({
memory: {
ttl: 60000, // 60 seconds
disabled: false
},
get: async (key: string) => {
// Fetch data from your source (database, API, etc.)
const value = await someExpensiveOperation(key);
return value;
}
});
// Using the cache
async function example() {
try {
const value = await cache.get('myKey');
console.log('Retrieved value:', value);
} catch (error) {
console.error('Error fetching data:', error);
}
}
const ASC = require('asc');
// Create a cache instance
const cache = new ASC({
memory: {
ttl: 60000, // 60 seconds
disabled: false
},
get: async (key) => {
// Fetch data from your source (database, API, etc.)
const value = await someExpensiveOperation(key);
return value;
}
});
// Using the cache
async function example() {
try {
const value = await cache.get('myKey');
console.log('Retrieved value:', value);
} catch (error) {
console.error('Error fetching data:', error);
}
}
import ASC from 'asc';
import Redis from 'ioredis';
import { Database } from './your-database';
interface UserData {
id: string;
name: string;
email: string;
}
const redis = new Redis();
const db = new Database();
const userCache = new ASC<string, UserData>({
memory: {
ttl: 30000, // 30 seconds
disabled: false
},
layers: [
// Redis Layer
{
get: async (key) => {
const data = await redis.get(key);
if (data) {
return JSON.parse(data);
}
return undefined;
},
set: async (key, data) => {
await redis.set(key, JSON.stringify(data), 'EX', 300); // 5 minutes
},
clear: async (key) => {
await redis.del(key);
}
},
// Database Layer
{
get: async (key) => {
return await db.users.findOne({ id: key });
}
}
]
});
// Usage
async function getUser(userId: string): Promise<UserData> {
return await userCache.get(userId);
}
const ASC = require('asc');
const Redis = require('ioredis');
const { Database } = require('./your-database');
const redis = new Redis();
const db = new Database();
const userCache = new ASC({
memory: {
ttl: 30000, // 30 seconds
disabled: false
},
layers: [
// Redis Layer
{
get: async (key) => {
const data = await redis.get(key);
if (data) {
return JSON.parse(data);
}
return undefined;
},
set: async (key, data) => {
await redis.set(key, JSON.stringify(data), 'EX', 300); // 5 minutes
},
clear: async (key) => {
await redis.del(key);
}
},
// Database Layer
{
get: async (key) => {
return await db.users.findOne({ id: key });
}
}
]
});
// Usage
async function getUser(userId) {
return await userCache.get(userId);
}
Layers are prioritized in the following order:
When get()
is called, ASC:
set()
method of each layer (if provided) to store the dataThe built-in memory cache uses your process's memory. For optimal performance:
ASC is ideal when:
ASC may not be suitable when:
interface MemoryParams {
disabled?: boolean; // Disable in-memory cache
ttl?: number; // Time-to-live in milliseconds
}
interface CacheLayer<K, V> {
get: (key: K) => Promise<V | undefined>;
set?: (key: K, data: V) => Promise<void>;
clear?: (key: K) => Promise<void>;
}
interface ConstructorParams<K, V> {
memory?: MemoryParams;
layers?: Array<CacheLayer<K, V>>;
get?: (key: K) => Promise<V | undefined>;
}
class ASC<K, V> {
constructor(params: ConstructorParams<K, V>);
get(key: K): Promise<V>;
set(key: K, data: V): Promise<void>;
clear(key: K): Promise<void>;
}
feature/your-feature-name
npm test
MIT License - See LICENSE file for details.
FAQs
A middleware layer between a service and a client. The service could be an in-process library, a file, an external web service, anything. Any time the results from a resource call can be cached, you can use ASC as a proxy to that resource.
We found that asc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.