@orangecheck/me-client 0.53.4 → 0.54.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 +19 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +155 -123
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -124
- package/dist/index.mjs.map +1 -1
- package/dist/{integrator-BM0Vy-ac.d.mts → integrator-DDeHg7vj.d.mts} +7 -1
- package/dist/{integrator-BM0Vy-ac.d.ts → integrator-DDeHg7vj.d.ts} +7 -1
- package/dist/integrator.d.mts +1 -1
- package/dist/integrator.d.ts +1 -1
- package/dist/integrator.js +109 -77
- package/dist/integrator.js.map +1 -1
- package/dist/integrator.mjs +107 -78
- package/dist/integrator.mjs.map +1 -1
- package/package.json +2 -1
- package/test-vectors/integrator-config.json +71 -0
package/dist/index.mjs
CHANGED
|
@@ -167,6 +167,129 @@ async function authorize(opts) {
|
|
|
167
167
|
}
|
|
168
168
|
var payment = { authorize };
|
|
169
169
|
|
|
170
|
+
// src/subtypes.ts
|
|
171
|
+
var EVENT_SUBTYPES = {
|
|
172
|
+
// ── Class A · durable state transitions ──
|
|
173
|
+
account_creation: {
|
|
174
|
+
id: "account_creation",
|
|
175
|
+
class: "A",
|
|
176
|
+
label: "account creation",
|
|
177
|
+
fires_when: "a new oc identity creates a durable account record on your surface (first sign-in, profile row inserted)",
|
|
178
|
+
example: "user signed up via email-OTP and your account row was inserted in your DB",
|
|
179
|
+
common_use_cases: ["onboarding", "signup", "registration", "first-login"],
|
|
180
|
+
typical_price_hint: "~1300 sats (~$1.24)"
|
|
181
|
+
},
|
|
182
|
+
account_recovery: {
|
|
183
|
+
id: "account_recovery",
|
|
184
|
+
class: "A",
|
|
185
|
+
label: "account recovery",
|
|
186
|
+
fires_when: "a user re-binds an existing account to a new device or recovery method",
|
|
187
|
+
example: "user lost their device and recovered the account via email OTP + recovery code",
|
|
188
|
+
common_use_cases: ["recovery", "device-rebind", "restore-access"],
|
|
189
|
+
typical_price_hint: "~650 sats (~$0.62)"
|
|
190
|
+
},
|
|
191
|
+
attest_bond_increased: {
|
|
192
|
+
id: "attest_bond_increased",
|
|
193
|
+
class: "A",
|
|
194
|
+
label: "attest bond increased",
|
|
195
|
+
fires_when: "a user upgrades their bond size (locks more sats to attest_tier=bonded with higher cap)",
|
|
196
|
+
example: "user moved from 10k-sat bond to 100k-sat bond to clear your higher-trust gate",
|
|
197
|
+
common_use_cases: ["bond-upgrade", "tier-promotion", "sybil-resistance"],
|
|
198
|
+
typical_price_hint: "~1600 sats (~$1.52) \xB7 OFF by default"
|
|
199
|
+
},
|
|
200
|
+
payment_method_connected: {
|
|
201
|
+
id: "payment_method_connected",
|
|
202
|
+
class: "A",
|
|
203
|
+
label: "payment method connected",
|
|
204
|
+
fires_when: "a user connects a Lightning address, BIP-322 wallet, or payment-routing channel to their account",
|
|
205
|
+
example: "user pasted a lightning@address.com receive address into their profile",
|
|
206
|
+
common_use_cases: ["payment-setup", "wallet-connect", "payout-config"],
|
|
207
|
+
typical_price_hint: "~320 sats (~$0.30)"
|
|
208
|
+
},
|
|
209
|
+
agent_delegation_issued: {
|
|
210
|
+
id: "agent_delegation_issued",
|
|
211
|
+
class: "A",
|
|
212
|
+
label: "agent delegation issued",
|
|
213
|
+
fires_when: "a user signs an oc-agent delegation envelope authorizing an AI agent to act on their behalf",
|
|
214
|
+
example: 'user delegated a "summarize my emails" agent for 24 hours with scope email:read',
|
|
215
|
+
common_use_cases: ["agent-grant", "ai-delegation", "scoped-authorization"],
|
|
216
|
+
typical_price_hint: "~320 sats \xB7 OFF by default (power-user)"
|
|
217
|
+
},
|
|
218
|
+
recovery_method_updated: {
|
|
219
|
+
id: "recovery_method_updated",
|
|
220
|
+
class: "A",
|
|
221
|
+
label: "recovery method updated",
|
|
222
|
+
fires_when: "a user changes their recovery email, recovery key, or social-recovery contacts",
|
|
223
|
+
example: "user rotated their recovery email after a phone change",
|
|
224
|
+
common_use_cases: ["recovery-rotation", "security-update"],
|
|
225
|
+
typical_price_hint: "~160 sats (~$0.15)"
|
|
226
|
+
},
|
|
227
|
+
// ── Class B · action-bound ──
|
|
228
|
+
payment_authorization: {
|
|
229
|
+
id: "payment_authorization",
|
|
230
|
+
class: "B",
|
|
231
|
+
label: "payment authorized",
|
|
232
|
+
fires_when: "a user authorizes a payment of underlying value (Lightning, on-chain BTC, or fiat-quoted)",
|
|
233
|
+
example: "user paid $5.00 (\u22485260 sats) for a premium feature on your site",
|
|
234
|
+
common_use_cases: ["payment", "checkout", "paywall", "subscription"],
|
|
235
|
+
typical_price_hint: "0.75% of payment amount (percent_of_amount)"
|
|
236
|
+
},
|
|
237
|
+
scoped_action_authorization: {
|
|
238
|
+
id: "scoped_action_authorization",
|
|
239
|
+
class: "B",
|
|
240
|
+
label: "scoped action authorized",
|
|
241
|
+
fires_when: "a user takes a specific action your site bills on (post, vote, comment, claim) where each instance is meaningful",
|
|
242
|
+
example: "user posted a long-form review that earns them sats from your editorial budget",
|
|
243
|
+
common_use_cases: ["post", "vote", "comment", "claim", "submit"],
|
|
244
|
+
typical_price_hint: "~100 sats (~$0.10)"
|
|
245
|
+
},
|
|
246
|
+
attest_verification_at_gate: {
|
|
247
|
+
id: "attest_verification_at_gate",
|
|
248
|
+
class: "B",
|
|
249
|
+
label: "attest verification",
|
|
250
|
+
fires_when: "your site's gate consulted the user's attest_tier and admitted them (counted only when admitted)",
|
|
251
|
+
example: "admin gate checked attest_tier=bonded with bond\u226510k sats and granted access",
|
|
252
|
+
common_use_cases: ["gate-check", "tier-gate", "sybil-filter"],
|
|
253
|
+
typical_price_hint: "~280 sats (~$0.27) \xB7 OFF by default"
|
|
254
|
+
},
|
|
255
|
+
stamp_signing: {
|
|
256
|
+
id: "stamp_signing",
|
|
257
|
+
class: "B",
|
|
258
|
+
label: "stamp signed",
|
|
259
|
+
fires_when: "a user signs an oc-stamp envelope (provenance attestation, review credential, content stamp)",
|
|
260
|
+
example: "user stamped their published recipe with their oc identity for downstream verification",
|
|
261
|
+
common_use_cases: ["provenance", "review", "credential", "attestation"],
|
|
262
|
+
typical_price_hint: "~55 sats (~$0.05) \xB7 OFF by default"
|
|
263
|
+
},
|
|
264
|
+
pledge_resolution: {
|
|
265
|
+
id: "pledge_resolution",
|
|
266
|
+
class: "B",
|
|
267
|
+
label: "pledge resolved",
|
|
268
|
+
fires_when: "an oc-pledge bonded commitment resolves on your surface (kept / broken / disputed / expired_unresolved). pledge bonds never move \u2014 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)",
|
|
269
|
+
example: "user staked sats \xD7 days-unspent on a prediction; the pledge resolved kept and the integrator paid out per its own composed terms",
|
|
270
|
+
common_use_cases: ["pledge", "staking", "resolution", "commit-reveal"],
|
|
271
|
+
typical_price_hint: "1% of pledge bond amount (percent_of_amount) \xB7 OFF by default"
|
|
272
|
+
},
|
|
273
|
+
// ── Class C · session ──
|
|
274
|
+
session_creation: {
|
|
275
|
+
id: "session_creation",
|
|
276
|
+
class: "C",
|
|
277
|
+
label: "session opened",
|
|
278
|
+
fires_when: "a fresh authenticated session is opened for a returning user (sign-in within an existing session is FREE)",
|
|
279
|
+
example: "user signed in after their last session expired; new session token issued",
|
|
280
|
+
common_use_cases: ["sign-in", "session", "authenticate"],
|
|
281
|
+
typical_price_hint: "~55 sats (~$0.05)"
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
function subtypesForClass(cls) {
|
|
285
|
+
return Object.values(EVENT_SUBTYPES).filter((m) => m.class === cls);
|
|
286
|
+
}
|
|
287
|
+
var ALL_EVENT_SUBTYPES = [
|
|
288
|
+
...subtypesForClass("A"),
|
|
289
|
+
...subtypesForClass("B"),
|
|
290
|
+
...subtypesForClass("C")
|
|
291
|
+
];
|
|
292
|
+
|
|
170
293
|
// src/types.ts
|
|
171
294
|
var PLATFORM_FEE_POLICY = {
|
|
172
295
|
/** Fraction of every gross_fee that OC retains. */
|
|
@@ -180,6 +303,17 @@ var PLATFORM_FEE_POLICY = {
|
|
|
180
303
|
var MIN_INTEGRATOR_PRICE_SATS = 1;
|
|
181
304
|
var MAX_INTEGRATOR_PRICE_SATS = 1e7;
|
|
182
305
|
var MAX_DROP_WINDOW_DAYS = 92;
|
|
306
|
+
var EVENT_CLASSES = /* @__PURE__ */ new Set(["A", "B", "C"]);
|
|
307
|
+
function isEventClass(value) {
|
|
308
|
+
return EVENT_CLASSES.has(value);
|
|
309
|
+
}
|
|
310
|
+
var CUSTOM_EVENT_KEY_RE = /^[a-z0-9](?:[a-z0-9_.:-]{0,62}[a-z0-9])?$/i;
|
|
311
|
+
var INHERITED_NAMES = new Set(
|
|
312
|
+
[...Object.getOwnPropertyNames(Object.prototype), "__proto__"].map((n) => n.toLowerCase())
|
|
313
|
+
);
|
|
314
|
+
function isInheritedName(key) {
|
|
315
|
+
return INHERITED_NAMES.has(key.toLowerCase());
|
|
316
|
+
}
|
|
183
317
|
function computeFees(cfg, payment_amount_sats, opts) {
|
|
184
318
|
const is_agent = opts?.is_agent === true;
|
|
185
319
|
if (is_agent && cfg.agent?.refuse) {
|
|
@@ -217,6 +351,24 @@ function validateIntegratorConfig(cfg) {
|
|
|
217
351
|
for (const [key, eventCfg] of Object.entries(cfg.events)) {
|
|
218
352
|
if (!eventCfg) continue;
|
|
219
353
|
const subtype = key;
|
|
354
|
+
const builtin = Object.prototype.hasOwnProperty.call(EVENT_SUBTYPES, key);
|
|
355
|
+
if (!builtin && !CUSTOM_EVENT_KEY_RE.test(key)) {
|
|
356
|
+
errors.push({
|
|
357
|
+
subtype,
|
|
358
|
+
message: `custom event key "${key}" must match ${CUSTOM_EVENT_KEY_RE} (1\u201364 chars, letters/digits/_.:- )`
|
|
359
|
+
});
|
|
360
|
+
} else if (!builtin && isInheritedName(key)) {
|
|
361
|
+
errors.push({
|
|
362
|
+
subtype,
|
|
363
|
+
message: `custom event key "${key}" is a name every object already has; pick another`
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
if (eventCfg.class != null && !isEventClass(eventCfg.class)) {
|
|
367
|
+
errors.push({
|
|
368
|
+
subtype,
|
|
369
|
+
message: `class must be A, B or C (got ${JSON.stringify(eventCfg.class)})`
|
|
370
|
+
});
|
|
371
|
+
}
|
|
220
372
|
if (!eventCfg.enabled) continue;
|
|
221
373
|
if (eventCfg.site_pays.kind === "fixed_sats") {
|
|
222
374
|
if (eventCfg.site_pays.sats < MIN_INTEGRATOR_PRICE_SATS) {
|
|
@@ -1510,129 +1662,6 @@ var identity = {
|
|
|
1510
1662
|
refreshEnvelopeJwks
|
|
1511
1663
|
};
|
|
1512
1664
|
|
|
1513
|
-
// src/subtypes.ts
|
|
1514
|
-
var EVENT_SUBTYPES = {
|
|
1515
|
-
// ── Class A · durable state transitions ──
|
|
1516
|
-
account_creation: {
|
|
1517
|
-
id: "account_creation",
|
|
1518
|
-
class: "A",
|
|
1519
|
-
label: "account creation",
|
|
1520
|
-
fires_when: "a new oc identity creates a durable account record on your surface (first sign-in, profile row inserted)",
|
|
1521
|
-
example: "user signed up via email-OTP and your account row was inserted in your DB",
|
|
1522
|
-
common_use_cases: ["onboarding", "signup", "registration", "first-login"],
|
|
1523
|
-
typical_price_hint: "~1300 sats (~$1.24)"
|
|
1524
|
-
},
|
|
1525
|
-
account_recovery: {
|
|
1526
|
-
id: "account_recovery",
|
|
1527
|
-
class: "A",
|
|
1528
|
-
label: "account recovery",
|
|
1529
|
-
fires_when: "a user re-binds an existing account to a new device or recovery method",
|
|
1530
|
-
example: "user lost their device and recovered the account via email OTP + recovery code",
|
|
1531
|
-
common_use_cases: ["recovery", "device-rebind", "restore-access"],
|
|
1532
|
-
typical_price_hint: "~650 sats (~$0.62)"
|
|
1533
|
-
},
|
|
1534
|
-
attest_bond_increased: {
|
|
1535
|
-
id: "attest_bond_increased",
|
|
1536
|
-
class: "A",
|
|
1537
|
-
label: "attest bond increased",
|
|
1538
|
-
fires_when: "a user upgrades their bond size (locks more sats to attest_tier=bonded with higher cap)",
|
|
1539
|
-
example: "user moved from 10k-sat bond to 100k-sat bond to clear your higher-trust gate",
|
|
1540
|
-
common_use_cases: ["bond-upgrade", "tier-promotion", "sybil-resistance"],
|
|
1541
|
-
typical_price_hint: "~1600 sats (~$1.52) \xB7 OFF by default"
|
|
1542
|
-
},
|
|
1543
|
-
payment_method_connected: {
|
|
1544
|
-
id: "payment_method_connected",
|
|
1545
|
-
class: "A",
|
|
1546
|
-
label: "payment method connected",
|
|
1547
|
-
fires_when: "a user connects a Lightning address, BIP-322 wallet, or payment-routing channel to their account",
|
|
1548
|
-
example: "user pasted a lightning@address.com receive address into their profile",
|
|
1549
|
-
common_use_cases: ["payment-setup", "wallet-connect", "payout-config"],
|
|
1550
|
-
typical_price_hint: "~320 sats (~$0.30)"
|
|
1551
|
-
},
|
|
1552
|
-
agent_delegation_issued: {
|
|
1553
|
-
id: "agent_delegation_issued",
|
|
1554
|
-
class: "A",
|
|
1555
|
-
label: "agent delegation issued",
|
|
1556
|
-
fires_when: "a user signs an oc-agent delegation envelope authorizing an AI agent to act on their behalf",
|
|
1557
|
-
example: 'user delegated a "summarize my emails" agent for 24 hours with scope email:read',
|
|
1558
|
-
common_use_cases: ["agent-grant", "ai-delegation", "scoped-authorization"],
|
|
1559
|
-
typical_price_hint: "~320 sats \xB7 OFF by default (power-user)"
|
|
1560
|
-
},
|
|
1561
|
-
recovery_method_updated: {
|
|
1562
|
-
id: "recovery_method_updated",
|
|
1563
|
-
class: "A",
|
|
1564
|
-
label: "recovery method updated",
|
|
1565
|
-
fires_when: "a user changes their recovery email, recovery key, or social-recovery contacts",
|
|
1566
|
-
example: "user rotated their recovery email after a phone change",
|
|
1567
|
-
common_use_cases: ["recovery-rotation", "security-update"],
|
|
1568
|
-
typical_price_hint: "~160 sats (~$0.15)"
|
|
1569
|
-
},
|
|
1570
|
-
// ── Class B · action-bound ──
|
|
1571
|
-
payment_authorization: {
|
|
1572
|
-
id: "payment_authorization",
|
|
1573
|
-
class: "B",
|
|
1574
|
-
label: "payment authorized",
|
|
1575
|
-
fires_when: "a user authorizes a payment of underlying value (Lightning, on-chain BTC, or fiat-quoted)",
|
|
1576
|
-
example: "user paid $5.00 (\u22485260 sats) for a premium feature on your site",
|
|
1577
|
-
common_use_cases: ["payment", "checkout", "paywall", "subscription"],
|
|
1578
|
-
typical_price_hint: "0.75% of payment amount (percent_of_amount)"
|
|
1579
|
-
},
|
|
1580
|
-
scoped_action_authorization: {
|
|
1581
|
-
id: "scoped_action_authorization",
|
|
1582
|
-
class: "B",
|
|
1583
|
-
label: "scoped action authorized",
|
|
1584
|
-
fires_when: "a user takes a specific action your site bills on (post, vote, comment, claim) where each instance is meaningful",
|
|
1585
|
-
example: "user posted a long-form review that earns them sats from your editorial budget",
|
|
1586
|
-
common_use_cases: ["post", "vote", "comment", "claim", "submit"],
|
|
1587
|
-
typical_price_hint: "~100 sats (~$0.10)"
|
|
1588
|
-
},
|
|
1589
|
-
attest_verification_at_gate: {
|
|
1590
|
-
id: "attest_verification_at_gate",
|
|
1591
|
-
class: "B",
|
|
1592
|
-
label: "attest verification",
|
|
1593
|
-
fires_when: "your site's gate consulted the user's attest_tier and admitted them (counted only when admitted)",
|
|
1594
|
-
example: "admin gate checked attest_tier=bonded with bond\u226510k sats and granted access",
|
|
1595
|
-
common_use_cases: ["gate-check", "tier-gate", "sybil-filter"],
|
|
1596
|
-
typical_price_hint: "~280 sats (~$0.27) \xB7 OFF by default"
|
|
1597
|
-
},
|
|
1598
|
-
stamp_signing: {
|
|
1599
|
-
id: "stamp_signing",
|
|
1600
|
-
class: "B",
|
|
1601
|
-
label: "stamp signed",
|
|
1602
|
-
fires_when: "a user signs an oc-stamp envelope (provenance attestation, review credential, content stamp)",
|
|
1603
|
-
example: "user stamped their published recipe with their oc identity for downstream verification",
|
|
1604
|
-
common_use_cases: ["provenance", "review", "credential", "attestation"],
|
|
1605
|
-
typical_price_hint: "~55 sats (~$0.05) \xB7 OFF by default"
|
|
1606
|
-
},
|
|
1607
|
-
pledge_resolution: {
|
|
1608
|
-
id: "pledge_resolution",
|
|
1609
|
-
class: "B",
|
|
1610
|
-
label: "pledge resolved",
|
|
1611
|
-
fires_when: "an oc-pledge bonded commitment resolves on your surface (kept / broken / disputed / expired_unresolved). pledge bonds never move \u2014 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)",
|
|
1612
|
-
example: "user staked sats \xD7 days-unspent on a prediction; the pledge resolved kept and the integrator paid out per its own composed terms",
|
|
1613
|
-
common_use_cases: ["pledge", "staking", "resolution", "commit-reveal"],
|
|
1614
|
-
typical_price_hint: "1% of pledge bond amount (percent_of_amount) \xB7 OFF by default"
|
|
1615
|
-
},
|
|
1616
|
-
// ── Class C · session ──
|
|
1617
|
-
session_creation: {
|
|
1618
|
-
id: "session_creation",
|
|
1619
|
-
class: "C",
|
|
1620
|
-
label: "session opened",
|
|
1621
|
-
fires_when: "a fresh authenticated session is opened for a returning user (sign-in within an existing session is FREE)",
|
|
1622
|
-
example: "user signed in after their last session expired; new session token issued",
|
|
1623
|
-
common_use_cases: ["sign-in", "session", "authenticate"],
|
|
1624
|
-
typical_price_hint: "~55 sats (~$0.05)"
|
|
1625
|
-
}
|
|
1626
|
-
};
|
|
1627
|
-
function subtypesForClass(cls) {
|
|
1628
|
-
return Object.values(EVENT_SUBTYPES).filter((m) => m.class === cls);
|
|
1629
|
-
}
|
|
1630
|
-
var ALL_EVENT_SUBTYPES = [
|
|
1631
|
-
...subtypesForClass("A"),
|
|
1632
|
-
...subtypesForClass("B"),
|
|
1633
|
-
...subtypesForClass("C")
|
|
1634
|
-
];
|
|
1635
|
-
|
|
1636
1665
|
// src/index.ts
|
|
1637
1666
|
var oc = {
|
|
1638
1667
|
session,
|
|
@@ -1646,6 +1675,6 @@ var oc = {
|
|
|
1646
1675
|
identity
|
|
1647
1676
|
};
|
|
1648
1677
|
|
|
1649
|
-
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL, EVENT_SUBTYPES, MAX_DROP_WINDOW_DAYS, MIN_INTEGRATOR_PRICE_SATS, MeClientError, PLATFORM_FEE_POLICY, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, identity, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
1678
|
+
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL, CUSTOM_EVENT_KEY_RE, EVENT_SUBTYPES, MAX_DROP_WINDOW_DAYS, MIN_INTEGRATOR_PRICE_SATS, MeClientError, PLATFORM_FEE_POLICY, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, identity, isEventClass, isInheritedName, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
1650
1679
|
//# sourceMappingURL=index.mjs.map
|
|
1651
1680
|
//# sourceMappingURL=index.mjs.map
|