@paybond/kit 0.6.0 → 0.6.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.
@@ -0,0 +1 @@
1
+ export declare function ensureEd25519Sha512Sync(): void;
@@ -0,0 +1,14 @@
1
+ import { createHash } from "node:crypto";
2
+ import { etc } from "@noble/ed25519";
3
+ export function ensureEd25519Sha512Sync() {
4
+ if (etc.sha512Sync) {
5
+ return;
6
+ }
7
+ etc.sha512Sync = (...messages) => {
8
+ const hash = createHash("sha512");
9
+ for (const message of messages) {
10
+ hash.update(message);
11
+ }
12
+ return new Uint8Array(hash.digest());
13
+ };
14
+ }
package/dist/index.d.ts CHANGED
@@ -792,8 +792,8 @@ export declare class HarborClient {
792
792
  */
793
793
  getLedgerAuthority(): Promise<Record<string, unknown>>;
794
794
  /**
795
- * `GET /ledger/v1/events` paginated append-only history; `afterSeq` is an exclusive cursor.
796
- * `limit` is clamped to 1256 to match Harbor.
795
+ * `GET /ledger/v1/events` - protected Harbor append-only history for trusted clients.
796
+ * `afterSeq` is an exclusive cursor; `limit` is clamped to 1..256 to match Harbor.
797
797
  */
798
798
  getLedgerEvents(options?: {
799
799
  afterSeq?: number;
@@ -953,7 +953,10 @@ export type PaybondCreateIntentParams = Omit<BuildSignedCreateIntentParams, "ten
953
953
  intentId?: string;
954
954
  };
955
955
  /** Parameters for {@link PaybondIntents.submitEvidence} (tenant is taken from the bound Harbor client). */
956
- export type PaybondSubmitEvidenceParams = Omit<SignPayeeEvidenceParams, "tenantId">;
956
+ export type PaybondSubmitEvidenceParams = Omit<SignPayeeEvidenceParams, "tenantId" | "artifactsBlake3Hex" | "submittedAtRfc3339"> & {
957
+ artifactsBlake3Hex?: string[];
958
+ submittedAtRfc3339?: string;
959
+ };
957
960
  /**
958
961
  * Ergonomic intent helpers: principal-signed intent create, x402 funding, and payee-signed evidence.
959
962
  */
package/dist/index.js CHANGED
@@ -613,8 +613,8 @@ export class HarborClient {
613
613
  return body;
614
614
  }
615
615
  /**
616
- * `GET /ledger/v1/events` paginated append-only history; `afterSeq` is an exclusive cursor.
617
- * `limit` is clamped to 1256 to match Harbor.
616
+ * `GET /ledger/v1/events` - protected Harbor append-only history for trusted clients.
617
+ * `afterSeq` is an exclusive cursor; `limit` is clamped to 1..256 to match Harbor.
618
618
  */
619
619
  async getLedgerEvents(options) {
620
620
  const afterSeq = Math.max(0, Math.floor(options?.afterSeq ?? 0));
@@ -1527,6 +1527,9 @@ export class ServiceAccountFraudSession {
1527
1527
  await Promise.resolve();
1528
1528
  }
1529
1529
  }
1530
+ function nowRfc3339Seconds() {
1531
+ return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
1532
+ }
1530
1533
  /**
1531
1534
  * Ergonomic intent helpers: principal-signed intent create, x402 funding, and payee-signed evidence.
1532
1535
  */
@@ -1562,9 +1565,11 @@ export class PaybondIntents {
1562
1565
  * Sign payee evidence and POST it. `payeeSigningSeed` must be 32 bytes.
1563
1566
  */
1564
1567
  async submitEvidence(params) {
1565
- const { idempotencyKey, ...rest } = params;
1568
+ const { idempotencyKey, artifactsBlake3Hex = [], submittedAtRfc3339 = nowRfc3339Seconds(), ...rest } = params;
1566
1569
  const wire = signPayeeEvidenceBinding({
1567
1570
  tenantId: this.harbor.tenantId,
1571
+ artifactsBlake3Hex,
1572
+ submittedAtRfc3339,
1568
1573
  ...rest,
1569
1574
  });
1570
1575
  return this.harbor.submitEvidence(rest.intentId, wire, { idempotencyKey });
@@ -4,6 +4,7 @@
4
4
  import { sign, getPublicKey } from "@noble/ed25519";
5
5
  import { createHash } from "blake3";
6
6
  import { parse as parseUuid } from "uuid";
7
+ import { ensureEd25519Sha512Sync } from "./ed25519-sync.js";
7
8
  import { jsonValueDigest } from "./json-digest.js";
8
9
  function concatBytes(...parts) {
9
10
  const n = parts.reduce((a, p) => a + p.length, 0);
@@ -65,6 +66,7 @@ export function signPayeeEvidenceBinding(params) {
65
66
  if (params.payeeSigningSeed.length !== 32) {
66
67
  throw new Error("payeeSigningSeed must be 32 bytes");
67
68
  }
69
+ ensureEd25519Sha512Sync();
68
70
  const artifactBin = params.artifactsBlake3Hex.map((h) => hexToBytes(h));
69
71
  const payloadDigest = jsonValueDigest(params.payload);
70
72
  const artDigest = artifactsDigest(artifactBin);
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { sign, getPublicKey } from "@noble/ed25519";
6
6
  import { parse as parseUuid } from "uuid";
7
+ import { ensureEd25519Sha512Sync } from "./ed25519-sync.js";
7
8
  import { jsonValueDigest } from "./json-digest.js";
8
9
  const SETTLEMENT_RAIL_VALUES = new Set(["stripe_connect", "x402_usdc_base"]);
9
10
  function validateSettlementRail(value) {
@@ -99,6 +100,7 @@ export function buildSignedCreateIntentBody(params) {
99
100
  }
100
101
  const settlementRail = validateSettlementRail(params.settlementRail);
101
102
  const predicateRef = params.predicateRef ?? "";
103
+ ensureEd25519Sha512Sync();
102
104
  const msg = intentCreationSignBytesRaw({
103
105
  tenantId: params.tenantId,
104
106
  intentId: params.intentId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybond/kit",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Paybond Kit for TypeScript: tenant-bound Harbor sessions, capability verification, and signed intent/evidence flows.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",