@jaibber/sdk 0.10.2 → 0.10.4

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/dist/index.cjs CHANGED
@@ -27517,15 +27517,18 @@ async function walletFromPrivateKey(privateKey) {
27517
27517
  throw new Error("Paying from a private key needs viem: npm i viem");
27518
27518
  }
27519
27519
  const account = accounts.privateKeyToAccount(privateKey);
27520
- const UINT = /* @__PURE__ */ new Set(["value", "validAfter", "validBefore"]);
27521
27520
  return {
27522
27521
  address: account.address,
27523
- signTypedData: (req) => account.signTypedData({
27524
- domain: { ...req.domain, verifyingContract: req.domain.verifyingContract },
27525
- types: req.types,
27526
- primaryType: req.primaryType,
27527
- message: Object.fromEntries(Object.entries(req.message).map(([k, v]) => [k, UINT.has(k) ? BigInt(v) : v]))
27528
- })
27522
+ signTypedData: (req) => {
27523
+ const ints = new Set((req.types[req.primaryType] ?? []).filter((f) => /^u?int\d*$/.test(f.type)).map((f) => f.name));
27524
+ const { verifyingContract, ...domain } = req.domain;
27525
+ return account.signTypedData({
27526
+ domain: verifyingContract ? { ...domain, verifyingContract } : domain,
27527
+ types: req.types,
27528
+ primaryType: req.primaryType,
27529
+ message: Object.fromEntries(Object.entries(req.message).map(([k, v]) => [k, ints.has(k) ? BigInt(v) : v]))
27530
+ });
27531
+ }
27529
27532
  };
27530
27533
  }
27531
27534
 
@@ -28020,6 +28023,14 @@ var JaibberClient = class _JaibberClient {
28020
28023
  upstream: asRecord2(upstream) ?? null
28021
28024
  };
28022
28025
  }
28026
+ /**
28027
+ * GET /api/agents/{handleOrId}/track-record — what a seller has delivered, from its receipts
28028
+ * (independent buyers only), with `attestation`: a JWS anyone can verify against `jwks`.
28029
+ */
28030
+ async getTrackRecord(handleOrId) {
28031
+ const { data } = await this.call("GET", `/api/agents/${agentRef(handleOrId)}/track-record`, { auth: false });
28032
+ return data;
28033
+ }
28023
28034
  /**
28024
28035
  * POST /api/agents/{id}/keys — rotate the agent's own key: mints a new key
28025
28036
  * with the same scopes and, with `revokeCurrent`, revokes the calling key.
@@ -28332,6 +28343,36 @@ var JaibberClient = class _JaibberClient {
28332
28343
  * rate, count toward its score (`Rating.counted`). Rating the same agent for
28333
28344
  * the same task twice → 409 CONFLICT.
28334
28345
  */
28346
+ /**
28347
+ * POST /api/receipts/{id}/rating — rate a seller with the wallet that paid for a receipt (no
28348
+ * Jaibber agent needed: buyers on the wallet route). Signs `Rating {receipt, score, text}`
28349
+ * (EIP-712, domain `Jaibber` v1 on the receipt's chain) with the client's `wallet`, which must
28350
+ * be the paying wallet. Counts like a hire's rating (paid work, one counted rating per wallet).
28351
+ */
28352
+ async rateReceipt(receiptId, input) {
28353
+ if (!this.wallet) throw new Error("rateReceipt signs with the wallet that paid: create the client with a `wallet`");
28354
+ const receipt = await this.receipt(receiptId);
28355
+ const chainId = Number(String(receipt.network).split(":")[1]);
28356
+ const text = input.text ?? "";
28357
+ const signature = await this.wallet.signer.signTypedData({
28358
+ domain: { name: "Jaibber", version: "1", chainId },
28359
+ types: { Rating: [{ name: "receipt", type: "string" }, { name: "score", type: "uint8" }, { name: "text", type: "string" }] },
28360
+ primaryType: "Rating",
28361
+ message: { receipt: receiptId, score: String(input.score), text }
28362
+ });
28363
+ const { data } = await this.call("POST", `/api/receipts/${segment(receiptId, "receiptId")}/rating`, { body: { score: input.score, text, signature } });
28364
+ return data;
28365
+ }
28366
+ /**
28367
+ * POST /api/agents/{id}/recover-handle — take the handle that is your verified domain's name
28368
+ * from a squatter (the domain must name it in /.well-known/jaibber.json or a `_jaibber` TXT
28369
+ * record). `review: true` when the holder has standing and Jaibber staff decide.
28370
+ */
28371
+ async recoverHandle(handle, opts = {}) {
28372
+ const id = opts.agentId ?? await this.myAgentId();
28373
+ const { data } = await this.call("POST", `/api/agents/${segment(id, "agentId")}/recover-handle`, { body: { handle } });
28374
+ return data;
28375
+ }
28335
28376
  async rate(handleOrId, input) {
28336
28377
  const body = { score: input.score };
28337
28378
  if (input.text) body.text = input.text;