@orangecheck/me-client 0.59.0 → 0.61.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/dist/index.mjs CHANGED
@@ -318,12 +318,15 @@ var INHERITED_NAMES = new Set(
318
318
  function isInheritedName(key) {
319
319
  return INHERITED_NAMES.has(key.toLowerCase());
320
320
  }
321
+ function sitePaysFor(cfg, is_agent) {
322
+ return is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;
323
+ }
321
324
  function computeFees(cfg, payment_amount_sats, opts) {
322
325
  const is_agent = opts?.is_agent === true;
323
326
  if (is_agent && cfg.agent?.refuse) {
324
327
  throw new Error("agent_refused");
325
328
  }
326
- const effective_site_pays = is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;
329
+ const effective_site_pays = sitePaysFor(cfg, is_agent);
327
330
  const effective_user_share_pct = is_agent && typeof cfg.agent?.user_share_pct === "number" ? cfg.agent.user_share_pct : cfg.user_share_pct;
328
331
  let gross = 0;
329
332
  if (effective_site_pays.kind === "fixed_sats") {
@@ -488,7 +491,7 @@ async function fire(options) {
488
491
  if (options.payment_amount_sats !== void 0)
489
492
  requestBody.payment_amount_sats = options.payment_amount_sats;
490
493
  if (options.action_label !== void 0) requestBody.action_label = options.action_label;
491
- if (options.metadata !== void 0) requestBody.metadata = options.metadata;
494
+ if (options.note !== void 0) requestBody.note = options.note;
492
495
  if (options.is_agent !== void 0) requestBody.is_agent = options.is_agent;
493
496
  if (earner !== void 0) requestBody.user_address = earner;
494
497
  const headers = {};
@@ -574,7 +577,23 @@ function verify(envelope, config2, payment_amount_sats, opts = {}) {
574
577
  ]
575
578
  };
576
579
  }
577
- if (eventCfg.site_pays.kind === "percent_of_amount" && payment_amount_sats == null) {
580
+ const is_agent = envelope.is_agent === true;
581
+ if (is_agent && eventCfg.agent?.refuse) {
582
+ return {
583
+ ok: false,
584
+ expected: null,
585
+ issues: [
586
+ ...issues,
587
+ {
588
+ field: "agent_refused",
589
+ expected: null,
590
+ actual: null,
591
+ message: `subtype ${envelope.subtype} refuses agents on integrator ${config2.project_key} but an agent's event was billed`
592
+ }
593
+ ]
594
+ };
595
+ }
596
+ if (sitePaysFor(eventCfg, is_agent).kind === "percent_of_amount" && payment_amount_sats == null) {
578
597
  return {
579
598
  ok: false,
580
599
  expected: null,
@@ -589,7 +608,7 @@ function verify(envelope, config2, payment_amount_sats, opts = {}) {
589
608
  ]
590
609
  };
591
610
  }
592
- const expected = computeFees(eventCfg, payment_amount_sats);
611
+ const expected = computeFees(eventCfg, payment_amount_sats, { is_agent });
593
612
  if (envelope.gross_fee_sats !== expected.gross_fee_sats) {
594
613
  issues.push({
595
614
  field: "gross_fee_sats",