engine7 7.1.113 → 7.1.115

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/dist/cli.mjs CHANGED
@@ -29529,6 +29529,7 @@ __export(provision_free_exports, {
29529
29529
  loadOrCreateInstallIdentity: () => loadOrCreateInstallIdentity,
29530
29530
  provisionFreeToken: () => provisionFreeToken,
29531
29531
  readInstallIdentity: () => readInstallIdentity,
29532
+ readInstallIdentityDetailed: () => readInstallIdentityDetailed,
29532
29533
  writeIdentityContactEmail: () => writeIdentityContactEmail
29533
29534
  });
29534
29535
  import { randomBytes as randomBytes6, randomUUID as randomUUID9 } from "node:crypto";
@@ -29573,19 +29574,37 @@ function loadOrCreateInstallIdentity(stateDir) {
29573
29574
  }
29574
29575
  return identity;
29575
29576
  }
29576
- function readInstallIdentity(stateDir) {
29577
+ function readInstallIdentityDetailed(stateDir) {
29578
+ const file2 = join51(stateDir, IDENTITY_FILE);
29579
+ if (!existsSync32(file2)) return { ok: false, reason: "missing" };
29580
+ let text;
29577
29581
  try {
29578
- const parsed = JSON.parse(readFileSync39(join51(stateDir, IDENTITY_FILE), "utf8"));
29579
- if (typeof parsed?.installId !== "string" || typeof parsed?.installSecret !== "string") return null;
29580
- const email = readContactEmailOf(parsed);
29581
- return {
29582
+ text = readFileSync39(file2, "utf8");
29583
+ } catch (e) {
29584
+ return { ok: false, reason: "corrupt", detail: `\u5B58\u5728\u4F46\u8BFB\u4E0D\u4E86\uFF08${e?.message ?? e}\uFF09` };
29585
+ }
29586
+ let parsed;
29587
+ try {
29588
+ parsed = JSON.parse(text);
29589
+ } catch (e) {
29590
+ return { ok: false, reason: "corrupt", detail: `\u4E0D\u662F\u5408\u6CD5 JSON\uFF08${e?.message ?? e}\uFF09` };
29591
+ }
29592
+ if (typeof parsed?.installId !== "string" || typeof parsed?.installSecret !== "string") {
29593
+ return { ok: false, reason: "corrupt", detail: "\u7F3A installId / installSecret \u5B57\u6BB5" };
29594
+ }
29595
+ const email = readContactEmailOf(parsed);
29596
+ return {
29597
+ ok: true,
29598
+ identity: {
29582
29599
  installId: parsed.installId,
29583
29600
  installSecret: parsed.installSecret,
29584
29601
  ...email ? { contactEmail: email } : {}
29585
- };
29586
- } catch {
29587
- return null;
29588
- }
29602
+ }
29603
+ };
29604
+ }
29605
+ function readInstallIdentity(stateDir) {
29606
+ const r = readInstallIdentityDetailed(stateDir);
29607
+ return r.ok ? r.identity : null;
29589
29608
  }
29590
29609
  function writeIdentityContactEmail(stateDir, email) {
29591
29610
  const identity = loadOrCreateInstallIdentity(stateDir);