@c4roa0/agentpay-user 0.3.1 → 0.3.2

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/AGENTS.md CHANGED
@@ -135,3 +135,13 @@ load Protocol fixtures from the pinned public package, not a source checkout.
135
135
  Do not remove scripts merely because their name contains smoke or Anvil: some are
136
136
  current onboarding entries. Review callers first. Never weaken signer or payment
137
137
  boundaries to simplify tests. Keep source maps and behavioral evidence limits current.
138
+
139
+ ## Tag-triggered npm releases
140
+
141
+ Package version `X.Y.Z` is released by pushing tag `vX.Y.Z` at the exact reviewed
142
+ source commit. `.github/workflows/publish.yml` validates this match, verifies the
143
+ package, publishes through OIDC and checks registry integrity. Pushing a release
144
+ tag is a publication action and needs maintainer authorization; ordinary branch
145
+ pushes do not publish. Never move an existing release tag. Verify registry state
146
+ before rerunning a failed publication. The `npm-publish` environment must allow
147
+ release tags (for example `v*`), not only the main branch.
package/README.md CHANGED
@@ -15,7 +15,7 @@ Install User with the command below. It automatically installs the matching Wall
15
15
  and Protocol packages; you do not need to download two repositories:
16
16
 
17
17
  ```sh
18
- npm install --global @c4roa0/agentpay-user@0.3.1
18
+ npm install --global @c4roa0/agentpay-user
19
19
  agentpay install --market https://YOUR_MARKET_ORIGIN
20
20
  ```
21
21
 
package/doc/TODO.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # User TODO
2
2
 
3
+ ## Tag-triggered publication
4
+
5
+ - [x] Use matching `vX.Y.Z` tags for npm publication; retain verification gates.
6
+ - [x] Owner confirmed release tags allowed in the GitHub `npm-publish` environment.
7
+ - [ ] Verify the first tag-triggered OIDC publication and registry integrity.
8
+
9
+ ## Official package 1.2.1 — 2026-11-08
10
+
11
+ - [x] Review actual published bytes, update the built-in official pin and verify fixed-download checks. Real Market fixed-version download/install repeated successfully in an isolated directory.
12
+ - [x] Inspect this participant installation’s prior-version official tests: saved 1.2.0 record is acknowledged; retained unchanged. This does not assert every user has completed old tests.
13
+ - [x] Load the reviewed User source update and run the normal 1.2.1 payment test with explicit user consent; terminal delivery/result/ack completed.
14
+ - [x] Verify website visibility and independently reconcile Settlement/chain outcome; prepare User 0.3.2 candidate.
15
+ - [x] Pin the verified public Wallet 0.3.2; align package/lockfile/update-pair.
16
+ - [ ] Publish User 0.3.2 through OIDC and verify registry artifact; then accept a real npm update.
17
+
18
+
19
+ ## Fixed Skill download loop — 2026-11-08
20
+
21
+ - [x] Request the official ZIP by the built-in SHA-256; reject unavailable/substituted versions without fallback.
22
+ - [x] Complete fixed-download regression/type checks and publication/deletion review; the separate Market schema-fixture issue was resolved in its later regression.
23
+ - [ ] After Market API/Web/nginx support is live, publish the next User version (not 0.3.1 again) and verify old pinned ZIP download and participant upgrade.
24
+
25
+
3
26
  ## Running-version release loop — 2026-11-07
4
27
 
5
28
  - [x] Verify User 0.3.0 public-registry publication; Trusted Publisher configured.
@@ -7,7 +30,8 @@
7
30
  - [x] Add process-start software reporting and status/repair mismatch handling; isolated checks passed.
8
31
  - [x] Wallet 0.3.1 published through the configured workflow; public npm version/dependencies verified.
9
32
  - [x] Pin User 0.3.1 to published Wallet 0.3.1; pairing metadata/lockfile and standalone archive verification complete.
10
- - [ ] Publish matching User release; validate User OIDC and real published-version update/restart.
33
+ - [x] Publish User 0.3.1; verify public npm/latest and successful Wallet/User OIDC runs.
34
+ - [ ] Verify real published-version update/restart on the participant installation.
11
35
 
12
36
 
13
37
  ## npm update follow-up — 2026-11-07
@@ -25,11 +49,12 @@
25
49
  - [x] Review step 2: guard normal packing against missing/stale builds, correct public-interface docs and verify a standalone TypeScript consumer.
26
50
  - [x] Step 3: migrate User to Wallet npm dependency and `agentpay` entry; remove sibling/build assumptions; isolated tarball/process acceptance passed.
27
51
  - [x] Step 4a: exact installed-package checks, service-path/client relocation, installer lock, recovery-safe preparation and explicit uninstall modes.
28
- - [ ] Step 4b: running-daemon version/interface negotiation and participant upgrade/interruption acceptance.
52
+ - [x] Step 4b implementation: installed/running version and interface checks.
53
+ - [ ] Step 4b acceptance: participant upgrade/interruption recovery (same gate as the running-version loop above).
29
54
  - [ ] Step 5: publish Wallet then User via OIDC; verify registry installs and update Market guides.
30
55
  - [x] Wallet 0.3.0 first Token publication; registry integrity/latest and fresh public install/CLI/IPC verified.
31
- - [x] Owner configured Wallet npm Trusted Publisher (pending validation).
32
- - [ ] Validate Wallet and User OIDC with later reviewed releases. Both 0.3.0 packages are published; Market guide updates remain pending.
56
+ - [x] Owner configured Wallet npm Trusted Publisher; validated by 0.3.1 publication.
57
+ - [x] Wallet and User OIDC validated by 0.3.1 releases; Market guide updates remain pending.
33
58
  - [ ] Step 6: participant setup/upgrade/restart/uninstall and official Anvil paid acceptance.
34
59
 
35
60
 
@@ -58,7 +83,7 @@
58
83
  ## Independent distribution (next development loop)
59
84
 
60
85
  - [ ] Define the supported Wallet client/IPC boundary and source/build/running compatibility requirements.
61
- - [ ] Replace exact version pairing with reviewed compatibility checks; preserve keys, Policies and recovery.
86
+ - [ ] Optional later: widen exact reviewed dependency pairs only with a verified compatibility matrix; preserve keys, Policies and recovery.
62
87
  - [ ] Optional later: combined ZIP/platform assets after primary npm installation acceptance.
63
88
  - [ ] Verify fresh Git/ZIP installation and missing/incompatible/stale version recovery; update Market guidance.
64
89
 
@@ -1,56 +1,62 @@
1
1
  # Publish User to npm
2
2
 
3
- This publishes the User CLI and Runtime, with its exact reviewed Wallet dependency.
4
- It does not deploy platform services or alter participant keys, Policies or Orders.
3
+ Push a reviewed `vX.Y.Z` tag to publish `@c4roa0/agentpay-user` through GitHub
4
+ Actions. The tag must match `package.json`. Ordinary branch pushes do not publish.
5
+ Keep `update-pair.json`, the lockfile and the reviewed Wallet dependency aligned.
6
+ Publish the required Wallet version before releasing User.
5
7
 
6
- ## Verify a release
8
+ ## One-time setup
7
9
 
8
- From a clean reviewed source checkout, using Node 22.22.3 or newer:
10
+ In GitHub **Settings → Environments → npm-publish**, allow deployment from tags
11
+ matching `v*`. A rule allowing only the `main` branch will block tag releases.
12
+ Keep required reviewer approval if desired. Restrict creation, update and deletion
13
+ of release tags to maintainers through repository rules.
9
14
 
10
- ```sh
11
- npm ci --ignore-scripts
12
- npm test
13
- node scripts/test-package.mjs artifacts/npm
14
- ```
15
+ On npm, configure this package's Trusted Publisher:
16
+
17
+ | Field | Value |
18
+ | --- | --- |
19
+ | Publisher | GitHub Actions |
20
+ | Organization/user | `c4rO-0` |
21
+ | Repository | `agentpay-user` |
22
+ | Workflow filename | `publish.yml` |
23
+ | Environment name | `npm-publish` |
24
+ | Allowed action | Direct publishing |
15
25
 
16
- Review the package inventory and README. The archive check installs the package in
17
- an isolated directory, checks the public command and starts disposable Wallet/Runtime
18
- processes. It never uses a participant's private data. Keep the exact verified archive
19
- for publication; do not rebuild it between verification and upload.
26
+ Existing matching npm trust settings need no change. The first successful OIDC
27
+ publication validates a pending connection; a local token upload does not.
28
+ No stored npm token is needed by this workflow.
20
29
 
21
- ## First publication
30
+ ## Release a version
22
31
 
23
- Authenticate as the package maintainer, then publish the verified archive:
32
+ 1. Update `package.json` and the changelog. Review code, documentation, dependencies
33
+ and package contents; complete the repository's verification steps.
34
+ 2. Commit and push the reviewed source to main, including the tag-triggered workflow.
35
+ 3. Create an annotated tag at that exact commit and push it. Replace `X.Y.Z` and
36
+ `REVIEWED_COMMIT` below with the release version and reviewed commit:
24
37
 
25
38
  ```sh
26
- npm publish artifacts/npm/c4roa0-agentpay-user-0.3.0.tgz --access public --ignore-scripts --registry=https://registry.npmjs.org/
27
- node scripts/verify-npm-release.mjs artifacts/npm/c4roa0-agentpay-user-0.3.0.tgz 0.3.0
39
+ git tag -a vX.Y.Z REVIEWED_COMMIT -m "Release X.Y.Z"
40
+ git push origin vX.Y.Z
28
41
  ```
29
42
 
30
- Never commit or share a publishing Token. If npm stages the first release, approve
31
- it on npm before verifying. A timeout is not proof of failure: check the registry
32
- before retrying publication. Published version numbers cannot be reused.
33
-
34
- ## GitHub Trusted Publisher
43
+ Pushing the tag starts **Publish User to npm** automatically. There is no version
44
+ input or separate Run workflow step. If the environment requires approval, approve
45
+ that deployment in GitHub. The workflow checks the tag against the manifest before
46
+ building, runs the existing verification gates, tests/packs the archive, publishes
47
+ with OIDC and checks public registry integrity. It builds the tagged source, even
48
+ if main advances. No production service or participant Wallet is upgraded.
35
49
 
36
- Create the GitHub environment `npm-publish` and restrict its deployment branch to
37
- `main`. Add maintainer approval if desired. In the npm package's Trusted Publisher
38
- settings, select GitHub Actions and enter:
50
+ ## Verify or recover a publication
39
51
 
40
- | Field | Value |
41
- | --- | --- |
42
- | Organization/user | `c4rO-0` |
43
- | Repository | `agentpay-user` |
44
- | Workflow filename | `publish.yml` |
45
- | Environment name | `npm-publish` |
46
- | Allowed action | Direct publishing |
52
+ Check the run's **Verify public registry integrity** result and the package version
53
+ on npm. Record the tag, source commit and result in progress. Do not claim success
54
+ from tag creation alone. Actual OIDC validation requires the GitHub run.
47
55
 
48
- Run **Publish User to npm** on `main` with a new reviewed package version matching
49
- `package.json` and `update-pair.json`. It tests, packs, verifies, publishes that exact
50
- archive through OIDC, and compares registry integrity. No stored npm Token is needed.
51
- The first successful OIDC release validates the connection; the initial Token upload
52
- does not. Afterwards, disable bypass-2FA tokens and retire unused publishing tokens.
53
- See [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers/).
56
+ If a run fails before upload, investigate before rerunning. If source needs a fix,
57
+ use a new version/tag; never move an existing release tag. If upload may have
58
+ succeeded, check registry state and archive integrity before rerunning; npm versions
59
+ are immutable and an already-published version must not be uploaded again.
54
60
 
55
- Publication is not real-network or participant upgrade acceptance. Record the exact
56
- source revision and verification outcome; test the published installation separately.
61
+ Publication is not participant upgrade acceptance, cross-platform verification or
62
+ real-funds approval.
@@ -9,9 +9,24 @@ hash reported by the same server that supplies the ZIP.
9
9
 
10
10
  This pin applies only to the maintained onboarding test. Generic Runtime calls and
11
11
  ordinary Skill installation do not require the random service or this package.
12
- The current pin is the reviewed random Skill 1.2.0 private rehearsal package;
12
+ The current pin is the reviewed random Skill 1.2.1 private rehearsal package;
13
13
  it includes its service reference. It is not a production-network release.
14
14
 
15
+ ## Download a fixed Market version
16
+
17
+ Setup and repair derive `/skills/bundles/:serviceId/versions/:sha256/metadata`
18
+ from the saved Market source, using User's built-in ZIP hash. They download the matching
19
+ fixed ZIP on the same origin and retain any `/market` ingress prefix. They no longer
20
+ require Market's current release to match the User release. The ZIP is still hashed
21
+ before parsing or saving; metadata cannot override the pin.
22
+
23
+ Market must retain the approved historical version and permit its public download.
24
+ If it is absent, withdrawn or no longer approved under current checks, preparation
25
+ stops with an unavailable message. No current-version or Provider-hosted fallback is
26
+ used. Existing local packages, requests and spending permission are unchanged.
27
+ This client change requires the Market fixed-version API rollout before distributing
28
+ the next User release; User 0.3.1 and earlier do not use this endpoint.
29
+
15
30
  ## Before publishing a User update
16
31
 
17
32
  1. Check whether the maintained official Skill has a new published version.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@c4roa0/agentpay-user",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "ethers": "^6.17.0",
7
- "fs-native-extensions": "1.5.3",
8
6
  "@c4roa0/agentpay-protocol": "0.14.3",
9
- "@c4roa0/agentpay-wallet": "0.3.1"
7
+ "@c4roa0/agentpay-wallet": "0.3.2",
8
+ "ethers": "^6.17.0",
9
+ "fs-native-extensions": "1.5.3"
10
10
  },
11
11
  "scripts": {
12
12
  "start": "node src/index.mjs",
package/progress.md CHANGED
@@ -1,6 +1,109 @@
1
1
  # AgentPay User progress
2
2
 
3
- ## User 0.3.1 paired release preparation — 2026-11-08
3
+ ## User 0.3.2 release pairing — 2026-11-08
4
+
5
+ Candidate now pins the verified public Wallet 0.3.2 with Protocol 0.14.3; package,
6
+ lockfile and update-pair metadata agree. This release includes fixed-version
7
+ Market downloads and the reviewed official Skill 1.2.1 pin. Historical notes
8
+ below describe earlier candidate pairings. Publish through tag `v0.3.2` after
9
+ final suite and standalone archive checks; no automatic new purchase is authorized.
10
+
11
+ ## Tag-triggered publication — 2026-11-08
12
+
13
+ Wallet, Protocol and User release workflows now run on pushed `vX.Y.Z` tags.
14
+ Each validates its package version, runs existing verification, publishes with
15
+ OIDC and checks registry integrity. Branch pushes do not publish. No tag was
16
+ pushed or npm version published for this workflow change. Owner confirmed `v*` tags allowed in the GitHub
17
+ `npm-publish` environment; npm trust fields remain unchanged. YAML/shell checks and six executable tag/version guard cases passed
18
+ per repository (matching version, mismatch, branch, prerelease, leading zero and
19
+ newline rejection). Actual GitHub/OIDC execution remains pending.
20
+
21
+ ## Official 1.2.1 payment reconciled / User 0.3.2 candidate — 2026-11-08
22
+
23
+ Participant confirmed Market Order visibility. Independent fixed-block chain reads,
24
+ receipts and token transfers match Settlement's finalized release record: paid
25
+ 0.7 rUSDC, seller 0.665, platform fee 0.035, no refund, empty Vault. Funding,
26
+ delivery and release events occur once for the verified Order. No further payment.
27
+ This is private Anvil acceptance, not real-network or production approval.
28
+ User 0.3.2 candidate includes fixed-version downloads and the reviewed official
29
+ 1.2.1 ZIP pin. Its preliminary package check used Wallet 0.3.1 and Protocol 0.14.3.
30
+ The maintainer requested Wallet 0.3.2 review/publication first; after registry
31
+ verification, update User’s exact dependency and reverify the final package.
32
+ Candidate publication and real npm update acceptance remain pending.
33
+
34
+ ## Official Skill 1.2.1 participant payment passed — 2026-11-08
35
+
36
+ Operator ran normal wallet unlock and payment-test commands after source repair.
37
+ The guide quoted a maximum 0.7 rUSDC and 10-minute service limit; the operator
38
+ explicitly confirmed. It reported delivery verification, saved-result verification
39
+ and receipt acknowledgement, then completed successfully. This is private Anvil
40
+ end-to-end participant evidence. The quoted maximum is not independently reconciled
41
+ actual charge; payout/refund terminal chain evidence has not been checked here.
42
+ User remains the 0.3.1-labelled source candidate, not a new published npm release.
43
+ Next: website Order visibility and read-only Settlement/chain reconciliation before
44
+ release closeout. Do not rerun a completed payment test just to inspect the result.
45
+
46
+ ## Participant repair completed — 2026-11-08
47
+
48
+ Operator ran the normal source repair entry. Official Skill 1.2.1 passed the
49
+ built-in hash check and was installed. Wallet and Runtime restarted; Wallet is
50
+ locked as expected. Saved Policy and Market connection remain present, and local
51
+ history reports two settled Orders plus one archived record. No purchase occurred.
52
+ This is source-candidate repair acceptance, not publication of a new npm version.
53
+ Next operator step unlocks Wallet and invokes the normal payment test; explicit
54
+ current-price confirmation remains required before creating a paid Order.
55
+
56
+ ## Official fixed-download acceptance — 2026-11-08
57
+
58
+ The normal prepareOfficialTestUpdate entry downloaded 1.2.1 twice from the running
59
+ Market fixed-version API into an isolated directory, verified the built-in hash,
60
+ installed successfully and preserved an existing prior-record fixture byte-for-byte.
61
+ The first diagnostic read assumed a flat archive; it was corrected to read the saved
62
+ publisher ZIP through User's parser. No product installation defect was found.
63
+ 17 targeted pin/download/update/payment-orchestration/prefix checks passed.
64
+ This proves download/install behavior, not paid invocation. No participant services
65
+ or Wallet data changed. Source repair and explicit payment acceptance are next;
66
+ the candidate is not yet a new npm release.
67
+
68
+ ## Official test pin 1.2.1 prepared — 2026-11-08
69
+
70
+ Reviewed the actual Provider ZIP and confirmed it matches the published fixed Market
71
+ download: 4373 bytes, SHA-256
72
+ `20633b314c66166f94dc6e7d7eb5bce54ab5901fb1ed314a04ea3fd49ca8a9a4`.
73
+ The official-test pin now selects 1.2.1; generic Runtime routing is unchanged.
74
+ The package checker and 14 controlled pin/download/update/payment-orchestration
75
+ checks passed. The payment fixture now follows the selected version instead of
76
+ hardcoding 1.2.0. No real payment, service restart or npm release was performed.
77
+ Before participant testing, check for unfinished tests from the previous version:
78
+ records are retained, but the payment-test entry selects a version-specific record.
79
+ Do not treat a new-version test as recovery of an old purchase.
80
+
81
+
82
+ ## Development dependency verification — 2026-11-08
83
+
84
+ Reinstalled dependencies from the unchanged lockfile after a stale local installation
85
+ could not resolve the already-declared Protocol package. Fixed-download/update/prefix
86
+ checks pass 8/8; the cross-repository publication/download/User preview regression
87
+ passes 27/27. No dependency pins, services or user data changed. This is controlled
88
+ verification, not a new npm release or live payment acceptance.
89
+
90
+
91
+ ## Fixed historical Skill downloads — 2026-11-08
92
+
93
+ Development adds SHA-256-fixed Market metadata/ZIP routes over retained releases,
94
+ a derived per-listing lookup, website forwarding and User official-test pin selection.
95
+ Current publication replacement no longer changes the requested ZIP. Hidden/deleted
96
+ listings, takedown, stale approval and damaged files remain unavailable. Historical
97
+ internal-version ZIP routes now also respect listing visibility. No DB migration,
98
+ Provider download dependency, service restart or payment was performed.
99
+ Deploy Market API/Web and the nginx route allowlist first, then release the updated User; current published User
100
+ 0.3.1 does not use the new fixed-version endpoint. Verification: User 33 targeted checks, Web 7 proxy checks, Deploy 8 route/build checks
101
+ and both Market/Web typechecks passed. Market publication regression: 69/70 passed;
102
+ the remaining pre-existing schema fixture fails with WALLET_MAPPING_SCHEMA_INVALID.
103
+ Controlled scanner/DB fixtures and local HTTP were used; no live database, nginx
104
+ rollout or participant acceptance is claimed.
105
+
106
+ ## User 0.3.1 paired release published — 2026-11-08
4
107
 
5
108
  Public npm now contains Wallet 0.3.1 with Protocol 0.14.3. User 0.3.1 pins that
6
109
  published Wallet exactly; pairing metadata and lockfile are updated together.
@@ -8,10 +111,19 @@ This release adds actual installed Protocol verification and running-version che
8
111
  for status/repair. Prior release-gate notes below describe earlier checkpoints.
9
112
  User 0.3.1 passed 378 behavioral tests and standalone npm archive installation,
10
113
  including real Wallet/Runtime restart and matching running-version reports.
11
- User 0.3.1 publication and real published-version upgrade acceptance remain pending.
114
+ User 0.3.1 is public and npm `latest`, with Wallet 0.3.1 and Protocol 0.14.3.
115
+ [User OIDC publication](https://github.com/c4rO-0/agentpay-user/actions/runs/42440841342)
116
+ passed from `46796ea`; [Wallet OIDC publication](https://github.com/c4rO-0/agentpay-wallet/actions/runs/42440112081)
117
+ passed from `7e4d4fa`. Registry metadata was independently checked.
118
+ Real published-version upgrade/restart acceptance remains pending.
12
119
  No participant services, keys, Policies or Orders are changed by package verification.
13
120
 
14
- ## Installed dependency verification / paired release — 2026-11-08
121
+ ## Historical checkpoints — superseded by the current release status above
122
+
123
+ The dated entries below preserve evidence and earlier decisions. Their pending
124
+ release labels are historical; use current TODO for remaining work.
125
+
126
+ ### Installed dependency verification / paired release — 2026-11-08
15
127
 
16
128
  User now checks the actual Protocol package resolved from User and Wallet separately,
17
129
  including nested npm copies. Process reports use resolved installed versions, not
@@ -7,7 +7,7 @@ import {
7
7
  verifyOfficialTestBytes,
8
8
  verifyOfficialTestDigest,
9
9
  } from "../src/official-test-package.mjs";
10
- import { marketDownloadUrl } from "../src/market-download-url.mjs";
10
+ import { marketDownloadUrl, marketVersionMetadataUrl } from "../src/market-download-url.mjs";
11
11
  import { resolve } from "node:path";
12
12
  import {
13
13
  inspectInstalledBundle,
@@ -42,7 +42,7 @@ if (
42
42
  }
43
43
  if (mode === "--prepare-official-test" && !marketMode)
44
44
  throw Error("OFFICIAL_TEST_MARKET_REQUIRED");
45
- const url = new URL(source);
45
+ const url = official ? marketVersionMetadataUrl(source, digest) : new URL(source);
46
46
  if (
47
47
  url.username ||
48
48
  url.password ||
@@ -62,6 +62,8 @@ if (marketMode) {
62
62
  redirect: "error",
63
63
  signal: AbortSignal.timeout(5000),
64
64
  });
65
+ if (official && [404, 410].includes(r.status))
66
+ throw Error("This official test version is unavailable in Market. Check for a reviewed User update or contact support; no replacement was selected.");
65
67
  if (!r.ok) throw new Error(`MARKET_BUNDLE_METADATA_HTTP_${r.status}`);
66
68
  const body = await r.json();
67
69
  metadata = body.result;
@@ -78,7 +80,7 @@ if (marketMode) {
78
80
  !metadata.publisherId ||
79
81
  typeof metadata.marketServiceId !== "string" ||
80
82
  metadata.marketDownloadPath !==
81
- `/skills/bundles/${encodeURIComponent(metadata.marketServiceId)}/download`
83
+ marketDownloadUrl(url, metadata.marketServiceId).pathname.replace(/^\/market(?=\/skills\/)/, "")
82
84
  )
83
85
  throw new Error("MARKET_BUNDLE_METADATA_INVALID");
84
86
  downloadUrl = marketDownloadUrl(url, metadata.marketServiceId);
@@ -1,21 +1,26 @@
1
1
  // SPDX-License-Identifier: MPL-2.0
2
2
  // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
3
3
  // If a copy was not distributed with this file, see https://mozilla.org/MPL/2.0/.
4
- // Preserve the approved metadata URL's ingress prefix; metadata cannot select a host.
4
+ // The configured origin/prefix owns the download location; metadata cannot change it.
5
+ function metadataLocation(value) {
6
+ const url = new URL(value);
7
+ const match = /^(|\/market)\/skills\/bundles\/([^/]+)(?:\/versions\/([a-f0-9]{64}))?\/metadata$/.exec(url.pathname);
8
+ if (url.username || url.password || url.search || url.hash || !match)
9
+ throw Error('MARKET_METADATA_PATH_MISMATCH');
10
+ return { url, prefix: match[1], service: match[2], digest: match[3] };
11
+ }
12
+
13
+ export function marketVersionMetadataUrl(source, digest) {
14
+ const location = metadataLocation(source);
15
+ if (!/^[a-f0-9]{64}$/.test(digest) || location.digest && location.digest !== digest)
16
+ throw Error('MARKET_PACKAGE_VERSION_MISMATCH');
17
+ location.url.pathname = `${location.prefix}/skills/bundles/${location.service}/versions/${digest}/metadata`;
18
+ return location.url;
19
+ }
20
+
5
21
  export function marketDownloadUrl(metadataUrl, serviceId) {
6
- const url = new URL(metadataUrl);
7
- const suffix = `/skills/bundles/${encodeURIComponent(serviceId)}/metadata`;
8
- if (
9
- url.username ||
10
- url.password ||
11
- url.search ||
12
- url.hash ||
13
- !url.pathname.endsWith(suffix)
14
- )
15
- throw Error("MARKET_METADATA_PATH_MISMATCH");
16
- const prefix = url.pathname.slice(0, -suffix.length);
17
- if (!["", "/market"].includes(prefix))
18
- throw Error("MARKET_METADATA_PREFIX_INVALID");
19
- url.pathname = prefix + suffix.replace(/\/metadata$/, "/download");
22
+ const {url, service} = metadataLocation(metadataUrl);
23
+ if (service !== encodeURIComponent(serviceId)) throw Error('MARKET_METADATA_PATH_MISMATCH');
24
+ url.pathname = url.pathname.replace(/\/metadata$/, '/download');
20
25
  return url;
21
26
  }
@@ -8,8 +8,8 @@ import { createHash } from "node:crypto";
8
8
  // This belongs to the official onboarding test, never generic Runtime routing.
9
9
  export const OFFICIAL_TEST_PACKAGE = Object.freeze({
10
10
  name: "agentpay-random",
11
- version: "1.2.0",
12
- sha256: "aa366fc2e747b5b444786d542b0a412a505e58ea15252ac1a792b99079084146",
11
+ version: "1.2.1",
12
+ sha256: "20633b314c66166f94dc6e7d7eb5bce54ab5901fb1ed314a04ea3fd49ca8a9a4",
13
13
  });
14
14
  const mismatch = () =>
15
15
  Object.assign(
@@ -10,7 +10,7 @@ import {
10
10
  verifyOfficialTestBytes,
11
11
  verifyOfficialTestDigest,
12
12
  } from "./official-test-package.mjs";
13
- import { marketDownloadUrl } from "./market-download-url.mjs";
13
+ import { marketDownloadUrl, marketVersionMetadataUrl } from "./market-download-url.mjs";
14
14
 
15
15
  async function localJson(path) {
16
16
  let handle;
@@ -48,6 +48,8 @@ async function download(fetchImpl, address, max) {
48
48
  redirect: "error",
49
49
  signal: AbortSignal.timeout(10000),
50
50
  });
51
+ if ([404, 410].includes(response.status))
52
+ throw Object.assign(Error("Official test version unavailable"), {code: "OFFICIAL_TEST_VERSION_UNAVAILABLE"});
51
53
  if (!response.ok || !response.body) throw Error("Market request failed");
52
54
  let length = 0;
53
55
  const chunks = [];
@@ -99,13 +101,7 @@ export async function prepareOfficialTestUpdate({
99
101
  );
100
102
  return { status: "unconfigured" };
101
103
  }
102
- const metadataUrl = url(source);
103
- if (
104
- !/^\/(?:market\/)?skills\/bundles\/[^/]+\/metadata$/.test(
105
- metadataUrl.pathname,
106
- )
107
- )
108
- throw Error("Invalid package metadata path");
104
+ const metadataUrl = marketVersionMetadataUrl(url(source), OFFICIAL_TEST_PACKAGE.sha256);
109
105
  const body = JSON.parse(
110
106
  (await download(fetchImpl, metadataUrl, 65536)).toString("utf8"),
111
107
  );
@@ -150,6 +146,8 @@ export async function prepareOfficialTestUpdate({
150
146
  write(
151
147
  "Not updated: the published ZIP does not match this User release. Check for a reviewed User update; do not bypass the file check.",
152
148
  );
149
+ else if (error.code === "OFFICIAL_TEST_VERSION_UNAVAILABLE")
150
+ write("This official test version is unavailable in Market. Check for a reviewed User update or contact support; no replacement package was selected.");
153
151
  else
154
152
  write(
155
153
  "Could not prepare the official test Skill. Check your Market connection and retry agentpay repair.",
package/update-pair.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": "agentpay.local-update-pair.v1",
3
- "userVersion": "0.3.1",
4
- "walletVersion": "0.3.1",
3
+ "userVersion": "0.3.2",
4
+ "walletVersion": "0.3.2",
5
5
  "typesDependency": "0.14.3"
6
6
  }