@orangecheck/me-client 0.15.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 +63 -4
- package/dist/index.d.ts +63 -4
- package/dist/index.js +375 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +369 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -422,11 +422,240 @@ function verify(envelope, config2, payment_amount_sats) {
|
|
|
422
422
|
}
|
|
423
423
|
var event = { fire, fireBatch, verify };
|
|
424
424
|
|
|
425
|
+
// src/templates.ts
|
|
426
|
+
var FIXED = (sats) => ({
|
|
427
|
+
kind: "fixed_sats",
|
|
428
|
+
sats
|
|
429
|
+
});
|
|
430
|
+
var PCT = (pct) => ({
|
|
431
|
+
kind: "percent_of_amount",
|
|
432
|
+
pct
|
|
433
|
+
});
|
|
434
|
+
var ARCHETYPE_TEMPLATES = [
|
|
435
|
+
{
|
|
436
|
+
id: "saas-paywall",
|
|
437
|
+
label: "SaaS \xB7 paywall",
|
|
438
|
+
summary: "Subscription product \xB7 users sign up, sign in, sometimes pay for premium tiers. Default cashback to encourage signup + retention.",
|
|
439
|
+
examples: ["Notion-like notes app", "Linear-like project tracker", "Figma-like editor"],
|
|
440
|
+
events: {
|
|
441
|
+
account_creation: {
|
|
442
|
+
enabled: true,
|
|
443
|
+
site_pays: FIXED(1300),
|
|
444
|
+
user_share_pct: 0.65
|
|
445
|
+
},
|
|
446
|
+
session_creation: {
|
|
447
|
+
enabled: true,
|
|
448
|
+
site_pays: FIXED(55),
|
|
449
|
+
user_share_pct: 0.65
|
|
450
|
+
},
|
|
451
|
+
payment_authorization: {
|
|
452
|
+
enabled: true,
|
|
453
|
+
site_pays: PCT(75e-4),
|
|
454
|
+
user_share_pct: 0.65
|
|
455
|
+
},
|
|
456
|
+
payment_method_connected: {
|
|
457
|
+
enabled: true,
|
|
458
|
+
site_pays: FIXED(320),
|
|
459
|
+
user_share_pct: 0.65
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
id: "marketplace",
|
|
465
|
+
label: "marketplace",
|
|
466
|
+
summary: "Two-sided marketplace \xB7 buyers + sellers transact. Heavy on payment_authorization and scoped_action_authorization for listings.",
|
|
467
|
+
examples: ["Stripe-like checkout", "Etsy-like marketplace", "Uber-like ride-hailing"],
|
|
468
|
+
events: {
|
|
469
|
+
account_creation: {
|
|
470
|
+
enabled: true,
|
|
471
|
+
site_pays: FIXED(1300),
|
|
472
|
+
user_share_pct: 0.65
|
|
473
|
+
},
|
|
474
|
+
session_creation: {
|
|
475
|
+
enabled: true,
|
|
476
|
+
site_pays: FIXED(55),
|
|
477
|
+
user_share_pct: 0.65
|
|
478
|
+
},
|
|
479
|
+
payment_authorization: {
|
|
480
|
+
enabled: true,
|
|
481
|
+
site_pays: PCT(75e-4),
|
|
482
|
+
user_share_pct: 0.65
|
|
483
|
+
},
|
|
484
|
+
scoped_action_authorization: {
|
|
485
|
+
enabled: true,
|
|
486
|
+
site_pays: FIXED(100),
|
|
487
|
+
user_share_pct: 0.65
|
|
488
|
+
},
|
|
489
|
+
payment_method_connected: {
|
|
490
|
+
enabled: true,
|
|
491
|
+
site_pays: FIXED(320),
|
|
492
|
+
user_share_pct: 0.65
|
|
493
|
+
},
|
|
494
|
+
attest_verification_at_gate: {
|
|
495
|
+
enabled: true,
|
|
496
|
+
site_pays: FIXED(280),
|
|
497
|
+
user_share_pct: 0.65
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
id: "content-platform",
|
|
503
|
+
label: "content platform",
|
|
504
|
+
summary: "User-generated content \xB7 posts, reviews, votes, comments. Each meaningful action is scoped_action_authorization; stamp_signing for credentialed reviews.",
|
|
505
|
+
examples: ["Reddit-like forum", "YouTube-like video host", "Substack-like publishing"],
|
|
506
|
+
events: {
|
|
507
|
+
account_creation: {
|
|
508
|
+
enabled: true,
|
|
509
|
+
site_pays: FIXED(1300),
|
|
510
|
+
user_share_pct: 0.7
|
|
511
|
+
},
|
|
512
|
+
session_creation: {
|
|
513
|
+
enabled: true,
|
|
514
|
+
site_pays: FIXED(55),
|
|
515
|
+
user_share_pct: 0.7
|
|
516
|
+
},
|
|
517
|
+
scoped_action_authorization: {
|
|
518
|
+
enabled: true,
|
|
519
|
+
site_pays: FIXED(100),
|
|
520
|
+
user_share_pct: 0.7
|
|
521
|
+
},
|
|
522
|
+
stamp_signing: {
|
|
523
|
+
enabled: true,
|
|
524
|
+
site_pays: FIXED(55),
|
|
525
|
+
user_share_pct: 0.7
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
id: "gaming",
|
|
531
|
+
label: "gaming",
|
|
532
|
+
summary: "Game with monetized actions \xB7 pledges + scoped actions are core. Higher cashback ratios reward in-game engagement.",
|
|
533
|
+
examples: [
|
|
534
|
+
"on-chain prediction markets",
|
|
535
|
+
"skill-staking tournaments",
|
|
536
|
+
"PvP wager games"
|
|
537
|
+
],
|
|
538
|
+
events: {
|
|
539
|
+
account_creation: {
|
|
540
|
+
enabled: true,
|
|
541
|
+
site_pays: FIXED(1300),
|
|
542
|
+
user_share_pct: 0.7
|
|
543
|
+
},
|
|
544
|
+
session_creation: {
|
|
545
|
+
enabled: true,
|
|
546
|
+
site_pays: FIXED(55),
|
|
547
|
+
user_share_pct: 0.7
|
|
548
|
+
},
|
|
549
|
+
scoped_action_authorization: {
|
|
550
|
+
enabled: true,
|
|
551
|
+
site_pays: FIXED(100),
|
|
552
|
+
user_share_pct: 0.7
|
|
553
|
+
},
|
|
554
|
+
payment_authorization: {
|
|
555
|
+
enabled: true,
|
|
556
|
+
site_pays: PCT(5e-3),
|
|
557
|
+
user_share_pct: 0.7
|
|
558
|
+
},
|
|
559
|
+
pledge_resolution: {
|
|
560
|
+
enabled: true,
|
|
561
|
+
site_pays: PCT(0.01),
|
|
562
|
+
user_share_pct: 0.7
|
|
563
|
+
},
|
|
564
|
+
attest_verification_at_gate: {
|
|
565
|
+
enabled: true,
|
|
566
|
+
site_pays: FIXED(280),
|
|
567
|
+
user_share_pct: 0.7
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
id: "agent-only",
|
|
573
|
+
label: "agent-only",
|
|
574
|
+
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.",
|
|
575
|
+
examples: [
|
|
576
|
+
"AI assistant calling APIs on user behalf",
|
|
577
|
+
"autonomous trading bot",
|
|
578
|
+
"agent-driven customer support"
|
|
579
|
+
],
|
|
580
|
+
events: {
|
|
581
|
+
account_creation: {
|
|
582
|
+
enabled: true,
|
|
583
|
+
site_pays: FIXED(1300),
|
|
584
|
+
user_share_pct: 0.65
|
|
585
|
+
},
|
|
586
|
+
agent_delegation_issued: {
|
|
587
|
+
enabled: true,
|
|
588
|
+
site_pays: FIXED(320),
|
|
589
|
+
user_share_pct: 0.65
|
|
590
|
+
},
|
|
591
|
+
scoped_action_authorization: {
|
|
592
|
+
enabled: true,
|
|
593
|
+
site_pays: FIXED(100),
|
|
594
|
+
user_share_pct: 0.65
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
];
|
|
599
|
+
var ARCHETYPES_BY_ID = Object.fromEntries(
|
|
600
|
+
ARCHETYPE_TEMPLATES.map((t) => [t.id, t])
|
|
601
|
+
);
|
|
602
|
+
var ALL_SUBTYPES = [
|
|
603
|
+
"account_creation",
|
|
604
|
+
"account_recovery",
|
|
605
|
+
"attest_bond_increased",
|
|
606
|
+
"payment_method_connected",
|
|
607
|
+
"agent_delegation_issued",
|
|
608
|
+
"recovery_method_updated",
|
|
609
|
+
"payment_authorization",
|
|
610
|
+
"scoped_action_authorization",
|
|
611
|
+
"attest_verification_at_gate",
|
|
612
|
+
"stamp_signing",
|
|
613
|
+
"pledge_resolution",
|
|
614
|
+
"session_creation"
|
|
615
|
+
];
|
|
616
|
+
var DEFAULT_DISABLED = {
|
|
617
|
+
enabled: false,
|
|
618
|
+
site_pays: { kind: "fixed_sats", sats: 100 },
|
|
619
|
+
user_share_pct: 0.65
|
|
620
|
+
};
|
|
621
|
+
function fromTemplate(useCase, identity) {
|
|
622
|
+
const template = ARCHETYPES_BY_ID[useCase];
|
|
623
|
+
if (!template) {
|
|
624
|
+
throw new Error(
|
|
625
|
+
`oc.config.fromTemplate: unknown archetype "${useCase}". Valid: ${Object.keys(
|
|
626
|
+
ARCHETYPES_BY_ID
|
|
627
|
+
).join(", ")}`
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
const events = {};
|
|
631
|
+
for (const sub of ALL_SUBTYPES) {
|
|
632
|
+
events[sub] = template.events[sub] ?? DEFAULT_DISABLED;
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
project_key: identity.project_key,
|
|
636
|
+
domain: identity.domain,
|
|
637
|
+
display_name: identity.display_name,
|
|
638
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
639
|
+
events
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function getArchetypeTemplate(id) {
|
|
643
|
+
return ARCHETYPES_BY_ID[id];
|
|
644
|
+
}
|
|
645
|
+
|
|
425
646
|
// src/config.ts
|
|
426
647
|
function validate(cfg) {
|
|
427
648
|
return validateIntegratorConfig(cfg);
|
|
428
649
|
}
|
|
429
|
-
var config = {
|
|
650
|
+
var config = {
|
|
651
|
+
validate,
|
|
652
|
+
fromTemplate,
|
|
653
|
+
/** Look up a template's metadata · for rendering "you picked X"
|
|
654
|
+
* state and offering one-click swaps in your own UI. */
|
|
655
|
+
getArchetype: getArchetypeTemplate,
|
|
656
|
+
/** All available archetypes · render in a picker. */
|
|
657
|
+
archetypes: ARCHETYPE_TEMPLATES
|
|
658
|
+
};
|
|
430
659
|
|
|
431
660
|
// node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
432
661
|
new TextEncoder();
|
|
@@ -793,8 +1022,21 @@ var VALID_SCOPES = [
|
|
|
793
1022
|
"attest_tier",
|
|
794
1023
|
"display_name",
|
|
795
1024
|
"cross_integrator_event_count",
|
|
796
|
-
"cross_integrator_human_event_count"
|
|
1025
|
+
"cross_integrator_human_event_count",
|
|
1026
|
+
"trust_attestation_count"
|
|
797
1027
|
];
|
|
1028
|
+
function parseTrustAttestationCount(value) {
|
|
1029
|
+
const parts = value.split(",");
|
|
1030
|
+
if (parts.length !== 4) return null;
|
|
1031
|
+
const ints = parts.map((p) => Number.parseInt(p, 10));
|
|
1032
|
+
if (ints.some((n) => !Number.isInteger(n) || n < 0)) return null;
|
|
1033
|
+
return {
|
|
1034
|
+
total: ints[0],
|
|
1035
|
+
good: ints[1],
|
|
1036
|
+
distinct_good_issuers: ints[2],
|
|
1037
|
+
caution: ints[3]
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
798
1040
|
async function granted(options) {
|
|
799
1041
|
if (!options.project_key) {
|
|
800
1042
|
throw new Error("oc.scope.granted: project_key is required");
|
|
@@ -837,7 +1079,7 @@ function request(scopes2, options) {
|
|
|
837
1079
|
window.location.assign(url.toString());
|
|
838
1080
|
throw new Error("oc.scope.request: redirected to consent prompt");
|
|
839
1081
|
}
|
|
840
|
-
var scope = { granted, request };
|
|
1082
|
+
var scope = { granted, request, parseTrustAttestationCount };
|
|
841
1083
|
|
|
842
1084
|
// src/family.ts
|
|
843
1085
|
var VALID_VERBS = [
|
|
@@ -874,9 +1116,132 @@ async function scopes(verb, options) {
|
|
|
874
1116
|
}
|
|
875
1117
|
var family = { scopes };
|
|
876
1118
|
|
|
1119
|
+
// src/subtypes.ts
|
|
1120
|
+
var EVENT_SUBTYPES = {
|
|
1121
|
+
// ── Class A · durable state transitions ──
|
|
1122
|
+
account_creation: {
|
|
1123
|
+
id: "account_creation",
|
|
1124
|
+
class: "A",
|
|
1125
|
+
label: "account creation",
|
|
1126
|
+
fires_when: "a new oc identity creates a durable account record on your surface (first sign-in, profile row inserted)",
|
|
1127
|
+
example: "user signed up via email-OTP and your account row was inserted in your DB",
|
|
1128
|
+
common_use_cases: ["onboarding", "signup", "registration", "first-login"],
|
|
1129
|
+
typical_price_hint: "~1300 sats (~$1.24)"
|
|
1130
|
+
},
|
|
1131
|
+
account_recovery: {
|
|
1132
|
+
id: "account_recovery",
|
|
1133
|
+
class: "A",
|
|
1134
|
+
label: "account recovery",
|
|
1135
|
+
fires_when: "a user re-binds an existing account to a new device or recovery method",
|
|
1136
|
+
example: "user lost their device and recovered the account via email OTP + recovery code",
|
|
1137
|
+
common_use_cases: ["recovery", "device-rebind", "restore-access"],
|
|
1138
|
+
typical_price_hint: "~650 sats (~$0.62)"
|
|
1139
|
+
},
|
|
1140
|
+
attest_bond_increased: {
|
|
1141
|
+
id: "attest_bond_increased",
|
|
1142
|
+
class: "A",
|
|
1143
|
+
label: "attest bond increased",
|
|
1144
|
+
fires_when: "a user upgrades their bond size (locks more sats to attest_tier=bonded with higher cap)",
|
|
1145
|
+
example: "user moved from 10k-sat bond to 100k-sat bond to clear your higher-trust gate",
|
|
1146
|
+
common_use_cases: ["bond-upgrade", "tier-promotion", "sybil-resistance"],
|
|
1147
|
+
typical_price_hint: "~1600 sats (~$1.52) \xB7 OFF by default"
|
|
1148
|
+
},
|
|
1149
|
+
payment_method_connected: {
|
|
1150
|
+
id: "payment_method_connected",
|
|
1151
|
+
class: "A",
|
|
1152
|
+
label: "payment method connected",
|
|
1153
|
+
fires_when: "a user connects a Lightning address, BIP-322 wallet, or payment-routing channel to their account",
|
|
1154
|
+
example: "user pasted a lightning@address.com receive address into their profile",
|
|
1155
|
+
common_use_cases: ["payment-setup", "wallet-connect", "payout-config"],
|
|
1156
|
+
typical_price_hint: "~320 sats (~$0.30)"
|
|
1157
|
+
},
|
|
1158
|
+
agent_delegation_issued: {
|
|
1159
|
+
id: "agent_delegation_issued",
|
|
1160
|
+
class: "A",
|
|
1161
|
+
label: "agent delegation issued",
|
|
1162
|
+
fires_when: "a user signs an oc-agent delegation envelope authorizing an AI agent to act on their behalf",
|
|
1163
|
+
example: 'user delegated a "summarize my emails" agent for 24 hours with scope email:read',
|
|
1164
|
+
common_use_cases: ["agent-grant", "ai-delegation", "scoped-authorization"],
|
|
1165
|
+
typical_price_hint: "~320 sats \xB7 OFF by default (power-user)"
|
|
1166
|
+
},
|
|
1167
|
+
recovery_method_updated: {
|
|
1168
|
+
id: "recovery_method_updated",
|
|
1169
|
+
class: "A",
|
|
1170
|
+
label: "recovery method updated",
|
|
1171
|
+
fires_when: "a user changes their recovery email, recovery key, or social-recovery contacts",
|
|
1172
|
+
example: "user rotated their recovery email after a phone change",
|
|
1173
|
+
common_use_cases: ["recovery-rotation", "security-update"],
|
|
1174
|
+
typical_price_hint: "~160 sats (~$0.15)"
|
|
1175
|
+
},
|
|
1176
|
+
// ── Class B · action-bound ──
|
|
1177
|
+
payment_authorization: {
|
|
1178
|
+
id: "payment_authorization",
|
|
1179
|
+
class: "B",
|
|
1180
|
+
label: "payment authorized",
|
|
1181
|
+
fires_when: "a user authorizes a payment of underlying value (Lightning, on-chain BTC, or fiat-quoted)",
|
|
1182
|
+
example: "user paid $5.00 (\u22485260 sats) for a premium feature on your site",
|
|
1183
|
+
common_use_cases: ["payment", "checkout", "paywall", "subscription"],
|
|
1184
|
+
typical_price_hint: "0.75% of payment amount (percent_of_amount)"
|
|
1185
|
+
},
|
|
1186
|
+
scoped_action_authorization: {
|
|
1187
|
+
id: "scoped_action_authorization",
|
|
1188
|
+
class: "B",
|
|
1189
|
+
label: "scoped action authorized",
|
|
1190
|
+
fires_when: "a user takes a specific action your site bills on (post, vote, comment, claim) where each instance is meaningful",
|
|
1191
|
+
example: "user posted a long-form review that earns them sats from your editorial budget",
|
|
1192
|
+
common_use_cases: ["post", "vote", "comment", "claim", "submit"],
|
|
1193
|
+
typical_price_hint: "~100 sats (~$0.10)"
|
|
1194
|
+
},
|
|
1195
|
+
attest_verification_at_gate: {
|
|
1196
|
+
id: "attest_verification_at_gate",
|
|
1197
|
+
class: "B",
|
|
1198
|
+
label: "attest verification",
|
|
1199
|
+
fires_when: "your site's gate consulted the user's attest_tier and admitted them (counted only when admitted)",
|
|
1200
|
+
example: "admin gate checked attest_tier=bonded with bond\u226510k sats and granted access",
|
|
1201
|
+
common_use_cases: ["gate-check", "tier-gate", "sybil-filter"],
|
|
1202
|
+
typical_price_hint: "~280 sats (~$0.27) \xB7 OFF by default"
|
|
1203
|
+
},
|
|
1204
|
+
stamp_signing: {
|
|
1205
|
+
id: "stamp_signing",
|
|
1206
|
+
class: "B",
|
|
1207
|
+
label: "stamp signed",
|
|
1208
|
+
fires_when: "a user signs an oc-stamp envelope (provenance attestation, review credential, content stamp)",
|
|
1209
|
+
example: "user stamped their published recipe with their oc identity for downstream verification",
|
|
1210
|
+
common_use_cases: ["provenance", "review", "credential", "attestation"],
|
|
1211
|
+
typical_price_hint: "~55 sats (~$0.05) \xB7 OFF by default"
|
|
1212
|
+
},
|
|
1213
|
+
pledge_resolution: {
|
|
1214
|
+
id: "pledge_resolution",
|
|
1215
|
+
class: "B",
|
|
1216
|
+
label: "pledge resolved",
|
|
1217
|
+
fires_when: "an oc-pledge bonded commitment resolves (paid out, slashed, or refunded) on your surface",
|
|
1218
|
+
example: "user staked 50k sats on a prediction; market resolved and the pledge paid out",
|
|
1219
|
+
common_use_cases: ["pledge", "staking", "resolution", "commit-reveal"],
|
|
1220
|
+
typical_price_hint: "1% of pledge amount (percent_of_amount) \xB7 OFF by default"
|
|
1221
|
+
},
|
|
1222
|
+
// ── Class C · session ──
|
|
1223
|
+
session_creation: {
|
|
1224
|
+
id: "session_creation",
|
|
1225
|
+
class: "C",
|
|
1226
|
+
label: "session opened",
|
|
1227
|
+
fires_when: "a fresh authenticated session is opened for a returning user (sign-in within an existing session is FREE)",
|
|
1228
|
+
example: "user signed in after their last session expired; new session token issued",
|
|
1229
|
+
common_use_cases: ["sign-in", "session", "authenticate"],
|
|
1230
|
+
typical_price_hint: "~55 sats (~$0.05)"
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
function subtypesForClass(cls) {
|
|
1234
|
+
return Object.values(EVENT_SUBTYPES).filter((m) => m.class === cls);
|
|
1235
|
+
}
|
|
1236
|
+
var ALL_EVENT_SUBTYPES = [
|
|
1237
|
+
...subtypesForClass("A"),
|
|
1238
|
+
...subtypesForClass("B"),
|
|
1239
|
+
...subtypesForClass("C")
|
|
1240
|
+
];
|
|
1241
|
+
|
|
877
1242
|
// src/index.ts
|
|
878
1243
|
var oc = { session, payment, event, config, webhook, federations, scope, family };
|
|
879
1244
|
|
|
880
|
-
export { MIN_INTEGRATOR_PRICE_SATS, MeClientError, OcSignInButton, PLATFORM_FEE_POLICY, clearBearerToken, computeFees, config, event, family, federations, getBearerToken, getOrigin, oc, onTelemetry, payment, scope, session, setBearerToken, setOrigin, validateIntegratorConfig, webhook, withRateLimitRetry };
|
|
1245
|
+
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, EVENT_SUBTYPES, MIN_INTEGRATOR_PRICE_SATS, MeClientError, OcSignInButton, PLATFORM_FEE_POLICY, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payment, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, webhook, withRateLimitRetry };
|
|
881
1246
|
//# sourceMappingURL=index.mjs.map
|
|
882
1247
|
//# sourceMappingURL=index.mjs.map
|