@orangecheck/me-client 0.53.4 → 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 +37 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +190 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -125
- package/dist/index.mjs.map +1 -1
- package/dist/{integrator-BM0Vy-ac.d.mts → integrator-DDeHg7vj.d.mts} +7 -1
- package/dist/{integrator-BM0Vy-ac.d.ts → integrator-DDeHg7vj.d.ts} +7 -1
- package/dist/integrator.d.mts +1 -1
- package/dist/integrator.d.ts +1 -1
- package/dist/integrator.js +143 -77
- package/dist/integrator.js.map +1 -1
- package/dist/integrator.mjs +141 -78
- package/dist/integrator.mjs.map +1 -1
- package/package.json +2 -1
- package/test-vectors/integrator-config.json +379 -0
|
@@ -6,11 +6,14 @@ declare const PLATFORM_FEE_POLICY: {
|
|
|
6
6
|
declare const MIN_INTEGRATOR_PRICE_SATS = 1;
|
|
7
7
|
declare const MAX_DROP_WINDOW_DAYS = 92;
|
|
8
8
|
type EventClass = 'A' | 'B' | 'C';
|
|
9
|
+
declare function isEventClass(value: unknown): value is EventClass;
|
|
9
10
|
type ClassASubtype = 'account_creation' | 'account_recovery' | 'attest_bond_increased' | 'payment_method_connected' | 'agent_delegation_issued' | 'recovery_method_updated';
|
|
10
11
|
type ClassBSubtype = 'payment_authorization' | 'scoped_action_authorization' | 'attest_verification_at_gate' | 'stamp_signing' | 'pledge_resolution';
|
|
11
12
|
type ClassCSubtype = 'session_creation';
|
|
12
13
|
type EventSubtype = ClassASubtype | ClassBSubtype | ClassCSubtype;
|
|
13
14
|
type EventKey = EventSubtype | (string & {});
|
|
15
|
+
declare const CUSTOM_EVENT_KEY_RE: RegExp;
|
|
16
|
+
declare function isInheritedName(key: string): boolean;
|
|
14
17
|
type AttestTier = 'anonymous' | 'bonded';
|
|
15
18
|
type SiteFeeShape = {
|
|
16
19
|
kind: 'fixed_sats';
|
|
@@ -29,6 +32,9 @@ interface IntegratorEventConfig {
|
|
|
29
32
|
site_pays: SiteFeeShape;
|
|
30
33
|
user_share_pct: number;
|
|
31
34
|
agent?: AgentClassOverride;
|
|
35
|
+
label?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
class?: EventClass;
|
|
32
38
|
}
|
|
33
39
|
interface IntegratorPriceConfig {
|
|
34
40
|
project_key: string;
|
|
@@ -241,4 +247,4 @@ declare const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata>;
|
|
|
241
247
|
declare function subtypesForClass(cls: EventClass): EventSubtypeMetadata[];
|
|
242
248
|
declare const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[];
|
|
243
249
|
|
|
244
|
-
export { type ArchetypeTemplate as A, type BillableEvent as B,
|
|
250
|
+
export { type ArchetypeTemplate as A, type BillableEvent as B, CUSTOM_EVENT_KEY_RE as C, type DropCadence as D, type EventKey as E, type Federation as F, PLATFORM_FEE_POLICY as G, type SessionPolicy as H, type IntegratorPriceConfig as I, type SigningMethod as J, type SiteFeeShape as K, type SystemWebhookPayload as L, MAX_DROP_WINDOW_DAYS as M, type WebhookPayload as N, computeFees as O, type PaymentAuthorizeOptions as P, isEventClass as Q, isInheritedName as R, type SignInOptions as S, type TelemetryEvent as T, subtypesForClass as U, type ValidationResult as V, type WebhookHeaders as W, validateIntegratorConfig as X, type Session as a, type PaymentResult as b, ALL_EVENT_SUBTYPES as c, ARCHETYPE_TEMPLATES as d, type AgentClassOverride as e, fromTemplate as f, getArchetypeTemplate as g, type AttestTier as h, type ClassASubtype as i, type ClassBSubtype as j, type ClassCSubtype as k, type ComputedFees as l, type DropClosedWebhookPayload as m, type DropResponseBlock as n, type DropScheduleSummary as o, EVENT_SUBTYPES as p, type EventClass as q, type EventSubtype as r, type EventSubtypeMetadata as s, type FederationMigratingWebhookPayload as t, type FederationMigrationCancelledWebhookPayload as u, type FederationStatus as v, type FederationSuccessor as w, type IntegratorArchetype as x, type IntegratorEventConfig as y, MIN_INTEGRATOR_PRICE_SATS as z };
|
|
@@ -6,11 +6,14 @@ declare const PLATFORM_FEE_POLICY: {
|
|
|
6
6
|
declare const MIN_INTEGRATOR_PRICE_SATS = 1;
|
|
7
7
|
declare const MAX_DROP_WINDOW_DAYS = 92;
|
|
8
8
|
type EventClass = 'A' | 'B' | 'C';
|
|
9
|
+
declare function isEventClass(value: unknown): value is EventClass;
|
|
9
10
|
type ClassASubtype = 'account_creation' | 'account_recovery' | 'attest_bond_increased' | 'payment_method_connected' | 'agent_delegation_issued' | 'recovery_method_updated';
|
|
10
11
|
type ClassBSubtype = 'payment_authorization' | 'scoped_action_authorization' | 'attest_verification_at_gate' | 'stamp_signing' | 'pledge_resolution';
|
|
11
12
|
type ClassCSubtype = 'session_creation';
|
|
12
13
|
type EventSubtype = ClassASubtype | ClassBSubtype | ClassCSubtype;
|
|
13
14
|
type EventKey = EventSubtype | (string & {});
|
|
15
|
+
declare const CUSTOM_EVENT_KEY_RE: RegExp;
|
|
16
|
+
declare function isInheritedName(key: string): boolean;
|
|
14
17
|
type AttestTier = 'anonymous' | 'bonded';
|
|
15
18
|
type SiteFeeShape = {
|
|
16
19
|
kind: 'fixed_sats';
|
|
@@ -29,6 +32,9 @@ interface IntegratorEventConfig {
|
|
|
29
32
|
site_pays: SiteFeeShape;
|
|
30
33
|
user_share_pct: number;
|
|
31
34
|
agent?: AgentClassOverride;
|
|
35
|
+
label?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
class?: EventClass;
|
|
32
38
|
}
|
|
33
39
|
interface IntegratorPriceConfig {
|
|
34
40
|
project_key: string;
|
|
@@ -241,4 +247,4 @@ declare const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata>;
|
|
|
241
247
|
declare function subtypesForClass(cls: EventClass): EventSubtypeMetadata[];
|
|
242
248
|
declare const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[];
|
|
243
249
|
|
|
244
|
-
export { type ArchetypeTemplate as A, type BillableEvent as B,
|
|
250
|
+
export { type ArchetypeTemplate as A, type BillableEvent as B, CUSTOM_EVENT_KEY_RE as C, type DropCadence as D, type EventKey as E, type Federation as F, PLATFORM_FEE_POLICY as G, type SessionPolicy as H, type IntegratorPriceConfig as I, type SigningMethod as J, type SiteFeeShape as K, type SystemWebhookPayload as L, MAX_DROP_WINDOW_DAYS as M, type WebhookPayload as N, computeFees as O, type PaymentAuthorizeOptions as P, isEventClass as Q, isInheritedName as R, type SignInOptions as S, type TelemetryEvent as T, subtypesForClass as U, type ValidationResult as V, type WebhookHeaders as W, validateIntegratorConfig as X, type Session as a, type PaymentResult as b, ALL_EVENT_SUBTYPES as c, ARCHETYPE_TEMPLATES as d, type AgentClassOverride as e, fromTemplate as f, getArchetypeTemplate as g, type AttestTier as h, type ClassASubtype as i, type ClassBSubtype as j, type ClassCSubtype as k, type ComputedFees as l, type DropClosedWebhookPayload as m, type DropResponseBlock as n, type DropScheduleSummary as o, EVENT_SUBTYPES as p, type EventClass as q, type EventSubtype as r, type EventSubtypeMetadata as s, type FederationMigratingWebhookPayload as t, type FederationMigrationCancelledWebhookPayload as u, type FederationStatus as v, type FederationSuccessor as w, type IntegratorArchetype as x, type IntegratorEventConfig as y, MIN_INTEGRATOR_PRICE_SATS as z };
|
package/dist/integrator.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, h as AttestTier, B as BillableEvent, C as
|
|
1
|
+
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, h as AttestTier, B as BillableEvent, C as CUSTOM_EVENT_KEY_RE, i as ClassASubtype, j as ClassBSubtype, k as ClassCSubtype, l as ComputedFees, m as DropClosedWebhookPayload, p as EVENT_SUBTYPES, q as EventClass, r as EventSubtype, s as EventSubtypeMetadata, t as FederationMigratingWebhookPayload, u as FederationMigrationCancelledWebhookPayload, w as FederationSuccessor, x as IntegratorArchetype, y as IntegratorEventConfig, I as IntegratorPriceConfig, z as MIN_INTEGRATOR_PRICE_SATS, G as PLATFORM_FEE_POLICY, K as SiteFeeShape, L as SystemWebhookPayload, V as ValidationResult, W as WebhookHeaders, N as WebhookPayload, O as computeFees, f as configFromTemplate, g as getArchetypeTemplate, Q as isEventClass, R as isInheritedName, U as subtypesForClass, X as validateIntegratorConfig } from './integrator-DDeHg7vj.mjs';
|
package/dist/integrator.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, h as AttestTier, B as BillableEvent, C as
|
|
1
|
+
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, h as AttestTier, B as BillableEvent, C as CUSTOM_EVENT_KEY_RE, i as ClassASubtype, j as ClassBSubtype, k as ClassCSubtype, l as ComputedFees, m as DropClosedWebhookPayload, p as EVENT_SUBTYPES, q as EventClass, r as EventSubtype, s as EventSubtypeMetadata, t as FederationMigratingWebhookPayload, u as FederationMigrationCancelledWebhookPayload, w as FederationSuccessor, x as IntegratorArchetype, y as IntegratorEventConfig, I as IntegratorPriceConfig, z as MIN_INTEGRATOR_PRICE_SATS, G as PLATFORM_FEE_POLICY, K as SiteFeeShape, L as SystemWebhookPayload, V as ValidationResult, W as WebhookHeaders, N as WebhookPayload, O as computeFees, f as configFromTemplate, g as getArchetypeTemplate, Q as isEventClass, R as isInheritedName, U as subtypesForClass, X as validateIntegratorConfig } from './integrator-DDeHg7vj.js';
|
package/dist/integrator.js
CHANGED
|
@@ -1,82 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/types.ts
|
|
4
|
-
var PLATFORM_FEE_POLICY = {
|
|
5
|
-
/** Fraction of every gross_fee that OC retains. */
|
|
6
|
-
pct: 0.2,
|
|
7
|
-
/** Absolute minimum platform fee, in sats. */
|
|
8
|
-
min_floor_sats: 1,
|
|
9
|
-
/** Date this policy was last ratified. Changes require a versioned
|
|
10
|
-
* @orangecheck/me-client release. */
|
|
11
|
-
ratified: "2026-04-30"
|
|
12
|
-
};
|
|
13
|
-
var MIN_INTEGRATOR_PRICE_SATS = 1;
|
|
14
|
-
var MAX_INTEGRATOR_PRICE_SATS = 1e7;
|
|
15
|
-
function computeFees(cfg, payment_amount_sats, opts) {
|
|
16
|
-
const is_agent = opts?.is_agent === true;
|
|
17
|
-
if (is_agent && cfg.agent?.refuse) {
|
|
18
|
-
throw new Error("agent_refused");
|
|
19
|
-
}
|
|
20
|
-
const effective_site_pays = is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;
|
|
21
|
-
const effective_user_share_pct = is_agent && typeof cfg.agent?.user_share_pct === "number" ? cfg.agent.user_share_pct : cfg.user_share_pct;
|
|
22
|
-
let gross = 0;
|
|
23
|
-
if (effective_site_pays.kind === "fixed_sats") {
|
|
24
|
-
gross = Math.max(MIN_INTEGRATOR_PRICE_SATS, Math.round(effective_site_pays.sats));
|
|
25
|
-
} else {
|
|
26
|
-
if (payment_amount_sats == null) {
|
|
27
|
-
throw new Error("percent_of_amount config requires payment_amount_sats");
|
|
28
|
-
}
|
|
29
|
-
gross = Math.max(
|
|
30
|
-
MIN_INTEGRATOR_PRICE_SATS,
|
|
31
|
-
Math.round(payment_amount_sats * effective_site_pays.pct)
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
gross = Math.min(gross, MAX_INTEGRATOR_PRICE_SATS);
|
|
35
|
-
const platform_fee_sats = Math.min(
|
|
36
|
-
gross,
|
|
37
|
-
Math.max(PLATFORM_FEE_POLICY.min_floor_sats, Math.round(gross * PLATFORM_FEE_POLICY.pct))
|
|
38
|
-
);
|
|
39
|
-
const user_share = Math.min(0.8, Math.max(0, effective_user_share_pct));
|
|
40
|
-
const user_earned_sats = Math.min(gross - platform_fee_sats, Math.round(gross * user_share));
|
|
41
|
-
const site_rebate_sats = gross - platform_fee_sats - user_earned_sats;
|
|
42
|
-
return { gross_fee_sats: gross, platform_fee_sats, user_earned_sats, site_rebate_sats };
|
|
43
|
-
}
|
|
44
|
-
function validateIntegratorConfig(cfg) {
|
|
45
|
-
const errors = [];
|
|
46
|
-
if (!cfg.project_key) errors.push({ message: "project_key is required" });
|
|
47
|
-
if (!cfg.display_name) errors.push({ message: "display_name is required" });
|
|
48
|
-
if (!cfg.domain) errors.push({ message: "domain is required" });
|
|
49
|
-
for (const [key, eventCfg] of Object.entries(cfg.events)) {
|
|
50
|
-
if (!eventCfg) continue;
|
|
51
|
-
const subtype = key;
|
|
52
|
-
if (!eventCfg.enabled) continue;
|
|
53
|
-
if (eventCfg.site_pays.kind === "fixed_sats") {
|
|
54
|
-
if (eventCfg.site_pays.sats < MIN_INTEGRATOR_PRICE_SATS) {
|
|
55
|
-
errors.push({
|
|
56
|
-
subtype,
|
|
57
|
-
message: `site_pays.sats (${eventCfg.site_pays.sats}) is below MIN_INTEGRATOR_PRICE_SATS (${MIN_INTEGRATOR_PRICE_SATS})`
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
const pct = eventCfg.site_pays.pct;
|
|
62
|
-
if (!(pct > 0 && pct <= 1)) {
|
|
63
|
-
errors.push({
|
|
64
|
-
subtype,
|
|
65
|
-
message: `site_pays.pct (${pct}) must be in (0, 1]`
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const u = eventCfg.user_share_pct;
|
|
70
|
-
if (u < 0 || u > 0.8) {
|
|
71
|
-
errors.push({
|
|
72
|
-
subtype,
|
|
73
|
-
message: `user_share_pct (${u}) must be in [0, 0.8]; max is 0.8 because platform_fee is ${PLATFORM_FEE_POLICY.pct}`
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return { ok: errors.length === 0, errors };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
3
|
// src/subtypes.ts
|
|
81
4
|
var EVENT_SUBTYPES = {
|
|
82
5
|
// ── Class A · durable state transitions ──
|
|
@@ -200,6 +123,146 @@ var ALL_EVENT_SUBTYPES = [
|
|
|
200
123
|
...subtypesForClass("C")
|
|
201
124
|
];
|
|
202
125
|
|
|
126
|
+
// src/types.ts
|
|
127
|
+
var PLATFORM_FEE_POLICY = {
|
|
128
|
+
/** Fraction of every gross_fee that OC retains. */
|
|
129
|
+
pct: 0.2,
|
|
130
|
+
/** Absolute minimum platform fee, in sats. */
|
|
131
|
+
min_floor_sats: 1,
|
|
132
|
+
/** Date this policy was last ratified. Changes require a versioned
|
|
133
|
+
* @orangecheck/me-client release. */
|
|
134
|
+
ratified: "2026-04-30"
|
|
135
|
+
};
|
|
136
|
+
var MIN_INTEGRATOR_PRICE_SATS = 1;
|
|
137
|
+
var MAX_INTEGRATOR_PRICE_SATS = 1e7;
|
|
138
|
+
var EVENT_CLASSES = /* @__PURE__ */ new Set(["A", "B", "C"]);
|
|
139
|
+
function isEventClass(value) {
|
|
140
|
+
return EVENT_CLASSES.has(value);
|
|
141
|
+
}
|
|
142
|
+
var CUSTOM_EVENT_KEY_RE = /^[a-z0-9](?:[a-z0-9_.:-]{0,62}[a-z0-9])?$/i;
|
|
143
|
+
var INHERITED_NAMES = new Set(
|
|
144
|
+
[...Object.getOwnPropertyNames(Object.prototype), "__proto__"].map((n) => n.toLowerCase())
|
|
145
|
+
);
|
|
146
|
+
function isInheritedName(key) {
|
|
147
|
+
return INHERITED_NAMES.has(key.toLowerCase());
|
|
148
|
+
}
|
|
149
|
+
function computeFees(cfg, payment_amount_sats, opts) {
|
|
150
|
+
const is_agent = opts?.is_agent === true;
|
|
151
|
+
if (is_agent && cfg.agent?.refuse) {
|
|
152
|
+
throw new Error("agent_refused");
|
|
153
|
+
}
|
|
154
|
+
const effective_site_pays = is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;
|
|
155
|
+
const effective_user_share_pct = is_agent && typeof cfg.agent?.user_share_pct === "number" ? cfg.agent.user_share_pct : cfg.user_share_pct;
|
|
156
|
+
let gross = 0;
|
|
157
|
+
if (effective_site_pays.kind === "fixed_sats") {
|
|
158
|
+
gross = Math.max(MIN_INTEGRATOR_PRICE_SATS, Math.round(effective_site_pays.sats));
|
|
159
|
+
} else {
|
|
160
|
+
if (payment_amount_sats == null) {
|
|
161
|
+
throw new Error("percent_of_amount config requires payment_amount_sats");
|
|
162
|
+
}
|
|
163
|
+
gross = Math.max(
|
|
164
|
+
MIN_INTEGRATOR_PRICE_SATS,
|
|
165
|
+
Math.round(payment_amount_sats * effective_site_pays.pct)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
gross = Math.min(gross, MAX_INTEGRATOR_PRICE_SATS);
|
|
169
|
+
const platform_fee_sats = Math.min(
|
|
170
|
+
gross,
|
|
171
|
+
Math.max(PLATFORM_FEE_POLICY.min_floor_sats, Math.round(gross * PLATFORM_FEE_POLICY.pct))
|
|
172
|
+
);
|
|
173
|
+
const user_share = Math.min(0.8, Math.max(0, effective_user_share_pct));
|
|
174
|
+
const user_earned_sats = Math.min(gross - platform_fee_sats, Math.round(gross * user_share));
|
|
175
|
+
const site_rebate_sats = gross - platform_fee_sats - user_earned_sats;
|
|
176
|
+
return { gross_fee_sats: gross, platform_fee_sats, user_earned_sats, site_rebate_sats };
|
|
177
|
+
}
|
|
178
|
+
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
179
|
+
function siteFeeShapeProblem(v) {
|
|
180
|
+
if (!isRecord(v)) return "must be an object";
|
|
181
|
+
if (v.kind === "fixed_sats") return Number.isFinite(v.sats) ? null : "sats must be a number";
|
|
182
|
+
if (v.kind === "percent_of_amount") {
|
|
183
|
+
return Number.isFinite(v.pct) ? null : "pct must be a number";
|
|
184
|
+
}
|
|
185
|
+
return `kind must be fixed_sats or percent_of_amount (got ${JSON.stringify(v.kind)})`;
|
|
186
|
+
}
|
|
187
|
+
function eventShapeProblem(e) {
|
|
188
|
+
const fee = siteFeeShapeProblem(e.site_pays);
|
|
189
|
+
if (fee) return `site_pays ${fee}`;
|
|
190
|
+
if (!Number.isFinite(e.user_share_pct)) return "user_share_pct must be a number";
|
|
191
|
+
if (e.agent == null) return null;
|
|
192
|
+
if (!isRecord(e.agent)) return "agent must be an object";
|
|
193
|
+
if (e.agent.site_pays != null) {
|
|
194
|
+
const agentFee = siteFeeShapeProblem(e.agent.site_pays);
|
|
195
|
+
if (agentFee) return `agent.site_pays ${agentFee}`;
|
|
196
|
+
}
|
|
197
|
+
if (e.agent.user_share_pct != null && !Number.isFinite(e.agent.user_share_pct)) {
|
|
198
|
+
return "agent.user_share_pct must be a number";
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
function validateIntegratorConfig(cfg) {
|
|
203
|
+
const errors = [];
|
|
204
|
+
if (!cfg.project_key) errors.push({ message: "project_key is required" });
|
|
205
|
+
if (!cfg.display_name) errors.push({ message: "display_name is required" });
|
|
206
|
+
if (!cfg.domain) errors.push({ message: "domain is required" });
|
|
207
|
+
if (!isRecord(cfg.events)) errors.push({ message: "events must be an object" });
|
|
208
|
+
for (const [key, eventCfg] of Object.entries(isRecord(cfg.events) ? cfg.events : {})) {
|
|
209
|
+
if (!eventCfg) continue;
|
|
210
|
+
const subtype = key;
|
|
211
|
+
if (!isRecord(eventCfg)) {
|
|
212
|
+
errors.push({ subtype, message: "must be an object" });
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const builtin = Object.prototype.hasOwnProperty.call(EVENT_SUBTYPES, key);
|
|
216
|
+
if (!builtin && !CUSTOM_EVENT_KEY_RE.test(key)) {
|
|
217
|
+
errors.push({
|
|
218
|
+
subtype,
|
|
219
|
+
message: `custom event key "${key}" must match ${CUSTOM_EVENT_KEY_RE} (1\u201364 chars, letters/digits/_.:- )`
|
|
220
|
+
});
|
|
221
|
+
} else if (!builtin && isInheritedName(key)) {
|
|
222
|
+
errors.push({
|
|
223
|
+
subtype,
|
|
224
|
+
message: `custom event key "${key}" is a name every object already has; pick another`
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if (eventCfg.class != null && !isEventClass(eventCfg.class)) {
|
|
228
|
+
errors.push({
|
|
229
|
+
subtype,
|
|
230
|
+
message: `class must be A, B or C (got ${JSON.stringify(eventCfg.class)})`
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (!eventCfg.enabled) continue;
|
|
234
|
+
const shape = eventShapeProblem(eventCfg);
|
|
235
|
+
if (shape) {
|
|
236
|
+
errors.push({ subtype, message: shape });
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (eventCfg.site_pays.kind === "fixed_sats") {
|
|
240
|
+
if (eventCfg.site_pays.sats < MIN_INTEGRATOR_PRICE_SATS) {
|
|
241
|
+
errors.push({
|
|
242
|
+
subtype,
|
|
243
|
+
message: `site_pays.sats (${eventCfg.site_pays.sats}) is below MIN_INTEGRATOR_PRICE_SATS (${MIN_INTEGRATOR_PRICE_SATS})`
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
const pct = eventCfg.site_pays.pct;
|
|
248
|
+
if (!(pct > 0 && pct <= 1)) {
|
|
249
|
+
errors.push({
|
|
250
|
+
subtype,
|
|
251
|
+
message: `site_pays.pct (${pct}) must be in (0, 1]`
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const u = eventCfg.user_share_pct;
|
|
256
|
+
if (u < 0 || u > 0.8) {
|
|
257
|
+
errors.push({
|
|
258
|
+
subtype,
|
|
259
|
+
message: `user_share_pct (${u}) must be in [0, 0.8]; max is 0.8 because platform_fee is ${PLATFORM_FEE_POLICY.pct}`
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return { ok: errors.length === 0, errors };
|
|
264
|
+
}
|
|
265
|
+
|
|
203
266
|
// src/templates.ts
|
|
204
267
|
var FIXED = (sats) => ({
|
|
205
268
|
kind: "fixed_sats",
|
|
@@ -423,12 +486,15 @@ function getArchetypeTemplate(id) {
|
|
|
423
486
|
|
|
424
487
|
exports.ALL_EVENT_SUBTYPES = ALL_EVENT_SUBTYPES;
|
|
425
488
|
exports.ARCHETYPE_TEMPLATES = ARCHETYPE_TEMPLATES;
|
|
489
|
+
exports.CUSTOM_EVENT_KEY_RE = CUSTOM_EVENT_KEY_RE;
|
|
426
490
|
exports.EVENT_SUBTYPES = EVENT_SUBTYPES;
|
|
427
491
|
exports.MIN_INTEGRATOR_PRICE_SATS = MIN_INTEGRATOR_PRICE_SATS;
|
|
428
492
|
exports.PLATFORM_FEE_POLICY = PLATFORM_FEE_POLICY;
|
|
429
493
|
exports.computeFees = computeFees;
|
|
430
494
|
exports.configFromTemplate = fromTemplate;
|
|
431
495
|
exports.getArchetypeTemplate = getArchetypeTemplate;
|
|
496
|
+
exports.isEventClass = isEventClass;
|
|
497
|
+
exports.isInheritedName = isInheritedName;
|
|
432
498
|
exports.subtypesForClass = subtypesForClass;
|
|
433
499
|
exports.validateIntegratorConfig = validateIntegratorConfig;
|
|
434
500
|
//# sourceMappingURL=integrator.js.map
|