@owney/sdk 0.7.25-beta.17 → 0.7.25-beta.18

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
@@ -4273,6 +4273,14 @@ function sponsorError(message, safeToFallback, details = {}) {
4273
4273
  "yieldseeker"
4274
4274
  );
4275
4275
  }
4276
+ function assertIntentFresh(expiresAt) {
4277
+ if (!Number.isFinite(expiresAt) || Date.now() + 5e3 >= expiresAt * 1e3)
4278
+ throw sponsorError(
4279
+ "The withdrawal sponsorship request expired. Please try again.",
4280
+ true,
4281
+ { failureCode: "SPONSOR_INTENT_EXPIRED" }
4282
+ );
4283
+ }
4276
4284
  function providerReason(value) {
4277
4285
  if (typeof value !== "string") return void 0;
4278
4286
  return value.replace(/https?:\/\/\S+/gi, "[url]").replace(/0x[0-9a-fA-F]{40,}/g, "[hex]").replace(/[A-Za-z0-9_+=\/-]{48,}/g, "[token]").slice(0, 300);
@@ -4561,6 +4569,7 @@ async function submitEoa(input) {
4561
4569
  }
4562
4570
  const userOpHash = operationHash(operation);
4563
4571
  await assertOwnerSession(input.state, input.owner);
4572
+ assertIntentFresh(input.expiresAt);
4564
4573
  const wallet = (0, import_viem11.createWalletClient)({
4565
4574
  account: input.owner,
4566
4575
  chain: import_chains3.base,
@@ -4569,6 +4578,7 @@ async function submitEoa(input) {
4569
4578
  const signature = await wallet.signMessage({ message: { raw: userOpHash } });
4570
4579
  operation = { ...operation, signature };
4571
4580
  await assertOwnerSession(input.state, input.owner);
4581
+ assertIntentFresh(input.expiresAt);
4572
4582
  const userOperation = {
4573
4583
  sender: operation.sender,
4574
4584
  nonce: operation.nonce,
@@ -4646,6 +4656,7 @@ async function submitSmart(input) {
4646
4656
  throw sponsorError("This account cannot use a paymaster on Base.", true);
4647
4657
  await assertOwnerSession(input.state, input.owner);
4648
4658
  let sent;
4659
+ assertIntentFresh(input.expiresAt);
4649
4660
  const requestedId = (0, import_viem11.toHex)(globalThis.crypto.getRandomValues(new Uint8Array(32)));
4650
4661
  savePending(input.onPending, { callsId: requestedId }, true);
4651
4662
  await checkpoint(input.onBeforeSubmission, { callsId: requestedId });
@@ -4744,7 +4755,8 @@ async function submitYieldseekerSponsoredWithdrawal(input) {
4744
4755
  action: "withdraw",
4745
4756
  refreshYieldseekerSignature: input.refreshYieldseekerSignature
4746
4757
  });
4747
- const args = { ...input, owner, rpcUrl };
4758
+ assertIntentFresh(intent.expiresAt);
4759
+ const args = { ...input, owner, rpcUrl, expiresAt: intent.expiresAt };
4748
4760
  return intent.ownerPath === "eoa" ? submitEoa(args) : submitSmart(args);
4749
4761
  }
4750
4762
  async function submitYieldseekerSponsoredUpgrade(input) {
@@ -4764,7 +4776,8 @@ async function submitYieldseekerSponsoredUpgrade(input) {
4764
4776
  });
4765
4777
  if (intent.ownerPath !== "smart")
4766
4778
  throw sponsorError("V1 upgrade sponsorship requires a Base Account owner.", true);
4767
- return submitSmart({ ...input, owner, rpcUrl });
4779
+ assertIntentFresh(intent.expiresAt);
4780
+ return submitSmart({ ...input, owner, rpcUrl, expiresAt: intent.expiresAt });
4768
4781
  }
4769
4782
 
4770
4783
  // src/agents/yieldseeker/yieldseeker.agent.ts
package/dist/index.js CHANGED
@@ -4268,6 +4268,14 @@ function sponsorError(message, safeToFallback, details = {}) {
4268
4268
  "yieldseeker"
4269
4269
  );
4270
4270
  }
4271
+ function assertIntentFresh(expiresAt) {
4272
+ if (!Number.isFinite(expiresAt) || Date.now() + 5e3 >= expiresAt * 1e3)
4273
+ throw sponsorError(
4274
+ "The withdrawal sponsorship request expired. Please try again.",
4275
+ true,
4276
+ { failureCode: "SPONSOR_INTENT_EXPIRED" }
4277
+ );
4278
+ }
4271
4279
  function providerReason(value) {
4272
4280
  if (typeof value !== "string") return void 0;
4273
4281
  return value.replace(/https?:\/\/\S+/gi, "[url]").replace(/0x[0-9a-fA-F]{40,}/g, "[hex]").replace(/[A-Za-z0-9_+=\/-]{48,}/g, "[token]").slice(0, 300);
@@ -4556,6 +4564,7 @@ async function submitEoa(input) {
4556
4564
  }
4557
4565
  const userOpHash = operationHash(operation);
4558
4566
  await assertOwnerSession(input.state, input.owner);
4567
+ assertIntentFresh(input.expiresAt);
4559
4568
  const wallet = createWalletClient2({
4560
4569
  account: input.owner,
4561
4570
  chain: base3,
@@ -4564,6 +4573,7 @@ async function submitEoa(input) {
4564
4573
  const signature = await wallet.signMessage({ message: { raw: userOpHash } });
4565
4574
  operation = { ...operation, signature };
4566
4575
  await assertOwnerSession(input.state, input.owner);
4576
+ assertIntentFresh(input.expiresAt);
4567
4577
  const userOperation = {
4568
4578
  sender: operation.sender,
4569
4579
  nonce: operation.nonce,
@@ -4641,6 +4651,7 @@ async function submitSmart(input) {
4641
4651
  throw sponsorError("This account cannot use a paymaster on Base.", true);
4642
4652
  await assertOwnerSession(input.state, input.owner);
4643
4653
  let sent;
4654
+ assertIntentFresh(input.expiresAt);
4644
4655
  const requestedId = toHex(globalThis.crypto.getRandomValues(new Uint8Array(32)));
4645
4656
  savePending(input.onPending, { callsId: requestedId }, true);
4646
4657
  await checkpoint(input.onBeforeSubmission, { callsId: requestedId });
@@ -4739,7 +4750,8 @@ async function submitYieldseekerSponsoredWithdrawal(input) {
4739
4750
  action: "withdraw",
4740
4751
  refreshYieldseekerSignature: input.refreshYieldseekerSignature
4741
4752
  });
4742
- const args = { ...input, owner, rpcUrl };
4753
+ assertIntentFresh(intent.expiresAt);
4754
+ const args = { ...input, owner, rpcUrl, expiresAt: intent.expiresAt };
4743
4755
  return intent.ownerPath === "eoa" ? submitEoa(args) : submitSmart(args);
4744
4756
  }
4745
4757
  async function submitYieldseekerSponsoredUpgrade(input) {
@@ -4759,7 +4771,8 @@ async function submitYieldseekerSponsoredUpgrade(input) {
4759
4771
  });
4760
4772
  if (intent.ownerPath !== "smart")
4761
4773
  throw sponsorError("V1 upgrade sponsorship requires a Base Account owner.", true);
4762
- return submitSmart({ ...input, owner, rpcUrl });
4774
+ assertIntentFresh(intent.expiresAt);
4775
+ return submitSmart({ ...input, owner, rpcUrl, expiresAt: intent.expiresAt });
4763
4776
  }
4764
4777
 
4765
4778
  // src/agents/yieldseeker/yieldseeker.agent.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.7.25-beta.17",
3
+ "version": "0.7.25-beta.18",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",