@orangecheck/me-client 0.16.0 → 0.17.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/dist/index.d.mts +53 -3
- package/dist/index.d.ts +53 -3
- package/dist/index.js +359 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +354 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -82,11 +82,11 @@ declare const PLATFORM_FEE_POLICY: {
|
|
|
82
82
|
};
|
|
83
83
|
declare const MIN_INTEGRATOR_PRICE_SATS = 5;
|
|
84
84
|
type EventClass = 'A' | 'B' | 'C';
|
|
85
|
-
type ClassASubtype = 'account_creation' | 'account_recovery' | '
|
|
85
|
+
type ClassASubtype = 'account_creation' | 'account_recovery' | 'attest_bond_increased' | 'payment_method_connected' | 'agent_delegation_issued' | 'recovery_method_updated';
|
|
86
86
|
type ClassBSubtype = 'payment_authorization' | 'scoped_action_authorization' | 'attest_verification_at_gate' | 'stamp_signing' | 'pledge_resolution';
|
|
87
87
|
type ClassCSubtype = 'session_creation';
|
|
88
88
|
type EventSubtype = ClassASubtype | ClassBSubtype | ClassCSubtype;
|
|
89
|
-
type AttestTier = 'anonymous' | 'bonded'
|
|
89
|
+
type AttestTier = 'anonymous' | 'bonded';
|
|
90
90
|
type SiteFeeShape = {
|
|
91
91
|
kind: 'fixed_sats';
|
|
92
92
|
sats: number;
|
|
@@ -135,6 +135,20 @@ interface BillableEvent {
|
|
|
135
135
|
user_earned_sats: number;
|
|
136
136
|
site_rebate_sats: number;
|
|
137
137
|
verify_url: string;
|
|
138
|
+
is_agent?: boolean;
|
|
139
|
+
}
|
|
140
|
+
interface WebhookPayload extends BillableEvent {
|
|
141
|
+
kind: 'oc-billable-event';
|
|
142
|
+
sub: string;
|
|
143
|
+
scopes?: Partial<Record<'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count' | 'trust_attestation_count' | 'trust_attestations_bundle', string>>;
|
|
144
|
+
}
|
|
145
|
+
interface WebhookHeaders {
|
|
146
|
+
'OC-Signature': string;
|
|
147
|
+
'OC-Key-Id': string;
|
|
148
|
+
'OC-Envelope-Id': string;
|
|
149
|
+
'OC-Subtype': EventSubtype;
|
|
150
|
+
'OC-Class': EventClass;
|
|
151
|
+
'OC-Delivery-Attempt': string;
|
|
138
152
|
}
|
|
139
153
|
interface SessionPolicy {
|
|
140
154
|
duration_seconds: number;
|
|
@@ -193,6 +207,23 @@ interface Federation {
|
|
|
193
207
|
}
|
|
194
208
|
type SigningMethod = 'fedimint_threshold' | 'fedimint_client' | 'bip322';
|
|
195
209
|
|
|
210
|
+
type IntegratorArchetype = 'saas-paywall' | 'marketplace' | 'content-platform' | 'gaming' | 'agent-only';
|
|
211
|
+
interface ProjectIdentity {
|
|
212
|
+
project_key: string;
|
|
213
|
+
domain: string;
|
|
214
|
+
display_name: string;
|
|
215
|
+
}
|
|
216
|
+
interface ArchetypeTemplate {
|
|
217
|
+
id: IntegratorArchetype;
|
|
218
|
+
label: string;
|
|
219
|
+
summary: string;
|
|
220
|
+
examples: readonly string[];
|
|
221
|
+
events: Partial<Record<EventSubtype, IntegratorEventConfig>>;
|
|
222
|
+
}
|
|
223
|
+
declare const ARCHETYPE_TEMPLATES: readonly ArchetypeTemplate[];
|
|
224
|
+
declare function fromTemplate(useCase: IntegratorArchetype, identity: ProjectIdentity): IntegratorPriceConfig;
|
|
225
|
+
declare function getArchetypeTemplate(id: IntegratorArchetype): ArchetypeTemplate;
|
|
226
|
+
|
|
196
227
|
interface FireEventOptions {
|
|
197
228
|
project_key: string;
|
|
198
229
|
subtype: EventSubtype;
|
|
@@ -285,6 +316,9 @@ declare const payment: {
|
|
|
285
316
|
declare function validate(cfg: IntegratorPriceConfig): ValidationResult;
|
|
286
317
|
declare const config: {
|
|
287
318
|
validate: typeof validate;
|
|
319
|
+
fromTemplate: typeof fromTemplate;
|
|
320
|
+
getArchetype: typeof getArchetypeTemplate;
|
|
321
|
+
archetypes: readonly ArchetypeTemplate[];
|
|
288
322
|
};
|
|
289
323
|
|
|
290
324
|
declare function list(): Promise<Federation[]>;
|
|
@@ -320,6 +354,19 @@ interface WithRateLimitRetryOptions {
|
|
|
320
354
|
}
|
|
321
355
|
declare function withRateLimitRetry<T>(fn: () => Promise<T>, opts?: WithRateLimitRetryOptions): Promise<T>;
|
|
322
356
|
|
|
357
|
+
interface EventSubtypeMetadata {
|
|
358
|
+
id: EventSubtype;
|
|
359
|
+
class: EventClass;
|
|
360
|
+
label: string;
|
|
361
|
+
fires_when: string;
|
|
362
|
+
example: string;
|
|
363
|
+
common_use_cases: readonly string[];
|
|
364
|
+
typical_price_hint: string;
|
|
365
|
+
}
|
|
366
|
+
declare const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata>;
|
|
367
|
+
declare function subtypesForClass(cls: EventClass): EventSubtypeMetadata[];
|
|
368
|
+
declare const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[];
|
|
369
|
+
|
|
323
370
|
declare const oc: {
|
|
324
371
|
session: {
|
|
325
372
|
create: (opts: SignInOptions) => Promise<Session>;
|
|
@@ -336,6 +383,9 @@ declare const oc: {
|
|
|
336
383
|
};
|
|
337
384
|
config: {
|
|
338
385
|
validate: (cfg: IntegratorPriceConfig) => ValidationResult;
|
|
386
|
+
fromTemplate: typeof fromTemplate;
|
|
387
|
+
getArchetype: typeof getArchetypeTemplate;
|
|
388
|
+
archetypes: readonly ArchetypeTemplate[];
|
|
339
389
|
};
|
|
340
390
|
webhook: {
|
|
341
391
|
verify: typeof verify$1;
|
|
@@ -357,4 +407,4 @@ declare const oc: {
|
|
|
357
407
|
};
|
|
358
408
|
};
|
|
359
409
|
|
|
360
|
-
export { type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, type EventClass, type EventSubtype, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type TrustAttestationCount, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, event, family, federations, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payment, scope, session, setBearerToken, setOrigin, validateIntegratorConfig, webhook, withRateLimitRetry };
|
|
410
|
+
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, type ArchetypeTemplate, type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, EVENT_SUBTYPES, type EventClass, type EventSubtype, type EventSubtypeMetadata, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorArchetype, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type TrustAttestationCount, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WebhookHeaders, type WebhookPayload, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payment, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, webhook, withRateLimitRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -82,11 +82,11 @@ declare const PLATFORM_FEE_POLICY: {
|
|
|
82
82
|
};
|
|
83
83
|
declare const MIN_INTEGRATOR_PRICE_SATS = 5;
|
|
84
84
|
type EventClass = 'A' | 'B' | 'C';
|
|
85
|
-
type ClassASubtype = 'account_creation' | 'account_recovery' | '
|
|
85
|
+
type ClassASubtype = 'account_creation' | 'account_recovery' | 'attest_bond_increased' | 'payment_method_connected' | 'agent_delegation_issued' | 'recovery_method_updated';
|
|
86
86
|
type ClassBSubtype = 'payment_authorization' | 'scoped_action_authorization' | 'attest_verification_at_gate' | 'stamp_signing' | 'pledge_resolution';
|
|
87
87
|
type ClassCSubtype = 'session_creation';
|
|
88
88
|
type EventSubtype = ClassASubtype | ClassBSubtype | ClassCSubtype;
|
|
89
|
-
type AttestTier = 'anonymous' | 'bonded'
|
|
89
|
+
type AttestTier = 'anonymous' | 'bonded';
|
|
90
90
|
type SiteFeeShape = {
|
|
91
91
|
kind: 'fixed_sats';
|
|
92
92
|
sats: number;
|
|
@@ -135,6 +135,20 @@ interface BillableEvent {
|
|
|
135
135
|
user_earned_sats: number;
|
|
136
136
|
site_rebate_sats: number;
|
|
137
137
|
verify_url: string;
|
|
138
|
+
is_agent?: boolean;
|
|
139
|
+
}
|
|
140
|
+
interface WebhookPayload extends BillableEvent {
|
|
141
|
+
kind: 'oc-billable-event';
|
|
142
|
+
sub: string;
|
|
143
|
+
scopes?: Partial<Record<'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count' | 'trust_attestation_count' | 'trust_attestations_bundle', string>>;
|
|
144
|
+
}
|
|
145
|
+
interface WebhookHeaders {
|
|
146
|
+
'OC-Signature': string;
|
|
147
|
+
'OC-Key-Id': string;
|
|
148
|
+
'OC-Envelope-Id': string;
|
|
149
|
+
'OC-Subtype': EventSubtype;
|
|
150
|
+
'OC-Class': EventClass;
|
|
151
|
+
'OC-Delivery-Attempt': string;
|
|
138
152
|
}
|
|
139
153
|
interface SessionPolicy {
|
|
140
154
|
duration_seconds: number;
|
|
@@ -193,6 +207,23 @@ interface Federation {
|
|
|
193
207
|
}
|
|
194
208
|
type SigningMethod = 'fedimint_threshold' | 'fedimint_client' | 'bip322';
|
|
195
209
|
|
|
210
|
+
type IntegratorArchetype = 'saas-paywall' | 'marketplace' | 'content-platform' | 'gaming' | 'agent-only';
|
|
211
|
+
interface ProjectIdentity {
|
|
212
|
+
project_key: string;
|
|
213
|
+
domain: string;
|
|
214
|
+
display_name: string;
|
|
215
|
+
}
|
|
216
|
+
interface ArchetypeTemplate {
|
|
217
|
+
id: IntegratorArchetype;
|
|
218
|
+
label: string;
|
|
219
|
+
summary: string;
|
|
220
|
+
examples: readonly string[];
|
|
221
|
+
events: Partial<Record<EventSubtype, IntegratorEventConfig>>;
|
|
222
|
+
}
|
|
223
|
+
declare const ARCHETYPE_TEMPLATES: readonly ArchetypeTemplate[];
|
|
224
|
+
declare function fromTemplate(useCase: IntegratorArchetype, identity: ProjectIdentity): IntegratorPriceConfig;
|
|
225
|
+
declare function getArchetypeTemplate(id: IntegratorArchetype): ArchetypeTemplate;
|
|
226
|
+
|
|
196
227
|
interface FireEventOptions {
|
|
197
228
|
project_key: string;
|
|
198
229
|
subtype: EventSubtype;
|
|
@@ -285,6 +316,9 @@ declare const payment: {
|
|
|
285
316
|
declare function validate(cfg: IntegratorPriceConfig): ValidationResult;
|
|
286
317
|
declare const config: {
|
|
287
318
|
validate: typeof validate;
|
|
319
|
+
fromTemplate: typeof fromTemplate;
|
|
320
|
+
getArchetype: typeof getArchetypeTemplate;
|
|
321
|
+
archetypes: readonly ArchetypeTemplate[];
|
|
288
322
|
};
|
|
289
323
|
|
|
290
324
|
declare function list(): Promise<Federation[]>;
|
|
@@ -320,6 +354,19 @@ interface WithRateLimitRetryOptions {
|
|
|
320
354
|
}
|
|
321
355
|
declare function withRateLimitRetry<T>(fn: () => Promise<T>, opts?: WithRateLimitRetryOptions): Promise<T>;
|
|
322
356
|
|
|
357
|
+
interface EventSubtypeMetadata {
|
|
358
|
+
id: EventSubtype;
|
|
359
|
+
class: EventClass;
|
|
360
|
+
label: string;
|
|
361
|
+
fires_when: string;
|
|
362
|
+
example: string;
|
|
363
|
+
common_use_cases: readonly string[];
|
|
364
|
+
typical_price_hint: string;
|
|
365
|
+
}
|
|
366
|
+
declare const EVENT_SUBTYPES: Record<EventSubtype, EventSubtypeMetadata>;
|
|
367
|
+
declare function subtypesForClass(cls: EventClass): EventSubtypeMetadata[];
|
|
368
|
+
declare const ALL_EVENT_SUBTYPES: readonly EventSubtypeMetadata[];
|
|
369
|
+
|
|
323
370
|
declare const oc: {
|
|
324
371
|
session: {
|
|
325
372
|
create: (opts: SignInOptions) => Promise<Session>;
|
|
@@ -336,6 +383,9 @@ declare const oc: {
|
|
|
336
383
|
};
|
|
337
384
|
config: {
|
|
338
385
|
validate: (cfg: IntegratorPriceConfig) => ValidationResult;
|
|
386
|
+
fromTemplate: typeof fromTemplate;
|
|
387
|
+
getArchetype: typeof getArchetypeTemplate;
|
|
388
|
+
archetypes: readonly ArchetypeTemplate[];
|
|
339
389
|
};
|
|
340
390
|
webhook: {
|
|
341
391
|
verify: typeof verify$1;
|
|
@@ -357,4 +407,4 @@ declare const oc: {
|
|
|
357
407
|
};
|
|
358
408
|
};
|
|
359
409
|
|
|
360
|
-
export { type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, type EventClass, type EventSubtype, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type TrustAttestationCount, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, event, family, federations, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payment, scope, session, setBearerToken, setOrigin, validateIntegratorConfig, webhook, withRateLimitRetry };
|
|
410
|
+
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, type ArchetypeTemplate, type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, EVENT_SUBTYPES, type EventClass, type EventSubtype, type EventSubtypeMetadata, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorArchetype, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type TrustAttestationCount, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WebhookHeaders, type WebhookPayload, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payment, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, webhook, withRateLimitRetry };
|
package/dist/index.js
CHANGED
|
@@ -444,11 +444,240 @@ function verify(envelope, config2, payment_amount_sats) {
|
|
|
444
444
|
}
|
|
445
445
|
var event = { fire, fireBatch, verify };
|
|
446
446
|
|
|
447
|
+
// src/templates.ts
|
|
448
|
+
var FIXED = (sats) => ({
|
|
449
|
+
kind: "fixed_sats",
|
|
450
|
+
sats
|
|
451
|
+
});
|
|
452
|
+
var PCT = (pct) => ({
|
|
453
|
+
kind: "percent_of_amount",
|
|
454
|
+
pct
|
|
455
|
+
});
|
|
456
|
+
var ARCHETYPE_TEMPLATES = [
|
|
457
|
+
{
|
|
458
|
+
id: "saas-paywall",
|
|
459
|
+
label: "SaaS \xB7 paywall",
|
|
460
|
+
summary: "Subscription product \xB7 users sign up, sign in, sometimes pay for premium tiers. Default cashback to encourage signup + retention.",
|
|
461
|
+
examples: ["Notion-like notes app", "Linear-like project tracker", "Figma-like editor"],
|
|
462
|
+
events: {
|
|
463
|
+
account_creation: {
|
|
464
|
+
enabled: true,
|
|
465
|
+
site_pays: FIXED(1300),
|
|
466
|
+
user_share_pct: 0.65
|
|
467
|
+
},
|
|
468
|
+
session_creation: {
|
|
469
|
+
enabled: true,
|
|
470
|
+
site_pays: FIXED(55),
|
|
471
|
+
user_share_pct: 0.65
|
|
472
|
+
},
|
|
473
|
+
payment_authorization: {
|
|
474
|
+
enabled: true,
|
|
475
|
+
site_pays: PCT(75e-4),
|
|
476
|
+
user_share_pct: 0.65
|
|
477
|
+
},
|
|
478
|
+
payment_method_connected: {
|
|
479
|
+
enabled: true,
|
|
480
|
+
site_pays: FIXED(320),
|
|
481
|
+
user_share_pct: 0.65
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
id: "marketplace",
|
|
487
|
+
label: "marketplace",
|
|
488
|
+
summary: "Two-sided marketplace \xB7 buyers + sellers transact. Heavy on payment_authorization and scoped_action_authorization for listings.",
|
|
489
|
+
examples: ["Stripe-like checkout", "Etsy-like marketplace", "Uber-like ride-hailing"],
|
|
490
|
+
events: {
|
|
491
|
+
account_creation: {
|
|
492
|
+
enabled: true,
|
|
493
|
+
site_pays: FIXED(1300),
|
|
494
|
+
user_share_pct: 0.65
|
|
495
|
+
},
|
|
496
|
+
session_creation: {
|
|
497
|
+
enabled: true,
|
|
498
|
+
site_pays: FIXED(55),
|
|
499
|
+
user_share_pct: 0.65
|
|
500
|
+
},
|
|
501
|
+
payment_authorization: {
|
|
502
|
+
enabled: true,
|
|
503
|
+
site_pays: PCT(75e-4),
|
|
504
|
+
user_share_pct: 0.65
|
|
505
|
+
},
|
|
506
|
+
scoped_action_authorization: {
|
|
507
|
+
enabled: true,
|
|
508
|
+
site_pays: FIXED(100),
|
|
509
|
+
user_share_pct: 0.65
|
|
510
|
+
},
|
|
511
|
+
payment_method_connected: {
|
|
512
|
+
enabled: true,
|
|
513
|
+
site_pays: FIXED(320),
|
|
514
|
+
user_share_pct: 0.65
|
|
515
|
+
},
|
|
516
|
+
attest_verification_at_gate: {
|
|
517
|
+
enabled: true,
|
|
518
|
+
site_pays: FIXED(280),
|
|
519
|
+
user_share_pct: 0.65
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
id: "content-platform",
|
|
525
|
+
label: "content platform",
|
|
526
|
+
summary: "User-generated content \xB7 posts, reviews, votes, comments. Each meaningful action is scoped_action_authorization; stamp_signing for credentialed reviews.",
|
|
527
|
+
examples: ["Reddit-like forum", "YouTube-like video host", "Substack-like publishing"],
|
|
528
|
+
events: {
|
|
529
|
+
account_creation: {
|
|
530
|
+
enabled: true,
|
|
531
|
+
site_pays: FIXED(1300),
|
|
532
|
+
user_share_pct: 0.7
|
|
533
|
+
},
|
|
534
|
+
session_creation: {
|
|
535
|
+
enabled: true,
|
|
536
|
+
site_pays: FIXED(55),
|
|
537
|
+
user_share_pct: 0.7
|
|
538
|
+
},
|
|
539
|
+
scoped_action_authorization: {
|
|
540
|
+
enabled: true,
|
|
541
|
+
site_pays: FIXED(100),
|
|
542
|
+
user_share_pct: 0.7
|
|
543
|
+
},
|
|
544
|
+
stamp_signing: {
|
|
545
|
+
enabled: true,
|
|
546
|
+
site_pays: FIXED(55),
|
|
547
|
+
user_share_pct: 0.7
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
id: "gaming",
|
|
553
|
+
label: "gaming",
|
|
554
|
+
summary: "Game with monetized actions \xB7 pledges + scoped actions are core. Higher cashback ratios reward in-game engagement.",
|
|
555
|
+
examples: [
|
|
556
|
+
"on-chain prediction markets",
|
|
557
|
+
"skill-staking tournaments",
|
|
558
|
+
"PvP wager games"
|
|
559
|
+
],
|
|
560
|
+
events: {
|
|
561
|
+
account_creation: {
|
|
562
|
+
enabled: true,
|
|
563
|
+
site_pays: FIXED(1300),
|
|
564
|
+
user_share_pct: 0.7
|
|
565
|
+
},
|
|
566
|
+
session_creation: {
|
|
567
|
+
enabled: true,
|
|
568
|
+
site_pays: FIXED(55),
|
|
569
|
+
user_share_pct: 0.7
|
|
570
|
+
},
|
|
571
|
+
scoped_action_authorization: {
|
|
572
|
+
enabled: true,
|
|
573
|
+
site_pays: FIXED(100),
|
|
574
|
+
user_share_pct: 0.7
|
|
575
|
+
},
|
|
576
|
+
payment_authorization: {
|
|
577
|
+
enabled: true,
|
|
578
|
+
site_pays: PCT(5e-3),
|
|
579
|
+
user_share_pct: 0.7
|
|
580
|
+
},
|
|
581
|
+
pledge_resolution: {
|
|
582
|
+
enabled: true,
|
|
583
|
+
site_pays: PCT(0.01),
|
|
584
|
+
user_share_pct: 0.7
|
|
585
|
+
},
|
|
586
|
+
attest_verification_at_gate: {
|
|
587
|
+
enabled: true,
|
|
588
|
+
site_pays: FIXED(280),
|
|
589
|
+
user_share_pct: 0.7
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
id: "agent-only",
|
|
595
|
+
label: "agent-only",
|
|
596
|
+
summary: "AI-agent surface \xB7 oc-agent delegations are the primary auth pattern. Session_creation off (delegations replace sessions); agent_delegation_issued + scoped_action_authorization carry the activity.",
|
|
597
|
+
examples: [
|
|
598
|
+
"AI assistant calling APIs on user behalf",
|
|
599
|
+
"autonomous trading bot",
|
|
600
|
+
"agent-driven customer support"
|
|
601
|
+
],
|
|
602
|
+
events: {
|
|
603
|
+
account_creation: {
|
|
604
|
+
enabled: true,
|
|
605
|
+
site_pays: FIXED(1300),
|
|
606
|
+
user_share_pct: 0.65
|
|
607
|
+
},
|
|
608
|
+
agent_delegation_issued: {
|
|
609
|
+
enabled: true,
|
|
610
|
+
site_pays: FIXED(320),
|
|
611
|
+
user_share_pct: 0.65
|
|
612
|
+
},
|
|
613
|
+
scoped_action_authorization: {
|
|
614
|
+
enabled: true,
|
|
615
|
+
site_pays: FIXED(100),
|
|
616
|
+
user_share_pct: 0.65
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
];
|
|
621
|
+
var ARCHETYPES_BY_ID = Object.fromEntries(
|
|
622
|
+
ARCHETYPE_TEMPLATES.map((t) => [t.id, t])
|
|
623
|
+
);
|
|
624
|
+
var ALL_SUBTYPES = [
|
|
625
|
+
"account_creation",
|
|
626
|
+
"account_recovery",
|
|
627
|
+
"attest_bond_increased",
|
|
628
|
+
"payment_method_connected",
|
|
629
|
+
"agent_delegation_issued",
|
|
630
|
+
"recovery_method_updated",
|
|
631
|
+
"payment_authorization",
|
|
632
|
+
"scoped_action_authorization",
|
|
633
|
+
"attest_verification_at_gate",
|
|
634
|
+
"stamp_signing",
|
|
635
|
+
"pledge_resolution",
|
|
636
|
+
"session_creation"
|
|
637
|
+
];
|
|
638
|
+
var DEFAULT_DISABLED = {
|
|
639
|
+
enabled: false,
|
|
640
|
+
site_pays: { kind: "fixed_sats", sats: 100 },
|
|
641
|
+
user_share_pct: 0.65
|
|
642
|
+
};
|
|
643
|
+
function fromTemplate(useCase, identity) {
|
|
644
|
+
const template = ARCHETYPES_BY_ID[useCase];
|
|
645
|
+
if (!template) {
|
|
646
|
+
throw new Error(
|
|
647
|
+
`oc.config.fromTemplate: unknown archetype "${useCase}". Valid: ${Object.keys(
|
|
648
|
+
ARCHETYPES_BY_ID
|
|
649
|
+
).join(", ")}`
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
const events = {};
|
|
653
|
+
for (const sub of ALL_SUBTYPES) {
|
|
654
|
+
events[sub] = template.events[sub] ?? DEFAULT_DISABLED;
|
|
655
|
+
}
|
|
656
|
+
return {
|
|
657
|
+
project_key: identity.project_key,
|
|
658
|
+
domain: identity.domain,
|
|
659
|
+
display_name: identity.display_name,
|
|
660
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
661
|
+
events
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
function getArchetypeTemplate(id) {
|
|
665
|
+
return ARCHETYPES_BY_ID[id];
|
|
666
|
+
}
|
|
667
|
+
|
|
447
668
|
// src/config.ts
|
|
448
669
|
function validate(cfg) {
|
|
449
670
|
return validateIntegratorConfig(cfg);
|
|
450
671
|
}
|
|
451
|
-
var config = {
|
|
672
|
+
var config = {
|
|
673
|
+
validate,
|
|
674
|
+
fromTemplate,
|
|
675
|
+
/** Look up a template's metadata · for rendering "you picked X"
|
|
676
|
+
* state and offering one-click swaps in your own UI. */
|
|
677
|
+
getArchetype: getArchetypeTemplate,
|
|
678
|
+
/** All available archetypes · render in a picker. */
|
|
679
|
+
archetypes: ARCHETYPE_TEMPLATES
|
|
680
|
+
};
|
|
452
681
|
|
|
453
682
|
// node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
454
683
|
new TextEncoder();
|
|
@@ -909,9 +1138,135 @@ async function scopes(verb, options) {
|
|
|
909
1138
|
}
|
|
910
1139
|
var family = { scopes };
|
|
911
1140
|
|
|
1141
|
+
// src/subtypes.ts
|
|
1142
|
+
var EVENT_SUBTYPES = {
|
|
1143
|
+
// ── Class A · durable state transitions ──
|
|
1144
|
+
account_creation: {
|
|
1145
|
+
id: "account_creation",
|
|
1146
|
+
class: "A",
|
|
1147
|
+
label: "account creation",
|
|
1148
|
+
fires_when: "a new oc identity creates a durable account record on your surface (first sign-in, profile row inserted)",
|
|
1149
|
+
example: "user signed up via email-OTP and your account row was inserted in your DB",
|
|
1150
|
+
common_use_cases: ["onboarding", "signup", "registration", "first-login"],
|
|
1151
|
+
typical_price_hint: "~1300 sats (~$1.24)"
|
|
1152
|
+
},
|
|
1153
|
+
account_recovery: {
|
|
1154
|
+
id: "account_recovery",
|
|
1155
|
+
class: "A",
|
|
1156
|
+
label: "account recovery",
|
|
1157
|
+
fires_when: "a user re-binds an existing account to a new device or recovery method",
|
|
1158
|
+
example: "user lost their device and recovered the account via email OTP + recovery code",
|
|
1159
|
+
common_use_cases: ["recovery", "device-rebind", "restore-access"],
|
|
1160
|
+
typical_price_hint: "~650 sats (~$0.62)"
|
|
1161
|
+
},
|
|
1162
|
+
attest_bond_increased: {
|
|
1163
|
+
id: "attest_bond_increased",
|
|
1164
|
+
class: "A",
|
|
1165
|
+
label: "attest bond increased",
|
|
1166
|
+
fires_when: "a user upgrades their bond size (locks more sats to attest_tier=bonded with higher cap)",
|
|
1167
|
+
example: "user moved from 10k-sat bond to 100k-sat bond to clear your higher-trust gate",
|
|
1168
|
+
common_use_cases: ["bond-upgrade", "tier-promotion", "sybil-resistance"],
|
|
1169
|
+
typical_price_hint: "~1600 sats (~$1.52) \xB7 OFF by default"
|
|
1170
|
+
},
|
|
1171
|
+
payment_method_connected: {
|
|
1172
|
+
id: "payment_method_connected",
|
|
1173
|
+
class: "A",
|
|
1174
|
+
label: "payment method connected",
|
|
1175
|
+
fires_when: "a user connects a Lightning address, BIP-322 wallet, or payment-routing channel to their account",
|
|
1176
|
+
example: "user pasted a lightning@address.com receive address into their profile",
|
|
1177
|
+
common_use_cases: ["payment-setup", "wallet-connect", "payout-config"],
|
|
1178
|
+
typical_price_hint: "~320 sats (~$0.30)"
|
|
1179
|
+
},
|
|
1180
|
+
agent_delegation_issued: {
|
|
1181
|
+
id: "agent_delegation_issued",
|
|
1182
|
+
class: "A",
|
|
1183
|
+
label: "agent delegation issued",
|
|
1184
|
+
fires_when: "a user signs an oc-agent delegation envelope authorizing an AI agent to act on their behalf",
|
|
1185
|
+
example: 'user delegated a "summarize my emails" agent for 24 hours with scope email:read',
|
|
1186
|
+
common_use_cases: ["agent-grant", "ai-delegation", "scoped-authorization"],
|
|
1187
|
+
typical_price_hint: "~320 sats \xB7 OFF by default (power-user)"
|
|
1188
|
+
},
|
|
1189
|
+
recovery_method_updated: {
|
|
1190
|
+
id: "recovery_method_updated",
|
|
1191
|
+
class: "A",
|
|
1192
|
+
label: "recovery method updated",
|
|
1193
|
+
fires_when: "a user changes their recovery email, recovery key, or social-recovery contacts",
|
|
1194
|
+
example: "user rotated their recovery email after a phone change",
|
|
1195
|
+
common_use_cases: ["recovery-rotation", "security-update"],
|
|
1196
|
+
typical_price_hint: "~160 sats (~$0.15)"
|
|
1197
|
+
},
|
|
1198
|
+
// ── Class B · action-bound ──
|
|
1199
|
+
payment_authorization: {
|
|
1200
|
+
id: "payment_authorization",
|
|
1201
|
+
class: "B",
|
|
1202
|
+
label: "payment authorized",
|
|
1203
|
+
fires_when: "a user authorizes a payment of underlying value (Lightning, on-chain BTC, or fiat-quoted)",
|
|
1204
|
+
example: "user paid $5.00 (\u22485260 sats) for a premium feature on your site",
|
|
1205
|
+
common_use_cases: ["payment", "checkout", "paywall", "subscription"],
|
|
1206
|
+
typical_price_hint: "0.75% of payment amount (percent_of_amount)"
|
|
1207
|
+
},
|
|
1208
|
+
scoped_action_authorization: {
|
|
1209
|
+
id: "scoped_action_authorization",
|
|
1210
|
+
class: "B",
|
|
1211
|
+
label: "scoped action authorized",
|
|
1212
|
+
fires_when: "a user takes a specific action your site bills on (post, vote, comment, claim) where each instance is meaningful",
|
|
1213
|
+
example: "user posted a long-form review that earns them sats from your editorial budget",
|
|
1214
|
+
common_use_cases: ["post", "vote", "comment", "claim", "submit"],
|
|
1215
|
+
typical_price_hint: "~100 sats (~$0.10)"
|
|
1216
|
+
},
|
|
1217
|
+
attest_verification_at_gate: {
|
|
1218
|
+
id: "attest_verification_at_gate",
|
|
1219
|
+
class: "B",
|
|
1220
|
+
label: "attest verification",
|
|
1221
|
+
fires_when: "your site's gate consulted the user's attest_tier and admitted them (counted only when admitted)",
|
|
1222
|
+
example: "admin gate checked attest_tier=bonded with bond\u226510k sats and granted access",
|
|
1223
|
+
common_use_cases: ["gate-check", "tier-gate", "sybil-filter"],
|
|
1224
|
+
typical_price_hint: "~280 sats (~$0.27) \xB7 OFF by default"
|
|
1225
|
+
},
|
|
1226
|
+
stamp_signing: {
|
|
1227
|
+
id: "stamp_signing",
|
|
1228
|
+
class: "B",
|
|
1229
|
+
label: "stamp signed",
|
|
1230
|
+
fires_when: "a user signs an oc-stamp envelope (provenance attestation, review credential, content stamp)",
|
|
1231
|
+
example: "user stamped their published recipe with their oc identity for downstream verification",
|
|
1232
|
+
common_use_cases: ["provenance", "review", "credential", "attestation"],
|
|
1233
|
+
typical_price_hint: "~55 sats (~$0.05) \xB7 OFF by default"
|
|
1234
|
+
},
|
|
1235
|
+
pledge_resolution: {
|
|
1236
|
+
id: "pledge_resolution",
|
|
1237
|
+
class: "B",
|
|
1238
|
+
label: "pledge resolved",
|
|
1239
|
+
fires_when: "an oc-pledge bonded commitment resolves (paid out, slashed, or refunded) on your surface",
|
|
1240
|
+
example: "user staked 50k sats on a prediction; market resolved and the pledge paid out",
|
|
1241
|
+
common_use_cases: ["pledge", "staking", "resolution", "commit-reveal"],
|
|
1242
|
+
typical_price_hint: "1% of pledge amount (percent_of_amount) \xB7 OFF by default"
|
|
1243
|
+
},
|
|
1244
|
+
// ── Class C · session ──
|
|
1245
|
+
session_creation: {
|
|
1246
|
+
id: "session_creation",
|
|
1247
|
+
class: "C",
|
|
1248
|
+
label: "session opened",
|
|
1249
|
+
fires_when: "a fresh authenticated session is opened for a returning user (sign-in within an existing session is FREE)",
|
|
1250
|
+
example: "user signed in after their last session expired; new session token issued",
|
|
1251
|
+
common_use_cases: ["sign-in", "session", "authenticate"],
|
|
1252
|
+
typical_price_hint: "~55 sats (~$0.05)"
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
function subtypesForClass(cls) {
|
|
1256
|
+
return Object.values(EVENT_SUBTYPES).filter((m) => m.class === cls);
|
|
1257
|
+
}
|
|
1258
|
+
var ALL_EVENT_SUBTYPES = [
|
|
1259
|
+
...subtypesForClass("A"),
|
|
1260
|
+
...subtypesForClass("B"),
|
|
1261
|
+
...subtypesForClass("C")
|
|
1262
|
+
];
|
|
1263
|
+
|
|
912
1264
|
// src/index.ts
|
|
913
1265
|
var oc = { session, payment, event, config, webhook, federations, scope, family };
|
|
914
1266
|
|
|
1267
|
+
exports.ALL_EVENT_SUBTYPES = ALL_EVENT_SUBTYPES;
|
|
1268
|
+
exports.ARCHETYPE_TEMPLATES = ARCHETYPE_TEMPLATES;
|
|
1269
|
+
exports.EVENT_SUBTYPES = EVENT_SUBTYPES;
|
|
915
1270
|
exports.MIN_INTEGRATOR_PRICE_SATS = MIN_INTEGRATOR_PRICE_SATS;
|
|
916
1271
|
exports.MeClientError = MeClientError;
|
|
917
1272
|
exports.OcSignInButton = OcSignInButton;
|
|
@@ -919,9 +1274,11 @@ exports.PLATFORM_FEE_POLICY = PLATFORM_FEE_POLICY;
|
|
|
919
1274
|
exports.clearBearerToken = clearBearerToken;
|
|
920
1275
|
exports.computeFees = computeFees;
|
|
921
1276
|
exports.config = config;
|
|
1277
|
+
exports.configFromTemplate = fromTemplate;
|
|
922
1278
|
exports.event = event;
|
|
923
1279
|
exports.family = family;
|
|
924
1280
|
exports.federations = federations;
|
|
1281
|
+
exports.getArchetypeTemplate = getArchetypeTemplate;
|
|
925
1282
|
exports.getBearerToken = getBearerToken;
|
|
926
1283
|
exports.getOrigin = getOrigin;
|
|
927
1284
|
exports.oc = oc;
|
|
@@ -932,6 +1289,7 @@ exports.scope = scope;
|
|
|
932
1289
|
exports.session = session;
|
|
933
1290
|
exports.setBearerToken = setBearerToken;
|
|
934
1291
|
exports.setOrigin = setOrigin;
|
|
1292
|
+
exports.subtypesForClass = subtypesForClass;
|
|
935
1293
|
exports.validateIntegratorConfig = validateIntegratorConfig;
|
|
936
1294
|
exports.webhook = webhook;
|
|
937
1295
|
exports.withRateLimitRetry = withRateLimitRetry;
|