
Research
/Security News
Laravel Lang Compromised with RCE Backdoor Across 700+ Versions
Laravel Lang packages were compromised with an RCE backdoor across hundreds of versions, exposing cloud, CI/CD, and developer secrets.
@codernote/utils
Advanced tools
笔记软件通用工具库
npm install @codernote/utils
import { ENV, setEnv } from "@codernote/utils";
// 手动指定环境
// 不手动指定则会根据域名自动识别
setEnv("dev" | "test" | "prod");
// 可以单独直接设定env值
setEnv({
URL_SERVER_HTTP: "http://localhost:7000",
});
console.log(ENV);
/*
ENV{
// 当前环境
ENV: "TEST",
// 后端服务域名
URL_DOMAIN,
// 后端HTTP服务地址
URL_SERVER_HTTP: "",
// 后端websocket服务地址
URL_SERVER_WSS: "",
// media服务地址
URL_SERVER_MEDIA: "",
// 公共登录页面地址
URL_PAGE_LOGIN_PC: "",
// 公共用户信息页面地址
URL_PAGE_USER_PC: "",
}
*/
uuid: 生成 uuid
import { uuid } from "@codernote/utils";
const id = uuid();
parseMimeType: 解析 mimeType
import { parseMimeType } from "@codernote/utils";
const mimeType = 'video/mp4; codec="avc1.42E01E"';
const parsed = parseMimeType(mimeType);
console.log(parsed);
// 输出: { mainType: 'video', subType: 'mp4', params: ['codec="avc1.42E01E"'] }
判断设备类型
import { detectDeviceType } from "@codernote/utils";
const type = detectDeviceType();
console.log(type);
// 输出: mobile | desktop
获取 url 参数
import { getQueryParam } from "@codernote/utils";
const a = getQueryParam("a");
优化字节大小展示
import { formatBytes } from "@codernote/utils";
const a = formatBytes(1024);
console.log(a);
// 1KB
截取字符串
import { truncateString } from "@codernote/utils";
const a = truncateString("xxxxxx", 3);
console.log(a);
// xxx...
根据 File 获取图片或视频宽高
import { getVideoSize, getImageSize } from "@codernote/utils";
const { width, height } = getVideoSize(fileVideo);
// 或
const { width, height } = getImageSize(fileImage);
根据最大宽高比例,重设宽高
import { resizeResource } from "@codernote/utils";
const width = 600;
const height = 400;
// 最大限制宽300, 限高300(均为默认值)
const size = resizeResource(width, height, 300, 300);
console.log(size);
// {width: 300, height: 200}
上传文件到 CDN
import { oss } from "@codernote/utils";
oss.uploadFile(files, (err, resArr) => {
if (!err) {
console.log(resArr);
}
});
删除上传的文件
import { oss } from "@codernote/utils";
oss.removeFile(filePath);
长按事件
import { addLongPressEventListener } from "@codernote/utils";
// 绑定domEl上,长按事件(500ms默认值)
addLongPressEventListener(domEl, callback, 1000);
一组常用 icons
import { icons } from "@codernote/utils";
console.log(icons);
/*
[
{ name: "add.svg", value: base64 }
...
]
*/
byNameFindIcon: 根据名称找 icon
import { byNameFindIcon } from "@codernote/utils";
byNameFindIcon("clear.svg");
npm publish --access public
FAQs
We found that @codernote/utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
/Security News
Laravel Lang packages were compromised with an RCE backdoor across hundreds of versions, exposing cloud, CI/CD, and developer secrets.

Security News
Socket found a malicious postinstall hook across 700+ GitHub repos, including PHP packages on Packagist and Node.js project repositories.

Security News
Vibe coding at scale is reshaping how packages are created, contributed, and selected across the software supply chain