@orangecheck/me-client 0.57.0 → 0.59.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 +44 -6
- package/README.md +4 -1
- package/dist/button-auto.js +12 -0
- package/dist/button-auto.js.map +1 -1
- package/dist/button-auto.mjs +12 -0
- package/dist/button-auto.mjs.map +1 -1
- package/dist/button.js +12 -0
- package/dist/button.js.map +1 -1
- package/dist/button.mjs +12 -0
- package/dist/button.mjs.map +1 -1
- package/dist/index.d.mts +3 -35
- package/dist/index.d.ts +3 -35
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{integrator-BmRHP_iX.d.mts → integrator-fTchEeNJ.d.mts} +36 -2
- package/dist/{integrator-BmRHP_iX.d.ts → integrator-fTchEeNJ.d.ts} +36 -2
- package/dist/integrator.d.mts +1 -1
- package/dist/integrator.d.ts +1 -1
- package/dist/integrator.js.map +1 -1
- package/dist/integrator.mjs.map +1 -1
- package/dist/popup.js +12 -0
- package/dist/popup.js.map +1 -1
- package/dist/popup.mjs +12 -0
- package/dist/popup.mjs.map +1 -1
- package/dist/react.js +12 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +12 -0
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
declare const SCOPE_IDS: readonly ["bitcoin_address", "email", "attest_tier", "display_name", "cross_integrator_event_count", "cross_integrator_human_event_count", "cross_integrator_lifetime_sats", "cross_integrator_distinct_count", "cross_integrator_oldest_event_at", "cross_integrator_active_days", "trust_attestation_count", "trust_attestations_bundle"];
|
|
2
|
+
type Scope = (typeof SCOPE_IDS)[number];
|
|
3
|
+
interface TrustAttestationCount {
|
|
4
|
+
total: number;
|
|
5
|
+
good: number;
|
|
6
|
+
distinct_good_issuers: number;
|
|
7
|
+
caution: number;
|
|
8
|
+
}
|
|
9
|
+
declare function parseTrustAttestationCount(value: string): TrustAttestationCount | null;
|
|
10
|
+
interface GrantedOptions {
|
|
11
|
+
project_key: string;
|
|
12
|
+
accountId?: string;
|
|
13
|
+
signingSecret?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
interface GrantedResult {
|
|
17
|
+
sub: string;
|
|
18
|
+
scopes_granted: Scope[];
|
|
19
|
+
scopes: Partial<Record<Scope, string>>;
|
|
20
|
+
}
|
|
21
|
+
declare function granted(options: GrantedOptions): Promise<GrantedResult>;
|
|
22
|
+
interface RequestOptions {
|
|
23
|
+
project_key: string;
|
|
24
|
+
return_to: string;
|
|
25
|
+
origin?: string;
|
|
26
|
+
}
|
|
27
|
+
declare function request(scopes: Scope[], options: RequestOptions): never;
|
|
28
|
+
declare const scope: {
|
|
29
|
+
granted: typeof granted;
|
|
30
|
+
request: typeof request;
|
|
31
|
+
parseTrustAttestationCount: typeof parseTrustAttestationCount;
|
|
32
|
+
};
|
|
33
|
+
|
|
1
34
|
declare const PLATFORM_FEE_POLICY: {
|
|
2
35
|
readonly pct: 0.2;
|
|
3
36
|
readonly min_floor_sats: 1;
|
|
@@ -108,7 +141,7 @@ interface DropResponseBlock {
|
|
|
108
141
|
interface WebhookPayload extends BillableEvent {
|
|
109
142
|
kind: 'oc-billable-event';
|
|
110
143
|
sub: string;
|
|
111
|
-
scopes?: Partial<Record<
|
|
144
|
+
scopes?: Partial<Record<Scope, string>>;
|
|
112
145
|
}
|
|
113
146
|
interface SystemWebhookPayload {
|
|
114
147
|
kind: 'oc-system-event';
|
|
@@ -184,6 +217,7 @@ interface PaymentAuthorizeOptions {
|
|
|
184
217
|
usd_cents?: number;
|
|
185
218
|
description: string;
|
|
186
219
|
external_ref?: string;
|
|
220
|
+
bearerToken?: string;
|
|
187
221
|
}
|
|
188
222
|
interface PaymentResult {
|
|
189
223
|
id: string;
|
|
@@ -247,4 +281,4 @@ declare const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata>;
|
|
|
247
281
|
declare function subtypesForClass(cls: EventClass): EventSubtypeMetadata[];
|
|
248
282
|
declare const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[];
|
|
249
283
|
|
|
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,
|
|
284
|
+
export { computeFees as $, 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, type GrantedOptions as G, type FederationSuccessor as H, type IntegratorPriceConfig as I, type IntegratorArchetype as J, type IntegratorEventConfig as K, MIN_INTEGRATOR_PRICE_SATS as L, MAX_DROP_WINDOW_DAYS as M, PLATFORM_FEE_POLICY as N, SCOPE_IDS as O, type PaymentAuthorizeOptions as P, type SessionPolicy as Q, type RequestOptions as R, type Scope as S, type TelemetryEvent as T, type SigningMethod as U, type ValidationResult as V, type SiteFeeShape as W, type SystemWebhookPayload as X, type TrustAttestationCount as Y, type WebhookHeaders as Z, type WebhookPayload as _, type SignInOptions as a, isEventClass as a0, isInheritedName as a1, scope as a2, subtypesForClass as a3, validateIntegratorConfig as a4, type Session as b, type PaymentResult as c, type GrantedResult as d, ALL_EVENT_SUBTYPES as e, fromTemplate as f, getArchetypeTemplate as g, ARCHETYPE_TEMPLATES as h, type AgentClassOverride as i, type AttestTier as j, type ClassASubtype as k, type ClassBSubtype as l, type ClassCSubtype as m, type ComputedFees as n, type DropClosedWebhookPayload as o, parseTrustAttestationCount as p, type DropResponseBlock as q, request as r, type DropScheduleSummary as s, EVENT_SUBTYPES as t, type EventClass as u, type EventSubtype as v, type EventSubtypeMetadata as w, type FederationMigratingWebhookPayload as x, type FederationMigrationCancelledWebhookPayload as y, type FederationStatus as z };
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
declare const SCOPE_IDS: readonly ["bitcoin_address", "email", "attest_tier", "display_name", "cross_integrator_event_count", "cross_integrator_human_event_count", "cross_integrator_lifetime_sats", "cross_integrator_distinct_count", "cross_integrator_oldest_event_at", "cross_integrator_active_days", "trust_attestation_count", "trust_attestations_bundle"];
|
|
2
|
+
type Scope = (typeof SCOPE_IDS)[number];
|
|
3
|
+
interface TrustAttestationCount {
|
|
4
|
+
total: number;
|
|
5
|
+
good: number;
|
|
6
|
+
distinct_good_issuers: number;
|
|
7
|
+
caution: number;
|
|
8
|
+
}
|
|
9
|
+
declare function parseTrustAttestationCount(value: string): TrustAttestationCount | null;
|
|
10
|
+
interface GrantedOptions {
|
|
11
|
+
project_key: string;
|
|
12
|
+
accountId?: string;
|
|
13
|
+
signingSecret?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
interface GrantedResult {
|
|
17
|
+
sub: string;
|
|
18
|
+
scopes_granted: Scope[];
|
|
19
|
+
scopes: Partial<Record<Scope, string>>;
|
|
20
|
+
}
|
|
21
|
+
declare function granted(options: GrantedOptions): Promise<GrantedResult>;
|
|
22
|
+
interface RequestOptions {
|
|
23
|
+
project_key: string;
|
|
24
|
+
return_to: string;
|
|
25
|
+
origin?: string;
|
|
26
|
+
}
|
|
27
|
+
declare function request(scopes: Scope[], options: RequestOptions): never;
|
|
28
|
+
declare const scope: {
|
|
29
|
+
granted: typeof granted;
|
|
30
|
+
request: typeof request;
|
|
31
|
+
parseTrustAttestationCount: typeof parseTrustAttestationCount;
|
|
32
|
+
};
|
|
33
|
+
|
|
1
34
|
declare const PLATFORM_FEE_POLICY: {
|
|
2
35
|
readonly pct: 0.2;
|
|
3
36
|
readonly min_floor_sats: 1;
|
|
@@ -108,7 +141,7 @@ interface DropResponseBlock {
|
|
|
108
141
|
interface WebhookPayload extends BillableEvent {
|
|
109
142
|
kind: 'oc-billable-event';
|
|
110
143
|
sub: string;
|
|
111
|
-
scopes?: Partial<Record<
|
|
144
|
+
scopes?: Partial<Record<Scope, string>>;
|
|
112
145
|
}
|
|
113
146
|
interface SystemWebhookPayload {
|
|
114
147
|
kind: 'oc-system-event';
|
|
@@ -184,6 +217,7 @@ interface PaymentAuthorizeOptions {
|
|
|
184
217
|
usd_cents?: number;
|
|
185
218
|
description: string;
|
|
186
219
|
external_ref?: string;
|
|
220
|
+
bearerToken?: string;
|
|
187
221
|
}
|
|
188
222
|
interface PaymentResult {
|
|
189
223
|
id: string;
|
|
@@ -247,4 +281,4 @@ declare const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata>;
|
|
|
247
281
|
declare function subtypesForClass(cls: EventClass): EventSubtypeMetadata[];
|
|
248
282
|
declare const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[];
|
|
249
283
|
|
|
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,
|
|
284
|
+
export { computeFees as $, 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, type GrantedOptions as G, type FederationSuccessor as H, type IntegratorPriceConfig as I, type IntegratorArchetype as J, type IntegratorEventConfig as K, MIN_INTEGRATOR_PRICE_SATS as L, MAX_DROP_WINDOW_DAYS as M, PLATFORM_FEE_POLICY as N, SCOPE_IDS as O, type PaymentAuthorizeOptions as P, type SessionPolicy as Q, type RequestOptions as R, type Scope as S, type TelemetryEvent as T, type SigningMethod as U, type ValidationResult as V, type SiteFeeShape as W, type SystemWebhookPayload as X, type TrustAttestationCount as Y, type WebhookHeaders as Z, type WebhookPayload as _, type SignInOptions as a, isEventClass as a0, isInheritedName as a1, scope as a2, subtypesForClass as a3, validateIntegratorConfig as a4, type Session as b, type PaymentResult as c, type GrantedResult as d, ALL_EVENT_SUBTYPES as e, fromTemplate as f, getArchetypeTemplate as g, ARCHETYPE_TEMPLATES as h, type AgentClassOverride as i, type AttestTier as j, type ClassASubtype as k, type ClassBSubtype as l, type ClassCSubtype as m, type ComputedFees as n, type DropClosedWebhookPayload as o, parseTrustAttestationCount as p, type DropResponseBlock as q, request as r, type DropScheduleSummary as s, EVENT_SUBTYPES as t, type EventClass as u, type EventSubtype as v, type EventSubtypeMetadata as w, type FederationMigratingWebhookPayload as x, type FederationMigrationCancelledWebhookPayload as y, type FederationStatus as z };
|
package/dist/integrator.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { e as ALL_EVENT_SUBTYPES, h as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, j as AttestTier, B as BillableEvent, C as CUSTOM_EVENT_KEY_RE, k as ClassASubtype, l as ClassBSubtype, m as ClassCSubtype, n as ComputedFees, o as DropClosedWebhookPayload, t as EVENT_SUBTYPES, u as EventClass, v as EventSubtype, w as EventSubtypeMetadata, x as FederationMigratingWebhookPayload, y as FederationMigrationCancelledWebhookPayload, H as FederationSuccessor, J as IntegratorArchetype, K as IntegratorEventConfig, I as IntegratorPriceConfig, L as MIN_INTEGRATOR_PRICE_SATS, N as PLATFORM_FEE_POLICY, W as SiteFeeShape, X as SystemWebhookPayload, V as ValidationResult, Z as WebhookHeaders, _ as WebhookPayload, $ as computeFees, f as configFromTemplate, g as getArchetypeTemplate, a0 as isEventClass, a1 as isInheritedName, a3 as subtypesForClass, a4 as validateIntegratorConfig } from './integrator-fTchEeNJ.mjs';
|
package/dist/integrator.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { e as ALL_EVENT_SUBTYPES, h as ARCHETYPE_TEMPLATES, A as ArchetypeTemplate, j as AttestTier, B as BillableEvent, C as CUSTOM_EVENT_KEY_RE, k as ClassASubtype, l as ClassBSubtype, m as ClassCSubtype, n as ComputedFees, o as DropClosedWebhookPayload, t as EVENT_SUBTYPES, u as EventClass, v as EventSubtype, w as EventSubtypeMetadata, x as FederationMigratingWebhookPayload, y as FederationMigrationCancelledWebhookPayload, H as FederationSuccessor, J as IntegratorArchetype, K as IntegratorEventConfig, I as IntegratorPriceConfig, L as MIN_INTEGRATOR_PRICE_SATS, N as PLATFORM_FEE_POLICY, W as SiteFeeShape, X as SystemWebhookPayload, V as ValidationResult, Z as WebhookHeaders, _ as WebhookPayload, $ as computeFees, f as configFromTemplate, g as getArchetypeTemplate, a0 as isEventClass, a1 as isInheritedName, a3 as subtypesForClass, a4 as validateIntegratorConfig } from './integrator-fTchEeNJ.js';
|
package/dist/integrator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/subtypes.ts","../src/types.ts","../src/templates.ts"],"names":[],"mappings":";;;AAiDO,IAAM,cAAA,GAA6D;AAAA;AAAA,EAEtE,gBAAA,EAAkB;AAAA,IACd,EAAA,EAAI,kBAAA;AAAA,IACJ,KAAA,EAAO,GAAA;AAAA,IACP,KAAA,EAAO,kBAAA;AAAA,IACP,UAAA,EACI,0GAAA;AAAA,IACJ,OAAA,EAAS,2EAAA;AAAA,IACT,gBAAA,EAAkB,CAAC,YAAA,EAAc,QAAA,EAAU,gBAAgB,aAAa,CAAA;AAAA,IACxE,kBAAA,EAAoB;AAAA,GACxB;AAAA,EACA,gBAAA,EAAkB;AAAA,IACd,EAAA,EAAI,kBAAA;AAAA,IACJ,KAAA,EAAO,GAAA;AAAA,IACP,KAAA,EAAO,kBAAA;AAAA,IACP,UAAA,EACI,wEAAA;AAAA,IACJ,OAAA,EAAS,gFAAA;AAAA,IACT,gBAAA,EAAkB,CAAC,UAAA,EAAY,eAAA,EAAiB,gBAAgB,CAAA;AAAA,IAChE,kBAAA,EAAoB;AAAA,GACxB;AAAA,EACA,qBAAA,EAAuB;AAAA,IACnB,EAAA,EAAI,uBAAA;AAAA,IACJ,KAAA,EAAO,GAAA;AAAA,IACP,KAAA,EAAO,uBAAA;AAAA,IACP,UAAA,EACI,yFAAA;AAAA,IACJ,OAAA,EAAS,+EAAA;AAAA,IACT,gBAAA,EAAkB,CAAC,cAAA,EAAgB,gBAAA,EAAkB,kBAAkB,CAAA;AAAA,IACvE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A,OACJ,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,KAChB;AAAA,EACJ;AACA,EAAA,MAAM,SAA0C,EAAC;AACjD,EAAA,KAAA,MAAW,OAAO,YAAA,EAAc;AAC5B,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,QAAA,CAAS,MAAA,CAAO,GAAG,CAAA,IAAK,gBAAA;AAAA,EAC1C;AACA,EAAA,OAAO;AAAA,IACH,aAAa,QAAA,CAAS,WAAA;AAAA,IACtB,QAAQ,QAAA,CAAS,MAAA;AAAA,IACjB,cAAc,QAAA,CAAS,YAAA;AAAA,IACvB,UAAA,EAAA,iBAAY,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAAA,IACnC;AAAA,GACJ;AACJ;AAIO,SAAS,qBAAqB,EAAA,EAA4C;AAC7E,EAAA,OAAO,iBAAiB,EAAE,CAAA;AAC9B","file":"integrator.js","sourcesContent":["/**\n * Rich metadata for every billable event subtype.\n *\n * The SDK already exports the `EventSubtype` union (closed enum, type-\n * checked), but a new integrator picking between\n * `'scoped_action_authorization'` and `'stamp_signing'` and\n * `'attest_verification_at_gate'` has no inline guidance on which fits\n * their flow. This file is the canonical \"when do I use this subtype\"\n * reference, programmatically accessible:\n *\n * import { oc, EVENT_SUBTYPES } from '@orangecheck/me-client';\n *\n * for (const meta of Object.values(EVENT_SUBTYPES)) {\n * console.log(`${meta.id} (class ${meta.class}) — ${meta.fires_when}`);\n * }\n *\n * Or per-subtype:\n *\n * const meta = EVENT_SUBTYPES.account_creation;\n * console.log(meta.example); // → \"user signed up via email-OTP and the account row was inserted\"\n *\n * Used by `oc.config.fromTemplate()` to assemble archetype configs and\n * by /me/projects/* dashboards to drive consent prompts and config\n * editor labels from a single source.\n */\n\nimport type { EventClass, EventSubtype } from './types';\n\nexport interface EventSubtypeMetadata {\n id: EventSubtype;\n class: EventClass;\n /** Short label · matches SUBTYPE_LABELS on the server. */\n label: string;\n /** When this fires · imperative-mood plain English. The integrator\n * reads this to know which event in their codebase should call\n * `oc.event.fire()` with this subtype. */\n fires_when: string;\n /** A concrete example from a typical SaaS · helps integrators map\n * an unfamiliar subtype name to a real flow they recognize. */\n example: string;\n /** Common use cases · lets integrators search their own product\n * for matching flows. Two-three terms each, lowercase. */\n common_use_cases: readonly string[];\n /** What an integrator typically pays for this subtype, anchored at\n * $1 ≈ 1052 sats. Returns null for percent-of-amount subtypes\n * where the price scales with the underlying transaction. */\n typical_price_hint: string;\n}\n\nexport const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata> = {\n // ── Class A · durable state transitions ──\n account_creation: {\n id: 'account_creation',\n class: 'A',\n label: 'account creation',\n fires_when:\n 'a new oc identity creates a durable account record on your surface (first sign-in, profile row inserted)',\n example: 'user signed up via email-OTP and your account row was inserted in your DB',\n common_use_cases: ['onboarding', 'signup', 'registration', 'first-login'],\n typical_price_hint: '~1300 sats (~$1.24)',\n },\n account_recovery: {\n id: 'account_recovery',\n class: 'A',\n label: 'account recovery',\n fires_when:\n 'a user re-binds an existing account to a new device or recovery method',\n example: 'user lost their device and recovered the account via email OTP + recovery code',\n common_use_cases: ['recovery', 'device-rebind', 'restore-access'],\n typical_price_hint: '~650 sats (~$0.62)',\n },\n attest_bond_increased: {\n id: 'attest_bond_increased',\n class: 'A',\n label: 'attest bond increased',\n fires_when:\n 'a user upgrades their bond size (locks more sats to attest_tier=bonded with higher cap)',\n example: 'user moved from 10k-sat bond to 100k-sat bond to clear your higher-trust gate',\n common_use_cases: ['bond-upgrade', 'tier-promotion', 'sybil-resistance'],\n typical_price_hint: '~1600 sats (~$1.52) · OFF by default',\n },\n payment_method_connected: {\n id: 'payment_method_connected',\n class: 'A',\n label: 'payment method connected',\n fires_when:\n 'a user connects a Lightning address, BIP-322 wallet, or payment-routing channel to their account',\n example: 'user pasted a lightning@address.com receive address into their profile',\n common_use_cases: ['payment-setup', 'wallet-connect', 'payout-config'],\n typical_price_hint: '~320 sats (~$0.30)',\n },\n agent_delegation_issued: {\n id: 'agent_delegation_issued',\n class: 'A',\n label: 'agent delegation issued',\n fires_when:\n 'a user signs an oc-agent delegation envelope authorizing an AI agent to act on their behalf',\n example: 'user delegated a \"summarize my emails\" agent for 24 hours with scope email:read',\n common_use_cases: ['agent-grant', 'ai-delegation', 'scoped-authorization'],\n typical_price_hint: '~320 sats · OFF by default (power-user)',\n },\n recovery_method_updated: {\n id: 'recovery_method_updated',\n class: 'A',\n label: 'recovery method updated',\n fires_when:\n 'a user changes their recovery email, recovery key, or social-recovery contacts',\n example: 'user rotated their recovery email after a phone change',\n common_use_cases: ['recovery-rotation', 'security-update'],\n typical_price_hint: '~160 sats (~$0.15)',\n },\n\n // ── Class B · action-bound ──\n payment_authorization: {\n id: 'payment_authorization',\n class: 'B',\n label: 'payment authorized',\n fires_when:\n 'a user authorizes a payment of underlying value (Lightning, on-chain BTC, or fiat-quoted)',\n example: 'user paid $5.00 (≈5260 sats) for a premium feature on your site',\n common_use_cases: ['payment', 'checkout', 'paywall', 'subscription'],\n typical_price_hint: '0.75% of payment amount (percent_of_amount)',\n },\n scoped_action_authorization: {\n id: 'scoped_action_authorization',\n class: 'B',\n label: 'scoped action authorized',\n fires_when:\n 'a user takes a specific action your site bills on (post, vote, comment, claim) where each instance is meaningful',\n example: 'user posted a long-form review that earns them sats from your editorial budget',\n common_use_cases: ['post', 'vote', 'comment', 'claim', 'submit'],\n typical_price_hint: '~100 sats (~$0.10)',\n },\n attest_verification_at_gate: {\n id: 'attest_verification_at_gate',\n class: 'B',\n label: 'attest verification',\n fires_when:\n \"your site's gate consulted the user's attest_tier and admitted them (counted only when admitted)\",\n example: 'admin gate checked attest_tier=bonded with bond≥10k sats and granted access',\n common_use_cases: ['gate-check', 'tier-gate', 'sybil-filter'],\n typical_price_hint: '~280 sats (~$0.27) · OFF by default',\n },\n stamp_signing: {\n id: 'stamp_signing',\n class: 'B',\n label: 'stamp signed',\n fires_when:\n 'a user signs an oc-stamp envelope (provenance attestation, review credential, content stamp)',\n example: 'user stamped their published recipe with their oc identity for downstream verification',\n common_use_cases: ['provenance', 'review', 'credential', 'attestation'],\n typical_price_hint: '~55 sats (~$0.05) · OFF by default',\n },\n pledge_resolution: {\n id: 'pledge_resolution',\n class: 'B',\n label: 'pledge resolved',\n fires_when:\n 'an oc-pledge bonded commitment resolves on your surface (kept / broken / disputed / expired_unresolved). pledge bonds never move — any sat payout is an integrator-composed flow on top of pledge (e.g., HTLC), not a pledge primitive (oc-pledge-protocol WHY.md H7)',\n example:\n 'user staked sats × days-unspent on a prediction; the pledge resolved kept and the integrator paid out per its own composed terms',\n common_use_cases: ['pledge', 'staking', 'resolution', 'commit-reveal'],\n typical_price_hint: '1% of pledge bond amount (percent_of_amount) · OFF by default',\n },\n\n // ── Class C · session ──\n session_creation: {\n id: 'session_creation',\n class: 'C',\n label: 'session opened',\n fires_when:\n 'a fresh authenticated session is opened for a returning user (sign-in within an existing session is FREE)',\n example: 'user signed in after their last session expired; new session token issued',\n common_use_cases: ['sign-in', 'session', 'authenticate'],\n typical_price_hint: '~55 sats (~$0.05)',\n },\n};\n\n/** All subtypes for a given class · convenience accessor. */\nexport function subtypesForClass(cls: EventClass): EventSubtypeMetadata[] {\n return Object.values(EVENT_SUBTYPES).filter((m) => m.class === cls);\n}\n\n/** All subtypes as a flat list, ordered class A → B → C. */\nexport const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[] = [\n ...subtypesForClass('A'),\n ...subtypesForClass('B'),\n ...subtypesForClass('C'),\n];\n","/**\n * Canonical types for me.ochk.io integrators.\n *\n * Mirrors the source of truth at oc-me-web/src/lib/events/types.ts. Two\n * layers:\n * - Platform-level (PLATFORM_FEE_POLICY, MIN_INTEGRATOR_PRICE_SATS) —\n * fixed by OC, surfaced as constants here so integrators can validate\n * their config client-side before posting it.\n * - Integrator-level (IntegratorPriceConfig) — every integrator declares\n * their own per-event prices and user-share splits.\n *\n * Per Addendum 01: every chargeable event is in exactly one of three\n * classes. Sites pay for sessions and actions, not for clicks. Free\n * events never instantiate a BillableEvent.\n */\n\nimport { EVENT_SUBTYPES } from './subtypes';\n\n// ── platform constants (fixed by OC) ──────────────────────────────────────\n\nexport const PLATFORM_FEE_POLICY = {\n /** Fraction of every gross_fee that OC retains. */\n pct: 0.2,\n /** Absolute minimum platform fee, in sats. */\n min_floor_sats: 1,\n /** Date this policy was last ratified. Changes require a versioned\n * @orangecheck/me-client release. */\n ratified: '2026-04-30',\n} as const;\n\n/** Per-event price floor. 1 sat — the natural atomic Bitcoin unit.\n * Integrators choose their own per-event prices above this; OC does\n * not impose sybil-resistance opinions on integrators (that's their\n * call, from their own threat model). The 1-sat floor is purely\n * mechanical — fees can't be fractional sats. Mirrors the canonical\n * value at oc-me-web/src/lib/events/types.ts (a previous SDK release\n * drifted to 5 while the platform ratified 1). */\nexport const MIN_INTEGRATOR_PRICE_SATS = 1;\n\n/**\n * Hard per-event ceiling, mirroring the server's own bound.\n *\n * The server clamps gross to this before splitting it; this package did not,\n * so `verify()` re-derived 99,000,000 for an envelope the server had recorded\n * at 10,000,000 and rejected a correct receipt. It also over-reported what a\n * misconfigured site would be charged, by the ratio of the two numbers.\n *\n * 10,000,000 sats = 0.1 BTC: orders of magnitude above any real per-event\n * price, low enough that a misconfiguration cannot mint an unbounded number\n * of sats in one event. Found by the cross-package vector test in oc-me-web\n * on its first run.\n */\nexport const MAX_INTEGRATOR_PRICE_SATS = 10_000_000;\n\n/** Platform ceiling on a release window: no integrator schedule may\n * hold a user's earned sats longer than this, whatever its cadence.\n * Published as `max_drop_window_days` at https://me.ochk.io/api/abuse-limits. */\nexport const MAX_DROP_WINDOW_DAYS = 92;\n\n// ── event taxonomy ────────────────────────────────────────────────────────\n\nexport type EventClass = 'A' | 'B' | 'C';\n\nconst EVENT_CLASSES: ReadonlySet<unknown> = new Set<EventClass>(['A', 'B', 'C']);\n\n/** Whether a value is one of the three billing classes. */\nexport function isEventClass(value: unknown): value is EventClass {\n return EVENT_CLASSES.has(value);\n}\n\nexport type ClassASubtype =\n | 'account_creation'\n | 'account_recovery'\n | 'attest_bond_increased'\n | 'payment_method_connected'\n | 'agent_delegation_issued'\n | 'recovery_method_updated';\n\nexport type ClassBSubtype =\n | 'payment_authorization'\n | 'scoped_action_authorization'\n | 'attest_verification_at_gate'\n | 'stamp_signing'\n | 'pledge_resolution';\n\nexport type ClassCSubtype = 'session_creation';\n\nexport type EventSubtype = ClassASubtype | ClassBSubtype | ClassCSubtype;\n\n/**\n * Any billable event key. A project's catalog is OPEN: alongside the built-in\n * subtypes above, an integrator can define their own event keys (with their own\n * label + class + price) on the project config. `EventKey` keeps autocomplete\n * for the built-ins while accepting any custom string — the `(string & {})`\n * arm preserves the literal union in editors instead of collapsing it to\n * `string`. The server resolves class/label off the project's catalog for\n * custom keys.\n */\nexport type EventKey = EventSubtype | (string & {});\n\n/** Slug shape a custom event key must satisfy: 1 to 64 letters, digits or `_.:-`,\n * starting and ending with a letter or digit. */\nexport const CUSTOM_EVENT_KEY_RE = /^[a-z0-9](?:[a-z0-9_.:-]{0,62}[a-z0-9])?$/i;\n\nconst INHERITED_NAMES: ReadonlySet<string> = new Set(\n [...Object.getOwnPropertyNames(Object.prototype), '__proto__'].map((n) => n.toLowerCase())\n);\n\n/** Whether a plain object answers this name without holding it (\"constructor\",\n * \"toString\"), in any case. me.ochk.io refuses such a custom event key. */\nexport function isInheritedName(key: string): boolean {\n return INHERITED_NAMES.has(key.toLowerCase());\n}\n\n/** AttestTier · what an integrator's gate can read about an oc identity.\n *\n * me.ochk does NOT do KYC. Sybil resistance is bounded by three\n * composable mechanisms, none of which involve OC handling PII:\n * 1. paid-action history · billable events cost real sats\n * 2. BIP-322 sat-bonding · bond size + age via signed attestation\n * 3. integrator-defined gates · per-site threat-model overlays\n *\n * Tier itself is intentionally simple — anonymous | bonded.\n * Granularity (bond_sats, bond_locked_at, etc) carried separately. */\nexport type AttestTier = 'anonymous' | 'bonded';\n\n/** The shape of a per-event fee — either a fixed sats amount or a percent\n * of the underlying transaction amount (used for payments + pledges). */\nexport type SiteFeeShape =\n | { kind: 'fixed_sats'; sats: number }\n | { kind: 'percent_of_amount'; pct: number };\n\n/** Optional per-class pricing overrides · per OCHK-V3-PLAN §7 phase-1.\n * Agents acting under a scoped oc-agent delegation may bill\n * differently than humans firing the same subtype. When `agent` is\n * unset on a subtype, agent traffic bills at the human rate. `refuse:\n * true` makes the subtype human-only — the endpoint returns 422\n * agent_refused for is_agent=true requests. */\nexport interface AgentClassOverride {\n /** Override site_pays for agent-fired events. */\n site_pays?: SiteFeeShape;\n /** Override user_share_pct. Same default-fallback as site_pays. */\n user_share_pct?: number;\n /** When true, agent traffic is refused for this subtype. */\n refuse?: boolean;\n}\n\n/** What an integrator declares for a single event subtype. */\nexport interface IntegratorEventConfig {\n /** Whether this site bills this event subtype at all. */\n enabled: boolean;\n /** The per-event fee the site pays. */\n site_pays: SiteFeeShape;\n /** Fraction of GROSS that flows to the user (0–0.8 since the\n * platform fee is 20%). The remainder is a rebate to the site's\n * OC project balance. */\n user_share_pct: number;\n /** Optional per-agent-class pricing override applied when an event\n * fires with is_agent=true. */\n agent?: AgentClassOverride;\n /** Custom events only: a human-readable label. Built-ins ignore it. */\n label?: string;\n /** Custom events only: a description for the dashboard and docs. */\n description?: string;\n /** Custom events only: A, B or C. Built-ins take their class from the\n * taxonomy; a custom event without one is billed as class B. */\n class?: EventClass;\n}\n\n/** A complete integrator pricing config. Posted to me.ochk.io once at\n * integration time, mutable via the configurator UI or this SDK any time\n * after. */\nexport interface IntegratorPriceConfig {\n project_key: string;\n display_name: string;\n domain: string;\n /** ISO-8601 timestamp the config was last updated. */\n updated_at: string;\n /** Per-event configs, keyed by event key. Open catalog: built-in subtypes\n * AND your own custom keys. Keys not listed are disabled by default. */\n events: Partial<Record<EventKey, IntegratorEventConfig>>;\n}\n\n/** A computed fee breakdown for a single event. site_rebate_sats is what\n * flows back to the developer's balance after the platform fee and what\n * the user earns: zero at the full user share, 0.8. */\nexport interface ComputedFees {\n gross_fee_sats: number;\n platform_fee_sats: number;\n user_earned_sats: number;\n site_rebate_sats: number;\n}\n\n/** Compute the four-way fee split for an event given an integrator's\n * config and (for percent_of_amount events) the underlying payment\n * amount. MIRRORS oc-me-web/src/lib/events/types.ts computeFees()\n * EXACTLY — the SDK-side replay (oc.event.verify) re-runs this against\n * envelopes the server billed, so any drift is a false \"divergence\".\n *\n * Invariants:\n * 1. gross_fee_sats >= MIN_INTEGRATOR_PRICE_SATS (1-sat atomic floor)\n * 2. platform_fee_sats = min(gross, max(min_floor, round(gross × pct)))\n * — bounded above by gross so a 1-sat event can't owe more\n * platform fee than it grossed\n * 3. user_earned_sats = min(gross − platform, round(gross × share)),\n * share clamped to [0, 0.8]\n * 4. site_rebate_sats = gross − platform − user (exact remainder)\n * 5. gross == platform + user + rebate exactly\n *\n * When `opts.is_agent` is true AND the config has an `agent` override,\n * the agent's site_pays / user_share_pct apply. `agent.refuse: true`\n * throws 'agent_refused' (the server maps it to 422). */\nexport function computeFees(\n cfg: IntegratorEventConfig,\n payment_amount_sats?: number,\n opts?: { is_agent?: boolean }\n): ComputedFees {\n const is_agent = opts?.is_agent === true;\n if (is_agent && cfg.agent?.refuse) {\n throw new Error('agent_refused');\n }\n const effective_site_pays =\n is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;\n const effective_user_share_pct =\n is_agent && typeof cfg.agent?.user_share_pct === 'number'\n ? cfg.agent.user_share_pct\n : cfg.user_share_pct;\n\n let gross = 0;\n if (effective_site_pays.kind === 'fixed_sats') {\n gross = Math.max(MIN_INTEGRATOR_PRICE_SATS, Math.round(effective_site_pays.sats));\n } else {\n if (payment_amount_sats == null) {\n throw new Error('percent_of_amount config requires payment_amount_sats');\n }\n gross = Math.max(\n MIN_INTEGRATOR_PRICE_SATS,\n Math.round(payment_amount_sats * effective_site_pays.pct)\n );\n }\n // Hard ceiling · no single event mints more than MAX_INTEGRATOR_PRICE_SATS.\n // The server applies this before splitting; omitting it here made verify()\n // reject correct envelopes priced above the bound.\n gross = Math.min(gross, MAX_INTEGRATOR_PRICE_SATS);\n const platform_fee_sats = Math.min(\n gross,\n Math.max(PLATFORM_FEE_POLICY.min_floor_sats, Math.round(gross * PLATFORM_FEE_POLICY.pct))\n );\n const user_share = Math.min(0.8, Math.max(0, effective_user_share_pct));\n const user_earned_sats = Math.min(gross - platform_fee_sats, Math.round(gross * user_share));\n const site_rebate_sats = gross - platform_fee_sats - user_earned_sats;\n return { gross_fee_sats: gross, platform_fee_sats, user_earned_sats, site_rebate_sats };\n}\n\n/** Result of validating an IntegratorPriceConfig. */\nexport interface ValidationResult {\n ok: boolean;\n errors: { subtype?: EventKey; message: string }[];\n}\n\n/**\n * Validate an integrator's pricing config against the platform's\n * non-negotiable rules. Run client-side before posting; the server runs\n * the same checks and rejects anything that fails.\n */\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v);\n\n/** Why a fee shape cannot be read, or null: a known kind and a finite number. */\nfunction siteFeeShapeProblem(v: unknown): string | null {\n if (!isRecord(v)) return 'must be an object';\n if (v.kind === 'fixed_sats') return Number.isFinite(v.sats) ? null : 'sats must be a number';\n if (v.kind === 'percent_of_amount') {\n return Number.isFinite(v.pct) ? null : 'pct must be a number';\n }\n return `kind must be fixed_sats or percent_of_amount (got ${JSON.stringify(v.kind)})`;\n}\n\n/** Why an enabled event's config cannot be priced, or null: every field the\n * fee code reads is present and of its type. me.ochk.io applies the same rule. */\nfunction eventShapeProblem(e: Record<string, unknown>): string | null {\n const fee = siteFeeShapeProblem(e.site_pays);\n if (fee) return `site_pays ${fee}`;\n if (!Number.isFinite(e.user_share_pct)) return 'user_share_pct must be a number';\n if (e.agent == null) return null;\n if (!isRecord(e.agent)) return 'agent must be an object';\n if (e.agent.site_pays != null) {\n const agentFee = siteFeeShapeProblem(e.agent.site_pays);\n if (agentFee) return `agent.site_pays ${agentFee}`;\n }\n if (e.agent.user_share_pct != null && !Number.isFinite(e.agent.user_share_pct)) {\n return 'agent.user_share_pct must be a number';\n }\n return null;\n}\n\nexport function validateIntegratorConfig(cfg: IntegratorPriceConfig): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n if (!cfg.project_key) errors.push({ message: 'project_key is required' });\n if (!cfg.display_name) errors.push({ message: 'display_name is required' });\n if (!cfg.domain) errors.push({ message: 'domain is required' });\n\n if (!isRecord(cfg.events)) errors.push({ message: 'events must be an object' });\n for (const [key, eventCfg] of Object.entries(isRecord(cfg.events) ? cfg.events : {})) {\n if (!eventCfg) continue;\n const subtype = key as EventKey;\n if (!isRecord(eventCfg)) {\n errors.push({ subtype, message: 'must be an object' });\n continue;\n }\n const builtin = Object.prototype.hasOwnProperty.call(EVENT_SUBTYPES, key);\n if (!builtin && !CUSTOM_EVENT_KEY_RE.test(key)) {\n errors.push({\n subtype,\n message: `custom event key \"${key}\" must match ${CUSTOM_EVENT_KEY_RE} (1–64 chars, letters/digits/_.:- )`,\n });\n } else if (!builtin && isInheritedName(key)) {\n errors.push({\n subtype,\n message: `custom event key \"${key}\" is a name every object already has; pick another`,\n });\n }\n if (eventCfg.class != null && !isEventClass(eventCfg.class)) {\n errors.push({\n subtype,\n message: `class must be A, B or C (got ${JSON.stringify(eventCfg.class)})`,\n });\n }\n if (!eventCfg.enabled) continue;\n const shape = eventShapeProblem(eventCfg as unknown as Record<string, unknown>);\n if (shape) {\n errors.push({ subtype, message: shape });\n continue;\n }\n\n if (eventCfg.site_pays.kind === 'fixed_sats') {\n if (eventCfg.site_pays.sats < MIN_INTEGRATOR_PRICE_SATS) {\n errors.push({\n subtype,\n message: `site_pays.sats (${eventCfg.site_pays.sats}) is below MIN_INTEGRATOR_PRICE_SATS (${MIN_INTEGRATOR_PRICE_SATS})`,\n });\n }\n } else {\n const pct = eventCfg.site_pays.pct;\n if (!(pct > 0 && pct <= 1)) {\n errors.push({\n subtype,\n message: `site_pays.pct (${pct}) must be in (0, 1]`,\n });\n }\n }\n\n const u = eventCfg.user_share_pct;\n if (u < 0 || u > 0.8) {\n errors.push({\n subtype,\n message: `user_share_pct (${u}) must be in [0, 0.8]; max is 0.8 because platform_fee is ${PLATFORM_FEE_POLICY.pct}`,\n });\n }\n }\n\n return { ok: errors.length === 0, errors };\n}\n\n// ── canonical envelope ────────────────────────────────────────────────────\n\nexport interface BillableEvent {\n id: string;\n occurred_at: string;\n class: EventClass;\n subtype: EventKey;\n site: { domain: string; display_name: string };\n gross_fee_sats: number;\n platform_fee_sats: number;\n user_earned_sats: number;\n site_rebate_sats: number;\n verify_url: string;\n /** Per OCHK-V3-PLAN §7 phase-1 · true when the event was fired by\n * an oc-agent delegation rather than a human session. The\n * integrator's IntegratorEventConfig.agent block may price\n * these differently or refuse them. Optional · canonical encoder\n * branches to v=3 only when present, so legacy human-fired\n * events keep their v=2 hash + signature. */\n is_agent?: boolean;\n /** Drop-period stamp · present when the project covers this\n * subtype with a drop schedule. The user-share of a stamped event\n * MATURES until the window's boundary, then vests as one batch\n * (the drop). Billing is untouched. Part of the SIGNED canonical\n * bytes (encoder branches to v=4 when present). No clawback\n * exists — vesting is unconditional, and an open window's\n * boundary can only ever move earlier. */\n drop?: {\n /** Deterministic window id · the window's signed manifest is\n * verifiable at ochk.app/verify/<manifest_id> after close. */\n window_id: string;\n /** Block-denominated vesting boundary; null when no chain tip\n * was observable at window open (wallclock + the published\n * 24h safety valve then govern). */\n close_height_target: number | null;\n } | null;\n}\n\n// ── drop periods · integrator-scheduled payout windows ───────────────────\n\n/** A drop schedule's cadence. Weekly/monthly close at a fixed UTC\n * boundary; manual closes when the integrator says (Drop now), with a\n * hard auto-close at max_open_days (≤ MAX_DROP_WINDOW_DAYS). */\nexport type DropCadence =\n | { kind: 'weekly'; day: number; hour: number }\n | { kind: 'monthly'; day: number; hour: number }\n | { kind: 'manual'; max_open_days: number };\n\n/** Public shape of an enabled drop schedule, as returned in the\n * `drops` array of GET /api/integrator/config — part of the project's\n * public payout contract (earners can see when covered subtypes pay\n * out before earning under them). */\nexport interface DropScheduleSummary {\n schedule_id: string;\n label: string;\n subtypes: EventSubtype[];\n cadence: DropCadence;\n}\n\n/** Drop-period context on event-ingest responses (single route:\n * top-level `drop`; batch route: per-result `drop`). `state` flips\n * from 'open' to 'closing' once the scheduled boundary passes and the\n * window awaits its sweep (~15 min) — render \"processing\", never a\n * negative countdown. */\nexport interface DropResponseBlock {\n window_id: string;\n label: string;\n state: 'open' | 'closing';\n closes_at_target: string;\n close_height_target: number | null;\n}\n\n// ── webhook payload ───────────────────────────────────────────────────────\n\n/**\n * The exact JSON body delivered to a registered webhook endpoint when\n * a billable event fires. Imported by integrator backends so the\n * receive handler is type-checked end-to-end without re-declaring the\n * shape.\n *\n * import type { WebhookPayload } from '@orangecheck/me-client';\n *\n * export async function POST(req: Request) {\n * const payload = (await req.json()) as WebhookPayload;\n * if (payload.subtype === 'payment_authorization') {\n * creditUser(payload.sub, payload.user_earned_sats);\n * }\n * }\n *\n * Headers carry the signature and metadata (see WebhookHeaders below).\n * Verify the signature with `oc.webhook.verify({ body, headers, jwks })`.\n *\n * Privacy contract · the master oc identity is NEVER in the payload.\n * Integrators see `sub` (per-integrator anonymous id) plus any\n * `scopes` the user explicitly granted. See PRIVACY-ARCHITECTURE.md.\n */\nexport interface WebhookPayload extends BillableEvent {\n /** Discriminator · identifies the payload kind for routing on\n * the integrator's side. Always 'oc-billable-event' today; future\n * webhook payload kinds (refunds, charters, etc) will use\n * distinct discriminator values. */\n kind: 'oc-billable-event';\n /** Per-integrator anonymous subject id · stable across events for\n * the same (oc_identity, project_key) pair. Key your user records\n * on this; OC will never give you the master address unless the\n * user explicitly grants `bitcoin_address` or `email` scope. */\n sub: string;\n /** Resolved scoped fields · only present for scopes the user has\n * granted to this project. Wire format is string-keyed (every\n * value is stringified · ints stringified, addresses as-is). */\n scopes?: Partial<\n Record<\n | 'bitcoin_address'\n | 'email'\n | 'attest_tier'\n | 'display_name'\n | 'cross_integrator_event_count'\n | 'cross_integrator_human_event_count'\n | 'trust_attestation_count'\n | 'trust_attestations_bundle',\n string\n >\n >;\n}\n\n/**\n * Non-billable SYSTEM webhook deliveries — project-level operational\n * signals (escrow.low, escrow.depleted, escrow.recovered, drop.closed,\n * connect.claimed, federation.migrating, federation.migration_cancelled).\n * Same signing + headers as billable deliveries; receivers subscribe\n * via the same `subscribed` list ('*' or the explicit subtype string).\n * Carries no user identity, except connect.claimed. It has no `id`: the\n * `OC-Envelope-Id` header is its only id, so deduplicate on that.\n * Discriminate on `kind` first, then `subtype`:\n *\n * const payload = JSON.parse(body) as WebhookPayload | SystemWebhookPayload;\n * if (payload.kind === 'oc-system-event' && payload.subtype === 'drop.closed') { … }\n */\nexport interface SystemWebhookPayload {\n kind: 'oc-system-event';\n subtype: string;\n project_key: string;\n [extra: string]: unknown;\n}\n\n/** The `drop.closed` system event — one per closed drop window. The\n * manifest is the signed, content-addressed record (Merkle commitments\n * over member events + recipients); verify_url renders + live-verifies\n * it, and /api/envelope/<manifest_id> serves the raw canonical bytes. */\nexport interface DropClosedWebhookPayload extends SystemWebhookPayload {\n subtype: 'drop.closed';\n window_id: string;\n schedule_id: string;\n label: string;\n manifest_id: string;\n verify_url: string;\n sealed_at: string;\n sealed_height: number | null;\n event_count: number;\n recipient_count: number;\n gross_fee_sats: number;\n user_share_sats: number;\n}\n\n/** The federation a project moves to, as `federation.migrating` names it. */\nexport interface FederationSuccessor {\n slug: string;\n name: string;\n /** `\"3-of-4\"`; null while the successor has none set. */\n threshold: string | null;\n /** `\"bitcoin\"`, `\"signet\"`, …; null while unset. */\n network: string | null;\n /** The successor's ratified charter, by hash; null before it has one. */\n charter_hash: string | null;\n /** Each guardian seat's operator key, hex. */\n guardians: string[];\n}\n\n/**\n * `federation.migrating`: your project's federation is being replaced. Top-ups\n * pause now; events and sign-in carry on. The project and its balance move no\n * sooner than `flip_not_before`.\n */\nexport interface FederationMigratingWebhookPayload extends SystemWebhookPayload {\n subtype: 'federation.migrating';\n migration_id: string;\n /** The federation the project is on now (its slug). */\n from: string;\n /** The federation it moves to (its slug). */\n to: string;\n /** ISO time: the earliest the move can happen. */\n flip_not_before: string;\n successor: FederationSuccessor;\n}\n\n/** `federation.migration_cancelled`: that move is off, and top-ups work again. */\nexport interface FederationMigrationCancelledWebhookPayload extends SystemWebhookPayload {\n subtype: 'federation.migration_cancelled';\n migration_id: string;\n from: string;\n to: string;\n}\n\n/**\n * HTTP headers OC sends with every webhook delivery. Capture these in\n * the receive handler · `OC-Signature` is what verifies the body.\n */\nexport interface WebhookHeaders {\n /** Ed25519 signature over the raw request body, hex-encoded. */\n 'OC-Signature': string;\n /** kid of the key that signed it, published by me.ochk.io at\n * https://me.ochk.io/api/dev-jwks (not ochk.io's sign-in keys). */\n 'OC-Key-Id': string;\n /** For a billable event, its `id`, the same as `payload.id`. A system\n * notice (`OC-Class: system`) has no `id` in its body: this header is\n * its only id, the delivery's own. Not signed. Deduplicate on\n * `payload.id` when there is one, else on this. */\n 'OC-Envelope-Id': string;\n /** Subtype · matches payload.subtype (built-in or a custom event key,\n * or a system notice's subtype); lets routers branch on the header\n * before parsing. */\n 'OC-Subtype': EventKey;\n /** Class · matches payload.class; `system` for a system notice. */\n 'OC-Class': EventClass;\n /** 1-indexed delivery attempt count. >1 means the prior attempt\n * did not return a 2xx within the timeout · idempotency key on\n * payload.id is critical. */\n 'OC-Delivery-Attempt': string;\n}\n\n// ── session lifecycle ────────────────────────────────────────────────────\n\nexport interface SessionPolicy {\n duration_seconds: number;\n refresh: 'sliding' | 'rolling' | 'fixed';\n sensitive_actions?: 're-auth' | 'allow';\n}\n\nexport interface Session {\n id: string;\n identity: string;\n issued_at: string;\n expires_at: string;\n policy: SessionPolicy;\n scope: string[];\n}\n\nexport interface SignInOptions {\n scope: string[];\n sessionPolicy?: Partial<SessionPolicy>;\n returnTo?: string;\n}\n\nexport interface PaymentAuthorizeOptions {\n /** @deprecated Ignored: the server takes the account from the session. */\n identity?: string;\n amount_sats?: number;\n usd_cents?: number;\n description: string;\n external_ref?: string;\n}\n\nexport interface PaymentResult {\n id: string;\n status: 'authorized' | 'failed' | 'cancelled';\n sats_charged?: number;\n user_envelope_id?: string;\n verify_url?: string;\n}\n\nexport interface TelemetryEvent {\n code:\n | 'session.intra_signin'\n | 'session.token_refresh'\n | 'session.navigation'\n /** Emitted by `session.invalidate()`. Was `session.intra_signin`, which\n * means the opposite thing — \"user pressed sign-in while a valid\n * session was already open\" — so a subscriber saw a sign-in event\n * every time the integrator tore a session down. Non-billable. */\n | 'session.teardown'\n | 'auth.signin_failed'\n | 'auth.signin_cancelled'\n | 'auth.signin_rejected'\n | 'verify.passive_check';\n timestamp: string;\n session_id?: string;\n}\n\n// ── federation directory ───────────────────────────────────────────────\n//\n// The SDK consumes the federation directory at runtime so multi-federation\n// routing is a directory write, not a code change. v1 has one live\n// federation; the directory is plural-shaped so federation #2 lights up\n// without an SDK release.\n\nexport type FederationStatus = 'recruiting' | 'forming' | 'binding' | 'live';\n\n/** Federation directory entry. Mirrors `oc-me-web/src/lib/federations/registry.ts`\n * field-for-field; this package is the public consumption shape. */\nexport interface Federation {\n slug: string;\n name: string;\n status: FederationStatus;\n threshold: string;\n target_guardian_count: number;\n /** Fedimint invite code; null until status === 'live'. */\n invite: string | null;\n /** SHA-256 of the canonical federation charter, hex-encoded. */\n charter_hash: string | null;\n /** ISO-8601 of the most recent ongoing-attestation envelope. */\n last_attestation_at: string | null;\n geography_hint: string;\n // Operator-recruiting fields (present on slots in 'recruiting' /\n // 'forming' / 'binding' state). Nullable so one shape spans the\n // lifecycle.\n geography_requirements?: string;\n charter_status?: string;\n ceremony_window?: string;\n why_this_one?: string;\n apply_cta?: string;\n apply_href?: string;\n}\n\n/** SigningMethod discriminator on the user identity. Federation-agnostic\n * by construction — the OC identity (did:email or BIP-322 address)\n * remains stable across all three states. Transitions are recorded as\n * anchored \"rebind\" envelopes on the canonical event log. Graduation\n * is the product thesis; this discriminator is the structural primitive\n * that records where a user is on the custody-state graph. */\nexport type SigningMethod = 'fedimint_threshold' | 'fedimint_client' | 'bip322';\n","/**\n * Archetype templates for `oc.config.fromTemplate(useCase, ...)`.\n *\n * A new integrator with a 30-second decision shouldn't have to fill\n * 12 IntegratorEventConfig entries by hand. Pick the archetype that\n * matches your site, get a sensible starting config, tweak whatever\n * you want, submit:\n *\n * import { oc } from '@orangecheck/me-client';\n *\n * const config = oc.config.fromTemplate('saas-paywall', {\n * project_key: 'pk_live_yourcompany',\n * domain: 'yoursite.com',\n * display_name: 'Your Site',\n * });\n * await oc.config.save(config);\n *\n * Templates differ on which subtypes are enabled (a content platform\n * doesn't need payment_authorization; a marketplace does) and on the\n * price per subtype. Every price is at the full user share, 0.8: the\n * user gets everything the 20% platform fee leaves. A smaller share only\n * returned part of the fee to the developer's own balance after it was\n * charged, so it cost more for nothing.\n *\n * To customize after picking a template:\n *\n * const config = oc.config.fromTemplate('marketplace', { ... });\n * config.events.payment_authorization!.site_pays = {\n * kind: 'percent_of_amount',\n * pct: 0.005, // 0.5% instead of the template's 0.75%\n * };\n */\n\nimport type {\n EventSubtype,\n IntegratorEventConfig,\n IntegratorPriceConfig,\n} from './types';\n\nexport type IntegratorArchetype =\n | 'saas-paywall'\n | 'marketplace'\n | 'content-platform'\n | 'gaming'\n | 'agent-only';\n\ninterface ProjectIdentity {\n project_key: string;\n domain: string;\n display_name: string;\n}\n\n/** Template descriptor · what each archetype enables and prices.\n * Exposed so dashboards can render \"you're using the X template\"\n * state and offer one-click swaps. */\nexport interface ArchetypeTemplate {\n id: IntegratorArchetype;\n label: string;\n /** One-sentence summary shown next to the picker. */\n summary: string;\n /** Concrete examples of sites this archetype fits. */\n examples: readonly string[];\n /** Per-subtype config the template emits. Subtypes not listed are\n * emitted as `enabled: false` (the SDK fills them with a\n * conservative default to keep the type happy without firing). */\n events: Partial<Record<EventSubtype, IntegratorEventConfig>>;\n}\n\nconst FIXED = (sats: number): IntegratorEventConfig['site_pays'] => ({\n kind: 'fixed_sats',\n sats,\n});\nconst PCT = (pct: number): IntegratorEventConfig['site_pays'] => ({\n kind: 'percent_of_amount',\n pct,\n});\n\n/**\n * The full archetype catalog. Add new templates here · one record per\n * common integrator pattern. Keep the list curated (≤8 archetypes) —\n * if there are too many, none feel like the obvious default and\n * integrators stall on the picker.\n */\nexport const ARCHETYPE_TEMPLATES: readonly ArchetypeTemplate[] = [\n {\n id: 'saas-paywall',\n label: 'SaaS · paywall',\n summary:\n 'A subscription product: people sign up, sign in and sometimes pay for more. Pays them for signing up and coming back.',\n examples: ['notes app', 'project tracker', 'design editor'],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1056),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(45),\n user_share_pct: 0.8,\n },\n payment_authorization: {\n enabled: true,\n site_pays: PCT(0.00609375),\n user_share_pct: 0.8,\n },\n payment_method_connected: {\n enabled: true,\n site_pays: FIXED(260),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'marketplace',\n label: 'marketplace',\n summary:\n 'Buyers and sellers trade. Pays on payments, listings and new payment methods.',\n examples: ['checkout', 'handmade-goods market', 'ride-hailing'],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1056),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(45),\n user_share_pct: 0.8,\n },\n payment_authorization: {\n enabled: true,\n site_pays: PCT(0.00609375),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(81),\n user_share_pct: 0.8,\n },\n payment_method_connected: {\n enabled: true,\n site_pays: FIXED(260),\n user_share_pct: 0.8,\n },\n attest_verification_at_gate: {\n enabled: true,\n site_pays: FIXED(227),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'content-platform',\n label: 'content platform',\n summary:\n 'Posts, reviews, votes and comments. Pays for each meaningful action, and for signed reviews.',\n examples: ['forum', 'video host', 'newsletter'],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1137),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(49),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(87),\n user_share_pct: 0.8,\n },\n stamp_signing: {\n enabled: true,\n site_pays: FIXED(49),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'gaming',\n label: 'gaming',\n summary:\n 'A game where actions carry value. Pays for playing, paying and settled pledges.',\n examples: [\n 'on-chain prediction markets',\n 'skill-staking tournaments',\n 'multiplayer games',\n ],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1137),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(49),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(87),\n user_share_pct: 0.8,\n },\n payment_authorization: {\n enabled: true,\n site_pays: PCT(0.004375),\n user_share_pct: 0.8,\n },\n pledge_resolution: {\n enabled: true,\n site_pays: PCT(0.00875),\n user_share_pct: 0.8,\n },\n attest_verification_at_gate: {\n enabled: true,\n site_pays: FIXED(245),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'agent-only',\n label: 'agent-only',\n summary:\n 'AI agents act for people under a delegation. Sessions are off; delegations and the actions they allow carry the activity.',\n examples: [\n 'AI assistant calling APIs on user behalf',\n 'autonomous trading bot',\n 'agent-driven customer support',\n ],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1056),\n user_share_pct: 0.8,\n },\n agent_delegation_issued: {\n enabled: true,\n site_pays: FIXED(260),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(81),\n user_share_pct: 0.8,\n },\n },\n },\n];\n\nconst ARCHETYPES_BY_ID: Record<IntegratorArchetype, ArchetypeTemplate> = Object.fromEntries(\n ARCHETYPE_TEMPLATES.map((t) => [t.id, t])\n) as Record<IntegratorArchetype, ArchetypeTemplate>;\n\n/** All 12 subtypes — used to fill `enabled: false` defaults for any\n * subtype the chosen archetype doesn't list. */\nconst ALL_SUBTYPES: readonly EventSubtype[] = [\n 'account_creation',\n 'account_recovery',\n 'attest_bond_increased',\n 'payment_method_connected',\n 'agent_delegation_issued',\n 'recovery_method_updated',\n 'payment_authorization',\n 'scoped_action_authorization',\n 'attest_verification_at_gate',\n 'stamp_signing',\n 'pledge_resolution',\n 'session_creation',\n];\n\nconst DEFAULT_DISABLED: IntegratorEventConfig = {\n enabled: false,\n site_pays: { kind: 'fixed_sats', sats: 100 },\n user_share_pct: 0.8,\n};\n\n/**\n * Build a complete IntegratorPriceConfig from an archetype id + the\n * project's identity fields. Every subtype gets an entry — the\n * archetype's listed subtypes get the template's pricing; everything\n * else gets `enabled: false` with conservative defaults so the config\n * is type-complete and the integrator can flip-on later subtypes\n * without re-deriving prices.\n *\n * Throws synchronously if `useCase` isn't a known archetype id.\n */\nexport function fromTemplate(\n useCase: IntegratorArchetype,\n identity: ProjectIdentity\n): IntegratorPriceConfig {\n const template = ARCHETYPES_BY_ID[useCase];\n if (!template) {\n throw new Error(\n `oc.config.fromTemplate: unknown archetype \"${useCase}\". Valid: ${Object.keys(\n ARCHETYPES_BY_ID\n ).join(', ')}`\n );\n }\n const events: IntegratorPriceConfig['events'] = {};\n for (const sub of ALL_SUBTYPES) {\n events[sub] = template.events[sub] ?? DEFAULT_DISABLED;\n }\n return {\n project_key: identity.project_key,\n domain: identity.domain,\n display_name: identity.display_name,\n updated_at: new Date().toISOString(),\n events,\n };\n}\n\n/** Look up a template's metadata · used by config-editor UIs to render\n * \"you're on the X template · here's what it enables\" copy. */\nexport function getArchetypeTemplate(id: IntegratorArchetype): ArchetypeTemplate {\n return ARCHETYPES_BY_ID[id];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/subtypes.ts","../src/types.ts","../src/templates.ts"],"names":[],"mappings":";;;AAiDO,IAAM,cAAA,GAA6D;AAAA;AAAA,EAEtE,gBAAA,EAAkB;AAAA,IACd,EAAA,EAAI,kBAAA;AAAA,IACJ,KAAA,EAAO,GAAA;AAAA,IAC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EAAA,EAA4C;AAC7E,EAAA,OAAO,iBAAiB,EAAE,CAAA;AAC9B","file":"integrator.js","sourcesContent":["/**\n * Rich metadata for every billable event subtype.\n *\n * The SDK already exports the `EventSubtype` union (closed enum, type-\n * checked), but a new integrator picking between\n * `'scoped_action_authorization'` and `'stamp_signing'` and\n * `'attest_verification_at_gate'` has no inline guidance on which fits\n * their flow. This file is the canonical \"when do I use this subtype\"\n * reference, programmatically accessible:\n *\n * import { oc, EVENT_SUBTYPES } from '@orangecheck/me-client';\n *\n * for (const meta of Object.values(EVENT_SUBTYPES)) {\n * console.log(`${meta.id} (class ${meta.class}) — ${meta.fires_when}`);\n * }\n *\n * Or per-subtype:\n *\n * const meta = EVENT_SUBTYPES.account_creation;\n * console.log(meta.example); // → \"user signed up via email-OTP and the account row was inserted\"\n *\n * Used by `oc.config.fromTemplate()` to assemble archetype configs and\n * by /me/projects/* dashboards to drive consent prompts and config\n * editor labels from a single source.\n */\n\nimport type { EventClass, EventSubtype } from './types';\n\nexport interface EventSubtypeMetadata {\n id: EventSubtype;\n class: EventClass;\n /** Short label · matches SUBTYPE_LABELS on the server. */\n label: string;\n /** When this fires · imperative-mood plain English. The integrator\n * reads this to know which event in their codebase should call\n * `oc.event.fire()` with this subtype. */\n fires_when: string;\n /** A concrete example from a typical SaaS · helps integrators map\n * an unfamiliar subtype name to a real flow they recognize. */\n example: string;\n /** Common use cases · lets integrators search their own product\n * for matching flows. Two-three terms each, lowercase. */\n common_use_cases: readonly string[];\n /** What an integrator typically pays for this subtype, anchored at\n * $1 ≈ 1052 sats. Returns null for percent-of-amount subtypes\n * where the price scales with the underlying transaction. */\n typical_price_hint: string;\n}\n\nexport const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata> = {\n // ── Class A · durable state transitions ──\n account_creation: {\n id: 'account_creation',\n class: 'A',\n label: 'account creation',\n fires_when:\n 'a new oc identity creates a durable account record on your surface (first sign-in, profile row inserted)',\n example: 'user signed up via email-OTP and your account row was inserted in your DB',\n common_use_cases: ['onboarding', 'signup', 'registration', 'first-login'],\n typical_price_hint: '~1300 sats (~$1.24)',\n },\n account_recovery: {\n id: 'account_recovery',\n class: 'A',\n label: 'account recovery',\n fires_when:\n 'a user re-binds an existing account to a new device or recovery method',\n example: 'user lost their device and recovered the account via email OTP + recovery code',\n common_use_cases: ['recovery', 'device-rebind', 'restore-access'],\n typical_price_hint: '~650 sats (~$0.62)',\n },\n attest_bond_increased: {\n id: 'attest_bond_increased',\n class: 'A',\n label: 'attest bond increased',\n fires_when:\n 'a user upgrades their bond size (locks more sats to attest_tier=bonded with higher cap)',\n example: 'user moved from 10k-sat bond to 100k-sat bond to clear your higher-trust gate',\n common_use_cases: ['bond-upgrade', 'tier-promotion', 'sybil-resistance'],\n typical_price_hint: '~1600 sats (~$1.52) · OFF by default',\n },\n payment_method_connected: {\n id: 'payment_method_connected',\n class: 'A',\n label: 'payment method connected',\n fires_when:\n 'a user connects a Lightning address, BIP-322 wallet, or payment-routing channel to their account',\n example: 'user pasted a lightning@address.com receive address into their profile',\n common_use_cases: ['payment-setup', 'wallet-connect', 'payout-config'],\n typical_price_hint: '~320 sats (~$0.30)',\n },\n agent_delegation_issued: {\n id: 'agent_delegation_issued',\n class: 'A',\n label: 'agent delegation issued',\n fires_when:\n 'a user signs an oc-agent delegation envelope authorizing an AI agent to act on their behalf',\n example: 'user delegated a \"summarize my emails\" agent for 24 hours with scope email:read',\n common_use_cases: ['agent-grant', 'ai-delegation', 'scoped-authorization'],\n typical_price_hint: '~320 sats · OFF by default (power-user)',\n },\n recovery_method_updated: {\n id: 'recovery_method_updated',\n class: 'A',\n label: 'recovery method updated',\n fires_when:\n 'a user changes their recovery email, recovery key, or social-recovery contacts',\n example: 'user rotated their recovery email after a phone change',\n common_use_cases: ['recovery-rotation', 'security-update'],\n typical_price_hint: '~160 sats (~$0.15)',\n },\n\n // ── Class B · action-bound ──\n payment_authorization: {\n id: 'payment_authorization',\n class: 'B',\n label: 'payment authorized',\n fires_when:\n 'a user authorizes a payment of underlying value (Lightning, on-chain BTC, or fiat-quoted)',\n example: 'user paid $5.00 (≈5260 sats) for a premium feature on your site',\n common_use_cases: ['payment', 'checkout', 'paywall', 'subscription'],\n typical_price_hint: '0.75% of payment amount (percent_of_amount)',\n },\n scoped_action_authorization: {\n id: 'scoped_action_authorization',\n class: 'B',\n label: 'scoped action authorized',\n fires_when:\n 'a user takes a specific action your site bills on (post, vote, comment, claim) where each instance is meaningful',\n example: 'user posted a long-form review that earns them sats from your editorial budget',\n common_use_cases: ['post', 'vote', 'comment', 'claim', 'submit'],\n typical_price_hint: '~100 sats (~$0.10)',\n },\n attest_verification_at_gate: {\n id: 'attest_verification_at_gate',\n class: 'B',\n label: 'attest verification',\n fires_when:\n \"your site's gate consulted the user's attest_tier and admitted them (counted only when admitted)\",\n example: 'admin gate checked attest_tier=bonded with bond≥10k sats and granted access',\n common_use_cases: ['gate-check', 'tier-gate', 'sybil-filter'],\n typical_price_hint: '~280 sats (~$0.27) · OFF by default',\n },\n stamp_signing: {\n id: 'stamp_signing',\n class: 'B',\n label: 'stamp signed',\n fires_when:\n 'a user signs an oc-stamp envelope (provenance attestation, review credential, content stamp)',\n example: 'user stamped their published recipe with their oc identity for downstream verification',\n common_use_cases: ['provenance', 'review', 'credential', 'attestation'],\n typical_price_hint: '~55 sats (~$0.05) · OFF by default',\n },\n pledge_resolution: {\n id: 'pledge_resolution',\n class: 'B',\n label: 'pledge resolved',\n fires_when:\n 'an oc-pledge bonded commitment resolves on your surface (kept / broken / disputed / expired_unresolved). pledge bonds never move — any sat payout is an integrator-composed flow on top of pledge (e.g., HTLC), not a pledge primitive (oc-pledge-protocol WHY.md H7)',\n example:\n 'user staked sats × days-unspent on a prediction; the pledge resolved kept and the integrator paid out per its own composed terms',\n common_use_cases: ['pledge', 'staking', 'resolution', 'commit-reveal'],\n typical_price_hint: '1% of pledge bond amount (percent_of_amount) · OFF by default',\n },\n\n // ── Class C · session ──\n session_creation: {\n id: 'session_creation',\n class: 'C',\n label: 'session opened',\n fires_when:\n 'a fresh authenticated session is opened for a returning user (sign-in within an existing session is FREE)',\n example: 'user signed in after their last session expired; new session token issued',\n common_use_cases: ['sign-in', 'session', 'authenticate'],\n typical_price_hint: '~55 sats (~$0.05)',\n },\n};\n\n/** All subtypes for a given class · convenience accessor. */\nexport function subtypesForClass(cls: EventClass): EventSubtypeMetadata[] {\n return Object.values(EVENT_SUBTYPES).filter((m) => m.class === cls);\n}\n\n/** All subtypes as a flat list, ordered class A → B → C. */\nexport const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[] = [\n ...subtypesForClass('A'),\n ...subtypesForClass('B'),\n ...subtypesForClass('C'),\n];\n","/**\n * Canonical types for me.ochk.io integrators.\n *\n * Mirrors the source of truth at oc-me-web/src/lib/events/types.ts. Two\n * layers:\n * - Platform-level (PLATFORM_FEE_POLICY, MIN_INTEGRATOR_PRICE_SATS) —\n * fixed by OC, surfaced as constants here so integrators can validate\n * their config client-side before posting it.\n * - Integrator-level (IntegratorPriceConfig) — every integrator declares\n * their own per-event prices and user-share splits.\n *\n * Per Addendum 01: every chargeable event is in exactly one of three\n * classes. Sites pay for sessions and actions, not for clicks. Free\n * events never instantiate a BillableEvent.\n */\n\nimport type { Scope } from './scope';\nimport { EVENT_SUBTYPES } from './subtypes';\n\n// ── platform constants (fixed by OC) ──────────────────────────────────────\n\nexport const PLATFORM_FEE_POLICY = {\n /** Fraction of every gross_fee that OC retains. */\n pct: 0.2,\n /** Absolute minimum platform fee, in sats. */\n min_floor_sats: 1,\n /** Date this policy was last ratified. Changes require a versioned\n * @orangecheck/me-client release. */\n ratified: '2026-04-30',\n} as const;\n\n/** Per-event price floor. 1 sat — the natural atomic Bitcoin unit.\n * Integrators choose their own per-event prices above this; OC does\n * not impose sybil-resistance opinions on integrators (that's their\n * call, from their own threat model). The 1-sat floor is purely\n * mechanical — fees can't be fractional sats. Mirrors the canonical\n * value at oc-me-web/src/lib/events/types.ts (a previous SDK release\n * drifted to 5 while the platform ratified 1). */\nexport const MIN_INTEGRATOR_PRICE_SATS = 1;\n\n/**\n * Hard per-event ceiling, mirroring the server's own bound.\n *\n * The server clamps gross to this before splitting it; this package did not,\n * so `verify()` re-derived 99,000,000 for an envelope the server had recorded\n * at 10,000,000 and rejected a correct receipt. It also over-reported what a\n * misconfigured site would be charged, by the ratio of the two numbers.\n *\n * 10,000,000 sats = 0.1 BTC: orders of magnitude above any real per-event\n * price, low enough that a misconfiguration cannot mint an unbounded number\n * of sats in one event. Found by the cross-package vector test in oc-me-web\n * on its first run.\n */\nexport const MAX_INTEGRATOR_PRICE_SATS = 10_000_000;\n\n/** Platform ceiling on a release window: no integrator schedule may\n * hold a user's earned sats longer than this, whatever its cadence.\n * Published as `max_drop_window_days` at https://me.ochk.io/api/abuse-limits. */\nexport const MAX_DROP_WINDOW_DAYS = 92;\n\n// ── event taxonomy ────────────────────────────────────────────────────────\n\nexport type EventClass = 'A' | 'B' | 'C';\n\nconst EVENT_CLASSES: ReadonlySet<unknown> = new Set<EventClass>(['A', 'B', 'C']);\n\n/** Whether a value is one of the three billing classes. */\nexport function isEventClass(value: unknown): value is EventClass {\n return EVENT_CLASSES.has(value);\n}\n\nexport type ClassASubtype =\n | 'account_creation'\n | 'account_recovery'\n | 'attest_bond_increased'\n | 'payment_method_connected'\n | 'agent_delegation_issued'\n | 'recovery_method_updated';\n\nexport type ClassBSubtype =\n | 'payment_authorization'\n | 'scoped_action_authorization'\n | 'attest_verification_at_gate'\n | 'stamp_signing'\n | 'pledge_resolution';\n\nexport type ClassCSubtype = 'session_creation';\n\nexport type EventSubtype = ClassASubtype | ClassBSubtype | ClassCSubtype;\n\n/**\n * Any billable event key. A project's catalog is OPEN: alongside the built-in\n * subtypes above, an integrator can define their own event keys (with their own\n * label + class + price) on the project config. `EventKey` keeps autocomplete\n * for the built-ins while accepting any custom string — the `(string & {})`\n * arm preserves the literal union in editors instead of collapsing it to\n * `string`. The server resolves class/label off the project's catalog for\n * custom keys.\n */\nexport type EventKey = EventSubtype | (string & {});\n\n/** Slug shape a custom event key must satisfy: 1 to 64 letters, digits or `_.:-`,\n * starting and ending with a letter or digit. */\nexport const CUSTOM_EVENT_KEY_RE = /^[a-z0-9](?:[a-z0-9_.:-]{0,62}[a-z0-9])?$/i;\n\nconst INHERITED_NAMES: ReadonlySet<string> = new Set(\n [...Object.getOwnPropertyNames(Object.prototype), '__proto__'].map((n) => n.toLowerCase())\n);\n\n/** Whether a plain object answers this name without holding it (\"constructor\",\n * \"toString\"), in any case. me.ochk.io refuses such a custom event key. */\nexport function isInheritedName(key: string): boolean {\n return INHERITED_NAMES.has(key.toLowerCase());\n}\n\n/** AttestTier · what an integrator's gate can read about an oc identity.\n *\n * me.ochk does NOT do KYC. Sybil resistance is bounded by three\n * composable mechanisms, none of which involve OC handling PII:\n * 1. paid-action history · billable events cost real sats\n * 2. BIP-322 sat-bonding · bond size + age via signed attestation\n * 3. integrator-defined gates · per-site threat-model overlays\n *\n * Tier itself is intentionally simple — anonymous | bonded.\n * Granularity (bond_sats, bond_locked_at, etc) carried separately. */\nexport type AttestTier = 'anonymous' | 'bonded';\n\n/** The shape of a per-event fee — either a fixed sats amount or a percent\n * of the underlying transaction amount (used for payments + pledges). */\nexport type SiteFeeShape =\n | { kind: 'fixed_sats'; sats: number }\n | { kind: 'percent_of_amount'; pct: number };\n\n/** Optional per-class pricing overrides · per OCHK-V3-PLAN §7 phase-1.\n * Agents acting under a scoped oc-agent delegation may bill\n * differently than humans firing the same subtype. When `agent` is\n * unset on a subtype, agent traffic bills at the human rate. `refuse:\n * true` makes the subtype human-only — the endpoint returns 422\n * agent_refused for is_agent=true requests. */\nexport interface AgentClassOverride {\n /** Override site_pays for agent-fired events. */\n site_pays?: SiteFeeShape;\n /** Override user_share_pct. Same default-fallback as site_pays. */\n user_share_pct?: number;\n /** When true, agent traffic is refused for this subtype. */\n refuse?: boolean;\n}\n\n/** What an integrator declares for a single event subtype. */\nexport interface IntegratorEventConfig {\n /** Whether this site bills this event subtype at all. */\n enabled: boolean;\n /** The per-event fee the site pays. */\n site_pays: SiteFeeShape;\n /** Fraction of GROSS that flows to the user (0–0.8 since the\n * platform fee is 20%). The remainder is a rebate to the site's\n * OC project balance. */\n user_share_pct: number;\n /** Optional per-agent-class pricing override applied when an event\n * fires with is_agent=true. */\n agent?: AgentClassOverride;\n /** Custom events only: a human-readable label. Built-ins ignore it. */\n label?: string;\n /** Custom events only: a description for the dashboard and docs. */\n description?: string;\n /** Custom events only: A, B or C. Built-ins take their class from the\n * taxonomy; a custom event without one is billed as class B. */\n class?: EventClass;\n}\n\n/** A complete integrator pricing config. Posted to me.ochk.io once at\n * integration time, mutable via the configurator UI or this SDK any time\n * after. */\nexport interface IntegratorPriceConfig {\n project_key: string;\n display_name: string;\n domain: string;\n /** ISO-8601 timestamp the config was last updated. */\n updated_at: string;\n /** Per-event configs, keyed by event key. Open catalog: built-in subtypes\n * AND your own custom keys. Keys not listed are disabled by default. */\n events: Partial<Record<EventKey, IntegratorEventConfig>>;\n}\n\n/** A computed fee breakdown for a single event. site_rebate_sats is what\n * flows back to the developer's balance after the platform fee and what\n * the user earns: zero at the full user share, 0.8. */\nexport interface ComputedFees {\n gross_fee_sats: number;\n platform_fee_sats: number;\n user_earned_sats: number;\n site_rebate_sats: number;\n}\n\n/** Compute the four-way fee split for an event given an integrator's\n * config and (for percent_of_amount events) the underlying payment\n * amount. MIRRORS oc-me-web/src/lib/events/types.ts computeFees()\n * EXACTLY — the SDK-side replay (oc.event.verify) re-runs this against\n * envelopes the server billed, so any drift is a false \"divergence\".\n *\n * Invariants:\n * 1. gross_fee_sats >= MIN_INTEGRATOR_PRICE_SATS (1-sat atomic floor)\n * 2. platform_fee_sats = min(gross, max(min_floor, round(gross × pct)))\n * — bounded above by gross so a 1-sat event can't owe more\n * platform fee than it grossed\n * 3. user_earned_sats = min(gross − platform, round(gross × share)),\n * share clamped to [0, 0.8]\n * 4. site_rebate_sats = gross − platform − user (exact remainder)\n * 5. gross == platform + user + rebate exactly\n *\n * When `opts.is_agent` is true AND the config has an `agent` override,\n * the agent's site_pays / user_share_pct apply. `agent.refuse: true`\n * throws 'agent_refused' (the server maps it to 422). */\nexport function computeFees(\n cfg: IntegratorEventConfig,\n payment_amount_sats?: number,\n opts?: { is_agent?: boolean }\n): ComputedFees {\n const is_agent = opts?.is_agent === true;\n if (is_agent && cfg.agent?.refuse) {\n throw new Error('agent_refused');\n }\n const effective_site_pays =\n is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;\n const effective_user_share_pct =\n is_agent && typeof cfg.agent?.user_share_pct === 'number'\n ? cfg.agent.user_share_pct\n : cfg.user_share_pct;\n\n let gross = 0;\n if (effective_site_pays.kind === 'fixed_sats') {\n gross = Math.max(MIN_INTEGRATOR_PRICE_SATS, Math.round(effective_site_pays.sats));\n } else {\n if (payment_amount_sats == null) {\n throw new Error('percent_of_amount config requires payment_amount_sats');\n }\n gross = Math.max(\n MIN_INTEGRATOR_PRICE_SATS,\n Math.round(payment_amount_sats * effective_site_pays.pct)\n );\n }\n // Hard ceiling · no single event mints more than MAX_INTEGRATOR_PRICE_SATS.\n // The server applies this before splitting; omitting it here made verify()\n // reject correct envelopes priced above the bound.\n gross = Math.min(gross, MAX_INTEGRATOR_PRICE_SATS);\n const platform_fee_sats = Math.min(\n gross,\n Math.max(PLATFORM_FEE_POLICY.min_floor_sats, Math.round(gross * PLATFORM_FEE_POLICY.pct))\n );\n const user_share = Math.min(0.8, Math.max(0, effective_user_share_pct));\n const user_earned_sats = Math.min(gross - platform_fee_sats, Math.round(gross * user_share));\n const site_rebate_sats = gross - platform_fee_sats - user_earned_sats;\n return { gross_fee_sats: gross, platform_fee_sats, user_earned_sats, site_rebate_sats };\n}\n\n/** Result of validating an IntegratorPriceConfig. */\nexport interface ValidationResult {\n ok: boolean;\n errors: { subtype?: EventKey; message: string }[];\n}\n\n/**\n * Validate an integrator's pricing config against the platform's\n * non-negotiable rules. Run client-side before posting; the server runs\n * the same checks and rejects anything that fails.\n */\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v);\n\n/** Why a fee shape cannot be read, or null: a known kind and a finite number. */\nfunction siteFeeShapeProblem(v: unknown): string | null {\n if (!isRecord(v)) return 'must be an object';\n if (v.kind === 'fixed_sats') return Number.isFinite(v.sats) ? null : 'sats must be a number';\n if (v.kind === 'percent_of_amount') {\n return Number.isFinite(v.pct) ? null : 'pct must be a number';\n }\n return `kind must be fixed_sats or percent_of_amount (got ${JSON.stringify(v.kind)})`;\n}\n\n/** Why an enabled event's config cannot be priced, or null: every field the\n * fee code reads is present and of its type. me.ochk.io applies the same rule. */\nfunction eventShapeProblem(e: Record<string, unknown>): string | null {\n const fee = siteFeeShapeProblem(e.site_pays);\n if (fee) return `site_pays ${fee}`;\n if (!Number.isFinite(e.user_share_pct)) return 'user_share_pct must be a number';\n if (e.agent == null) return null;\n if (!isRecord(e.agent)) return 'agent must be an object';\n if (e.agent.site_pays != null) {\n const agentFee = siteFeeShapeProblem(e.agent.site_pays);\n if (agentFee) return `agent.site_pays ${agentFee}`;\n }\n if (e.agent.user_share_pct != null && !Number.isFinite(e.agent.user_share_pct)) {\n return 'agent.user_share_pct must be a number';\n }\n return null;\n}\n\nexport function validateIntegratorConfig(cfg: IntegratorPriceConfig): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n if (!cfg.project_key) errors.push({ message: 'project_key is required' });\n if (!cfg.display_name) errors.push({ message: 'display_name is required' });\n if (!cfg.domain) errors.push({ message: 'domain is required' });\n\n if (!isRecord(cfg.events)) errors.push({ message: 'events must be an object' });\n for (const [key, eventCfg] of Object.entries(isRecord(cfg.events) ? cfg.events : {})) {\n if (!eventCfg) continue;\n const subtype = key as EventKey;\n if (!isRecord(eventCfg)) {\n errors.push({ subtype, message: 'must be an object' });\n continue;\n }\n const builtin = Object.prototype.hasOwnProperty.call(EVENT_SUBTYPES, key);\n if (!builtin && !CUSTOM_EVENT_KEY_RE.test(key)) {\n errors.push({\n subtype,\n message: `custom event key \"${key}\" must match ${CUSTOM_EVENT_KEY_RE} (1–64 chars, letters/digits/_.:- )`,\n });\n } else if (!builtin && isInheritedName(key)) {\n errors.push({\n subtype,\n message: `custom event key \"${key}\" is a name every object already has; pick another`,\n });\n }\n if (eventCfg.class != null && !isEventClass(eventCfg.class)) {\n errors.push({\n subtype,\n message: `class must be A, B or C (got ${JSON.stringify(eventCfg.class)})`,\n });\n }\n if (!eventCfg.enabled) continue;\n const shape = eventShapeProblem(eventCfg as unknown as Record<string, unknown>);\n if (shape) {\n errors.push({ subtype, message: shape });\n continue;\n }\n\n if (eventCfg.site_pays.kind === 'fixed_sats') {\n if (eventCfg.site_pays.sats < MIN_INTEGRATOR_PRICE_SATS) {\n errors.push({\n subtype,\n message: `site_pays.sats (${eventCfg.site_pays.sats}) is below MIN_INTEGRATOR_PRICE_SATS (${MIN_INTEGRATOR_PRICE_SATS})`,\n });\n }\n } else {\n const pct = eventCfg.site_pays.pct;\n if (!(pct > 0 && pct <= 1)) {\n errors.push({\n subtype,\n message: `site_pays.pct (${pct}) must be in (0, 1]`,\n });\n }\n }\n\n const u = eventCfg.user_share_pct;\n if (u < 0 || u > 0.8) {\n errors.push({\n subtype,\n message: `user_share_pct (${u}) must be in [0, 0.8]; max is 0.8 because platform_fee is ${PLATFORM_FEE_POLICY.pct}`,\n });\n }\n }\n\n return { ok: errors.length === 0, errors };\n}\n\n// ── canonical envelope ────────────────────────────────────────────────────\n\nexport interface BillableEvent {\n id: string;\n occurred_at: string;\n class: EventClass;\n subtype: EventKey;\n site: { domain: string; display_name: string };\n gross_fee_sats: number;\n platform_fee_sats: number;\n user_earned_sats: number;\n site_rebate_sats: number;\n verify_url: string;\n /** Per OCHK-V3-PLAN §7 phase-1 · true when the event was fired by\n * an oc-agent delegation rather than a human session. The\n * integrator's IntegratorEventConfig.agent block may price\n * these differently or refuse them. Optional · canonical encoder\n * branches to v=3 only when present, so legacy human-fired\n * events keep their v=2 hash + signature. */\n is_agent?: boolean;\n /** Drop-period stamp · present when the project covers this\n * subtype with a drop schedule. The user-share of a stamped event\n * MATURES until the window's boundary, then vests as one batch\n * (the drop). Billing is untouched. Part of the SIGNED canonical\n * bytes (encoder branches to v=4 when present). No clawback\n * exists — vesting is unconditional, and an open window's\n * boundary can only ever move earlier. */\n drop?: {\n /** Deterministic window id · the window's signed manifest is\n * verifiable at ochk.app/verify/<manifest_id> after close. */\n window_id: string;\n /** Block-denominated vesting boundary; null when no chain tip\n * was observable at window open (wallclock + the published\n * 24h safety valve then govern). */\n close_height_target: number | null;\n } | null;\n}\n\n// ── drop periods · integrator-scheduled payout windows ───────────────────\n\n/** A drop schedule's cadence. Weekly/monthly close at a fixed UTC\n * boundary; manual closes when the integrator says (Drop now), with a\n * hard auto-close at max_open_days (≤ MAX_DROP_WINDOW_DAYS). */\nexport type DropCadence =\n | { kind: 'weekly'; day: number; hour: number }\n | { kind: 'monthly'; day: number; hour: number }\n | { kind: 'manual'; max_open_days: number };\n\n/** Public shape of an enabled drop schedule, as returned in the\n * `drops` array of GET /api/integrator/config — part of the project's\n * public payout contract (earners can see when covered subtypes pay\n * out before earning under them). */\nexport interface DropScheduleSummary {\n schedule_id: string;\n label: string;\n subtypes: EventSubtype[];\n cadence: DropCadence;\n}\n\n/** Drop-period context on event-ingest responses (single route:\n * top-level `drop`; batch route: per-result `drop`). `state` flips\n * from 'open' to 'closing' once the scheduled boundary passes and the\n * window awaits its sweep (~15 min) — render \"processing\", never a\n * negative countdown. */\nexport interface DropResponseBlock {\n window_id: string;\n label: string;\n state: 'open' | 'closing';\n closes_at_target: string;\n close_height_target: number | null;\n}\n\n// ── webhook payload ───────────────────────────────────────────────────────\n\n/**\n * The exact JSON body delivered to a registered webhook endpoint when\n * a billable event fires. Imported by integrator backends so the\n * receive handler is type-checked end-to-end without re-declaring the\n * shape.\n *\n * import type { WebhookPayload } from '@orangecheck/me-client';\n *\n * export async function POST(req: Request) {\n * const payload = (await req.json()) as WebhookPayload;\n * if (payload.subtype === 'payment_authorization') {\n * creditUser(payload.sub, payload.user_earned_sats);\n * }\n * }\n *\n * Headers carry the signature and metadata (see WebhookHeaders below).\n * Verify the signature with `oc.webhook.verify({ body, headers, jwks })`.\n *\n * Privacy contract · the master oc identity is NEVER in the payload.\n * Integrators see `sub` (per-integrator anonymous id) plus any\n * `scopes` the user explicitly granted. See PRIVACY-ARCHITECTURE.md.\n */\nexport interface WebhookPayload extends BillableEvent {\n /** Discriminator · identifies the payload kind for routing on\n * the integrator's side. Always 'oc-billable-event' today; future\n * webhook payload kinds (refunds, charters, etc) will use\n * distinct discriminator values. */\n kind: 'oc-billable-event';\n /** Per-integrator anonymous subject id · stable across events for\n * the same (oc_identity, project_key) pair. Key your user records\n * on this; OC will never give you the master address unless the\n * user explicitly grants `bitcoin_address` or `email` scope. */\n sub: string;\n /** Resolved scoped fields · only present for scopes the user has\n * granted to this project. Wire format is string-keyed (every\n * value is stringified · ints stringified, addresses as-is). */\n scopes?: Partial<Record<Scope, string>>;\n}\n\n/**\n * Non-billable SYSTEM webhook deliveries — project-level operational\n * signals (escrow.low, escrow.depleted, escrow.recovered, drop.closed,\n * connect.claimed, federation.migrating, federation.migration_cancelled).\n * Same signing + headers as billable deliveries; receivers subscribe\n * via the same `subscribed` list ('*' or the explicit subtype string).\n * Carries no user identity, except connect.claimed. It has no `id`: the\n * `OC-Envelope-Id` header is its only id, so deduplicate on that.\n * Discriminate on `kind` first, then `subtype`:\n *\n * const payload = JSON.parse(body) as WebhookPayload | SystemWebhookPayload;\n * if (payload.kind === 'oc-system-event' && payload.subtype === 'drop.closed') { … }\n */\nexport interface SystemWebhookPayload {\n kind: 'oc-system-event';\n subtype: string;\n project_key: string;\n [extra: string]: unknown;\n}\n\n/** The `drop.closed` system event — one per closed drop window. The\n * manifest is the signed, content-addressed record (Merkle commitments\n * over member events + recipients); verify_url renders + live-verifies\n * it, and /api/envelope/<manifest_id> serves the raw canonical bytes. */\nexport interface DropClosedWebhookPayload extends SystemWebhookPayload {\n subtype: 'drop.closed';\n window_id: string;\n schedule_id: string;\n label: string;\n manifest_id: string;\n verify_url: string;\n sealed_at: string;\n sealed_height: number | null;\n event_count: number;\n recipient_count: number;\n gross_fee_sats: number;\n user_share_sats: number;\n}\n\n/** The federation a project moves to, as `federation.migrating` names it. */\nexport interface FederationSuccessor {\n slug: string;\n name: string;\n /** `\"3-of-4\"`; null while the successor has none set. */\n threshold: string | null;\n /** `\"bitcoin\"`, `\"signet\"`, …; null while unset. */\n network: string | null;\n /** The successor's ratified charter, by hash; null before it has one. */\n charter_hash: string | null;\n /** Each guardian seat's operator key, hex. */\n guardians: string[];\n}\n\n/**\n * `federation.migrating`: your project's federation is being replaced. Top-ups\n * pause now; events and sign-in carry on. The project and its balance move no\n * sooner than `flip_not_before`.\n */\nexport interface FederationMigratingWebhookPayload extends SystemWebhookPayload {\n subtype: 'federation.migrating';\n migration_id: string;\n /** The federation the project is on now (its slug). */\n from: string;\n /** The federation it moves to (its slug). */\n to: string;\n /** ISO time: the earliest the move can happen. */\n flip_not_before: string;\n successor: FederationSuccessor;\n}\n\n/** `federation.migration_cancelled`: that move is off, and top-ups work again. */\nexport interface FederationMigrationCancelledWebhookPayload extends SystemWebhookPayload {\n subtype: 'federation.migration_cancelled';\n migration_id: string;\n from: string;\n to: string;\n}\n\n/**\n * HTTP headers OC sends with every webhook delivery. Capture these in\n * the receive handler · `OC-Signature` is what verifies the body.\n */\nexport interface WebhookHeaders {\n /** Ed25519 signature over the raw request body, hex-encoded. */\n 'OC-Signature': string;\n /** kid of the key that signed it, published by me.ochk.io at\n * https://me.ochk.io/api/dev-jwks (not ochk.io's sign-in keys). */\n 'OC-Key-Id': string;\n /** For a billable event, its `id`, the same as `payload.id`. A system\n * notice (`OC-Class: system`) has no `id` in its body: this header is\n * its only id, the delivery's own. Not signed. Deduplicate on\n * `payload.id` when there is one, else on this. */\n 'OC-Envelope-Id': string;\n /** Subtype · matches payload.subtype (built-in or a custom event key,\n * or a system notice's subtype); lets routers branch on the header\n * before parsing. */\n 'OC-Subtype': EventKey;\n /** Class · matches payload.class; `system` for a system notice. */\n 'OC-Class': EventClass;\n /** 1-indexed delivery attempt count. >1 means the prior attempt\n * did not return a 2xx within the timeout · idempotency key on\n * payload.id is critical. */\n 'OC-Delivery-Attempt': string;\n}\n\n// ── session lifecycle ────────────────────────────────────────────────────\n\nexport interface SessionPolicy {\n duration_seconds: number;\n refresh: 'sliding' | 'rolling' | 'fixed';\n sensitive_actions?: 're-auth' | 'allow';\n}\n\nexport interface Session {\n id: string;\n identity: string;\n issued_at: string;\n expires_at: string;\n policy: SessionPolicy;\n scope: string[];\n}\n\nexport interface SignInOptions {\n scope: string[];\n sessionPolicy?: Partial<SessionPolicy>;\n returnTo?: string;\n}\n\nexport interface PaymentAuthorizeOptions {\n /** @deprecated Ignored: the server takes the account from the session. */\n identity?: string;\n amount_sats?: number;\n usd_cents?: number;\n description: string;\n external_ref?: string;\n /** The person's oc_session JWT (the `token` from the sign-in result), for\n * this call only. Pass it on a server that serves many people:\n * setBearerToken is one value for the whole process, so two payments in\n * flight would share it. Sent as Authorization, never in the body. */\n bearerToken?: string;\n}\n\nexport interface PaymentResult {\n id: string;\n status: 'authorized' | 'failed' | 'cancelled';\n sats_charged?: number;\n user_envelope_id?: string;\n verify_url?: string;\n}\n\nexport interface TelemetryEvent {\n code:\n | 'session.intra_signin'\n | 'session.token_refresh'\n | 'session.navigation'\n /** Emitted by `session.invalidate()`. Was `session.intra_signin`, which\n * means the opposite thing — \"user pressed sign-in while a valid\n * session was already open\" — so a subscriber saw a sign-in event\n * every time the integrator tore a session down. Non-billable. */\n | 'session.teardown'\n | 'auth.signin_failed'\n | 'auth.signin_cancelled'\n | 'auth.signin_rejected'\n | 'verify.passive_check';\n timestamp: string;\n session_id?: string;\n}\n\n// ── federation directory ───────────────────────────────────────────────\n//\n// The SDK consumes the federation directory at runtime so multi-federation\n// routing is a directory write, not a code change. v1 has one live\n// federation; the directory is plural-shaped so federation #2 lights up\n// without an SDK release.\n\nexport type FederationStatus = 'recruiting' | 'forming' | 'binding' | 'live';\n\n/** Federation directory entry. Mirrors `oc-me-web/src/lib/federations/registry.ts`\n * field-for-field; this package is the public consumption shape. */\nexport interface Federation {\n slug: string;\n name: string;\n status: FederationStatus;\n threshold: string;\n target_guardian_count: number;\n /** Fedimint invite code; null until status === 'live'. */\n invite: string | null;\n /** SHA-256 of the canonical federation charter, hex-encoded. */\n charter_hash: string | null;\n /** ISO-8601 of the most recent ongoing-attestation envelope. */\n last_attestation_at: string | null;\n geography_hint: string;\n // Operator-recruiting fields (present on slots in 'recruiting' /\n // 'forming' / 'binding' state). Nullable so one shape spans the\n // lifecycle.\n geography_requirements?: string;\n charter_status?: string;\n ceremony_window?: string;\n why_this_one?: string;\n apply_cta?: string;\n apply_href?: string;\n}\n\n/** SigningMethod discriminator on the user identity. Federation-agnostic\n * by construction — the OC identity (did:email or BIP-322 address)\n * remains stable across all three states. Transitions are recorded as\n * anchored \"rebind\" envelopes on the canonical event log. Graduation\n * is the product thesis; this discriminator is the structural primitive\n * that records where a user is on the custody-state graph. */\nexport type SigningMethod = 'fedimint_threshold' | 'fedimint_client' | 'bip322';\n","/**\n * Archetype templates for `oc.config.fromTemplate(useCase, ...)`.\n *\n * A new integrator with a 30-second decision shouldn't have to fill\n * 12 IntegratorEventConfig entries by hand. Pick the archetype that\n * matches your site, get a sensible starting config, tweak whatever\n * you want, submit:\n *\n * import { oc } from '@orangecheck/me-client';\n *\n * const config = oc.config.fromTemplate('saas-paywall', {\n * project_key: 'pk_live_yourcompany',\n * domain: 'yoursite.com',\n * display_name: 'Your Site',\n * });\n * await oc.config.save(config);\n *\n * Templates differ on which subtypes are enabled (a content platform\n * doesn't need payment_authorization; a marketplace does) and on the\n * price per subtype. Every price is at the full user share, 0.8: the\n * user gets everything the 20% platform fee leaves. A smaller share only\n * returned part of the fee to the developer's own balance after it was\n * charged, so it cost more for nothing.\n *\n * To customize after picking a template:\n *\n * const config = oc.config.fromTemplate('marketplace', { ... });\n * config.events.payment_authorization!.site_pays = {\n * kind: 'percent_of_amount',\n * pct: 0.005, // 0.5% instead of the template's 0.75%\n * };\n */\n\nimport type {\n EventSubtype,\n IntegratorEventConfig,\n IntegratorPriceConfig,\n} from './types';\n\nexport type IntegratorArchetype =\n | 'saas-paywall'\n | 'marketplace'\n | 'content-platform'\n | 'gaming'\n | 'agent-only';\n\ninterface ProjectIdentity {\n project_key: string;\n domain: string;\n display_name: string;\n}\n\n/** Template descriptor · what each archetype enables and prices.\n * Exposed so dashboards can render \"you're using the X template\"\n * state and offer one-click swaps. */\nexport interface ArchetypeTemplate {\n id: IntegratorArchetype;\n label: string;\n /** One-sentence summary shown next to the picker. */\n summary: string;\n /** Concrete examples of sites this archetype fits. */\n examples: readonly string[];\n /** Per-subtype config the template emits. Subtypes not listed are\n * emitted as `enabled: false` (the SDK fills them with a\n * conservative default to keep the type happy without firing). */\n events: Partial<Record<EventSubtype, IntegratorEventConfig>>;\n}\n\nconst FIXED = (sats: number): IntegratorEventConfig['site_pays'] => ({\n kind: 'fixed_sats',\n sats,\n});\nconst PCT = (pct: number): IntegratorEventConfig['site_pays'] => ({\n kind: 'percent_of_amount',\n pct,\n});\n\n/**\n * The full archetype catalog. Add new templates here · one record per\n * common integrator pattern. Keep the list curated (≤8 archetypes) —\n * if there are too many, none feel like the obvious default and\n * integrators stall on the picker.\n */\nexport const ARCHETYPE_TEMPLATES: readonly ArchetypeTemplate[] = [\n {\n id: 'saas-paywall',\n label: 'SaaS · paywall',\n summary:\n 'A subscription product: people sign up, sign in and sometimes pay for more. Pays them for signing up and coming back.',\n examples: ['notes app', 'project tracker', 'design editor'],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1056),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(45),\n user_share_pct: 0.8,\n },\n payment_authorization: {\n enabled: true,\n site_pays: PCT(0.00609375),\n user_share_pct: 0.8,\n },\n payment_method_connected: {\n enabled: true,\n site_pays: FIXED(260),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'marketplace',\n label: 'marketplace',\n summary:\n 'Buyers and sellers trade. Pays on payments, listings and new payment methods.',\n examples: ['checkout', 'handmade-goods market', 'ride-hailing'],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1056),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(45),\n user_share_pct: 0.8,\n },\n payment_authorization: {\n enabled: true,\n site_pays: PCT(0.00609375),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(81),\n user_share_pct: 0.8,\n },\n payment_method_connected: {\n enabled: true,\n site_pays: FIXED(260),\n user_share_pct: 0.8,\n },\n attest_verification_at_gate: {\n enabled: true,\n site_pays: FIXED(227),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'content-platform',\n label: 'content platform',\n summary:\n 'Posts, reviews, votes and comments. Pays for each meaningful action, and for signed reviews.',\n examples: ['forum', 'video host', 'newsletter'],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1137),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(49),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(87),\n user_share_pct: 0.8,\n },\n stamp_signing: {\n enabled: true,\n site_pays: FIXED(49),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'gaming',\n label: 'gaming',\n summary:\n 'A game where actions carry value. Pays for playing, paying and settled pledges.',\n examples: [\n 'on-chain prediction markets',\n 'skill-staking tournaments',\n 'multiplayer games',\n ],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1137),\n user_share_pct: 0.8,\n },\n session_creation: {\n enabled: true,\n site_pays: FIXED(49),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(87),\n user_share_pct: 0.8,\n },\n payment_authorization: {\n enabled: true,\n site_pays: PCT(0.004375),\n user_share_pct: 0.8,\n },\n pledge_resolution: {\n enabled: true,\n site_pays: PCT(0.00875),\n user_share_pct: 0.8,\n },\n attest_verification_at_gate: {\n enabled: true,\n site_pays: FIXED(245),\n user_share_pct: 0.8,\n },\n },\n },\n {\n id: 'agent-only',\n label: 'agent-only',\n summary:\n 'AI agents act for people under a delegation. Sessions are off; delegations and the actions they allow carry the activity.',\n examples: [\n 'AI assistant calling APIs on user behalf',\n 'autonomous trading bot',\n 'agent-driven customer support',\n ],\n events: {\n account_creation: {\n enabled: true,\n site_pays: FIXED(1056),\n user_share_pct: 0.8,\n },\n agent_delegation_issued: {\n enabled: true,\n site_pays: FIXED(260),\n user_share_pct: 0.8,\n },\n scoped_action_authorization: {\n enabled: true,\n site_pays: FIXED(81),\n user_share_pct: 0.8,\n },\n },\n },\n];\n\nconst ARCHETYPES_BY_ID: Record<IntegratorArchetype, ArchetypeTemplate> = Object.fromEntries(\n ARCHETYPE_TEMPLATES.map((t) => [t.id, t])\n) as Record<IntegratorArchetype, ArchetypeTemplate>;\n\n/** All 12 subtypes — used to fill `enabled: false` defaults for any\n * subtype the chosen archetype doesn't list. */\nconst ALL_SUBTYPES: readonly EventSubtype[] = [\n 'account_creation',\n 'account_recovery',\n 'attest_bond_increased',\n 'payment_method_connected',\n 'agent_delegation_issued',\n 'recovery_method_updated',\n 'payment_authorization',\n 'scoped_action_authorization',\n 'attest_verification_at_gate',\n 'stamp_signing',\n 'pledge_resolution',\n 'session_creation',\n];\n\nconst DEFAULT_DISABLED: IntegratorEventConfig = {\n enabled: false,\n site_pays: { kind: 'fixed_sats', sats: 100 },\n user_share_pct: 0.8,\n};\n\n/**\n * Build a complete IntegratorPriceConfig from an archetype id + the\n * project's identity fields. Every subtype gets an entry — the\n * archetype's listed subtypes get the template's pricing; everything\n * else gets `enabled: false` with conservative defaults so the config\n * is type-complete and the integrator can flip-on later subtypes\n * without re-deriving prices.\n *\n * Throws synchronously if `useCase` isn't a known archetype id.\n */\nexport function fromTemplate(\n useCase: IntegratorArchetype,\n identity: ProjectIdentity\n): IntegratorPriceConfig {\n const template = ARCHETYPES_BY_ID[useCase];\n if (!template) {\n throw new Error(\n `oc.config.fromTemplate: unknown archetype \"${useCase}\". Valid: ${Object.keys(\n ARCHETYPES_BY_ID\n ).join(', ')}`\n );\n }\n const events: IntegratorPriceConfig['events'] = {};\n for (const sub of ALL_SUBTYPES) {\n events[sub] = template.events[sub] ?? DEFAULT_DISABLED;\n }\n return {\n project_key: identity.project_key,\n domain: identity.domain,\n display_name: identity.display_name,\n updated_at: new Date().toISOString(),\n events,\n };\n}\n\n/** Look up a template's metadata · used by config-editor UIs to render\n * \"you're on the X template · here's what it enables\" copy. */\nexport function getArchetypeTemplate(id: IntegratorArchetype): ArchetypeTemplate {\n return ARCHETYPES_BY_ID[id];\n}\n"]}
|