@orangecheck/me-client 0.28.0 → 0.29.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/README.md +19 -1
- package/dist/index.d.mts +45 -7
- package/dist/index.d.ts +45 -7
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -317,6 +317,18 @@ function validateIntegratorConfig(cfg) {
|
|
|
317
317
|
return { ok: errors.length === 0, errors };
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
// src/pay-periods.ts
|
|
321
|
+
var ms = (iso) => Date.parse(iso);
|
|
322
|
+
function payingAt(periods, at = /* @__PURE__ */ new Date()) {
|
|
323
|
+
const t = at.getTime();
|
|
324
|
+
const current = periods.find(
|
|
325
|
+
(p) => ms(p.starts_at) <= t && (p.ends_at === null || t < ms(p.ends_at))
|
|
326
|
+
);
|
|
327
|
+
if (current) return { paying: true, period: current };
|
|
328
|
+
const next = periods.filter((p) => ms(p.starts_at) > t).sort((a, b) => ms(a.starts_at) - ms(b.starts_at))[0];
|
|
329
|
+
return { paying: false, next: next ?? null };
|
|
330
|
+
}
|
|
331
|
+
|
|
320
332
|
// src/event.ts
|
|
321
333
|
async function hmacSha256Hex(secret, message) {
|
|
322
334
|
const enc = new TextEncoder();
|
|
@@ -399,14 +411,23 @@ async function fireBatch(options) {
|
|
|
399
411
|
bearerToken: options.bearerToken
|
|
400
412
|
});
|
|
401
413
|
}
|
|
402
|
-
function verify(envelope, config2, payment_amount_sats) {
|
|
414
|
+
function verify(envelope, config2, payment_amount_sats, opts = {}) {
|
|
403
415
|
const issues = [];
|
|
416
|
+
if (opts.payPeriods && !payingAt(opts.payPeriods, new Date(envelope.occurred_at)).paying) {
|
|
417
|
+
issues.push({
|
|
418
|
+
field: "outside_pay_period",
|
|
419
|
+
expected: null,
|
|
420
|
+
actual: null,
|
|
421
|
+
message: `billed at ${envelope.occurred_at}, when ${config2.project_key} wasn't paying its users`
|
|
422
|
+
});
|
|
423
|
+
}
|
|
404
424
|
const eventCfg = config2.events[envelope.subtype];
|
|
405
425
|
if (!eventCfg) {
|
|
406
426
|
return {
|
|
407
427
|
ok: false,
|
|
408
428
|
expected: null,
|
|
409
429
|
issues: [
|
|
430
|
+
...issues,
|
|
410
431
|
{
|
|
411
432
|
field: "subtype_unconfigured",
|
|
412
433
|
expected: null,
|
|
@@ -421,6 +442,7 @@ function verify(envelope, config2, payment_amount_sats) {
|
|
|
421
442
|
ok: false,
|
|
422
443
|
expected: null,
|
|
423
444
|
issues: [
|
|
445
|
+
...issues,
|
|
424
446
|
{
|
|
425
447
|
field: "subtype_disabled",
|
|
426
448
|
expected: null,
|
|
@@ -435,6 +457,7 @@ function verify(envelope, config2, payment_amount_sats) {
|
|
|
435
457
|
ok: false,
|
|
436
458
|
expected: null,
|
|
437
459
|
issues: [
|
|
460
|
+
...issues,
|
|
438
461
|
{
|
|
439
462
|
field: "percent_amount_missing",
|
|
440
463
|
expected: null,
|
|
@@ -1530,6 +1553,6 @@ var oc = {
|
|
|
1530
1553
|
identity
|
|
1531
1554
|
};
|
|
1532
1555
|
|
|
1533
|
-
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, EVENT_SUBTYPES, MAX_DROP_WINDOW_DAYS, MIN_INTEGRATOR_PRICE_SATS, MeClientError, OcSignInButton, PLATFORM_FEE_POLICY, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, identity, oc, onTelemetry, parseTrustAttestationCount, payment, refreshEnvelopeJwks, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
1556
|
+
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, EVENT_SUBTYPES, MAX_DROP_WINDOW_DAYS, MIN_INTEGRATOR_PRICE_SATS, MeClientError, OcSignInButton, PLATFORM_FEE_POLICY, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, identity, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
1534
1557
|
//# sourceMappingURL=index.mjs.map
|
|
1535
1558
|
//# sourceMappingURL=index.mjs.map
|