@odla-ai/chapter 0.31.2 → 0.31.4

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.
@@ -1,8 +1,8 @@
1
1
  import * as preact from 'preact';
2
2
  import { ComponentChildren, JSX } from 'preact';
3
3
  import { CrmClient, Crm, CrmRecord } from '@odla-ai/crm';
4
- import { a as Chapter, b as ChapterCopy } from '../../copy-context-HAhNTZdl.js';
5
- export { C as ChapterCopyProvider, u as useChapterCopy } from '../../copy-context-HAhNTZdl.js';
4
+ import { a as Chapter, b as ChapterCopy } from '../../copy-context-BXBEdp4p.js';
5
+ export { C as ChapterCopyProvider, u as useChapterCopy } from '../../copy-context-BXBEdp4p.js';
6
6
  import { CrmLifecycleAdapter, CrmWorkspaceMasterContext, CrmWorkspaceRecordContext, RecordPanelTab } from '@odla-ai/crm/ui';
7
7
 
8
8
  /** Normalized public auth configuration consumed by the Clerk gate. */
@@ -1,5 +1,5 @@
1
1
  export { AdminAccountMenuProps, AdminChrome, AdminNote, AdminPage, AdminResource, AdminRouteState, AdminRouteTarget, AdminRouting, AdminSection, AdminSectionContext, AdminWorkspace, AdminWorkspaceNavProps, AvailabilitySectionOptions, BillingSectionOptions, ChapterAdmin, ChapterAdminAuthAdapter, ChapterAdminAuthConfig, ChapterAdminAuthLoadContext, ChapterAdminProps, ChapterAdminUser, CollectionSectionOptions, DashboardSectionOptions, EmailSectionOptions, LeaderNetworkOverview, MeetingsSectionOptions, NetworkRecordsWorkspace, NetworkShareActions, NetworkShareActionsProps, Panel, PeopleSectionOptions, RecordActions, RecordActionsProps, ThemeWarning, adminFetch, adminRouteFromUrl, adminRouteHref, adminSectionFromUrl, adminSectionHref, applicationLifecycleAdapter, availabilitySection, billingSection, collectionSection, dashboardSection, defaultAdminSections, defaultAdminWorkspaces, emailSection, loadChapterAdminConfig, loadChapterAdminUser, meetingsSection, networkRecordsWorkspace, peopleSection, useAdminResource } from './admin/index.js';
2
- export { C as ChapterCopyProvider, u as useChapterCopy } from '../copy-context-HAhNTZdl.js';
2
+ export { C as ChapterCopyProvider, u as useChapterCopy } from '../copy-context-BXBEdp4p.js';
3
3
  export { ApiFn, BrandStyle, BrandStyleProps, JoinConfig, JoinFlowState, JoinIsland, JoinIslandProps, JoinStepRenderContext, JoinSubmitRenderContext, JoinTier, JoinTierRenderContext, MemberProvisionalRenderContext, MembersArea, MembersAreaProps, PaymentPriceLines, PaymentStep, PaymentStepProps, RescheduleProps, Rescheduler, Slot, SlotPicker, SlotPickerClasses, SlotPickerProps, TierPlaceholder, dayKey, dayLabel, fmtDate, fmtMoney, fullLabel, groupSlotsByDay, loadJoinResume, tierNeedsPayment, timeLabel, tzShort, useTierSelection } from './member/index.js';
4
4
  import 'preact';
5
5
  import '@odla-ai/crm';
@@ -1,7 +1,7 @@
1
1
  import * as preact from 'preact';
2
2
  import { ComponentChildren, JSX } from 'preact';
3
- import { b as ChapterCopy, c as ChapterBrand } from '../../copy-context-HAhNTZdl.js';
4
- export { C as ChapterCopyProvider, u as useChapterCopy } from '../../copy-context-HAhNTZdl.js';
3
+ import { b as ChapterCopy, c as ChapterBrand } from '../../copy-context-BXBEdp4p.js';
4
+ export { C as ChapterCopyProvider, u as useChapterCopy } from '../../copy-context-BXBEdp4p.js';
5
5
  import '@odla-ai/crm';
6
6
 
7
7
  /** A bookable slot: a start instant in epoch milliseconds. */
@@ -1481,50 +1481,7 @@ var handleSchedule = async (req, url, env, ctx) => {
1481
1481
  };
1482
1482
 
1483
1483
  // src/payments.ts
1484
- function parseSigHeader(header) {
1485
- const parts = {};
1486
- for (const p of header.split(",")) {
1487
- const [k, v] = p.split("=", 2);
1488
- if (k && v !== void 0) parts[k] = v;
1489
- }
1490
- return { t: parts.t, v1: parts.v1 };
1491
- }
1492
- function toHex(buf) {
1493
- return [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, "0")).join("");
1494
- }
1495
- function timingSafeEqual(a, b) {
1496
- if (a.length !== b.length) return false;
1497
- let diff = 0;
1498
- for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
1499
- return diff === 0;
1500
- }
1501
- async function verifyStripeSignature(payload, header, secret, opts = {}) {
1502
- const { t, v1 } = parseSigHeader(header);
1503
- if (!t || !v1) return false;
1504
- const ts = Number(t);
1505
- if (!Number.isFinite(ts)) return false;
1506
- const nowSec = (opts.now ?? Date.now()) / 1e3;
1507
- const tolerance = opts.toleranceSec ?? 300;
1508
- if (Math.abs(nowSec - ts) > tolerance) return false;
1509
- const enc = new TextEncoder();
1510
- const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
1511
- const mac = await crypto.subtle.sign("HMAC", key, enc.encode(`${t}.${payload}`));
1512
- return timingSafeEqual(toHex(mac), v1);
1513
- }
1514
- function stripeForm(params) {
1515
- const out = new URLSearchParams();
1516
- for (const [k, v] of Object.entries(params)) {
1517
- if (v === void 0 || v === null) continue;
1518
- if (typeof v === "object") {
1519
- for (const [k2, v2] of Object.entries(v)) {
1520
- if (v2 !== void 0 && v2 !== null) out.append(`${k}[${k2}]`, String(v2));
1521
- }
1522
- } else {
1523
- out.append(k, String(v));
1524
- }
1525
- }
1526
- return out.toString();
1527
- }
1484
+ var import_stripe = require("@odla-ai/stripe");
1528
1485
  function webhookMutationId(eventId) {
1529
1486
  return `stripe:${eventId}`;
1530
1487
  }
@@ -1571,18 +1528,15 @@ function canceledPatch() {
1571
1528
  }
1572
1529
 
1573
1530
  // src/payments-stripe.ts
1531
+ var import_stripe2 = require("@odla-ai/stripe");
1574
1532
  async function stripeCall(sk, method, path, params, idempotencyKey) {
1575
- const qs = method === "GET" && params ? `?${stripeForm(params)}` : "";
1576
- const headers = { authorization: `Bearer ${sk}` };
1577
- if (idempotencyKey) headers["idempotency-key"] = idempotencyKey;
1578
- const init = { method, headers };
1579
- if (method === "POST" && params) {
1580
- headers["content-type"] = "application/x-www-form-urlencoded";
1581
- init.body = stripeForm(params);
1582
- }
1583
- const res = await fetch(`https://api.stripe.com${path}${qs}`, init);
1584
- const body = await res.json().catch(() => ({}));
1585
- return { ok: res.ok, status: res.status, body };
1533
+ return (0, import_stripe2.stripeRequest)(
1534
+ { secretKey: sk },
1535
+ method,
1536
+ path,
1537
+ params,
1538
+ idempotencyKey ? { idempotencyKey } : {}
1539
+ );
1586
1540
  }
1587
1541
  function fail(op, r) {
1588
1542
  const err = new Error(`stripe ${op} failed: ${r.status}`);
@@ -1645,7 +1599,7 @@ function createStripeProvider(config) {
1645
1599
  return { customerId, subscriptionId: String(sub.body.id), clientSecret };
1646
1600
  },
1647
1601
  async ingestWebhook(rawBody, sigHeader) {
1648
- if (!webhookSecret || !await verifyStripeSignature(rawBody, sigHeader, webhookSecret)) {
1602
+ if (!webhookSecret || !await (0, import_stripe2.verifyStripeSignature)(rawBody, sigHeader, webhookSecret)) {
1649
1603
  return { ok: false, reason: "bad_signature" };
1650
1604
  }
1651
1605
  const event = JSON.parse(rawBody);