# @cubist-labs/cubesigner-sdk-key-import 中文文档

规范地址：https://npmcn.com/package/%40cubist-labs/cubesigner-sdk-key-import/

版本：0\.4\.284
npm 元数据更新时间：2026-09-09T06:44:02.462Z
中文译文更新时间：2026-11-11T04:34:47.975Z
软件包许可：MIT OR Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40cubist-labs/cubesigner-sdk-key-import
原文对照：https://npmcn.com/package/%40cubist-labs/cubesigner-sdk-key-import/?lang=original
项目主页：https://github.com/cubist-labs/CubeSigner-TypeScript-SDK#readme
源码仓库：https://github.com/cubist-labs/CubeSigner-TypeScript-SDK

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：110 kB，31 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：8 个
- peer 依赖：@cubist-labs/cubesigner-sdk ^0\.4\.284
- 首次发布：2024-09-13T04:36:11.858Z
- 最新版本发布：2026-09-09T06:44:02.098Z
- 近 30 天下载量：5307（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：106（近 12 个月 50 个）

## 中文简介

用于 CubeSigner 的客户端密钥导入机械

## 安装

```sh
npm install @cubist-labs/cubesigner-sdk-key-import
```

也可以使用：`pnpm add @cubist-labs/cubesigner-sdk-key-import`、`yarn add @cubist-labs/cubesigner-sdk-key-import`、`bun add @cubist-labs/cubesigner-sdk-key-import`

## README

# 立方体Signer 密钥导入

此库执行用于导入密钥的客户端加密 进入CubeSigner.

## 警告

使用在不可信环境下运行的代码导入密钥 **危险** 因为密码必须处理秘密的关键材料 例如,进口 用户网页浏览器的密钥为 **非常危险**: 披露密钥 浏览器中指恶意网页、广告和扩展 可能可以偷你的钥匙。 JS执行环境也很好 目标为侧道攻击者.

只要有可能,Cubist强烈建议使用 `createKey` API (英语). 我们强烈建议不使用本地键源加 导入以替换真正的灾后恢复备份。 请联系 如果你对灾后恢复规划有疑问或需要帮助的话.

## 示例

```ts
import * as cs from "@cubist-labs/cubesigner-sdk";
import * as csFs from "@cubist-labs/cubesigner-sdk-fs-storage";
import { KeyImporter, type MnemonicToImport } from "@cubist-labs/cubesigner-sdk-key-import";

// create a CubeSigner client from credentials on-disk, which
// you can create by running `cs login` from the CLI.
const client = await cs.CubeSignerClient.create(csFs.defaultManagementSessionManager());

// create the key-importer instance
const keyImporter = new KeyImporter(client.org());

// mnemonics to import directly as EVM keys
const evmMnemonics: MnemonicToImport[] = [
  {
    mnemonic: "car split like parrot uphold faint amount alert inch bean priority custom auction denial reason oyster food duck horn top battle video seed company",
    derivationPath: "m/44'/60'/0'/0/0",
  },
  {
    mnemonic: "force focus walnut scale barrel faint hotel fabric source because heavy provide bridge intact they receive stairs matter fetch family color happy slender accident",
    derivationPath: "m/44'/60'/1'/0/0",
    password: "bip39 passwords are silly",
  },
];
// mnemonic to import directly as Bitcoin Segwit keys
const btcMnemonics: MnemonicToImport[] = [
  {
    mnemonic: "style goddess hair mountain open when train mail fly engage fork walnut end toe mail price priority ocean uncover immune spray person slogan avoid",
    derivationPath: "m/84'/0'/0'/0/0",
  },
  {
    mnemonic: "marine airport maze doll note assume deliver second bus include deal escape detail friend letter captain glide actual resemble nation shell search elephant busy",
    derivationPath: "m/84'/0'/9'/0/1",
  },
];

// import the keys
const evmKeys = await keyImporter.importMnemonics(cs.Secp256k1.Evm, evmMnemonics);
const btcKeys = await keyImporter.importMnemonics(cs.Secp256k1.Btc, btcMnemonics);

// If you want to derive many keys from the same mnemonic, you should import
// the bare mnemonic and use the `deriveKey` and/or `deriveKeys` methods to
// create keys.
const bareMnemonic: MnemonicToImport = {
  mnemonic: "divide impact town typical inhale uncover rifle pet multiply idea long before debate apart pulse type need produce among pony attend cat injury ring",
};

// First, import the bare mnemonic
const mnemonic = (await keyImporter.importMnemonics(cs.Mnemonic, [bareMnemonic]))[0];

// Then derive keys from it.
const deriveResponse = await org.deriveKey(cs.Secp256k1.Taproot, "m/86'/0'/3'/1/0", mnemonic.materialId);
const otherDeriveResponses = await org.deriveKeys(
  cs.Secp256k1.Ava,
  [
    "m/1'/2'/3",
    "m/4'/5/6",
    "m/7/8'/9",
  ],
  mnemonic.materialId,
);
```

# 许可证

版权(C)2024 Cubist, Inc. 版权所有.

这个图书馆根据麻省理工学院和Apache-2.0许可证获得许可. 详情见\[././NOTICE\]档案.

## 常见问题

### @cubist-labs/cubesigner-sdk-key-import 是什么？

用于 CubeSigner 的客户端密钥导入机械

### 如何安装 @cubist-labs/cubesigner-sdk-key-import？

在项目目录运行 npm install @cubist-labs/cubesigner-sdk-key-import，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@cubist-labs/cubesigner-sdk（^0\.4\.284）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @cubist-labs/cubesigner-sdk-key-import 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @cubist-labs/cubesigner-sdk-key-import 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @cubist-labs/cubesigner-sdk-key-import 可以商用吗？

@cubist-labs/cubesigner-sdk-key-import 使用 MIT OR Apache-2\.0 许可。可在 MIT、Apache-2\.0 中任选其一遵守。选择 MIT 时，宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @cubist-labs/cubesigner-sdk-key-import 的下载量有多少？

根据 npm 官方下载统计，@cubist-labs/cubesigner-sdk-key-import 在 2026/10/11 – 2026/11/09 这 30 天内被下载 5,307 次，日均约 177 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @cubist-labs/cubesigner-sdk-key-import 还在维护吗？

最新版本 0\.4\.284 发布于 2026/09/09（2 个月前）；至今共发布 106 个版本，其中过去 12 个月发布了 50 个；首次发布于 2024/09/13。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

