
Research
Malicious NuGet Packages Typosquat Nethereum to Exfiltrate Wallet Keys
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
@ibash/idb-logger
Advanced tools
Online use | 中文 | Changelog | issue feedback | Gitee
idb-logger is committed to helping web developers access a high-performance logging system conveniently and efficiently. Relying on webworker and indexedDB technologies, web applications can store large-capacity logs in the browser in a way that hardly affects the user experience, and Report it to the server at the right time, or download it by the user.
npm i idb-logger
import Logger from 'idb-logger';
<script src="https://cdn.jsdelivr.net/npm/idb-logger/idb-logger.min.js"></script>
<script>
window.IDBLogger;
</script>
const logger = new Logger();
logger.log('an ordinary log');
logger.error('an error log', 'additional information', {type: 'additional information'});
logger.download(); // download log
ts declaration:
declare class Logger {
static version: string;
private_store;
id: string;
storeType: TLogStoreType;
constructor({ id, useConsole, storeType, maxRecords, baseInfo, onReport, onDiscard, }?: ILoggerOption);
injectBaseInfo(baseInfo?: IBaseInfoOption & IJson): Promise<void>;
log(...args: any[]): Promise<IAddReturn>;
error(...args: any[]): Promise<IAddReturn>;
warn(...args: any[]): Promise<IAddReturn>;
info(...args: any[]): Promise<IAddReturn>;
private _logCommon;
close(): Promise<boolean>;
destory(): Promise<boolean>;
clear(): Promise<boolean>;
count(): Promise<number>;
delete(logid: string): Promise<boolean>;
refreshTraceId(): Promise<void>;
refreshDurationStart(): Promise<void>;
download({ name, filter }?: {
name?: string;
filter?: TFilterOption;
keys?: string[];
}): Promise<number>;
get(logid: string): Promise<ILogDBData | null>;
getAll(): Promise<ILogDBData[]>;
filter(filter?: TFilterOption): Promise<ILogDBData[]>;
}
complete logdata
interface ILogDBData {
uid: string; // user id will be stored in storage
clientid: string; // client id will be stored in storage
traceid: string; // This access id can be refreshed by refreshTraceId
network: string; // network status
url: string; // current url
ua: string; // browser ua
msg: string; // message type, if the first parameter of log is a string, take this value
payload?: any; // other parameters of log
type: TLogType; // log info warn error
duration: number; // The time when the page enters the current log, you can refresh the timing at seven o'clock through refreshDurationStart
time: string; // time string
timestamp: number; // timestamp
logid: string; // log unique id
}
new Logger({
id, // Specify the database name Default value: default
useConsole, // whether to print to the console default true
storeType, // storage mode, default idb, support idb storage temp none
maxRecords, // maximum number of stored records default 10000
baseInfo, // inject custom base information
onReport, // Triggered when the log is generated, can be used to customize the report data
onDiscard // Triggered when maxRecords is reached, discarded data
});
idb means using indexedDB to store logs, storage means using localStorage to store logs, temp means using js variables to store data (non-persistent), none means not storing data (only using idb-logger as a log generation tool)
The default value is idb. When a certain storage type is not supported by the browser, the next mode will be automatically selected backward.
In order to reduce client performance consumption, you can specify a maximum storage amount. When this amount is exceeded, the logger will automatically delete the oldest record and trigger the onDiscard callback
Accepts a json, which is used to inject the basic information of the log. When the name is consistent with the default baseInfo, the default baseInfo will be overwritten
Default baseInfo clientid, uid, traceid, network, url, ua
There are four methods on the logger object: log, error, warn, info
The usage method is similar to support the incoming of any amount and any type of data
parameter rules
await logger.log('start'); // Return Promise<{discard, add}> add is the added log data. The call method conforms to rule 1
await logger.info({
msg: 'start', // write message
time: 'xxxx', // Override log properties
your_custom: 'xxxx', // custom properties
}); // This call method conforms to rule 2
await logger.warn({}, [], '', 1); // This call method conforms to rule 3
await logger.error('error', {}, [], '', 1); // This call method conforms to rule 1
await logger.filter(filter); // return Promise
filter supports three modes
Support to pass in a function (data: ILogDBData) => boolean
, the callback function is the log data, return true or false to indicate whether the data hits
Note: In indexedDB mode, since the function will be passed to the worker for execution, it is required that other methods or features not supported in the worker cannot be called in the function.
await logger.filter(item=>{
return item.msg.includes('xxx') && item.type === 'log';
})
Pass in a json, each attribute will be used and String together, supports regular expressions
await logger.filter({
msg: /xxx/i,
type: 'log',
})
Pass in a json array, each element in the array is connected with or logic, and the and logic is used between the attributes within the element, which is consistent with 2
await logger.filter([{
msg: /xxx/i,
}, {
type: 'log',
}])
The above statement means that msg in the log contains xxx or type is equal to log
Download logs stored in indexedDB
await logger.download({
name, // optional name of the downloaded file defaults to timestamp
filter, // optional same as filter in 1.2.3
keys, // optional specifies additional properties to download
});
get all logs
await logger.getAll();
Get a log based on the log id
await logger.getAll(logid);
Get the number of logs
await logger.count();
Delete a log by log id
await logger.delete(logid);
Inject log basic information
await logger.injectBaseInfo({
network: 'wifi',
phone: 'xxxx',
});
Refresh the traceid, generally used for reconnection, etc., considered to be the second visit scenario
Also refreshDurationStart
await logger.refreshTraceId();
Refresh the timing starting point, generally used in scenarios that need to re-count the time
await logger.refreshTraceId();
close the database
await logger.close();
close and clear the database
await logger.clear();
Close, empty and delete the database
await logger.destory();
FAQs
Makes creating WebWorkers easier
The npm package @ibash/idb-logger receives a total of 6 weekly downloads. As such, @ibash/idb-logger popularity was classified as not popular.
We found that @ibash/idb-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.
Product
Socket is launching experimental protection for the Hugging Face ecosystem, scanning for malware and malicious payload injections inside model files to prevent silent AI supply chain attacks.