@orangecheck/me-client 0.17.0 → 0.19.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.
@@ -0,0 +1,163 @@
1
+ declare const PLATFORM_FEE_POLICY: {
2
+ readonly pct: 0.2;
3
+ readonly min_floor_sats: 1;
4
+ readonly ratified: "2026-04-30";
5
+ };
6
+ declare const MIN_INTEGRATOR_PRICE_SATS = 5;
7
+ type EventClass = 'A' | 'B' | 'C';
8
+ type ClassASubtype = 'account_creation' | 'account_recovery' | 'attest_bond_increased' | 'payment_method_connected' | 'agent_delegation_issued' | 'recovery_method_updated';
9
+ type ClassBSubtype = 'payment_authorization' | 'scoped_action_authorization' | 'attest_verification_at_gate' | 'stamp_signing' | 'pledge_resolution';
10
+ type ClassCSubtype = 'session_creation';
11
+ type EventSubtype = ClassASubtype | ClassBSubtype | ClassCSubtype;
12
+ type AttestTier = 'anonymous' | 'bonded';
13
+ type SiteFeeShape = {
14
+ kind: 'fixed_sats';
15
+ sats: number;
16
+ } | {
17
+ kind: 'percent_of_amount';
18
+ pct: number;
19
+ };
20
+ interface IntegratorEventConfig {
21
+ enabled: boolean;
22
+ site_pays: SiteFeeShape;
23
+ user_share_pct: number;
24
+ }
25
+ interface IntegratorPriceConfig {
26
+ project_key: string;
27
+ display_name: string;
28
+ domain: string;
29
+ updated_at: string;
30
+ events: Partial<Record<EventSubtype, IntegratorEventConfig>>;
31
+ }
32
+ interface ComputedFees {
33
+ gross_fee_sats: number;
34
+ platform_fee_sats: number;
35
+ user_earned_sats: number;
36
+ site_rebate_sats: number;
37
+ }
38
+ declare function computeFees(cfg: IntegratorEventConfig, payment_amount_sats?: number): ComputedFees;
39
+ interface ValidationResult {
40
+ ok: boolean;
41
+ errors: {
42
+ subtype?: EventSubtype;
43
+ message: string;
44
+ }[];
45
+ }
46
+ declare function validateIntegratorConfig(cfg: IntegratorPriceConfig): ValidationResult;
47
+ interface BillableEvent {
48
+ id: string;
49
+ occurred_at: string;
50
+ class: EventClass;
51
+ subtype: EventSubtype;
52
+ site: {
53
+ domain: string;
54
+ display_name: string;
55
+ };
56
+ gross_fee_sats: number;
57
+ platform_fee_sats: number;
58
+ user_earned_sats: number;
59
+ site_rebate_sats: number;
60
+ verify_url: string;
61
+ is_agent?: boolean;
62
+ }
63
+ interface WebhookPayload extends BillableEvent {
64
+ kind: 'oc-billable-event';
65
+ sub: string;
66
+ scopes?: Partial<Record<'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count' | 'trust_attestation_count' | 'trust_attestations_bundle', string>>;
67
+ }
68
+ interface WebhookHeaders {
69
+ 'OC-Signature': string;
70
+ 'OC-Key-Id': string;
71
+ 'OC-Envelope-Id': string;
72
+ 'OC-Subtype': EventSubtype;
73
+ 'OC-Class': EventClass;
74
+ 'OC-Delivery-Attempt': string;
75
+ }
76
+ interface SessionPolicy {
77
+ duration_seconds: number;
78
+ refresh: 'sliding' | 'rolling' | 'none';
79
+ sensitive_actions?: 're-auth' | 'none';
80
+ }
81
+ interface Session {
82
+ id: string;
83
+ identity: string;
84
+ opens_at: string;
85
+ expires_at: string;
86
+ policy: SessionPolicy;
87
+ scope: string[];
88
+ }
89
+ interface SignInOptions {
90
+ scope: string[];
91
+ sessionPolicy?: Partial<SessionPolicy>;
92
+ returnTo?: string;
93
+ }
94
+ interface PaymentAuthorizeOptions {
95
+ identity: string;
96
+ amount_sats?: number;
97
+ usd_cents?: number;
98
+ description: string;
99
+ external_ref?: string;
100
+ }
101
+ interface PaymentResult {
102
+ id: string;
103
+ status: 'authorized' | 'failed' | 'cancelled';
104
+ sats_charged?: number;
105
+ user_envelope_id?: string;
106
+ verify_url?: string;
107
+ }
108
+ interface TelemetryEvent {
109
+ code: 'session.intra_signin' | 'session.token_refresh' | 'session.navigation' | 'auth.signin_failed' | 'auth.signin_cancelled' | 'auth.signin_rejected' | 'verify.passive_check';
110
+ timestamp: string;
111
+ session_id?: string;
112
+ }
113
+ type FederationStatus = 'recruiting' | 'forming' | 'binding' | 'live';
114
+ interface Federation {
115
+ slug: string;
116
+ name: string;
117
+ status: FederationStatus;
118
+ threshold: string;
119
+ target_guardian_count: number;
120
+ invite: string | null;
121
+ charter_hash: string | null;
122
+ last_attestation_at: string | null;
123
+ geography_hint: string;
124
+ geography_requirements?: string;
125
+ charter_status?: string;
126
+ ceremony_window?: string;
127
+ why_this_one?: string;
128
+ apply_cta?: string;
129
+ apply_href?: string;
130
+ }
131
+ type SigningMethod = 'fedimint_threshold' | 'fedimint_client' | 'bip322';
132
+
133
+ type IntegratorArchetype = 'saas-paywall' | 'marketplace' | 'content-platform' | 'gaming' | 'agent-only';
134
+ interface ProjectIdentity {
135
+ project_key: string;
136
+ domain: string;
137
+ display_name: string;
138
+ }
139
+ interface ArchetypeTemplate {
140
+ id: IntegratorArchetype;
141
+ label: string;
142
+ summary: string;
143
+ examples: readonly string[];
144
+ events: Partial<Record<EventSubtype, IntegratorEventConfig>>;
145
+ }
146
+ declare const ARCHETYPE_TEMPLATES: readonly ArchetypeTemplate[];
147
+ declare function fromTemplate(useCase: IntegratorArchetype, identity: ProjectIdentity): IntegratorPriceConfig;
148
+ declare function getArchetypeTemplate(id: IntegratorArchetype): ArchetypeTemplate;
149
+
150
+ interface EventSubtypeMetadata {
151
+ id: EventSubtype;
152
+ class: EventClass;
153
+ label: string;
154
+ fires_when: string;
155
+ example: string;
156
+ common_use_cases: readonly string[];
157
+ typical_price_hint: string;
158
+ }
159
+ declare const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata>;
160
+ declare function subtypesForClass(cls: EventClass): EventSubtypeMetadata[];
161
+ declare const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[];
162
+
163
+ export { type ArchetypeTemplate as A, type BillableEvent as B, type ClassASubtype as C, type EventSubtype as E, type Federation as F, type IntegratorPriceConfig as I, MIN_INTEGRATOR_PRICE_SATS as M, type PaymentAuthorizeOptions as P, type SessionPolicy as S, type TelemetryEvent as T, type ValidationResult as V, type WebhookHeaders as W, type Session as a, type SignInOptions as b, type PaymentResult as c, ALL_EVENT_SUBTYPES as d, ARCHETYPE_TEMPLATES as e, fromTemplate as f, getArchetypeTemplate as g, type AttestTier as h, type ClassBSubtype as i, type ClassCSubtype as j, type ComputedFees as k, EVENT_SUBTYPES as l, type EventClass as m, type EventSubtypeMetadata as n, type FederationStatus as o, type IntegratorArchetype as p, type IntegratorEventConfig as q, PLATFORM_FEE_POLICY as r, type SigningMethod as s, type SiteFeeShape as t, type WebhookPayload as u, computeFees as v, subtypesForClass as w, validateIntegratorConfig as x };
@@ -0,0 +1 @@
1
+ export { d as ALL_EVENT_SUBTYPES, e as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, h as AttestTier, B as BillableEvent, C as ClassASubtype, i as ClassBSubtype, j as ClassCSubtype, k as ComputedFees, l as EVENT_SUBTYPES, m as EventClass, E as EventSubtype, n as EventSubtypeMetadata, p as IntegratorArchetype, q as IntegratorEventConfig, I as IntegratorPriceConfig, M as MIN_INTEGRATOR_PRICE_SATS, r as PLATFORM_FEE_POLICY, t as SiteFeeShape, V as ValidationResult, W as WebhookHeaders, u as WebhookPayload, v as computeFees, f as configFromTemplate, g as getArchetypeTemplate, w as subtypesForClass, x as validateIntegratorConfig } from './integrator-m712Srxt.mjs';
@@ -0,0 +1 @@
1
+ export { d as ALL_EVENT_SUBTYPES, e as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, h as AttestTier, B as BillableEvent, C as ClassASubtype, i as ClassBSubtype, j as ClassCSubtype, k as ComputedFees, l as EVENT_SUBTYPES, m as EventClass, E as EventSubtype, n as EventSubtypeMetadata, p as IntegratorArchetype, q as IntegratorEventConfig, I as IntegratorPriceConfig, M as MIN_INTEGRATOR_PRICE_SATS, r as PLATFORM_FEE_POLICY, t as SiteFeeShape, V as ValidationResult, W as WebhookHeaders, u as WebhookPayload, v as computeFees, f as configFromTemplate, g as getArchetypeTemplate, w as subtypesForClass, x as validateIntegratorConfig } from './integrator-m712Srxt.js';
@@ -0,0 +1,427 @@
1
+ 'use strict';
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 = 5;
14
+ function computeFees(cfg, payment_amount_sats) {
15
+ let gross = 0;
16
+ if (cfg.site_pays.kind === "fixed_sats") {
17
+ gross = Math.max(MIN_INTEGRATOR_PRICE_SATS, Math.round(cfg.site_pays.sats));
18
+ } else {
19
+ if (payment_amount_sats == null) {
20
+ throw new Error("percent_of_amount config requires payment_amount_sats");
21
+ }
22
+ gross = Math.max(
23
+ MIN_INTEGRATOR_PRICE_SATS,
24
+ Math.round(payment_amount_sats * cfg.site_pays.pct)
25
+ );
26
+ }
27
+ const platform_fee_sats = Math.max(
28
+ PLATFORM_FEE_POLICY.min_floor_sats,
29
+ Math.round(gross * PLATFORM_FEE_POLICY.pct)
30
+ );
31
+ const user_share = Math.min(0.8, Math.max(0, cfg.user_share_pct));
32
+ const user_earned_sats = Math.round(gross * user_share);
33
+ const site_rebate_sats = Math.max(0, gross - platform_fee_sats - user_earned_sats);
34
+ return { gross_fee_sats: gross, platform_fee_sats, user_earned_sats, site_rebate_sats };
35
+ }
36
+ function validateIntegratorConfig(cfg) {
37
+ const errors = [];
38
+ if (!cfg.project_key) errors.push({ message: "project_key is required" });
39
+ if (!cfg.display_name) errors.push({ message: "display_name is required" });
40
+ if (!cfg.domain) errors.push({ message: "domain is required" });
41
+ for (const [key, eventCfg] of Object.entries(cfg.events)) {
42
+ if (!eventCfg) continue;
43
+ const subtype = key;
44
+ if (!eventCfg.enabled) continue;
45
+ if (eventCfg.site_pays.kind === "fixed_sats") {
46
+ if (eventCfg.site_pays.sats < MIN_INTEGRATOR_PRICE_SATS) {
47
+ errors.push({
48
+ subtype,
49
+ message: `site_pays.sats (${eventCfg.site_pays.sats}) is below MIN_INTEGRATOR_PRICE_SATS (${MIN_INTEGRATOR_PRICE_SATS})`
50
+ });
51
+ }
52
+ } else {
53
+ const pct = eventCfg.site_pays.pct;
54
+ if (!(pct > 0 && pct <= 1)) {
55
+ errors.push({
56
+ subtype,
57
+ message: `site_pays.pct (${pct}) must be in (0, 1]`
58
+ });
59
+ }
60
+ }
61
+ const u = eventCfg.user_share_pct;
62
+ if (u < 0 || u > 0.8) {
63
+ errors.push({
64
+ subtype,
65
+ message: `user_share_pct (${u}) must be in [0, 0.8]; max is 0.8 because platform_fee is ${PLATFORM_FEE_POLICY.pct}`
66
+ });
67
+ }
68
+ }
69
+ return { ok: errors.length === 0, errors };
70
+ }
71
+
72
+ // src/subtypes.ts
73
+ var EVENT_SUBTYPES = {
74
+ // ── Class A · durable state transitions ──
75
+ account_creation: {
76
+ id: "account_creation",
77
+ class: "A",
78
+ label: "account creation",
79
+ fires_when: "a new oc identity creates a durable account record on your surface (first sign-in, profile row inserted)",
80
+ example: "user signed up via email-OTP and your account row was inserted in your DB",
81
+ common_use_cases: ["onboarding", "signup", "registration", "first-login"],
82
+ typical_price_hint: "~1300 sats (~$1.24)"
83
+ },
84
+ account_recovery: {
85
+ id: "account_recovery",
86
+ class: "A",
87
+ label: "account recovery",
88
+ fires_when: "a user re-binds an existing account to a new device or recovery method",
89
+ example: "user lost their device and recovered the account via email OTP + recovery code",
90
+ common_use_cases: ["recovery", "device-rebind", "restore-access"],
91
+ typical_price_hint: "~650 sats (~$0.62)"
92
+ },
93
+ attest_bond_increased: {
94
+ id: "attest_bond_increased",
95
+ class: "A",
96
+ label: "attest bond increased",
97
+ fires_when: "a user upgrades their bond size (locks more sats to attest_tier=bonded with higher cap)",
98
+ example: "user moved from 10k-sat bond to 100k-sat bond to clear your higher-trust gate",
99
+ common_use_cases: ["bond-upgrade", "tier-promotion", "sybil-resistance"],
100
+ typical_price_hint: "~1600 sats (~$1.52) \xB7 OFF by default"
101
+ },
102
+ payment_method_connected: {
103
+ id: "payment_method_connected",
104
+ class: "A",
105
+ label: "payment method connected",
106
+ fires_when: "a user connects a Lightning address, BIP-322 wallet, or payment-routing channel to their account",
107
+ example: "user pasted a lightning@address.com receive address into their profile",
108
+ common_use_cases: ["payment-setup", "wallet-connect", "payout-config"],
109
+ typical_price_hint: "~320 sats (~$0.30)"
110
+ },
111
+ agent_delegation_issued: {
112
+ id: "agent_delegation_issued",
113
+ class: "A",
114
+ label: "agent delegation issued",
115
+ fires_when: "a user signs an oc-agent delegation envelope authorizing an AI agent to act on their behalf",
116
+ example: 'user delegated a "summarize my emails" agent for 24 hours with scope email:read',
117
+ common_use_cases: ["agent-grant", "ai-delegation", "scoped-authorization"],
118
+ typical_price_hint: "~320 sats \xB7 OFF by default (power-user)"
119
+ },
120
+ recovery_method_updated: {
121
+ id: "recovery_method_updated",
122
+ class: "A",
123
+ label: "recovery method updated",
124
+ fires_when: "a user changes their recovery email, recovery key, or social-recovery contacts",
125
+ example: "user rotated their recovery email after a phone change",
126
+ common_use_cases: ["recovery-rotation", "security-update"],
127
+ typical_price_hint: "~160 sats (~$0.15)"
128
+ },
129
+ // ── Class B · action-bound ──
130
+ payment_authorization: {
131
+ id: "payment_authorization",
132
+ class: "B",
133
+ label: "payment authorized",
134
+ fires_when: "a user authorizes a payment of underlying value (Lightning, on-chain BTC, or fiat-quoted)",
135
+ example: "user paid $5.00 (\u22485260 sats) for a premium feature on your site",
136
+ common_use_cases: ["payment", "checkout", "paywall", "subscription"],
137
+ typical_price_hint: "0.75% of payment amount (percent_of_amount)"
138
+ },
139
+ scoped_action_authorization: {
140
+ id: "scoped_action_authorization",
141
+ class: "B",
142
+ label: "scoped action authorized",
143
+ fires_when: "a user takes a specific action your site bills on (post, vote, comment, claim) where each instance is meaningful",
144
+ example: "user posted a long-form review that earns them sats from your editorial budget",
145
+ common_use_cases: ["post", "vote", "comment", "claim", "submit"],
146
+ typical_price_hint: "~100 sats (~$0.10)"
147
+ },
148
+ attest_verification_at_gate: {
149
+ id: "attest_verification_at_gate",
150
+ class: "B",
151
+ label: "attest verification",
152
+ fires_when: "your site's gate consulted the user's attest_tier and admitted them (counted only when admitted)",
153
+ example: "admin gate checked attest_tier=bonded with bond\u226510k sats and granted access",
154
+ common_use_cases: ["gate-check", "tier-gate", "sybil-filter"],
155
+ typical_price_hint: "~280 sats (~$0.27) \xB7 OFF by default"
156
+ },
157
+ stamp_signing: {
158
+ id: "stamp_signing",
159
+ class: "B",
160
+ label: "stamp signed",
161
+ fires_when: "a user signs an oc-stamp envelope (provenance attestation, review credential, content stamp)",
162
+ example: "user stamped their published recipe with their oc identity for downstream verification",
163
+ common_use_cases: ["provenance", "review", "credential", "attestation"],
164
+ typical_price_hint: "~55 sats (~$0.05) \xB7 OFF by default"
165
+ },
166
+ pledge_resolution: {
167
+ id: "pledge_resolution",
168
+ class: "B",
169
+ label: "pledge resolved",
170
+ fires_when: "an oc-pledge bonded commitment resolves (paid out, slashed, or refunded) on your surface",
171
+ example: "user staked 50k sats on a prediction; market resolved and the pledge paid out",
172
+ common_use_cases: ["pledge", "staking", "resolution", "commit-reveal"],
173
+ typical_price_hint: "1% of pledge amount (percent_of_amount) \xB7 OFF by default"
174
+ },
175
+ // ── Class C · session ──
176
+ session_creation: {
177
+ id: "session_creation",
178
+ class: "C",
179
+ label: "session opened",
180
+ fires_when: "a fresh authenticated session is opened for a returning user (sign-in within an existing session is FREE)",
181
+ example: "user signed in after their last session expired; new session token issued",
182
+ common_use_cases: ["sign-in", "session", "authenticate"],
183
+ typical_price_hint: "~55 sats (~$0.05)"
184
+ }
185
+ };
186
+ function subtypesForClass(cls) {
187
+ return Object.values(EVENT_SUBTYPES).filter((m) => m.class === cls);
188
+ }
189
+ var ALL_EVENT_SUBTYPES = [
190
+ ...subtypesForClass("A"),
191
+ ...subtypesForClass("B"),
192
+ ...subtypesForClass("C")
193
+ ];
194
+
195
+ // src/templates.ts
196
+ var FIXED = (sats) => ({
197
+ kind: "fixed_sats",
198
+ sats
199
+ });
200
+ var PCT = (pct) => ({
201
+ kind: "percent_of_amount",
202
+ pct
203
+ });
204
+ var ARCHETYPE_TEMPLATES = [
205
+ {
206
+ id: "saas-paywall",
207
+ label: "SaaS \xB7 paywall",
208
+ summary: "Subscription product \xB7 users sign up, sign in, sometimes pay for premium tiers. Default cashback to encourage signup + retention.",
209
+ examples: ["Notion-like notes app", "Linear-like project tracker", "Figma-like editor"],
210
+ events: {
211
+ account_creation: {
212
+ enabled: true,
213
+ site_pays: FIXED(1300),
214
+ user_share_pct: 0.65
215
+ },
216
+ session_creation: {
217
+ enabled: true,
218
+ site_pays: FIXED(55),
219
+ user_share_pct: 0.65
220
+ },
221
+ payment_authorization: {
222
+ enabled: true,
223
+ site_pays: PCT(75e-4),
224
+ user_share_pct: 0.65
225
+ },
226
+ payment_method_connected: {
227
+ enabled: true,
228
+ site_pays: FIXED(320),
229
+ user_share_pct: 0.65
230
+ }
231
+ }
232
+ },
233
+ {
234
+ id: "marketplace",
235
+ label: "marketplace",
236
+ summary: "Two-sided marketplace \xB7 buyers + sellers transact. Heavy on payment_authorization and scoped_action_authorization for listings.",
237
+ examples: ["Stripe-like checkout", "Etsy-like marketplace", "Uber-like ride-hailing"],
238
+ events: {
239
+ account_creation: {
240
+ enabled: true,
241
+ site_pays: FIXED(1300),
242
+ user_share_pct: 0.65
243
+ },
244
+ session_creation: {
245
+ enabled: true,
246
+ site_pays: FIXED(55),
247
+ user_share_pct: 0.65
248
+ },
249
+ payment_authorization: {
250
+ enabled: true,
251
+ site_pays: PCT(75e-4),
252
+ user_share_pct: 0.65
253
+ },
254
+ scoped_action_authorization: {
255
+ enabled: true,
256
+ site_pays: FIXED(100),
257
+ user_share_pct: 0.65
258
+ },
259
+ payment_method_connected: {
260
+ enabled: true,
261
+ site_pays: FIXED(320),
262
+ user_share_pct: 0.65
263
+ },
264
+ attest_verification_at_gate: {
265
+ enabled: true,
266
+ site_pays: FIXED(280),
267
+ user_share_pct: 0.65
268
+ }
269
+ }
270
+ },
271
+ {
272
+ id: "content-platform",
273
+ label: "content platform",
274
+ summary: "User-generated content \xB7 posts, reviews, votes, comments. Each meaningful action is scoped_action_authorization; stamp_signing for credentialed reviews.",
275
+ examples: ["Reddit-like forum", "YouTube-like video host", "Substack-like publishing"],
276
+ events: {
277
+ account_creation: {
278
+ enabled: true,
279
+ site_pays: FIXED(1300),
280
+ user_share_pct: 0.7
281
+ },
282
+ session_creation: {
283
+ enabled: true,
284
+ site_pays: FIXED(55),
285
+ user_share_pct: 0.7
286
+ },
287
+ scoped_action_authorization: {
288
+ enabled: true,
289
+ site_pays: FIXED(100),
290
+ user_share_pct: 0.7
291
+ },
292
+ stamp_signing: {
293
+ enabled: true,
294
+ site_pays: FIXED(55),
295
+ user_share_pct: 0.7
296
+ }
297
+ }
298
+ },
299
+ {
300
+ id: "gaming",
301
+ label: "gaming",
302
+ summary: "Game with monetized actions \xB7 pledges + scoped actions are core. Higher cashback ratios reward in-game engagement.",
303
+ examples: [
304
+ "on-chain prediction markets",
305
+ "skill-staking tournaments",
306
+ "PvP wager games"
307
+ ],
308
+ events: {
309
+ account_creation: {
310
+ enabled: true,
311
+ site_pays: FIXED(1300),
312
+ user_share_pct: 0.7
313
+ },
314
+ session_creation: {
315
+ enabled: true,
316
+ site_pays: FIXED(55),
317
+ user_share_pct: 0.7
318
+ },
319
+ scoped_action_authorization: {
320
+ enabled: true,
321
+ site_pays: FIXED(100),
322
+ user_share_pct: 0.7
323
+ },
324
+ payment_authorization: {
325
+ enabled: true,
326
+ site_pays: PCT(5e-3),
327
+ user_share_pct: 0.7
328
+ },
329
+ pledge_resolution: {
330
+ enabled: true,
331
+ site_pays: PCT(0.01),
332
+ user_share_pct: 0.7
333
+ },
334
+ attest_verification_at_gate: {
335
+ enabled: true,
336
+ site_pays: FIXED(280),
337
+ user_share_pct: 0.7
338
+ }
339
+ }
340
+ },
341
+ {
342
+ id: "agent-only",
343
+ label: "agent-only",
344
+ summary: "AI-agent surface \xB7 oc-agent delegations are the primary auth pattern. Session_creation off (delegations replace sessions); agent_delegation_issued + scoped_action_authorization carry the activity.",
345
+ examples: [
346
+ "AI assistant calling APIs on user behalf",
347
+ "autonomous trading bot",
348
+ "agent-driven customer support"
349
+ ],
350
+ events: {
351
+ account_creation: {
352
+ enabled: true,
353
+ site_pays: FIXED(1300),
354
+ user_share_pct: 0.65
355
+ },
356
+ agent_delegation_issued: {
357
+ enabled: true,
358
+ site_pays: FIXED(320),
359
+ user_share_pct: 0.65
360
+ },
361
+ scoped_action_authorization: {
362
+ enabled: true,
363
+ site_pays: FIXED(100),
364
+ user_share_pct: 0.65
365
+ }
366
+ }
367
+ }
368
+ ];
369
+ var ARCHETYPES_BY_ID = Object.fromEntries(
370
+ ARCHETYPE_TEMPLATES.map((t) => [t.id, t])
371
+ );
372
+ var ALL_SUBTYPES = [
373
+ "account_creation",
374
+ "account_recovery",
375
+ "attest_bond_increased",
376
+ "payment_method_connected",
377
+ "agent_delegation_issued",
378
+ "recovery_method_updated",
379
+ "payment_authorization",
380
+ "scoped_action_authorization",
381
+ "attest_verification_at_gate",
382
+ "stamp_signing",
383
+ "pledge_resolution",
384
+ "session_creation"
385
+ ];
386
+ var DEFAULT_DISABLED = {
387
+ enabled: false,
388
+ site_pays: { kind: "fixed_sats", sats: 100 },
389
+ user_share_pct: 0.65
390
+ };
391
+ function fromTemplate(useCase, identity) {
392
+ const template = ARCHETYPES_BY_ID[useCase];
393
+ if (!template) {
394
+ throw new Error(
395
+ `oc.config.fromTemplate: unknown archetype "${useCase}". Valid: ${Object.keys(
396
+ ARCHETYPES_BY_ID
397
+ ).join(", ")}`
398
+ );
399
+ }
400
+ const events = {};
401
+ for (const sub of ALL_SUBTYPES) {
402
+ events[sub] = template.events[sub] ?? DEFAULT_DISABLED;
403
+ }
404
+ return {
405
+ project_key: identity.project_key,
406
+ domain: identity.domain,
407
+ display_name: identity.display_name,
408
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
409
+ events
410
+ };
411
+ }
412
+ function getArchetypeTemplate(id) {
413
+ return ARCHETYPES_BY_ID[id];
414
+ }
415
+
416
+ exports.ALL_EVENT_SUBTYPES = ALL_EVENT_SUBTYPES;
417
+ exports.ARCHETYPE_TEMPLATES = ARCHETYPE_TEMPLATES;
418
+ exports.EVENT_SUBTYPES = EVENT_SUBTYPES;
419
+ exports.MIN_INTEGRATOR_PRICE_SATS = MIN_INTEGRATOR_PRICE_SATS;
420
+ exports.PLATFORM_FEE_POLICY = PLATFORM_FEE_POLICY;
421
+ exports.computeFees = computeFees;
422
+ exports.configFromTemplate = fromTemplate;
423
+ exports.getArchetypeTemplate = getArchetypeTemplate;
424
+ exports.subtypesForClass = subtypesForClass;
425
+ exports.validateIntegratorConfig = validateIntegratorConfig;
426
+ //# sourceMappingURL=integrator.js.map
427
+ //# sourceMappingURL=integrator.js.map