@peers-app/peers-sdk 0.21.0 → 0.21.1

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.
@@ -1,3 +1,4 @@
1
+ export * from "./package-author-signer";
1
2
  export * from "./package-author-signing";
2
3
  export * from "./package-cloner";
3
4
  export * from "./package-creator";
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./package-author-signer"), exports);
17
18
  __exportStar(require("./package-author-signing"), exports);
18
19
  __exportStar(require("./package-cloner"), exports);
19
20
  __exportStar(require("./package-creator"), exports);
@@ -0,0 +1,25 @@
1
+ import { type AuthorSignableFields } from "./package-author-signing";
2
+ /**
3
+ * Load and decrypt the package author signing secret key from the user's personal group.
4
+ * Returns `undefined` when the key is missing or cannot be decrypted.
5
+ *
6
+ * @param packageId - Package whose `packageSigningKey_<id>` secret pvar to load
7
+ * @param getUserSecretKey - Platform callback that returns the signed-in user's secret key
8
+ */
9
+ export declare function loadPackageSigningKey(packageId: string, getUserSecretKey: () => Promise<string>): Promise<string | undefined>;
10
+ /**
11
+ * Sign a package version with the package author's key.
12
+ *
13
+ * Safe to call from Electron (main process) or PWA (single-process client). The
14
+ * signing key is loaded from a secret persistent variable and never returned to
15
+ * callers — only the detached signature is.
16
+ *
17
+ * Returns the base64url detached signature, or `undefined` if the signing key
18
+ * isn't available or signing fails. Callers that require a signature (e.g.
19
+ * remote publish) should treat `undefined` as an error; create/promote may leave
20
+ * `packageAuthorSignature` unset.
21
+ *
22
+ * @param pvFields - Author-signable PackageVersion fields
23
+ * @param getUserSecretKey - Platform callback that returns the signed-in user's secret key
24
+ */
25
+ export declare function trySignPackageAuthorVersion(pvFields: AuthorSignableFields, getUserSecretKey: () => Promise<string>): Promise<string | undefined>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadPackageSigningKey = loadPackageSigningKey;
4
+ exports.trySignPackageAuthorVersion = trySignPackageAuthorVersion;
5
+ const user_context_singleton_1 = require("../context/user-context-singleton");
6
+ const persistent_vars_1 = require("../data/persistent-vars");
7
+ const keys_1 = require("../keys");
8
+ const package_author_signing_1 = require("./package-author-signing");
9
+ /**
10
+ * Load and decrypt the package author signing secret key from the user's personal group.
11
+ * Returns `undefined` when the key is missing or cannot be decrypted.
12
+ *
13
+ * @param packageId - Package whose `packageSigningKey_<id>` secret pvar to load
14
+ * @param getUserSecretKey - Platform callback that returns the signed-in user's secret key
15
+ */
16
+ async function loadPackageSigningKey(packageId, getUserSecretKey) {
17
+ try {
18
+ const userContext = await (0, user_context_singleton_1.getUserContext)();
19
+ const secretKey = await getUserSecretKey();
20
+ const keyName = `${package_author_signing_1.PACKAGE_SIGNING_KEY_PREFIX}${packageId}`;
21
+ const keyPvar = await (0, persistent_vars_1.PersistentVars)(userContext.userDataContext).findOne({ name: keyName });
22
+ if (!keyPvar?.value?.value || !keyPvar.isSecret) {
23
+ return undefined;
24
+ }
25
+ return (0, keys_1.decryptData)(keyPvar.value.value, secretKey) || undefined;
26
+ }
27
+ catch {
28
+ return undefined;
29
+ }
30
+ }
31
+ /**
32
+ * Sign a package version with the package author's key.
33
+ *
34
+ * Safe to call from Electron (main process) or PWA (single-process client). The
35
+ * signing key is loaded from a secret persistent variable and never returned to
36
+ * callers — only the detached signature is.
37
+ *
38
+ * Returns the base64url detached signature, or `undefined` if the signing key
39
+ * isn't available or signing fails. Callers that require a signature (e.g.
40
+ * remote publish) should treat `undefined` as an error; create/promote may leave
41
+ * `packageAuthorSignature` unset.
42
+ *
43
+ * @param pvFields - Author-signable PackageVersion fields
44
+ * @param getUserSecretKey - Platform callback that returns the signed-in user's secret key
45
+ */
46
+ async function trySignPackageAuthorVersion(pvFields, getUserSecretKey) {
47
+ try {
48
+ const signingKey = await loadPackageSigningKey(pvFields.packageId, getUserSecretKey);
49
+ if (!signingKey) {
50
+ return undefined;
51
+ }
52
+ return (0, package_author_signing_1.signPackageAuthor)(pvFields, signingKey);
53
+ }
54
+ catch {
55
+ return undefined;
56
+ }
57
+ }
@@ -1,4 +1,5 @@
1
1
  import type { DataContext } from "../context/data-context";
2
+ import type { IPackageVersion } from "../data/package-versions";
2
3
  import type { IInstallOpts, IInstallResult, IPackageInfo, IPackageInstallerDeps } from "./types";
3
4
  /**
4
5
  * Install or update a dev PackageVersion from locally-built bundle files.
@@ -9,6 +10,20 @@ import type { IInstallOpts, IInstallResult, IPackageInfo, IPackageInstallerDeps
9
10
  * triggers the package loader and device version resolution.
10
11
  */
11
12
  export declare function installPackageFromBundles(dataContext: DataContext, deps: IPackageInstallerDeps, packageId: string, opts?: IInstallOpts): Promise<IInstallResult>;
13
+ /**
14
+ * Ensure a PackageVersion has `appNavs` from its package definition.
15
+ * No-ops when appNavs are already present or the package cannot be loaded.
16
+ *
17
+ * Used to repair PVs that were created with `skipLoad` (startup sync while the
18
+ * group was not on `dev`) and later activated/promoted without nav metadata.
19
+ *
20
+ * @param dataContext - Group or personal data context holding the PV
21
+ * @param deps - Filesystem / path helpers
22
+ * @param packageId - Package that owns the version
23
+ * @param packageVersionId - Specific PV to repair
24
+ * @returns The PV after any update, or `undefined` if not found
25
+ */
26
+ export declare function ensurePackageVersionAppNavs(dataContext: DataContext, deps: IPackageInstallerDeps, packageId: string, packageVersionId: string): Promise<IPackageVersion | undefined>;
12
27
  /**
13
28
  * Install bundles for all non-disabled packages in a data context.
14
29
  * Errors are caught per-package so one failure doesn't block others.
@@ -30,3 +45,15 @@ export declare function saveBundleFile(dataContext: DataContext, content: string
30
45
  * Uses `deps.fs.readJson` instead of `require()` — no cache issues.
31
46
  */
32
47
  export declare function getPackageInfo(deps: IPackageInstallerDeps, localPath: string): Promise<IPackageInfo>;
48
+ /**
49
+ * Resolve the local filesystem path for a package based on device vars.
50
+ * Awaits the loading promise to ensure the DB-stored value is available
51
+ * before reading. Falls back to paths from other data contexts on this device,
52
+ * then to `{packagesRootDir}/{name-slug}` when that directory exists.
53
+ *
54
+ * @param packageId - Package to resolve
55
+ * @param dataContext - Preferred data context for the `packageLocalPath_*` device var
56
+ * @param deps - Filesystem / path helpers used by the package installer
57
+ * @returns Absolute (or deps-resolved) path to the package directory
58
+ */
59
+ export declare function getPackageLocalPath(packageId: string, dataContext: DataContext, deps: IPackageInstallerDeps): Promise<string>;
@@ -1,15 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.installPackageFromBundles = installPackageFromBundles;
4
+ exports.ensurePackageVersionAppNavs = ensurePackageVersionAppNavs;
4
5
  exports.installAllPackageBundles = installAllPackageBundles;
5
6
  exports.saveBundleFile = saveBundleFile;
6
7
  exports.getPackageInfo = getPackageInfo;
8
+ exports.getPackageLocalPath = getPackageLocalPath;
7
9
  const file_types_1 = require("../data/files/file.types");
8
10
  const files_1 = require("../data/files/files");
9
11
  const package_version_resolver_1 = require("../data/package-version-resolver");
10
12
  const package_versions_1 = require("../data/package-versions");
11
13
  const packages_1 = require("../data/packages");
12
14
  const persistent_vars_1 = require("../data/persistent-vars");
15
+ const rpc_types_1 = require("../rpc-types");
13
16
  const utils_1 = require("../utils");
14
17
  /**
15
18
  * Install or update a dev PackageVersion from locally-built bundle files.
@@ -50,14 +53,22 @@ async function installPackageFromBundles(dataContext, deps, packageId, opts) {
50
53
  const uiHash = uiBundle ? (0, file_types_1.computeFileHash)(uiBundle) : undefined;
51
54
  // 5. Compute PV hash
52
55
  const pvHash = (0, package_versions_1.computePackageVersionHash)(version, "", packageHash, routesHash, uiHash);
53
- // 6. Early exit if unchanged
56
+ // 6. Early exit if unchanged (still repair missing appNavs — see syncDevBundles skipLoad)
54
57
  const pvTable = (0, package_versions_1.PackageVersions)(dataContext);
55
58
  const existingPv = await pvTable.findOne({ packageId, versionTag });
56
59
  if (existingPv && existingPv.packageVersionHash === pvHash) {
60
+ if (existingPv.appNavs?.length) {
61
+ return {
62
+ packageVersion: existingPv,
63
+ loaded: undefined,
64
+ unchanged: true,
65
+ };
66
+ }
67
+ const loaded = await loadAndPersistAppNavs(dataContext, packageId, existingPv, localPath);
57
68
  return {
58
69
  packageVersion: existingPv,
59
- loaded: undefined,
60
- unchanged: true,
70
+ loaded,
71
+ unchanged: !loaded?.appNavs?.length,
61
72
  };
62
73
  }
63
74
  // 7. Save bundle files (deduped by hash)
@@ -91,22 +102,13 @@ async function installPackageFromBundles(dataContext, deps, packageId, opts) {
91
102
  createdAt: now,
92
103
  };
93
104
  const savedPv = await pvTable.signAndSave(pv);
94
- // 9. Load package (unless skipLoad)
105
+ // 9. Load package for in-memory use and/or appNavs backfill.
106
+ // `skipLoad` is used by startup sync when the group is not on `dev` (avoid
107
+ // activating), but we must still persist appNavs or the apps list stays empty
108
+ // after that PV is later activated/promoted.
95
109
  let loaded;
96
- if (!opts?.skipLoad) {
97
- const pkg = await (0, packages_1.Packages)(dataContext).get(packageId);
98
- if (pkg) {
99
- loaded = await dataContext.packageLoader.loadPackage(pkg, {
100
- force: true,
101
- localPath,
102
- packageVersionId: savedPv.packageVersionId,
103
- });
104
- // Extract appNavs from loaded instance onto the PV
105
- if (loaded?.appNavs && JSON.stringify(loaded.appNavs) !== JSON.stringify(savedPv.appNavs)) {
106
- savedPv.appNavs = loaded.appNavs;
107
- await pvTable.signAndSave(savedPv);
108
- }
109
- }
110
+ if (!opts?.skipLoad || !savedPv.appNavs?.length) {
111
+ loaded = await loadAndPersistAppNavs(dataContext, packageId, savedPv, localPath);
110
112
  }
111
113
  // 10. Update package record if needed (description, first-install activation)
112
114
  const pkg = await (0, packages_1.Packages)(dataContext).get(packageId);
@@ -134,6 +136,69 @@ async function installPackageFromBundles(dataContext, deps, packageId, opts) {
134
136
  }
135
137
  return { packageVersion: savedPv, loaded, unchanged: false };
136
138
  }
139
+ /**
140
+ * Load a package bundle and persist `appNavs` onto the PackageVersion when the
141
+ * definition provides them.
142
+ *
143
+ * If the PV already has a `packageAuthorSignature`, refresh it (or clear it when
144
+ * the signing key is unavailable) because `appNavs` is part of the author-signed
145
+ * payload.
146
+ */
147
+ async function loadAndPersistAppNavs(dataContext, packageId, pv, localPath) {
148
+ const pkg = await (0, packages_1.Packages)(dataContext).get(packageId);
149
+ if (!pkg)
150
+ return undefined;
151
+ const loaded = await dataContext.packageLoader.loadPackage(pkg, {
152
+ force: true,
153
+ localPath,
154
+ packageVersionId: pv.packageVersionId,
155
+ });
156
+ if (!loaded?.appNavs?.length)
157
+ return loaded;
158
+ if (JSON.stringify(loaded.appNavs) === JSON.stringify(pv.appNavs))
159
+ return loaded;
160
+ pv.appNavs = loaded.appNavs;
161
+ if (pv.packageAuthorSignature) {
162
+ const authorSig = await rpc_types_1.rpcServerCalls.signPackageAuthorVersion({
163
+ packageId: pv.packageId,
164
+ packageVersionId: pv.packageVersionId,
165
+ version: pv.version,
166
+ versionTag: pv.versionTag ?? "",
167
+ packageBundleFileHash: pv.packageBundleFileHash,
168
+ routesBundleFileHash: pv.routesBundleFileHash,
169
+ uiBundleFileHash: pv.uiBundleFileHash,
170
+ appNavs: pv.appNavs,
171
+ createdBy: pv.createdBy,
172
+ createdAt: pv.createdAt,
173
+ });
174
+ pv.packageAuthorSignature = authorSig;
175
+ }
176
+ await (0, package_versions_1.PackageVersions)(dataContext).signAndSave(pv);
177
+ return loaded;
178
+ }
179
+ /**
180
+ * Ensure a PackageVersion has `appNavs` from its package definition.
181
+ * No-ops when appNavs are already present or the package cannot be loaded.
182
+ *
183
+ * Used to repair PVs that were created with `skipLoad` (startup sync while the
184
+ * group was not on `dev`) and later activated/promoted without nav metadata.
185
+ *
186
+ * @param dataContext - Group or personal data context holding the PV
187
+ * @param deps - Filesystem / path helpers
188
+ * @param packageId - Package that owns the version
189
+ * @param packageVersionId - Specific PV to repair
190
+ * @returns The PV after any update, or `undefined` if not found
191
+ */
192
+ async function ensurePackageVersionAppNavs(dataContext, deps, packageId, packageVersionId) {
193
+ const pv = await (0, package_versions_1.PackageVersions)(dataContext).get(packageVersionId);
194
+ if (!pv)
195
+ return undefined;
196
+ if (pv.appNavs?.length)
197
+ return pv;
198
+ const localPath = await getPackageLocalPath(packageId, dataContext, deps);
199
+ await loadAndPersistAppNavs(dataContext, packageId, pv, localPath);
200
+ return pv;
201
+ }
137
202
  /**
138
203
  * Install bundles for all non-disabled packages in a data context.
139
204
  * Errors are caught per-package so one failure doesn't block others.
@@ -247,6 +312,11 @@ function packageNameToFolderSlug(name) {
247
312
  * Awaits the loading promise to ensure the DB-stored value is available
248
313
  * before reading. Falls back to paths from other data contexts on this device,
249
314
  * then to `{packagesRootDir}/{name-slug}` when that directory exists.
315
+ *
316
+ * @param packageId - Package to resolve
317
+ * @param dataContext - Preferred data context for the `packageLocalPath_*` device var
318
+ * @param deps - Filesystem / path helpers used by the package installer
319
+ * @returns Absolute (or deps-resolved) path to the package directory
250
320
  */
251
321
  async function getPackageLocalPath(packageId, dataContext, deps) {
252
322
  const candidates = [];
@@ -440,6 +440,55 @@ describe("installPackageFromBundles", () => {
440
440
  const secondCall = mockSignAndSavePV.mock.calls[1][0];
441
441
  expect(secondCall.appNavs).toEqual(appNavs);
442
442
  });
443
+ it("backfills appNavs even when skipLoad is true", async () => {
444
+ const { deps } = setupBasicInstall();
445
+ const appNavs = [{ name: "App", iconClassName: "bi bi-app", navigationPath: "app" }];
446
+ const mockLoadPackage = jest.fn().mockResolvedValue({ packageId, appNavs });
447
+ const dc = mockDataContext({
448
+ packageLoader: { loadPackage: mockLoadPackage },
449
+ });
450
+ await (0, package_installer_1.installPackageFromBundles)(dc, deps, packageId, {
451
+ skipLoad: true,
452
+ skipResolve: true,
453
+ });
454
+ expect(mockLoadPackage).toHaveBeenCalled();
455
+ expect(mockSignAndSavePV).toHaveBeenCalledTimes(2);
456
+ expect(mockSignAndSavePV.mock.calls[1][0].appNavs).toEqual(appNavs);
457
+ });
458
+ it("repairs missing appNavs on unchanged early-return", async () => {
459
+ const { deps } = setupBasicInstall();
460
+ const packageHash = (0, file_types_1.computeFileHash)(packageBundle);
461
+ const routesHash = (0, file_types_1.computeFileHash)(routesBundle);
462
+ const uiHash = (0, file_types_1.computeFileHash)(uiBundle);
463
+ const { computePackageVersionHash } = jest.requireActual("../data/package-versions");
464
+ const expectedPvHash = computePackageVersionHash("1.2.3", "", packageHash, routesHash, uiHash);
465
+ const appNavs = [{ name: "App", iconClassName: "bi bi-app", navigationPath: "app" }];
466
+ mockFindOnePV.mockResolvedValue({
467
+ packageVersionId: (0, utils_1.newid)(),
468
+ packageId,
469
+ version: "1.2.3",
470
+ versionTag: "dev",
471
+ packageVersionHash: expectedPvHash,
472
+ packageBundleFileHash: packageHash,
473
+ routesBundleFileHash: routesHash,
474
+ uiBundleFileHash: uiHash,
475
+ appNavs: undefined,
476
+ signature: "sig",
477
+ createdBy: "user1",
478
+ createdAt: "2024-01-01T00:00:00.000Z",
479
+ });
480
+ const mockLoadPackage = jest.fn().mockResolvedValue({ packageId, appNavs });
481
+ const dc = mockDataContext({
482
+ packageLoader: { loadPackage: mockLoadPackage },
483
+ });
484
+ const result = await (0, package_installer_1.installPackageFromBundles)(dc, deps, packageId, {
485
+ skipLoad: true,
486
+ skipResolve: true,
487
+ });
488
+ expect(mockLoadPackage).toHaveBeenCalled();
489
+ expect(result.packageVersion.appNavs).toEqual(appNavs);
490
+ expect(mockSignAndSavePV).toHaveBeenCalledTimes(1);
491
+ });
443
492
  it("calls updatePackagePrefs and resolveDevicePackageVersion when skipResolve is false", async () => {
444
493
  const { deps } = setupBasicInstall();
445
494
  const dc = mockDataContext();
@@ -47,7 +47,7 @@ export interface IInstallOpts {
47
47
  localPath?: string;
48
48
  /** Version tag for the created PackageVersion. Defaults to `"dev"`. */
49
49
  versionTag?: string;
50
- /** Skip `packageLoader.loadPackage` (useful for batch installs). */
50
+ /** Skip keeping the package in the loader cache for activation. AppNavs are still backfilled when missing. */
51
51
  skipLoad?: boolean;
52
52
  /** Skip `resolveDevicePackageVersion` after install. */
53
53
  skipResolve?: boolean;
@@ -23,9 +23,9 @@ export declare class PackageLoader {
23
23
  private _readLocalBundle;
24
24
  /**
25
25
  * Post-correction: if the package definition carries a version string,
26
- * update the active IPackageVersion record to match. This fixes cases where
27
- * the PV record was created with stale or placeholder values (e.g. "0.0.1")
28
- * before the bundle was evaluated.
26
+ * update the active IPackageVersion record to match — but only when that
27
+ * active version is the mutable `dev` working copy. Never rewrite
28
+ * beta/stable version labels from a local package.json bump.
29
29
  */
30
30
  private correctPackageVersion;
31
31
  private _evaluateBundle;
@@ -104,9 +104,9 @@ class PackageLoader {
104
104
  }
105
105
  /**
106
106
  * Post-correction: if the package definition carries a version string,
107
- * update the active IPackageVersion record to match. This fixes cases where
108
- * the PV record was created with stale or placeholder values (e.g. "0.0.1")
109
- * before the bundle was evaluated.
107
+ * update the active IPackageVersion record to match — but only when that
108
+ * active version is the mutable `dev` working copy. Never rewrite
109
+ * beta/stable version labels from a local package.json bump.
110
110
  */
111
111
  correctPackageVersion(pkg, def) {
112
112
  if (!pkg.activePackageVersionId)
@@ -119,8 +119,18 @@ class PackageLoader {
119
119
  .then((pv) => {
120
120
  if (!pv)
121
121
  return;
122
+ if (pv.versionTag !== "dev")
123
+ return;
122
124
  if (def.version && pv.version !== def.version) {
123
- return pvTable.signAndSave({ ...pv, version: def.version });
125
+ const packageVersionHash = (0, package_versions_1.computePackageVersionHash)(def.version, pv.versionTag || "dev", pv.packageBundleFileHash, pv.routesBundleFileHash, pv.uiBundleFileHash);
126
+ // Version is part of both the content hash and the author-signed
127
+ // payload — clear any prior author signature so it cannot go stale.
128
+ const { packageAuthorSignature: _staleSig, ...rest } = pv;
129
+ return pvTable.signAndSave({
130
+ ...rest,
131
+ version: def.version,
132
+ packageVersionHash,
133
+ });
124
134
  }
125
135
  })
126
136
  .catch((err) => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mockGet = jest.fn();
4
+ const mockSignAndSave = jest.fn();
5
+ const mockComputePackageVersionHash = jest.fn((version, _tag, packageBundleFileHash, _routesBundleFileHash, _uiBundleFileHash) => `hash-${version}-${packageBundleFileHash}`);
6
+ jest.mock("../data/package-versions", () => ({
7
+ PackageVersions: () => ({
8
+ get: (...args) => mockGet(...args),
9
+ signAndSave: (...args) => mockSignAndSave(...args),
10
+ }),
11
+ computePackageVersionHash: (version, versionTag, packageBundleFileHash, routesBundleFileHash, uiBundleFileHash) => mockComputePackageVersionHash(version, versionTag, packageBundleFileHash, routesBundleFileHash, uiBundleFileHash),
12
+ }));
13
+ const package_loader_1 = require("./package-loader");
14
+ describe("PackageLoader.correctPackageVersion", () => {
15
+ const activePvId = "pv-active";
16
+ const pkg = {
17
+ packageId: "pkg-1",
18
+ name: "Test Package",
19
+ activePackageVersionId: activePvId,
20
+ };
21
+ const def = { version: "0.3.6" };
22
+ let loader;
23
+ beforeEach(() => {
24
+ jest.clearAllMocks();
25
+ mockSignAndSave.mockResolvedValue(undefined);
26
+ loader = new package_loader_1.PackageLoader({ dataContextId: "ctx" });
27
+ });
28
+ async function correctPackageVersion() {
29
+ loader.correctPackageVersion(pkg, def);
30
+ // Flush the fire-and-forget promise chain
31
+ await new Promise((r) => setImmediate(r));
32
+ }
33
+ it("updates the active PV hash and clears a stale author signature", async () => {
34
+ mockGet.mockResolvedValue({
35
+ packageVersionId: activePvId,
36
+ version: "0.3.1",
37
+ versionTag: "dev",
38
+ packageBundleFileHash: "bundle-hash",
39
+ routesBundleFileHash: "routes-hash",
40
+ uiBundleFileHash: "ui-hash",
41
+ packageAuthorSignature: "stale-sig",
42
+ packageVersionHash: "old-hash",
43
+ });
44
+ await correctPackageVersion();
45
+ expect(mockComputePackageVersionHash).toHaveBeenCalledWith("0.3.6", "dev", "bundle-hash", "routes-hash", "ui-hash");
46
+ expect(mockSignAndSave).toHaveBeenCalledWith(expect.objectContaining({
47
+ packageVersionId: activePvId,
48
+ version: "0.3.6",
49
+ versionTag: "dev",
50
+ packageVersionHash: "hash-0.3.6-bundle-hash",
51
+ }));
52
+ expect(mockSignAndSave.mock.calls[0][0].packageAuthorSignature).toBeUndefined();
53
+ });
54
+ it("does not update the active PV when it is stable", async () => {
55
+ mockGet.mockResolvedValue({
56
+ packageVersionId: activePvId,
57
+ version: "0.3.5",
58
+ versionTag: "stable",
59
+ });
60
+ await correctPackageVersion();
61
+ expect(mockSignAndSave).not.toHaveBeenCalled();
62
+ });
63
+ it("does not update the active PV when it is beta", async () => {
64
+ mockGet.mockResolvedValue({
65
+ packageVersionId: activePvId,
66
+ version: "0.3.5",
67
+ versionTag: "beta",
68
+ });
69
+ await correctPackageVersion();
70
+ expect(mockSignAndSave).not.toHaveBeenCalled();
71
+ });
72
+ it("does nothing when the active PV version already matches", async () => {
73
+ mockGet.mockResolvedValue({
74
+ packageVersionId: activePvId,
75
+ version: "0.3.6",
76
+ versionTag: "dev",
77
+ });
78
+ await correctPackageVersion();
79
+ expect(mockSignAndSave).not.toHaveBeenCalled();
80
+ });
81
+ });
@@ -2,6 +2,7 @@ import type { IDeviceDatabaseQueryResult, IDeviceOperationStatus, IDeviceToolRun
2
2
  import type { ITool } from "./data/tools";
3
3
  import type { DevicePairingCeremonyAction, DevicePairingStartDestinationInput, DevicePairingStartSourceResult, DevicePairingState } from "./device-pairing";
4
4
  import type { IConsoleLog } from "./logging/console-logs.table";
5
+ import type { IAppNav } from "./types/app-nav";
5
6
  /** Named event payload sent across the frontend RPC bridge. */
6
7
  export interface IEventData<T = any> {
7
8
  name: string;
@@ -115,6 +116,8 @@ export declare const rpcServerCalls: {
115
116
  /**
116
117
  * Sign a package version with the package author's key (server-side only — key never leaves the server).
117
118
  * Returns the base64url detached signature, or undefined if the signing key isn't available.
119
+ * Optional fields (appNavs, createdBy, createdAt) must match the PV record when present so
120
+ * propagation verification of the full record succeeds.
118
121
  */
119
122
  signPackageAuthorVersion: (pvFields: {
120
123
  packageId: string;
@@ -124,6 +127,9 @@ export declare const rpcServerCalls: {
124
127
  packageBundleFileHash: string;
125
128
  routesBundleFileHash?: string;
126
129
  uiBundleFileHash?: string;
130
+ appNavs?: IAppNav[];
131
+ createdBy?: string;
132
+ createdAt?: string;
127
133
  }) => Promise<string | undefined>;
128
134
  registerWithPeersServices: () => Promise<string>;
129
135
  appQuit: () => Promise<void>;
package/dist/rpc-types.js CHANGED
@@ -58,6 +58,8 @@ exports.rpcServerCalls = {
58
58
  /**
59
59
  * Sign a package version with the package author's key (server-side only — key never leaves the server).
60
60
  * Returns the base64url detached signature, or undefined if the signing key isn't available.
61
+ * Optional fields (appNavs, createdBy, createdAt) must match the PV record when present so
62
+ * propagation verification of the full record succeeds.
61
63
  */
62
64
  signPackageAuthorVersion: rpcStub("signPackageAuthorVersion"),
63
65
  registerWithPeersServices: rpcStub("registerWithPeersServices"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-sdk",
3
- "version": "0.21.0",
3
+ "version": "0.21.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-sdk.git"