@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/CHANGELOG.md CHANGED
@@ -10,6 +10,51 @@ this file tracks the package's TS / Node / runtime API surface.
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.61.0] — 2026-11-12
14
+
15
+ ### Added
16
+
17
+ - `event.fire` takes `note`, as a batch entry already does. It is sent inside
18
+ the signed body.
19
+
20
+ ### Changed
21
+
22
+ - The `note` comment on `BatchEventInput` adds the 280-character limit, that a
23
+ class B or C built-in drops it, and the `invalid_note` refusal. A note is
24
+ public: it is in the event's receipt, which anyone with its link can read.
25
+ - The `payment_amount_sats` comments on `FireEventOptions` and
26
+ `BatchEventInput` say whole sats above 0, as me.ochk.io reads it, and that an
27
+ agent's event is priced by the agent price when one is set.
28
+ - `event.verify` prices an event an agent fired (`is_agent`) by its subtype's
29
+ agent override, as me.ochk.io does, and asks for a payment amount only when
30
+ that price is a percent of one. An agent's event under a subtype that
31
+ refuses agents is reported as `agent_refused`, a new issue field.
32
+
33
+ ## [0.60.0] — 2026-11-11
34
+
35
+ ### Changed
36
+
37
+ - The `projectKey` comment says what holds while the sign-in rule can't be
38
+ read: the last one read stands for up to ten minutes, then signed-in
39
+ requests are refused until it can. The comment on the rule's own read gives
40
+ the price config's full cache age: ten minutes at the edge, then up to an
41
+ hour stale.
42
+ - The `user_share_pct` comment says me.ochk.io saves every event at the full
43
+ share of 0.8, which leaves no rebate, and that a rebate an event does carry
44
+ is never debited, so it stays in the project's balance.
45
+ - The `ComputedFees` comment says `site_rebate_sats` is what is left after the
46
+ platform fee and what the user earns, and that me.ochk.io never debits it.
47
+ - The `not_paying` comments and the README say no event is recorded or
48
+ charged. A call carrying the person's own token for your verified domain
49
+ still records that they use your project.
50
+ - `event.fire` no longer puts `metadata` in the request body.
51
+
52
+ ### Deprecated
53
+
54
+ - `FireEventOptions.metadata`. me.ochk.io does not read it, so it is never
55
+ stored on the envelope or published. The option stays in the type so
56
+ existing callers still compile.
57
+
13
58
  ## [0.59.0] — 2026-11-10
14
59
 
15
60
  ### Added
package/README.md CHANGED
@@ -119,7 +119,7 @@ It takes only the session object `verifyOcToken`, `checkOcToken`, `getOcSession`
119
119
 
120
120
  ## Pay your users, when you choose to
121
121
 
122
- Paying the people who use your app is optional. In your project's dashboard you turn it on, schedule promos ("Launch week", Oct 20 to 27), or leave it off. While a pay period runs, each event you send earns the person their share and takes its fee from your balance. Outside every period an event earns and costs nothing, and me.ochk.io records nothing, so you can fire events from code that runs all the time:
122
+ Paying the people who use your app is optional. In your project's dashboard you turn it on, schedule promos ("Launch week", Oct 20 to 27), or leave it off. While a pay period runs, each event you send earns the person their share and takes its fee from your balance. Outside every period an event earns and costs nothing, and me.ochk.io records no event, so you can fire events from code that runs all the time:
123
123
 
124
124
  ```ts
125
125
  const res = await oc.event.fire({
package/dist/index.d.mts CHANGED
@@ -68,6 +68,7 @@ interface FireEventOptions {
68
68
  project_key: string;
69
69
  subtype: EventKey;
70
70
  action_label?: string;
71
+ note?: string;
71
72
  payment_amount_sats?: number;
72
73
  metadata?: Record<string, unknown>;
73
74
  is_agent?: boolean;
@@ -136,7 +137,7 @@ declare function fireBatch(options: FireBatchOptions): Promise<FireBatchResponse
136
137
  interface VerifyEventResult {
137
138
  ok: boolean;
138
139
  issues: Array<{
139
- field: 'gross_fee_sats' | 'platform_fee_sats' | 'user_earned_sats' | 'site_rebate_sats' | 'subtype_disabled' | 'subtype_unconfigured' | 'percent_amount_missing' | 'outside_pay_period';
140
+ field: 'gross_fee_sats' | 'platform_fee_sats' | 'user_earned_sats' | 'site_rebate_sats' | 'subtype_disabled' | 'subtype_unconfigured' | 'percent_amount_missing' | 'agent_refused' | 'outside_pay_period';
140
141
  expected: number | null;
141
142
  actual: number | null;
142
143
  message: string;
package/dist/index.d.ts CHANGED
@@ -68,6 +68,7 @@ interface FireEventOptions {
68
68
  project_key: string;
69
69
  subtype: EventKey;
70
70
  action_label?: string;
71
+ note?: string;
71
72
  payment_amount_sats?: number;
72
73
  metadata?: Record<string, unknown>;
73
74
  is_agent?: boolean;
@@ -136,7 +137,7 @@ declare function fireBatch(options: FireBatchOptions): Promise<FireBatchResponse
136
137
  interface VerifyEventResult {
137
138
  ok: boolean;
138
139
  issues: Array<{
139
- field: 'gross_fee_sats' | 'platform_fee_sats' | 'user_earned_sats' | 'site_rebate_sats' | 'subtype_disabled' | 'subtype_unconfigured' | 'percent_amount_missing' | 'outside_pay_period';
140
+ field: 'gross_fee_sats' | 'platform_fee_sats' | 'user_earned_sats' | 'site_rebate_sats' | 'subtype_disabled' | 'subtype_unconfigured' | 'percent_amount_missing' | 'agent_refused' | 'outside_pay_period';
140
141
  expected: number | null;
141
142
  actual: number | null;
142
143
  message: string;
package/dist/index.js CHANGED
@@ -320,12 +320,15 @@ var INHERITED_NAMES = new Set(
320
320
  function isInheritedName(key) {
321
321
  return INHERITED_NAMES.has(key.toLowerCase());
322
322
  }
323
+ function sitePaysFor(cfg, is_agent) {
324
+ return is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;
325
+ }
323
326
  function computeFees(cfg, payment_amount_sats, opts) {
324
327
  const is_agent = opts?.is_agent === true;
325
328
  if (is_agent && cfg.agent?.refuse) {
326
329
  throw new Error("agent_refused");
327
330
  }
328
- const effective_site_pays = is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;
331
+ const effective_site_pays = sitePaysFor(cfg, is_agent);
329
332
  const effective_user_share_pct = is_agent && typeof cfg.agent?.user_share_pct === "number" ? cfg.agent.user_share_pct : cfg.user_share_pct;
330
333
  let gross = 0;
331
334
  if (effective_site_pays.kind === "fixed_sats") {
@@ -490,7 +493,7 @@ async function fire(options) {
490
493
  if (options.payment_amount_sats !== void 0)
491
494
  requestBody.payment_amount_sats = options.payment_amount_sats;
492
495
  if (options.action_label !== void 0) requestBody.action_label = options.action_label;
493
- if (options.metadata !== void 0) requestBody.metadata = options.metadata;
496
+ if (options.note !== void 0) requestBody.note = options.note;
494
497
  if (options.is_agent !== void 0) requestBody.is_agent = options.is_agent;
495
498
  if (earner !== void 0) requestBody.user_address = earner;
496
499
  const headers = {};
@@ -576,7 +579,23 @@ function verify(envelope, config2, payment_amount_sats, opts = {}) {
576
579
  ]
577
580
  };
578
581
  }
579
- if (eventCfg.site_pays.kind === "percent_of_amount" && payment_amount_sats == null) {
582
+ const is_agent = envelope.is_agent === true;
583
+ if (is_agent && eventCfg.agent?.refuse) {
584
+ return {
585
+ ok: false,
586
+ expected: null,
587
+ issues: [
588
+ ...issues,
589
+ {
590
+ field: "agent_refused",
591
+ expected: null,
592
+ actual: null,
593
+ message: `subtype ${envelope.subtype} refuses agents on integrator ${config2.project_key} but an agent's event was billed`
594
+ }
595
+ ]
596
+ };
597
+ }
598
+ if (sitePaysFor(eventCfg, is_agent).kind === "percent_of_amount" && payment_amount_sats == null) {
580
599
  return {
581
600
  ok: false,
582
601
  expected: null,
@@ -591,7 +610,7 @@ function verify(envelope, config2, payment_amount_sats, opts = {}) {
591
610
  ]
592
611
  };
593
612
  }
594
- const expected = computeFees(eventCfg, payment_amount_sats);
613
+ const expected = computeFees(eventCfg, payment_amount_sats, { is_agent });
595
614
  if (envelope.gross_fee_sats !== expected.gross_fee_sats) {
596
615
  issues.push({
597
616
  field: "gross_fee_sats",