connect-api-cli 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -9
- package/dist/cli.js +126 -39
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ connect-api-cli provision device-add --devices devices.json
|
|
|
175
175
|
connect-api-cli provision csr-generate --alias mykey --out-dir .certs --pwd <用户输入的密码>
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
-
`--pwd` 必填:先弹框让用户输入证书签名密码再传入,只出现在 JSON `.pwd`(**不写文件**)。一套材料在 `.certs/<随机数>/` 下:`key_*.p12` / `.csr`,`cert_*.cer`,`profile_*.p7b`。`csr-generate` 会把
|
|
178
|
+
`--pwd` 必填:先弹框让用户输入证书签名密码再传入,只出现在 JSON `.pwd`(**不写文件**)。一套材料在 `.certs/<随机数>/` 下:`key_*.p12` / `.csr`,`cert_*.cer`,`profile_*.p7b`。`csr-generate` 会把 `material/` 放到该目录旁(没有则自动生成,已有目录不覆盖),**不要**把签名文件拷到工程根目录。后续步骤用返回的 `.csrPath` / `.cerPath` / `.p7bPath` / `.pwd`。应用工程可将 `.certs/` 自行加入 `.gitignore`(CLI 不会在该目录写入 `.gitignore`)。
|
|
179
179
|
|
|
180
180
|
**D5. 创建调试证书**
|
|
181
181
|
|
|
@@ -214,7 +214,7 @@ P12_PWD=$(jq -r '.pwd' <<<'<csr-generate JSON>')
|
|
|
214
214
|
connect-api-cli provision encrypt-pwd --pwd "$P12_PWD" --config-dir "$HOME/.ohos/config"
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
-
输出 JSON 中的 `keyPassword`、`storePassword` 填入 `signingConfigs.material
|
|
217
|
+
输出 JSON 中的 `keyPassword`、`storePassword` 填入 `signingConfigs.material`。`--config-dir` 指向 `~/.ohos/config`(Windows 用 `%USERPROFILE%\.ohos\config`)。该目录下没有 `material/` 时 CLI 会自动生成,已有目录不覆盖。
|
|
218
218
|
|
|
219
219
|
`signingConfigs` 示例(`json5`):
|
|
220
220
|
|
|
@@ -234,11 +234,7 @@ connect-api-cli provision encrypt-pwd --pwd "$P12_PWD" --config-dir "$HOME/.ohos
|
|
|
234
234
|
}
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
`csr-generate` 会把
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
ln -s ~/.ohos/config/material <storePath>/material
|
|
241
|
-
```
|
|
237
|
+
`csr-generate` 会把 `material/` 放到 `.p12` 同级(JSON `.materialPath`)。用户主目录还没有这份材料时会先生成。**不要**把签名文件拷到工程根目录。
|
|
242
238
|
|
|
243
239
|
**D9. 构建签名 HAP**
|
|
244
240
|
|
|
@@ -371,7 +367,7 @@ hdc shell aa start -a EntryAbility -b <包名>
|
|
|
371
367
|
- **应用创建**:直接 `publish app-create`(`--app-name`、`--parent-type`:`2` 游戏 / `13` 应用,`--installation-free`:`0` 应用须 `-p` / `1` 元服务不传包名)。省略 `--project-id` 时,服务端会先创建与应用同名的项目再创建应用。要把应用挂到已有项目时,用 `project list` 取出 `projectId` 再传 `--project-id`。也可在控制台创建。若 `publish app-id` 返回空 `appids`,多为包名未注册或应用未创建。
|
|
372
368
|
- **API 客户端与 403**:客户端仅能访问其团队/项目下的资源;403 常见原因为权限不足,请在「用户与访问 → API 客户端」核对权限范围。
|
|
373
369
|
- **bundleName 与 Profile**:`app.json5` 的 `bundleName` 须与 HarmonyOS 开发者中心应用包名、`.p7b` 一致。
|
|
374
|
-
- **密码与 material**:`csr-generate` 默认把每套材料写入 **`.certs/<随机数>/`**(`key_*.p12`、`cert_*.cer`、`profile_*.p7b`,JSON `.storePath` / `.filename`);`--pwd` 为用户输入的 P12 密码。hvigor 所需 `material/` 会放到 `.p12`
|
|
370
|
+
- **密码与 material**:`csr-generate` 默认把每套材料写入 **`.certs/<随机数>/`**(`key_*.p12`、`cert_*.cer`、`profile_*.p7b`,JSON `.storePath` / `.filename`);`--pwd` 为用户输入的 P12 密码。hvigor 所需 `material/` 会放到 `.p12` 同级(没有则在 `~/.ohos/config/material` 自动生成,已有目录不覆盖),**不要**拷到工程根目录。`build-profile.json5` 需使用 **AES-128-GCM** 加密后的密码(`encrypt-pwd` 输出)。
|
|
375
371
|
- **设备类型**(`deviceType` 等场景):`1` 运动手表,`2` 智能手表,`4` 手机,`5` 平板,`8` 智慧屏,`19` PC / 2in1(以 HarmonyOS 开发者中心最新文档为准)。
|
|
376
372
|
- **JSON 文件入参**:`--devices`、`--domains`、`--acls` 等需传入**文件路径**,内容为合法 JSON。
|
|
377
373
|
- **逗号分隔 ID**:`--cert-ids`、`--device-ids`、`--fps` 等使用英文逗号分隔,如 `id1,id2`。
|
|
@@ -397,7 +393,7 @@ import { AuthService, PublishService, UploadService, ProvisionService } from 'co
|
|
|
397
393
|
|
|
398
394
|
## 开发与打包
|
|
399
395
|
|
|
400
|
-
- `npm run build`:构建库、npm CLI(`dist/cli.js
|
|
396
|
+
- `npm run build`:构建库、npm CLI(`dist/cli.js`)、Skill ZIP(`dist/hmos-connect-api-cli-skill.zip`)和 npm 安装包(`dist/connect-api-cli-*.tgz`)。Skill 通过 npm 安装的 `connect-api-cli` 命令运行,安装方式见 [Skill 说明](.claude/skills/hmos-connect-api-cli-skill/SKILL.md#2-安装并调用-cli)。
|
|
401
397
|
- `npm run pack:release`:自动测试、类型检查、构建及临时安装验证后再打 tgz(发布前用)。
|
|
402
398
|
- `npm publish`:从项目目录发布时同样执行上述 prepack 检查。发布已生成的 tgz 时应使用经过验证的产物。
|
|
403
399
|
|
package/dist/cli.js
CHANGED
|
@@ -693,7 +693,7 @@ function getRequestSource() {
|
|
|
693
693
|
return agent ? `${agent}-skill` : SKILL_CHANNEL;
|
|
694
694
|
}
|
|
695
695
|
function readVersion() {
|
|
696
|
-
const fromBuild = injected(true ? "1.1.
|
|
696
|
+
const fromBuild = injected(true ? "1.1.8" : void 0);
|
|
697
697
|
if (fromBuild) return fromBuild;
|
|
698
698
|
const candidates = [
|
|
699
699
|
import_path4.default.join(__dirname, "..", "..", "package.json"),
|
|
@@ -1513,6 +1513,7 @@ var DomainService = class {
|
|
|
1513
1513
|
|
|
1514
1514
|
// src/services/sign.ts
|
|
1515
1515
|
var import_fs8 = __toESM(require("fs"));
|
|
1516
|
+
var import_os3 = __toESM(require("os"));
|
|
1516
1517
|
var import_path6 = __toESM(require("path"));
|
|
1517
1518
|
var import_child_process2 = require("child_process");
|
|
1518
1519
|
var import_crypto = __toESM(require("crypto"));
|
|
@@ -1533,8 +1534,14 @@ var SignService = class {
|
|
|
1533
1534
|
filename: signId
|
|
1534
1535
|
};
|
|
1535
1536
|
}
|
|
1536
|
-
/**
|
|
1537
|
-
|
|
1537
|
+
/**
|
|
1538
|
+
* 签名工具都在 SDK 的 `toolchains/lib/`。
|
|
1539
|
+
* Windows / macOS 是 `hap-sign-tool.jar`(`java -jar`);
|
|
1540
|
+
* 鸿蒙 PC 是同目录无后缀的 `hap-sign-tool`(直接执行)。
|
|
1541
|
+
*/
|
|
1542
|
+
static HAP_SIGN_TOOL_DIR = ["default", "openharmony", "toolchains", "lib"];
|
|
1543
|
+
static HAP_SIGN_TOOL_JAR = "hap-sign-tool.jar";
|
|
1544
|
+
static HAP_SIGN_TOOL_NATIVE = "hap-sign-tool";
|
|
1538
1545
|
/**
|
|
1539
1546
|
* 只根据调用方给出的路径解析 SDK:`--sdk-path` → `DEVECO_HOME` 下的 `sdk/` 或 `Contents/sdk/`。
|
|
1540
1547
|
* 不扫盘、不猜常见安装目录。
|
|
@@ -1547,10 +1554,27 @@ var SignService = class {
|
|
|
1547
1554
|
static sdkPathFromDevEcoHome(home) {
|
|
1548
1555
|
if (!home) return void 0;
|
|
1549
1556
|
for (const sdk of [import_path6.default.join(home, "sdk"), import_path6.default.join(home, "Contents", "sdk")]) {
|
|
1550
|
-
if (
|
|
1557
|
+
if (this.resolveSignTool(sdk)) return sdk;
|
|
1551
1558
|
}
|
|
1552
1559
|
return void 0;
|
|
1553
1560
|
}
|
|
1561
|
+
/** jar 与无后缀可执行文件的绝对路径(不一定存在) */
|
|
1562
|
+
static signToolCandidates(sdkPath) {
|
|
1563
|
+
const dir = import_path6.default.join(sdkPath, ...this.HAP_SIGN_TOOL_DIR);
|
|
1564
|
+
return {
|
|
1565
|
+
jar: import_path6.default.join(dir, this.HAP_SIGN_TOOL_JAR),
|
|
1566
|
+
native: import_path6.default.join(dir, this.HAP_SIGN_TOOL_NATIVE)
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
/**
|
|
1570
|
+
* 有 jar 就用 jar(Windows / macOS)。否则用同目录无后缀可执行文件(鸿蒙 PC)。
|
|
1571
|
+
*/
|
|
1572
|
+
static resolveSignTool(sdkPath) {
|
|
1573
|
+
const { jar, native } = this.signToolCandidates(sdkPath);
|
|
1574
|
+
if (import_fs8.default.existsSync(jar)) return { mode: "jar", path: jar };
|
|
1575
|
+
if (import_fs8.default.existsSync(native)) return { mode: "native", path: native };
|
|
1576
|
+
return void 0;
|
|
1577
|
+
}
|
|
1554
1578
|
static async createSignP12AndCsr(options) {
|
|
1555
1579
|
const pwd = options.pwd;
|
|
1556
1580
|
if (!pwd) {
|
|
@@ -1568,9 +1592,10 @@ var SignService = class {
|
|
|
1568
1592
|
"sdkPath is required. Provide it via --sdk-path or DEVECO_HOME in .env."
|
|
1569
1593
|
);
|
|
1570
1594
|
}
|
|
1571
|
-
const
|
|
1572
|
-
if (!
|
|
1573
|
-
|
|
1595
|
+
const signTool = this.resolveSignTool(sdkPath);
|
|
1596
|
+
if (!signTool) {
|
|
1597
|
+
const { jar, native } = this.signToolCandidates(sdkPath);
|
|
1598
|
+
throw new Error(`hap-sign-tool not found at ${jar} or ${native}`);
|
|
1574
1599
|
}
|
|
1575
1600
|
const { rootDir, bundleDir, filename } = this.resolveSignOutputLayout(options);
|
|
1576
1601
|
const createdBundleDir = !import_fs8.default.existsSync(bundleDir);
|
|
@@ -1582,8 +1607,8 @@ var SignService = class {
|
|
|
1582
1607
|
const csrFilePath = import_path6.default.join(bundleDir, this.signFileName(filename, "csr"));
|
|
1583
1608
|
const alias = options.alias;
|
|
1584
1609
|
try {
|
|
1585
|
-
this.doCreateSignFileP12(javaPath,
|
|
1586
|
-
this.doCreateSignFileCsr(javaPath,
|
|
1610
|
+
this.doCreateSignFileP12(javaPath, signTool, alias, pwd, p12FilePath);
|
|
1611
|
+
this.doCreateSignFileCsr(javaPath, signTool, alias, pwd, p12FilePath, csrFilePath);
|
|
1587
1612
|
const csrContent = import_fs8.default.readFileSync(csrFilePath, "utf8");
|
|
1588
1613
|
const materialPath = this.placeMaterialBesideStore(bundleDir);
|
|
1589
1614
|
return {
|
|
@@ -1618,19 +1643,15 @@ var SignService = class {
|
|
|
1618
1643
|
return import_crypto.default.randomBytes(16).toString("hex");
|
|
1619
1644
|
}
|
|
1620
1645
|
/**
|
|
1621
|
-
* hvigor 在 `.p12` 同级目录找 `material
|
|
1622
|
-
*
|
|
1646
|
+
* hvigor 在 `.p12` 同级目录找 `material/`。把加密材料放到本套证书目录,
|
|
1647
|
+
* 避免签名文件被拷到工程根目录才能编过。配置目录里还没有 material 时先生成。
|
|
1623
1648
|
*/
|
|
1624
1649
|
static placeMaterialBesideStore(bundleDir, configDir) {
|
|
1625
1650
|
const dest = import_path6.default.join(bundleDir, "material");
|
|
1626
1651
|
if (import_fs8.default.existsSync(dest)) {
|
|
1627
1652
|
return dest;
|
|
1628
1653
|
}
|
|
1629
|
-
const
|
|
1630
|
-
const src = import_path6.default.resolve(configDir || import_path6.default.join(home, ".ohos", "config"), "material");
|
|
1631
|
-
if (!import_fs8.default.existsSync(src)) {
|
|
1632
|
-
return void 0;
|
|
1633
|
-
}
|
|
1654
|
+
const src = this.ensureMaterial(this.resolveOhosConfigDir(configDir));
|
|
1634
1655
|
try {
|
|
1635
1656
|
import_fs8.default.symlinkSync(src, dest, process.platform === "win32" ? "junction" : "dir");
|
|
1636
1657
|
} catch {
|
|
@@ -1648,14 +1669,19 @@ var SignService = class {
|
|
|
1648
1669
|
* 执行签名工具:命令行与子进程输出统一走 stderr,
|
|
1649
1670
|
* 保证 stdout 只有 CLI 的 JSON 结果,便于 jq 等下游解析。
|
|
1650
1671
|
*/
|
|
1651
|
-
|
|
1672
|
+
/** jar 走 `java -jar`;无后缀可执行文件直接执行,子命令参数相同 */
|
|
1673
|
+
static runSignTool(javaPath, tool, toolArgs) {
|
|
1674
|
+
if (tool.mode === "native") {
|
|
1675
|
+
console.error(`Executing: ${tool.path} ${this.maskArgs(toolArgs)}`);
|
|
1676
|
+
(0, import_child_process2.execFileSync)(tool.path, toolArgs, { stdio: ["ignore", 2, "inherit"] });
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
const args = ["-jar", tool.path, ...toolArgs];
|
|
1652
1680
|
console.error(`Executing: ${javaPath} ${this.maskArgs(args)}`);
|
|
1653
1681
|
(0, import_child_process2.execFileSync)(javaPath, args, { stdio: ["ignore", 2, "inherit"] });
|
|
1654
1682
|
}
|
|
1655
|
-
static doCreateSignFileP12(javaPath,
|
|
1683
|
+
static doCreateSignFileP12(javaPath, tool, alias, pwd, outFilePath) {
|
|
1656
1684
|
const args = [
|
|
1657
|
-
"-jar",
|
|
1658
|
-
signToolPath,
|
|
1659
1685
|
"generate-keypair",
|
|
1660
1686
|
"-keyAlias",
|
|
1661
1687
|
alias,
|
|
@@ -1670,12 +1696,10 @@ var SignService = class {
|
|
|
1670
1696
|
"-keystorePwd",
|
|
1671
1697
|
pwd
|
|
1672
1698
|
];
|
|
1673
|
-
this.runSignTool(javaPath, args);
|
|
1699
|
+
this.runSignTool(javaPath, tool, args);
|
|
1674
1700
|
}
|
|
1675
|
-
static doCreateSignFileCsr(javaPath,
|
|
1701
|
+
static doCreateSignFileCsr(javaPath, tool, alias, pwd, p12Path, outFilePath) {
|
|
1676
1702
|
const args = [
|
|
1677
|
-
"-jar",
|
|
1678
|
-
signToolPath,
|
|
1679
1703
|
"generate-csr",
|
|
1680
1704
|
"-keyAlias",
|
|
1681
1705
|
alias,
|
|
@@ -1692,7 +1716,7 @@ var SignService = class {
|
|
|
1692
1716
|
"-outFile",
|
|
1693
1717
|
outFilePath
|
|
1694
1718
|
];
|
|
1695
|
-
this.runSignTool(javaPath, args);
|
|
1719
|
+
this.runSignTool(javaPath, tool, args);
|
|
1696
1720
|
}
|
|
1697
1721
|
static COMPONENT = new Int8Array([49, 243, 9, 115, 214, 175, 91, 184, 211, 190, 177, 88, 101, 131, 192, 119]);
|
|
1698
1722
|
static readDirBytes(dirPath) {
|
|
@@ -1722,34 +1746,97 @@ var SignService = class {
|
|
|
1722
1746
|
decipher.setAuthTag(d.subarray(d.length - 16));
|
|
1723
1747
|
return Buffer.concat([decipher.update(d.subarray(4 + ivLen, d.length - 16)), decipher.final()]);
|
|
1724
1748
|
}
|
|
1725
|
-
static
|
|
1749
|
+
static aesSeal(key, plaintext) {
|
|
1726
1750
|
const iv = import_crypto.default.randomBytes(12);
|
|
1727
1751
|
const cipher = import_crypto.default.createCipheriv("aes-128-gcm", key, iv);
|
|
1728
|
-
const enc = Buffer.concat([cipher.update(plaintext
|
|
1752
|
+
const enc = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
1729
1753
|
const tag = cipher.getAuthTag();
|
|
1730
1754
|
const header = Buffer.alloc(4);
|
|
1731
1755
|
header.writeUInt32BE(enc.length + 16, 0);
|
|
1732
|
-
return Buffer.concat([header, iv, enc, tag])
|
|
1756
|
+
return Buffer.concat([header, iv, enc, tag]);
|
|
1757
|
+
}
|
|
1758
|
+
static aesEncrypt(key, plaintext) {
|
|
1759
|
+
return this.aesSeal(key, Buffer.from(plaintext, "utf-8")).toString("hex").toUpperCase();
|
|
1760
|
+
}
|
|
1761
|
+
static deriveRootKey(components, salt) {
|
|
1762
|
+
return import_crypto.default.pbkdf2Sync(
|
|
1763
|
+
this.xorAll(components.concat(this.COMPONENT)).toString(),
|
|
1764
|
+
Buffer.from(salt),
|
|
1765
|
+
1e4,
|
|
1766
|
+
16,
|
|
1767
|
+
"sha256"
|
|
1768
|
+
);
|
|
1733
1769
|
}
|
|
1734
1770
|
static deriveEncryptionKey(configDir) {
|
|
1735
1771
|
const materialDir = import_path6.default.resolve(configDir, "material");
|
|
1736
1772
|
const fd = this.readFd(materialDir);
|
|
1737
1773
|
const salt = this.readDirBytes(import_path6.default.resolve(materialDir, "ac"));
|
|
1738
|
-
const rawKey = new Int8Array(
|
|
1739
|
-
import_crypto.default.pbkdf2Sync(this.xorAll(fd.concat(this.COMPONENT)).toString(), salt, 1e4, 16, "sha256")
|
|
1740
|
-
);
|
|
1774
|
+
const rawKey = new Int8Array(this.deriveRootKey(fd, salt));
|
|
1741
1775
|
return new Int8Array(this.aesDecrypt(rawKey, this.readDirBytes(import_path6.default.resolve(materialDir, "ce"))));
|
|
1742
1776
|
}
|
|
1777
|
+
/** 显式目录优先;否则用户主目录。不用空的 HOME 落到当前工作目录。 */
|
|
1778
|
+
static resolveOhosConfigDir(configDir) {
|
|
1779
|
+
if (configDir) return import_path6.default.resolve(configDir);
|
|
1780
|
+
const home = process.env.HOME || process.env.USERPROFILE || import_os3.default.homedir();
|
|
1781
|
+
return import_path6.default.join(home, ".ohos", "config");
|
|
1782
|
+
}
|
|
1743
1783
|
/**
|
|
1744
|
-
*
|
|
1784
|
+
* 与 devecocli KeyManager.generateMaterial 相同的 material/{fd,ac,ce}。
|
|
1785
|
+
* 目录已存在则直接复用,不删除、不覆盖,避免已加密密码失效。
|
|
1786
|
+
*/
|
|
1787
|
+
static ensureMaterial(configDir) {
|
|
1788
|
+
const materialDir = import_path6.default.resolve(configDir, "material");
|
|
1789
|
+
if (!import_fs8.default.existsSync(materialDir)) this.generateMaterial(configDir);
|
|
1790
|
+
return materialDir;
|
|
1791
|
+
}
|
|
1792
|
+
static generateMaterial(configDir) {
|
|
1793
|
+
const materialDir = import_path6.default.resolve(configDir, "material");
|
|
1794
|
+
if (import_fs8.default.existsSync(materialDir)) return;
|
|
1795
|
+
import_fs8.default.mkdirSync(configDir, { recursive: true, mode: 448 });
|
|
1796
|
+
const staging = import_path6.default.join(configDir, `.material-${import_crypto.default.randomBytes(8).toString("hex")}`);
|
|
1797
|
+
const acDir = import_path6.default.join(staging, "ac");
|
|
1798
|
+
const ceDir = import_path6.default.join(staging, "ce");
|
|
1799
|
+
import_fs8.default.mkdirSync(acDir, { recursive: true, mode: 448 });
|
|
1800
|
+
import_fs8.default.mkdirSync(ceDir, { recursive: true, mode: 448 });
|
|
1801
|
+
const salt = import_crypto.default.randomBytes(16);
|
|
1802
|
+
const components = [0, 1, 2].map(() => new Int8Array(import_crypto.default.randomBytes(16)));
|
|
1803
|
+
for (let i = 0; i < components.length; i++) {
|
|
1804
|
+
import_fs8.default.mkdirSync(import_path6.default.join(staging, "fd", String(i)), { recursive: true, mode: 448 });
|
|
1805
|
+
}
|
|
1806
|
+
const workKey = import_crypto.default.randomBytes(16);
|
|
1807
|
+
const derived = this.deriveRootKey(components, salt);
|
|
1808
|
+
this.writeMaterialFile(acDir, salt);
|
|
1809
|
+
this.writeMaterialFile(ceDir, this.aesSeal(derived, workKey));
|
|
1810
|
+
components.forEach((part, i) => {
|
|
1811
|
+
this.writeMaterialFile(import_path6.default.join(staging, "fd", String(i)), Buffer.from(part));
|
|
1812
|
+
});
|
|
1813
|
+
try {
|
|
1814
|
+
import_fs8.default.renameSync(staging, materialDir);
|
|
1815
|
+
} catch (err) {
|
|
1816
|
+
import_fs8.default.rmSync(staging, { recursive: true, force: true });
|
|
1817
|
+
if (!import_fs8.default.existsSync(materialDir)) throw err;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
static writeMaterialFile(dir, data) {
|
|
1821
|
+
import_fs8.default.writeFileSync(import_path6.default.join(dir, import_crypto.default.randomBytes(16).toString("hex")), data, { mode: 384 });
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* 使用与 devecocli / hvigor 相同的 AES-128-GCM 密钥加密密码,
|
|
1745
1825
|
* 生成 build-profile.json5 中 signingConfigs 所需的加密密码。
|
|
1826
|
+
* 配置目录下没有 material/ 时自动生成,已有目录不覆盖。
|
|
1746
1827
|
*/
|
|
1747
1828
|
static encryptPassword(password, configDir) {
|
|
1748
|
-
const dir =
|
|
1749
|
-
|
|
1750
|
-
|
|
1829
|
+
const dir = this.resolveOhosConfigDir(configDir);
|
|
1830
|
+
this.ensureMaterial(dir);
|
|
1831
|
+
let key;
|
|
1832
|
+
try {
|
|
1833
|
+
key = this.deriveEncryptionKey(dir);
|
|
1834
|
+
} catch (err) {
|
|
1835
|
+
throw new Error(
|
|
1836
|
+
`\u65E0\u6CD5\u8BFB\u53D6\u52A0\u5BC6\u6750\u6599 ${import_path6.default.resolve(dir, "material")}\u3002\u5DF2\u6709\u76EE\u5F55\u4E0D\u4F1A\u91CD\u65B0\u751F\u6210\uFF0C\u4EE5\u514D\u5DF2\u52A0\u5BC6\u5BC6\u7801\u5931\u6548\u3002`,
|
|
1837
|
+
{ cause: err }
|
|
1838
|
+
);
|
|
1751
1839
|
}
|
|
1752
|
-
const key = this.deriveEncryptionKey(dir);
|
|
1753
1840
|
return {
|
|
1754
1841
|
keyPassword: this.aesEncrypt(key, password),
|
|
1755
1842
|
storePassword: this.aesEncrypt(key, password)
|
|
@@ -2037,8 +2124,8 @@ var TestingService = class {
|
|
|
2037
2124
|
// src/cli/index.ts
|
|
2038
2125
|
var program = new import_commander.Command();
|
|
2039
2126
|
function readCliVersion() {
|
|
2040
|
-
if ("1.1.
|
|
2041
|
-
return "1.1.
|
|
2127
|
+
if ("1.1.8") {
|
|
2128
|
+
return "1.1.8";
|
|
2042
2129
|
}
|
|
2043
2130
|
try {
|
|
2044
2131
|
const pkgPath = import_path7.default.join(__dirname, "..", "package.json");
|
|
@@ -2534,7 +2621,7 @@ provisionCmd.command("csr-generate").description("Generate a new keypair and CSR
|
|
|
2534
2621
|
reportFailure("CSR generation failed:", e.message);
|
|
2535
2622
|
}
|
|
2536
2623
|
});
|
|
2537
|
-
provisionCmd.command("encrypt-pwd").description("\u52A0\u5BC6 P12 \u5BC6\u7801\uFF0C\u751F\u6210 build-profile.json5 \u6240\u9700\u7684 keyPassword / storePassword").requiredOption("--pwd <password>", "P12 \u5BC6\u7801\u660E\u6587").option("--config-dir <configDir>", "
|
|
2624
|
+
provisionCmd.command("encrypt-pwd").description("\u52A0\u5BC6 P12 \u5BC6\u7801\uFF0C\u751F\u6210 build-profile.json5 \u6240\u9700\u7684 keyPassword / storePassword").requiredOption("--pwd <password>", "P12 \u5BC6\u7801\u660E\u6587").option("--config-dir <configDir>", "\u52A0\u5BC6\u6750\u6599\u76EE\u5F55 (\u9ED8\u8BA4 ~/.ohos/config\uFF1B\u6CA1\u6709 material/ \u65F6\u81EA\u52A8\u751F\u6210\uFF0C\u5DF2\u6709\u76EE\u5F55\u4E0D\u8986\u76D6)").action(async (options) => {
|
|
2538
2625
|
try {
|
|
2539
2626
|
const res = SignService.encryptPassword(options.pwd, options.configDir);
|
|
2540
2627
|
printResult(res);
|
package/dist/index.js
CHANGED
|
@@ -686,7 +686,7 @@ function getRequestSource() {
|
|
|
686
686
|
return agent ? `${agent}-skill` : SKILL_CHANNEL;
|
|
687
687
|
}
|
|
688
688
|
function readVersion() {
|
|
689
|
-
const fromBuild = injected(true ? "1.1.
|
|
689
|
+
const fromBuild = injected(true ? "1.1.8" : void 0);
|
|
690
690
|
if (fromBuild) return fromBuild;
|
|
691
691
|
const candidates = [
|
|
692
692
|
import_path4.default.join(__dirname, "..", "..", "package.json"),
|
package/dist/index.mjs
CHANGED
|
@@ -644,7 +644,7 @@ function getRequestSource() {
|
|
|
644
644
|
return agent ? `${agent}-skill` : SKILL_CHANNEL;
|
|
645
645
|
}
|
|
646
646
|
function readVersion() {
|
|
647
|
-
const fromBuild = injected(true ? "1.1.
|
|
647
|
+
const fromBuild = injected(true ? "1.1.8" : void 0);
|
|
648
648
|
if (fromBuild) return fromBuild;
|
|
649
649
|
const candidates = [
|
|
650
650
|
path4.join(__dirname, "..", "..", "package.json"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "connect-api-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "node scripts/build-all.js",
|
|
22
22
|
"build:lib": "tsup && tsup --config tsup.config.cli.ts",
|
|
23
|
-
"build:skill": "
|
|
23
|
+
"build:skill": "npm run pack:skill",
|
|
24
24
|
"pack:skill": "node scripts/pack-skill.js",
|
|
25
25
|
"dev": "tsup --config tsup.config.cli.ts --watch",
|
|
26
26
|
"start": "node dist/cli.js",
|