@orangecheck/me-client 0.54.0 → 0.55.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 +18 -0
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -1
- package/dist/index.mjs.map +1 -1
- package/dist/integrator.js +35 -1
- package/dist/integrator.js.map +1 -1
- package/dist/integrator.mjs +35 -1
- package/dist/integrator.mjs.map +1 -1
- package/package.json +1 -1
- package/test-vectors/integrator-config.json +309 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,24 @@ and [Semantic Versioning](https://semver.org/). Wire-format / canonical-message
|
|
|
8
8
|
changes are coordinated via the relevant `oc-*-protocol` spec repo's CHANGELOG;
|
|
9
9
|
this file tracks the package's TS / Node / runtime API surface.
|
|
10
10
|
|
|
11
|
+
## [0.55.0] — 2026-10-26
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- `validateIntegratorConfig` refuses an enabled event whose fields the fee code
|
|
16
|
+
cannot read, naming the field, as me.ochk.io does: `site_pays` must be an
|
|
17
|
+
object of kind `fixed_sats` with a numeric `sats` or `percent_of_amount` with
|
|
18
|
+
a numeric `pct`; `user_share_pct` must be a number; an `agent` override must
|
|
19
|
+
be an object whose `site_pays` and `user_share_pct`, when given, follow the
|
|
20
|
+
same rules. An event that is not an object, and `events` that is not an
|
|
21
|
+
object, are refused too. A disabled event is still checked only for its key
|
|
22
|
+
and class.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- `test-vectors/integrator-config.json` carries the shape cases under `shape`,
|
|
27
|
+
each with the exact error me.ochk.io and this package give.
|
|
28
|
+
|
|
11
29
|
## [0.54.0] — 2026-10-26
|
|
12
30
|
|
|
13
31
|
### Changed
|
package/dist/index.js
CHANGED
|
@@ -345,14 +345,43 @@ function computeFees(cfg, payment_amount_sats, opts) {
|
|
|
345
345
|
const site_rebate_sats = gross - platform_fee_sats - user_earned_sats;
|
|
346
346
|
return { gross_fee_sats: gross, platform_fee_sats, user_earned_sats, site_rebate_sats };
|
|
347
347
|
}
|
|
348
|
+
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
349
|
+
function siteFeeShapeProblem(v) {
|
|
350
|
+
if (!isRecord(v)) return "must be an object";
|
|
351
|
+
if (v.kind === "fixed_sats") return Number.isFinite(v.sats) ? null : "sats must be a number";
|
|
352
|
+
if (v.kind === "percent_of_amount") {
|
|
353
|
+
return Number.isFinite(v.pct) ? null : "pct must be a number";
|
|
354
|
+
}
|
|
355
|
+
return `kind must be fixed_sats or percent_of_amount (got ${JSON.stringify(v.kind)})`;
|
|
356
|
+
}
|
|
357
|
+
function eventShapeProblem(e) {
|
|
358
|
+
const fee = siteFeeShapeProblem(e.site_pays);
|
|
359
|
+
if (fee) return `site_pays ${fee}`;
|
|
360
|
+
if (!Number.isFinite(e.user_share_pct)) return "user_share_pct must be a number";
|
|
361
|
+
if (e.agent == null) return null;
|
|
362
|
+
if (!isRecord(e.agent)) return "agent must be an object";
|
|
363
|
+
if (e.agent.site_pays != null) {
|
|
364
|
+
const agentFee = siteFeeShapeProblem(e.agent.site_pays);
|
|
365
|
+
if (agentFee) return `agent.site_pays ${agentFee}`;
|
|
366
|
+
}
|
|
367
|
+
if (e.agent.user_share_pct != null && !Number.isFinite(e.agent.user_share_pct)) {
|
|
368
|
+
return "agent.user_share_pct must be a number";
|
|
369
|
+
}
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
348
372
|
function validateIntegratorConfig(cfg) {
|
|
349
373
|
const errors = [];
|
|
350
374
|
if (!cfg.project_key) errors.push({ message: "project_key is required" });
|
|
351
375
|
if (!cfg.display_name) errors.push({ message: "display_name is required" });
|
|
352
376
|
if (!cfg.domain) errors.push({ message: "domain is required" });
|
|
353
|
-
|
|
377
|
+
if (!isRecord(cfg.events)) errors.push({ message: "events must be an object" });
|
|
378
|
+
for (const [key, eventCfg] of Object.entries(isRecord(cfg.events) ? cfg.events : {})) {
|
|
354
379
|
if (!eventCfg) continue;
|
|
355
380
|
const subtype = key;
|
|
381
|
+
if (!isRecord(eventCfg)) {
|
|
382
|
+
errors.push({ subtype, message: "must be an object" });
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
356
385
|
const builtin = Object.prototype.hasOwnProperty.call(EVENT_SUBTYPES, key);
|
|
357
386
|
if (!builtin && !CUSTOM_EVENT_KEY_RE.test(key)) {
|
|
358
387
|
errors.push({
|
|
@@ -372,6 +401,11 @@ function validateIntegratorConfig(cfg) {
|
|
|
372
401
|
});
|
|
373
402
|
}
|
|
374
403
|
if (!eventCfg.enabled) continue;
|
|
404
|
+
const shape = eventShapeProblem(eventCfg);
|
|
405
|
+
if (shape) {
|
|
406
|
+
errors.push({ subtype, message: shape });
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
375
409
|
if (eventCfg.site_pays.kind === "fixed_sats") {
|
|
376
410
|
if (eventCfg.site_pays.sats < MIN_INTEGRATOR_PRICE_SATS) {
|
|
377
411
|
errors.push({
|