@perkos/agent-sdk 0.1.0 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,79 @@
2
2
 
3
3
  All notable changes to `@perkos/agent-sdk` are documented here.
4
4
 
5
+ ## Unreleased
6
+
7
+ No changes yet.
8
+
9
+ ## 0.3.0 - 2026-08-27
10
+
11
+ ### Added
12
+
13
+ - Deterministic, request-bound x402 `PaymentIntent` construction for direct STX, sBTC, and USDCx
14
+ payments, including explicit payer, fee, nonce, quote fingerprint, and expiry.
15
+ - A concurrency-safe, fail-closed payment policy with network, asset, recipient, origin, merchant,
16
+ per-transaction, per-session, fee, and remaining-quote-validity controls.
17
+ - `LeatherSigner` using Stacks Connect `stx_signTransaction` with `broadcast: false`, plus a
18
+ `PolicySigner` callback for KMS/HSM/isolated wallet services that never supplies a private key to
19
+ the SDK.
20
+ - `NayoriX402PaymentClient`, which builds a canonical unsigned transaction, reserves policy budget,
21
+ delegates signing, independently verifies the result, and emits the hosted facilitator body
22
+ without broadcasting.
23
+ - An offline payer quickstart and integration guide for interactive wallets and automated agents.
24
+
25
+ ### Security
26
+
27
+ - Re-verify signer output against the trusted quote and exact request, including origin signature,
28
+ payer, fee, nonce, amount, recipient, asset, memo, deny mode, and post-conditions.
29
+ - Reserve concurrent amount and fee usage before signing, release on failure, and permanently count
30
+ valid signatures against the in-process session budget.
31
+ - Freeze cloned quote, request, requirement, payment payload, and settlement structures to avoid
32
+ caller mutation across asynchronous wallet or remote-signer boundaries.
33
+
34
+ ## 0.2.0 - 2026-08-26
35
+
36
+ ### Changed
37
+
38
+ - Renamed the existing GitHub repository from `PerkOS-Agent-SDK` to
39
+ `PerkOS-Nayori-Agent-SDK` without changing the public npm package name or its API. GitHub
40
+ history, releases, issues, pull requests, and legacy URL redirects remain intact.
41
+
42
+ ### Added
43
+
44
+ - A compatibility-first `stacks-signed-tx-v1` x402 profile for direct STX, sBTC, and USDCx
45
+ payments, with canonical internal CAIP-19 identities and explicit `upfront` semantics.
46
+ - Short-lived canonical request quotes and deterministic 31-byte memo fingerprints binding method,
47
+ URL, body digest, network, asset, exact amount, recipient, merchant, and expiry.
48
+ - A side-effect-free signed-transaction verifier for canonical Stacks encoding, origin signature,
49
+ payer, network, exact STX/SIP-010 transfer templates, memo, deny mode, and exact post-conditions.
50
+ - Deterministic quote vectors and adversarial coverage for request, requirement, network, signature,
51
+ asset, recipient, amount, memo, contract, function, and post-condition tampering.
52
+
53
+ - Official x402 v2 payment-requirement, signature, and response header codecs through
54
+ `@x402/core`.
55
+ - Strict Stacks CAIP-2, escrow-contract, asset, job, and amount validation for STX and sBTC x402
56
+ requirements.
57
+ - A client scheme adapter that validates the on-chain job, reuses SDK signing and spending policy,
58
+ confirms escrow funding, and returns a transaction proof.
59
+ - A safe x402 header quickstart, protocol design record, and regression coverage.
60
+ - A Stacks x402 facilitator that independently verifies current Hiro v3 transaction/event
61
+ evidence, exact escrow funding and confirmation freshness before settlement.
62
+ - An injected atomic replay-store contract, process-local implementation for demos/tests, and a
63
+ public fail-closed facilitator quickstart using historical mainnet evidence.
64
+
65
+ ### Security
66
+
67
+ - Kept direct-payment verification separate from merchant authentication, signed-quote trust,
68
+ durable replay/idempotency, balance/nonce preflight, simulation, sponsorship, broadcast,
69
+ confirmation, and resource delivery; those remain mandatory hosted-facilitator boundaries.
70
+ - Omit a final `transactionId` for origin-signed sponsored payments until the sponsor adds its
71
+ signature, preventing an incomplete transaction hash from being represented as a network txid.
72
+
73
+ - Documented that the client proof requires independent Stacks transaction verification and replay
74
+ protection before a production resource server can authorize access.
75
+ - Documented the remaining bearer-proof front-running boundary and the requirement for durable
76
+ shared replay storage and request binding before high-value production use.
77
+
5
78
  ## 0.1.0 - 2026-08-24
6
79
 
7
80
  ### Added
package/README.md CHANGED
@@ -5,10 +5,18 @@ TypeScript SDK for agent identity, escrow settlement, and reputation on Stacks.
5
5
  PerkOS gives AI agents a programmable path to register, hire, fund work with STX or sBTC,
6
6
  submit deliverables, settle escrow, and build job-linked reputation.
7
7
 
8
- > Status: 0.1.0 developer release. Read clients, transaction builders, browser and headless signer
8
+ This repository is the continuation of `PerkOS-xyz/PerkOS-Agent-SDK`, renamed to connect the
9
+ public SDK with the Nayori product identity. The npm package remains `@perkos/agent-sdk` and the
10
+ complete Git history, releases, issues, and pull requests are preserved.
11
+
12
+ > Status: 0.3.0 developer release. Read clients, transaction builders, browser and headless signer
9
13
  > adapters, confirmation receipts, safety policies, and a transactional testnet quickstart are
10
- > implemented. x402/MCP adapters, external review, and adoption evidence remain before Milestone 2
11
- > completion.
14
+ > implemented. The x402 v2 client and Stacks facilitator foundations are implemented; hosted quote
15
+ > infrastructure now exists separately, while production settlement enablement, MCP adapters,
16
+ > external review, and adoption evidence remain before Milestone 2 completion. The direct x402
17
+ > profile includes request-bound pure verification
18
+ > and payer-side intent, policy, Leather, and remote-signer foundations for STX, sBTC, and USDCx.
19
+ > It does not broadcast transactions, and hosted production settlement remains disabled.
12
20
 
13
21
  ## Requirements
14
22
 
@@ -24,8 +32,8 @@ npm install @perkos/agent-sdk
24
32
  To develop from source:
25
33
 
26
34
  ```bash
27
- git clone https://github.com/PerkOS-xyz/PerkOS-Agent-SDK.git
28
- cd PerkOS-Agent-SDK
35
+ git clone https://github.com/PerkOS-xyz/PerkOS-Nayori-Agent-SDK.git
36
+ cd PerkOS-Nayori-Agent-SDK
29
37
  npm install
30
38
  npm run verify
31
39
  npm run quickstart
@@ -34,6 +42,29 @@ npm run quickstart
34
42
  The quickstart performs public read-only calls and does not require a wallet or private key.
35
43
  Set `PERKOS_NETWORK=testnet` to read the testnet deployment.
36
44
 
45
+ The x402 foundation example is also read-only and requires no wallet. It creates and round-trips
46
+ the official v2 `PAYMENT-REQUIRED` header for an existing PerkOS escrow job:
47
+
48
+ ```bash
49
+ npm run quickstart:x402
50
+ ```
51
+
52
+ The facilitator example uses public Hiro v3 transaction and event data to inspect the historical
53
+ M1 mainnet funding transaction. It proves the verifier fails closed when that otherwise matching
54
+ proof is outside its payment window; it does not write replay state or submit a transaction:
55
+
56
+ ```bash
57
+ npm run quickstart:x402:facilitator
58
+ ```
59
+
60
+ The payer quickstart creates a request-bound USDCx intent, reserves explicit spending and fee
61
+ limits, and builds a canonical unsigned Stacks transaction. It contains no private key, performs no
62
+ network call, and does not request a wallet signature or broadcast:
63
+
64
+ ```bash
65
+ npm run quickstart:x402:payer
66
+ ```
67
+
37
68
  The transactional quickstart is also safe by default: it only prints a seven-step sBTC testnet
38
69
  lifecycle and its funding-policy decision.
39
70
 
@@ -184,6 +215,159 @@ await perkos.fundJob({
184
215
  The policy also limits networks and contract principals. Funding attempts without explicit
185
216
  per-transaction and per-session limits are rejected before the signer is called.
186
217
 
218
+ ## x402 v2 client foundation
219
+
220
+ The SDK uses the official `@x402/core` v2 envelope and header codecs while preserving the PerkOS
221
+ escrow lifecycle. A protected resource describes an existing, open job and its exact atomic
222
+ budget. The scheme client validates that quote against on-chain state, funds it through the
223
+ configured SDK signer and spending policy, waits for successful confirmation, and produces the
224
+ `PAYMENT-SIGNATURE` payload.
225
+
226
+ ```ts
227
+ import { x402Client } from "@x402/core/client";
228
+ import {
229
+ PerkOSClient,
230
+ PerkOSX402SchemeClient,
231
+ createPerkOSX402PaymentRequired,
232
+ encodePaymentRequiredHeader,
233
+ toStacksX402Network,
234
+ } from "@perkos/agent-sdk";
235
+
236
+ const perkos = new PerkOSClient({
237
+ network: "mainnet",
238
+ signer,
239
+ spendingPolicy: {
240
+ allowedAssets: ["sbtc"],
241
+ maxPerTransaction: { sbtc: 25_000n },
242
+ maxPerSession: { sbtc: 50_000n },
243
+ },
244
+ });
245
+
246
+ const required = createPerkOSX402PaymentRequired(perkos.config, {
247
+ resource: {
248
+ url: "https://agent.example/jobs/7/fund",
249
+ description: "Fund job 7 escrow",
250
+ mimeType: "application/json",
251
+ },
252
+ asset: "sbtc",
253
+ jobId: 7n,
254
+ amount: 25_000n,
255
+ });
256
+
257
+ const network = toStacksX402Network(perkos.config.network);
258
+ const paymentClient = new x402Client()
259
+ .setSpendControls({
260
+ allowedAssets: [
261
+ { network, asset: required.accepts[0].asset, maxAmountPerPayment: "25000" },
262
+ ],
263
+ })
264
+ .register(network, new PerkOSX402SchemeClient({ client: perkos }));
265
+
266
+ const paymentPayload = await paymentClient.createPaymentPayload(required);
267
+ console.log(encodePaymentRequiredHeader(required), paymentPayload);
268
+ ```
269
+
270
+ The proof produced here is client-side confirmation evidence, not authorization by itself. Use the
271
+ facilitator below to independently inspect the Stacks transaction, match its payment fields, apply
272
+ a confirmation policy, and consume it through a replay store.
273
+
274
+ ## Direct x402 payments on Stacks
275
+
276
+ The separate `stacks-signed-tx-v1` profile covers immediate pay-per-call resources. It uses the
277
+ official x402 v2 `exact` scheme and explicit `upfront` flow because the facilitator must commit the
278
+ signed Stacks transaction before the resource handler runs. It supports:
279
+
280
+ | Asset | Wire `asset` | Canonical internal identity | Atomic unit |
281
+ |---|---|---|---|
282
+ | STX | `STX` | CAIP-19 `slip44:5757` | micro-STX |
283
+ | sBTC | canonical `address.contract` | CAIP-19 SIP-010 | satoshi |
284
+ | USDCx | canonical `address.contract` | CAIP-19 SIP-010 | 10^-6 USDCx |
285
+
286
+ Create a short-lived request quote and compatibility-first requirement without a wallet or network
287
+ call:
288
+
289
+ ```ts
290
+ import {
291
+ createNayoriX402PaymentRequirements,
292
+ createNayoriX402Quote,
293
+ } from "@perkos/agent-sdk";
294
+
295
+ const quote = await createNayoriX402Quote({
296
+ quoteId: "quote-weather-001",
297
+ merchantId: "merchant-weather",
298
+ network: "testnet",
299
+ asset: "usdcx",
300
+ amount: 100_000n,
301
+ payTo: "ST...",
302
+ method: "POST",
303
+ url: "https://api.example.com/v1/weather",
304
+ body: JSON.stringify({ city: "Miami" }),
305
+ issuedAt: Math.floor(Date.now() / 1000),
306
+ expiresAt: Math.floor(Date.now() / 1000) + 300,
307
+ });
308
+
309
+ const requirement = await createNayoriX402PaymentRequirements(quote);
310
+ ```
311
+
312
+ The quote fingerprint is placed in the 34-byte Stacks/SIP-010 memo, so the origin signature binds
313
+ the transaction to the HTTP method, canonical URL, body digest, network, asset, exact amount,
314
+ recipient, merchant, and expiry. `verifyNayoriX402DirectPayment` then validates the x402 envelope,
315
+ trusted quote, actual request, canonical transaction encoding, origin signature, payer, network,
316
+ memo, transfer template, amount, recipient, token contract, function arguments, deny mode, and
317
+ exact post-condition.
318
+
319
+ The verifier is intentionally pure: it does not authenticate the merchant, validate a quote
320
+ signature, read balances/nonces, simulate, persist replay state, sponsor, broadcast, confirm, or
321
+ deliver a resource. A hosted facilitator must perform those controls before using the verified
322
+ plan. For origin-signed sponsored transactions the result omits `transactionId` until a sponsor
323
+ adds its signature; `transactionHash` identifies only the supplied serialization.
324
+
325
+ `NayoriX402PaymentClient` completes the payer side without weakening those boundaries. It creates
326
+ an immutable `PaymentIntent`, applies recipient/origin/asset and amount/fee limits, constructs the
327
+ canonical unsigned transfer, delegates signing to `LeatherSigner` (`broadcast: false`) or a
328
+ `PolicySigner` backed by external custody, and verifies the signed result before returning the exact
329
+ facilitator request body. See [`docs/X402_PAYMENTS.md`](docs/X402_PAYMENTS.md) for both integrations.
330
+
331
+ Direct payments and `perkos-escrow-v1` are complementary. Use direct payments for immediate
332
+ resources and escrow for jobs that require delivery, evaluation, payout, or reputation.
333
+
334
+ ## x402 v2 Stacks facilitator
335
+
336
+ `PerkOSX402Facilitator` implements the official `SchemeNetworkFacilitator` interface. It reloads
337
+ the transaction and events from Hiro, then matches the successful contract call, payer, commerce
338
+ contract, decoded `job-funded` event, exact STX/sBTC transfer, job, amount, token, block metadata,
339
+ confirmation depth, and payment-window freshness. Its `settle` method does not broadcast another
340
+ transaction: for the upfront flow it atomically consumes the already-confirmed funding proof.
341
+
342
+ ```ts
343
+ import { x402Facilitator } from "@x402/core/facilitator";
344
+ import {
345
+ InMemoryX402ReplayStore,
346
+ PerkOSX402Facilitator,
347
+ STACKS_X402_NETWORKS,
348
+ } from "@perkos/agent-sdk";
349
+
350
+ const stacks = new PerkOSX402Facilitator({
351
+ config: perkos.config,
352
+ replayStore: new InMemoryX402ReplayStore(),
353
+ minConfirmations: 2,
354
+ });
355
+ const facilitator = new x402Facilitator().register(
356
+ STACKS_X402_NETWORKS.mainnet,
357
+ stacks
358
+ );
359
+ ```
360
+
361
+ The in-memory replay store is only for tests, examples, local development, and a single-process
362
+ demo. Production must inject a durable shared implementation whose `consume` operation is atomic,
363
+ such as a database unique constraint or Redis `SET NX`.
364
+
365
+ The current Stacks proof is an already-public funding transaction rather than a request-bound
366
+ off-chain authorization. Freshness and one-time consumption prevent stale reuse, but a party that
367
+ obtains the proof before settlement could try to consume it first. Do not use this release for a
368
+ high-value production paywall until request binding is added through a payer signature/challenge
369
+ or facilitator-submitted signed transaction.
370
+
187
371
  ## Supported lifecycle
188
372
 
189
373
  - Register, update, and deactivate agents.
@@ -205,6 +389,8 @@ per-transaction and per-session limits are rejected before the signer is called.
205
389
  - `execute` refuses plans created for a different network or signer.
206
390
  - Broadcast receipts require a valid 32-byte Stacks transaction ID.
207
391
  - Automated workflows can wait for an explicit terminal confirmation before their next action.
392
+ - x402 quotes are bound to the configured network, escrow contract, asset, job, and exact budget.
393
+ - x402 settlement verifies current chain evidence and atomically consumes each funding txid once.
208
394
 
209
395
  This package has not yet completed the external security review required for PerkOS Milestone 2.
210
396
  Do not treat the developer release as audited software.
package/SECURITY.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Release status
4
4
 
5
- `@perkos/agent-sdk` 0.1.0 is an M2 foundation release and has not completed the external security
5
+ `@perkos/agent-sdk` 0.2.0 is an M2 developer release and has not completed the external security
6
6
  review required for the PerkOS Stacks Endowment milestone.
7
7
 
8
8
  Do not use this developer release to control material funds without your own review. Inspect every
@@ -36,6 +36,10 @@ disclosure.
36
36
  - Strict validation and normalization of signer-returned Stacks transaction IDs.
37
37
  - Bounded, cancellable confirmation polling with explicit abort, dropped, and timeout states.
38
38
  - Network mismatch rejection in both browser and headless signer adapters.
39
+ - Request-bound direct STX, sBTC, and USDCx payment intents with immutable economic fields.
40
+ - Explicit direct-payment recipient, HTTPS origin, merchant, amount, fee, and session limits.
41
+ - Concurrent payment reservations that prevent asynchronous agents from oversubscribing a budget.
42
+ - Independent verification of every signed direct-payment transaction before facilitator submission.
39
43
 
40
44
  ## Key handling
41
45
 
@@ -51,6 +55,13 @@ secret provider when the runtime permits it.
51
55
  The SDK does not make an unsafe runtime safe. Restrict process access, rotate credentials, separate
52
56
  client/provider/evaluator identities, and use an HSM, KMS, or isolated signer for material funds.
53
57
 
58
+ `LeatherSigner` uses `stx_signTransaction` with `broadcast: false` and requires Leather/Stacks
59
+ Connect to return the signed transaction bytes. `PolicySigner` receives only an immutable intent and
60
+ unsigned transaction; its application callback should call an isolated custody service. The SDK's
61
+ in-process policy is defense in depth and can be bypassed by a malicious host application, so the
62
+ custody service must independently authenticate callers, revalidate intent, enforce durable limits,
63
+ and keep keys outside the agent/LLM process.
64
+
54
65
  ## Confirmation handling
55
66
 
56
67
  A broadcast receipt means a node accepted the transaction, not that the contract call succeeded.
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type PerkOSErrorCode = "CONFIG_INVALID" | "INPUT_INVALID" | "CONTRACT_ERROR" | "READ_FAILED" | "SIGNER_REQUIRED" | "SIGNER_MISMATCH" | "POLICY_DENIED" | "POLICY_LIMIT_REQUIRED" | "SIGNING_FAILED" | "BROADCAST_REJECTED" | "CONFIRMATION_FAILED";
1
+ export type PerkOSErrorCode = "CONFIG_INVALID" | "INPUT_INVALID" | "CONTRACT_ERROR" | "READ_FAILED" | "SIGNER_REQUIRED" | "SIGNER_MISMATCH" | "POLICY_DENIED" | "POLICY_LIMIT_REQUIRED" | "SIGNING_FAILED" | "BROADCAST_REJECTED" | "CONFIRMATION_FAILED" | "X402_INVALID" | "X402_PAYMENT_FAILED";
2
2
  export interface PerkOSErrorDetails {
3
3
  readonly clarityCode?: bigint;
4
4
  readonly contract?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,uBAAuB,GACvB,gBAAgB,GAChB,oBAAoB,GACpB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC;gBAErC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;CAMjF"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,uBAAuB,GACvB,gBAAgB,GAChB,oBAAoB,GACpB,qBAAqB,GACrB,cAAc,GACd,qBAAqB,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC;gBAErC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;CAMjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAqBA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IACtB,OAAO,CAAiC;IAEjD,YAAY,IAAqB,EAAE,OAAe,EAAE,OAA4B;QAC9E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAuBA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IACtB,OAAO,CAAiC;IAEjD,YAAY,IAAqB,EAAE,OAAe,EAAE,OAA4B;QAC9E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -7,8 +7,16 @@ export { PerkOSError } from "./errors.js";
7
7
  export { DEFAULT_DEPLOYMENTS, JOB_STATUS, CLARITY_ERROR_MESSAGES } from "./constants.js";
8
8
  export { resolveConfig, toUint } from "./validation.js";
9
9
  export { normalizeTxid } from "./txid.js";
10
+ export { PERKOS_X402_ASSET_TRANSFER_METHOD, PERKOS_X402_PAYMENT_FLOW, PERKOS_X402_SCHEME, PerkOSX402SchemeClient, STACKS_X402_NETWORKS, X402_VERSION, createPerkOSX402PaymentRequired, decodePaymentRequiredHeader, decodePaymentResponseHeader, decodePaymentSignatureHeader, encodePaymentRequiredHeader, encodePaymentResponseHeader, encodePaymentSignatureHeader, fromStacksX402Network, parsePerkOSX402PaymentPayload, parsePerkOSX402Requirement, toStacksX402Network, } from "./x402.js";
11
+ export { HiroX402TransactionSource, InMemoryX402ReplayStore, PerkOSX402Facilitator, PerkOSX402VerificationError, perkosX402ReplayKey, } from "./x402-facilitator.js";
12
+ export { NAYORI_X402_DIRECT_ASSETS, NAYORI_X402_DIRECT_ASSET_TRANSFER_METHOD, NAYORI_X402_DIRECT_PAYMENT_FLOW, NAYORI_X402_QUOTE_FINGERPRINT_PREFIX, NAYORI_X402_QUOTE_VERSION, NayoriX402DirectVerificationError, canonicalizeNayoriX402Quote, canonicalizeNayoriX402ResourceUrl, createNayoriX402DirectPaymentPayload, createNayoriX402PaymentRequirements, createNayoriX402Quote, createNayoriX402QuoteFingerprint, getNayoriX402Asset, hashNayoriX402RequestBody, verifyNayoriX402DirectPayment, validateNayoriX402PaymentContext, } from "./x402-direct.js";
13
+ export { LeatherSigner, NAYORI_X402_PAYMENT_INTENT_PREFIX, NAYORI_X402_PAYMENT_INTENT_VERSION, NayoriX402PaymentClient, NayoriX402PaymentPolicy, PolicySigner, buildNayoriX402UnsignedPaymentTransaction, createNayoriX402PaymentIntent, } from "./x402-paying.js";
10
14
  export type { HeadlessSignerOptions, HeadlessTransactionExecutor, HeadlessTransactionRequest, PrivateKeyMaterial, PrivateKeyProvider, StacksConnectContractCallParams, StacksConnectRequest, StacksConnectSignerOptions, } from "./signers.js";
11
15
  export type { TrackerFetch, TransactionTrackerOptions, } from "./tracker.js";
12
16
  export type { AgentEndpoint, AgentRecord, Amount, AmountLike, AssignProviderInput, ConfirmationOptions, ConfirmedTransactionReceipt, ContractCallPlan, ContractId, CreateJobInput, FundJobInput, JobAmountInput, JobRecord, JobStatus, PaymentAsset, PerkOSConfig, PerkOSContracts, PerkOSNetwork, PerkOSOperation, PerkOSSigner, RateProviderInput, ReadOnlyCall, ReadOnlyTransport, RegisterAgentInput, ReputationRecord, ResolvedPerkOSConfig, SettleJobInput, SignerResult, SpendingApproval, SpendingPolicyInput, SubmitWorkInput, TransactionIntent, TransactionConfirmation, TransactionConfirmationStatus, TransactionReceipt, TransactionResultValue, TransactionTrackerLike, UpdateAgentInput, } from "./types.js";
13
17
  export type { PerkOSErrorCode, PerkOSErrorDetails } from "./errors.js";
18
+ export type { ParsedPerkOSX402Requirement, PaymentPayload, PaymentRequired, PaymentRequirements, PerkOSX402ClientLike, PerkOSX402PaymentProof, PerkOSX402PaymentRequiredInput, PerkOSX402SchemeClientOptions, ResourceInfo, SettleResponse, } from "./x402.js";
19
+ export type { HiroX402TransactionSourceOptions, PerkOSX402FacilitatorOptions, PerkOSX402ReplayRecord, PerkOSX402ReplayStore, PerkOSX402TransactionSource, PerkOSX402VerifiedPayment, X402VerifierFetch, } from "./x402-facilitator.js";
20
+ export type { NayoriStacksX402Network, NayoriX402AssetDefinition, NayoriX402DirectPaymentPayloadInput, NayoriX402PaymentAsset, NayoriX402ProtectedRequest, NayoriX402Quote, NayoriX402QuoteInput, NayoriX402VerifiedDirectPayment, NayoriX402ValidatedPaymentContext, ValidateNayoriX402PaymentContextInput, VerifyNayoriX402DirectPaymentInput, } from "./x402-direct.js";
21
+ export type { LeatherRequest, LeatherSignTransactionParams, LeatherSignerOptions, NayoriX402PaymentAuthorization, NayoriX402PaymentClientOptions, NayoriX402PaymentIntent, NayoriX402PaymentIntentInput, NayoriX402PaymentPolicyInput, NayoriX402PaymentSessionUsage, NayoriX402PaymentSignRequest, NayoriX402PaymentSigner, NayoriX402PreparePaymentInput, NayoriX402PreparedPayment, NayoriX402SettlementRequest, NayoriX402SignedTransaction, PolicySignerCallback, PolicySignerOptions, PolicySignerRequest, } from "./x402-paying.js";
14
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,YAAY,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,+BAA+B,EAC/B,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,aAAa,EACb,WAAW,EACX,MAAM,EACN,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,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B,EAAE,MAAM,aAAa,CAAC;AACvE,YAAY,EACV,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,8BAA8B,EAC9B,6BAA6B,EAC7B,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,gCAAgC,EAChC,4BAA4B,EAC5B,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,uBAAuB,EACvB,yBAAyB,EACzB,mCAAmC,EACnC,sBAAsB,EACtB,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,+BAA+B,EAC/B,iCAAiC,EACjC,qCAAqC,EACrC,kCAAkC,GACnC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,cAAc,EACd,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -7,4 +7,8 @@ export { PerkOSError } from "./errors.js";
7
7
  export { DEFAULT_DEPLOYMENTS, JOB_STATUS, CLARITY_ERROR_MESSAGES } from "./constants.js";
8
8
  export { resolveConfig, toUint } from "./validation.js";
9
9
  export { normalizeTxid } from "./txid.js";
10
+ export { PERKOS_X402_ASSET_TRANSFER_METHOD, PERKOS_X402_PAYMENT_FLOW, PERKOS_X402_SCHEME, PerkOSX402SchemeClient, STACKS_X402_NETWORKS, X402_VERSION, createPerkOSX402PaymentRequired, decodePaymentRequiredHeader, decodePaymentResponseHeader, decodePaymentSignatureHeader, encodePaymentRequiredHeader, encodePaymentResponseHeader, encodePaymentSignatureHeader, fromStacksX402Network, parsePerkOSX402PaymentPayload, parsePerkOSX402Requirement, toStacksX402Network, } from "./x402.js";
11
+ export { HiroX402TransactionSource, InMemoryX402ReplayStore, PerkOSX402Facilitator, PerkOSX402VerificationError, perkosX402ReplayKey, } from "./x402-facilitator.js";
12
+ export { NAYORI_X402_DIRECT_ASSETS, NAYORI_X402_DIRECT_ASSET_TRANSFER_METHOD, NAYORI_X402_DIRECT_PAYMENT_FLOW, NAYORI_X402_QUOTE_FINGERPRINT_PREFIX, NAYORI_X402_QUOTE_VERSION, NayoriX402DirectVerificationError, canonicalizeNayoriX402Quote, canonicalizeNayoriX402ResourceUrl, createNayoriX402DirectPaymentPayload, createNayoriX402PaymentRequirements, createNayoriX402Quote, createNayoriX402QuoteFingerprint, getNayoriX402Asset, hashNayoriX402RequestBody, verifyNayoriX402DirectPayment, validateNayoriX402PaymentContext, } from "./x402-direct.js";
13
+ export { LeatherSigner, NAYORI_X402_PAYMENT_INTENT_PREFIX, NAYORI_X402_PAYMENT_INTENT_VERSION, NayoriX402PaymentClient, NayoriX402PaymentPolicy, PolicySigner, buildNayoriX402UnsignedPaymentTransaction, createNayoriX402PaymentIntent, } from "./x402-paying.js";
10
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,E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B,iCAAiC,EACjC,2BAA2B,EAC3B,iCAAiC,EACjC,oCAAoC,EACpC,mCAAmC,EACnC,qBAAqB,EACrB,gCAAgC,EAChC,kBAAkB,EAClB,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,GACjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,iCAAiC,EACjC,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,yCAAyC,EACzC,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,116 @@
1
+ import type { PaymentPayload, PaymentRequirements, ResourceInfo } from "@x402/core/types";
2
+ import type { AmountLike, PerkOSNetwork } from "./types.js";
3
+ import { STACKS_X402_NETWORKS } from "./x402.js";
4
+ export declare const NAYORI_X402_DIRECT_ASSET_TRANSFER_METHOD = "stacks-signed-tx-v1";
5
+ export declare const NAYORI_X402_DIRECT_PAYMENT_FLOW = "upfront";
6
+ export declare const NAYORI_X402_QUOTE_VERSION = 1;
7
+ export declare const NAYORI_X402_QUOTE_FINGERPRINT_PREFIX = "ny1_";
8
+ export type NayoriX402PaymentAsset = "stx" | "sbtc" | "usdcx";
9
+ export type NayoriStacksX402Network = (typeof STACKS_X402_NETWORKS)[keyof typeof STACKS_X402_NETWORKS];
10
+ export interface NayoriX402AssetDefinition {
11
+ readonly network: PerkOSNetwork;
12
+ readonly x402Network: NayoriStacksX402Network;
13
+ readonly paymentAsset: NayoriX402PaymentAsset;
14
+ readonly symbol: "STX" | "sBTC" | "USDCx";
15
+ readonly decimals: 6 | 8;
16
+ readonly wireAsset: string;
17
+ readonly canonicalAssetId: string;
18
+ readonly kind: "stx" | "sip010";
19
+ readonly contract?: string;
20
+ readonly tokenName?: string;
21
+ readonly postConditionAsset?: string;
22
+ }
23
+ export declare const NAYORI_X402_DIRECT_ASSETS: Readonly<Record<PerkOSNetwork, Readonly<Record<NayoriX402PaymentAsset, NayoriX402AssetDefinition>>>>;
24
+ export interface NayoriX402ProtectedRequest {
25
+ readonly method: string;
26
+ readonly url: string;
27
+ readonly body?: string | Uint8Array;
28
+ }
29
+ export interface NayoriX402QuoteInput extends NayoriX402ProtectedRequest {
30
+ readonly quoteId: string;
31
+ readonly merchantId: string;
32
+ readonly network: PerkOSNetwork;
33
+ readonly asset: NayoriX402PaymentAsset;
34
+ readonly amount: AmountLike;
35
+ readonly payTo: string;
36
+ readonly issuedAt: number;
37
+ readonly expiresAt: number;
38
+ }
39
+ export interface NayoriX402Quote {
40
+ readonly version: typeof NAYORI_X402_QUOTE_VERSION;
41
+ readonly quoteId: string;
42
+ readonly merchantId: string;
43
+ readonly method: string;
44
+ readonly url: string;
45
+ readonly bodySha256: string;
46
+ readonly network: NayoriStacksX402Network;
47
+ readonly paymentAsset: NayoriX402PaymentAsset;
48
+ readonly asset: string;
49
+ readonly amount: string;
50
+ readonly payTo: string;
51
+ readonly issuedAt: number;
52
+ readonly expiresAt: number;
53
+ }
54
+ export interface NayoriX402DirectPaymentPayloadInput {
55
+ readonly paymentRequirements: PaymentRequirements;
56
+ readonly transaction: string;
57
+ readonly resource?: ResourceInfo;
58
+ }
59
+ export interface VerifyNayoriX402DirectPaymentInput {
60
+ readonly paymentPayload: PaymentPayload;
61
+ readonly paymentRequirements: PaymentRequirements;
62
+ /** The hosted layer must authenticate the merchant and validate the quote signature first. */
63
+ readonly trustedQuote: NayoriX402Quote;
64
+ readonly request: NayoriX402ProtectedRequest;
65
+ readonly nowSeconds?: number;
66
+ readonly clockSkewSeconds?: number;
67
+ }
68
+ export interface ValidateNayoriX402PaymentContextInput {
69
+ readonly paymentRequirements: PaymentRequirements;
70
+ /** The hosted layer must authenticate the merchant and validate the quote signature first. */
71
+ readonly trustedQuote: NayoriX402Quote;
72
+ readonly request: NayoriX402ProtectedRequest;
73
+ readonly nowSeconds?: number;
74
+ readonly clockSkewSeconds?: number;
75
+ }
76
+ export interface NayoriX402ValidatedPaymentContext {
77
+ readonly quote: NayoriX402Quote;
78
+ readonly network: PerkOSNetwork;
79
+ readonly assetDefinition: NayoriX402AssetDefinition;
80
+ readonly quoteFingerprint: string;
81
+ }
82
+ export interface NayoriX402VerifiedDirectPayment {
83
+ readonly network: PerkOSNetwork;
84
+ readonly x402Network: NayoriStacksX402Network;
85
+ readonly asset: NayoriX402PaymentAsset;
86
+ readonly assetDefinition: NayoriX402AssetDefinition;
87
+ readonly amount: bigint;
88
+ readonly payer: string;
89
+ readonly payTo: string;
90
+ readonly transaction: string;
91
+ /** Hash of the supplied serialization; sponsor signing changes it for sponsored payments. */
92
+ readonly transactionHash: string;
93
+ /** Final network transaction ID for standard payments; omitted until a sponsor signs. */
94
+ readonly transactionId?: string;
95
+ readonly originNonce: bigint;
96
+ readonly originFee: bigint;
97
+ readonly sponsored: boolean;
98
+ readonly quoteId: string;
99
+ readonly quoteFingerprint: string;
100
+ }
101
+ export declare class NayoriX402DirectVerificationError extends Error {
102
+ readonly reason: string;
103
+ readonly details: Readonly<Record<string, unknown>> | undefined;
104
+ constructor(reason: string, message: string, details?: Readonly<Record<string, unknown>>);
105
+ }
106
+ export declare function canonicalizeNayoriX402ResourceUrl(value: string): string;
107
+ export declare function hashNayoriX402RequestBody(body?: string | Uint8Array): Promise<string>;
108
+ export declare function getNayoriX402Asset(network: PerkOSNetwork, asset: NayoriX402PaymentAsset): NayoriX402AssetDefinition;
109
+ export declare function createNayoriX402Quote(input: NayoriX402QuoteInput): Promise<NayoriX402Quote>;
110
+ export declare function canonicalizeNayoriX402Quote(quote: NayoriX402Quote): string;
111
+ export declare function createNayoriX402QuoteFingerprint(quote: NayoriX402Quote): Promise<string>;
112
+ export declare function createNayoriX402PaymentRequirements(quoteInput: NayoriX402Quote): Promise<PaymentRequirements>;
113
+ export declare function createNayoriX402DirectPaymentPayload(input: NayoriX402DirectPaymentPayloadInput): PaymentPayload;
114
+ export declare function validateNayoriX402PaymentContext(input: ValidateNayoriX402PaymentContextInput): Promise<NayoriX402ValidatedPaymentContext>;
115
+ export declare function verifyNayoriX402DirectPayment(input: VerifyNayoriX402DirectPaymentInput): Promise<NayoriX402VerifiedDirectPayment>;
116
+ //# sourceMappingURL=x402-direct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-direct.d.ts","sourceRoot":"","sources":["../src/x402-direct.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,YAAY,EACb,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAEL,oBAAoB,EAIrB,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,wCAAwC,wBAAwB,CAAC;AAC9E,eAAO,MAAM,+BAA+B,YAAY,CAAC;AACzD,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,oCAAoC,SAAS,CAAC;AAa3D,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAC9D,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAEnE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,sBAAsB,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,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