npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@a-drowned-fish/om-utils

v1.0.13

Published

一个用于处理设备指纹、加密签名和认证的工具库,专为 OM 系统设计。

Downloads

1,830

Readme

@a-drowned-fish/om-utils

一个用于处理设备指纹、加密签名和认证的工具库,专为 OM 系统设计。

安装

npm install @a-drowned-fish/om-utils

快速开始

基本使用

import OmUtils from "@a-drowned-fish/om-utils";

// 初始化实例(PSK 为预共享密钥)
const omUtils = new OmUtils("your-pre-shared-key");

// 设置访问令牌
omUtils.setAccessToken("your-access-token");

// 获取公共请求头
const headers = await omUtils.getPublicHeaders();
console.log(headers);

注册流程

// 获取注册请求体
const registerBody = await omUtils.getRegisterBody();
console.log(registerBody);
// 输出: { d: "设备ID", n: "随机数", t: "时间戳", s: "签名" }

API 文档

OmUtils 类

构造函数

new OmUtils(psk: string, options?: BaseOmUtilsConstructorOptions)

参数:

  • psk - 预共享密钥,用于加密解密
  • options - 可选配置
    • uId - 用户ID,默认 "1234567812345678"
    • deviceId - 自定义设备ID(可选)

公共方法

setAccessToken(accessToken?: string)

设置访问令牌,会自动使用 SM4 解密处理。

getRegisterBody(): Promise

获取注册请求体,包含设备ID、随机数、时间戳和签名。

返回值:

{
    d: string; // 设备ID
    n: string; // 32位随机字符串
    t: string; // 时间戳
    s: string; // SM4加密签名
}
getPublicHeaders(): Promise

获取公共请求头,用于 API 认证。

返回值:

{
  "X-T": string; // 时间戳
  "X-N": string; // 32位随机字符串
  "X-DI": string; // 设备ID
  "X-S": string; // SM2签名
}

类型定义

完整的 TypeScript 类型定义包含在包中:

interface BaseOmUtilsConstructorOptions {
    uId?: string;
    deviceId?: string;
    deviceIdPrefix?: string; // 为不同环境的deviceId添加前缀,用以区别环境使用
}

开发指南

构建

项目使用现代构建工具,支持 CommonJS 和 ES Module 两种格式。

许可证

MIT License

作者

a-drowned-fish