@peers-app/peers-sdk 0.25.12 → 0.25.14

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.
@@ -128,6 +128,17 @@ describe("package-author-signing", () => {
128
128
  const result = (0, package_author_signing_1.verifyPackageAuthorSignature)(tampered, keys.publicKey);
129
129
  expect(result.valid).toBe(false);
130
130
  });
131
+ it("fails when a signed createdBy is changed", () => {
132
+ const signed = makePV({ createdBy: "00author0000000000000000a" });
133
+ const signedSignature = (0, package_author_signing_1.signPackageAuthor)(signed, keys.secretKey);
134
+ const tampered = {
135
+ ...signed,
136
+ createdBy: "00attacker000000000000000a",
137
+ packageAuthorSignature: signedSignature,
138
+ };
139
+ const result = (0, package_author_signing_1.verifyPackageAuthorSignature)(tampered, keys.publicKey);
140
+ expect(result.valid).toBe(false);
141
+ });
131
142
  });
132
143
  describe("verification fails with wrong key", () => {
133
144
  it("rejects when verified against a different key", () => {
@@ -33,7 +33,11 @@ export interface IBuildPublishArtifactsOpts {
33
33
  packageVersionId?: string;
34
34
  /** App navigation items to include in the tarball metadata. */
35
35
  appNavs?: IAppNav[];
36
- /** Peer ID of the publisher. Recorded as `createdBy` on the PV. */
36
+ /**
37
+ * Peer ID recorded as `createdBy` and covered by the author signature.
38
+ * Defaults to `packageId`. The remote installer persists this field, and
39
+ * clients reject the version when the stored value is not the one that was signed.
40
+ */
37
41
  createdBy?: string;
38
42
  }
39
43
  /** Artifacts produced by {@link buildPublishArtifacts}. */
@@ -42,7 +42,7 @@ async function buildPublishArtifacts(opts) {
42
42
  routesBundleFileHash,
43
43
  uiBundleFileHash,
44
44
  appNavs: opts.appNavs,
45
- createdBy: opts.createdBy,
45
+ createdBy: opts.createdBy || packageId,
46
46
  createdAt: now,
47
47
  };
48
48
  const payload = (0, package_author_signing_1.buildAuthorSignedPayload)(pvFields, publicKey);
@@ -93,6 +93,17 @@ describe("package-publisher", () => {
93
93
  const sigResult = (0, package_author_signing_1.verifyPackageAuthorSignature)(result.payload, wrongKeys.publicKey);
94
94
  expect(sigResult.valid).toBe(false);
95
95
  });
96
+ it("signs the package id as createdBy when the caller omits it", async () => {
97
+ const keys = (0, keys_1.newKeys)();
98
+ const opts = makeOpts({
99
+ publicKey: keys.publicKey,
100
+ sign: (payload) => (0, package_author_signing_1.signPackageAuthor)(payload, keys.secretKey),
101
+ });
102
+ const result = await (0, package_publisher_1.buildPublishArtifacts)(opts);
103
+ const unpacked = await (0, package_tarball_1.unpackPeersTarball)(result.tarball);
104
+ expect(unpacked.payload.createdBy).toBe(opts.packageId);
105
+ expect((0, package_author_signing_1.verifyPackageAuthorSignature)({ ...unpacked.payload, createdBy: opts.packageId }, keys.publicKey).valid).toBe(true);
106
+ });
96
107
  it("defaults versionTag to stable", async () => {
97
108
  const result = await (0, package_publisher_1.buildPublishArtifacts)(makeOpts());
98
109
  expect(result.pointer.versionTag).toBe("stable");
@@ -172,6 +172,9 @@ async function installRemotePackageVersion(dataContext, result) {
172
172
  appNavs: unpacked.payload.appNavs,
173
173
  packageAuthorSignature: unpacked.payload.packageAuthorSignature,
174
174
  signature: "",
175
+ // New publications include createdBy in the signed payload. Legacy
176
+ // tarballs omitted it, so their required database value defaults to the
177
+ // package id but does not pass later record-level author verification.
175
178
  createdBy: unpacked.payload.createdBy ?? packageId,
176
179
  createdAt: unpacked.payload.createdAt ?? new Date().toISOString(),
177
180
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-sdk",
3
- "version": "0.25.12",
3
+ "version": "0.25.14",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-sdk.git"