@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.
- package/README.md +8 -0
- package/dist/{copy-context-HAhNTZdl.d.ts → copy-context-BXBEdp4p.d.ts} +3 -3
- package/dist/index.cjs +203 -199
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -24
- package/dist/index.d.ts +13 -24
- package/dist/index.js +201 -197
- package/dist/index.js.map +1 -1
- package/dist/ui/admin/index.d.ts +2 -2
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/member/index.d.ts +2 -2
- package/dist/worker/index.cjs +10 -56
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +3 -3
- package/dist/worker/index.d.ts +3 -3
- package/dist/worker/index.js +10 -56
- package/dist/worker/index.js.map +1 -1
- package/package.json +2 -1
package/dist/worker/index.d.cts
CHANGED
|
@@ -370,9 +370,9 @@ interface ResolvedPipeline {
|
|
|
370
370
|
}
|
|
371
371
|
/** The application (join form) validation surface — which string fields are
|
|
372
372
|
* required vs accepted, their max lengths, and the request body cap. Drives
|
|
373
|
-
* submit validation
|
|
374
|
-
*
|
|
375
|
-
*
|
|
373
|
+
* submit validation, the generated `applications` schema, and the CRM slot
|
|
374
|
+
* projection; defaults to the reference form. Built-in fields retain their
|
|
375
|
+
* declared schema types/indexes, and site-defined fields become string attrs. */
|
|
376
376
|
interface ChapterApplication {
|
|
377
377
|
required?: readonly string[];
|
|
378
378
|
optional?: readonly string[];
|
package/dist/worker/index.d.ts
CHANGED
|
@@ -370,9 +370,9 @@ interface ResolvedPipeline {
|
|
|
370
370
|
}
|
|
371
371
|
/** The application (join form) validation surface — which string fields are
|
|
372
372
|
* required vs accepted, their max lengths, and the request body cap. Drives
|
|
373
|
-
* submit validation
|
|
374
|
-
*
|
|
375
|
-
*
|
|
373
|
+
* submit validation, the generated `applications` schema, and the CRM slot
|
|
374
|
+
* projection; defaults to the reference form. Built-in fields retain their
|
|
375
|
+
* declared schema types/indexes, and site-defined fields become string attrs. */
|
|
376
376
|
interface ChapterApplication {
|
|
377
377
|
required?: readonly string[];
|
|
378
378
|
optional?: readonly string[];
|
package/dist/worker/index.js
CHANGED
|
@@ -1459,50 +1459,7 @@ var handleSchedule = async (req, url, env, ctx) => {
|
|
|
1459
1459
|
};
|
|
1460
1460
|
|
|
1461
1461
|
// src/payments.ts
|
|
1462
|
-
|
|
1463
|
-
const parts = {};
|
|
1464
|
-
for (const p of header.split(",")) {
|
|
1465
|
-
const [k, v] = p.split("=", 2);
|
|
1466
|
-
if (k && v !== void 0) parts[k] = v;
|
|
1467
|
-
}
|
|
1468
|
-
return { t: parts.t, v1: parts.v1 };
|
|
1469
|
-
}
|
|
1470
|
-
function toHex(buf) {
|
|
1471
|
-
return [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1472
|
-
}
|
|
1473
|
-
function timingSafeEqual(a, b) {
|
|
1474
|
-
if (a.length !== b.length) return false;
|
|
1475
|
-
let diff = 0;
|
|
1476
|
-
for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
1477
|
-
return diff === 0;
|
|
1478
|
-
}
|
|
1479
|
-
async function verifyStripeSignature(payload, header, secret, opts = {}) {
|
|
1480
|
-
const { t, v1 } = parseSigHeader(header);
|
|
1481
|
-
if (!t || !v1) return false;
|
|
1482
|
-
const ts = Number(t);
|
|
1483
|
-
if (!Number.isFinite(ts)) return false;
|
|
1484
|
-
const nowSec = (opts.now ?? Date.now()) / 1e3;
|
|
1485
|
-
const tolerance = opts.toleranceSec ?? 300;
|
|
1486
|
-
if (Math.abs(nowSec - ts) > tolerance) return false;
|
|
1487
|
-
const enc = new TextEncoder();
|
|
1488
|
-
const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
1489
|
-
const mac = await crypto.subtle.sign("HMAC", key, enc.encode(`${t}.${payload}`));
|
|
1490
|
-
return timingSafeEqual(toHex(mac), v1);
|
|
1491
|
-
}
|
|
1492
|
-
function stripeForm(params) {
|
|
1493
|
-
const out = new URLSearchParams();
|
|
1494
|
-
for (const [k, v] of Object.entries(params)) {
|
|
1495
|
-
if (v === void 0 || v === null) continue;
|
|
1496
|
-
if (typeof v === "object") {
|
|
1497
|
-
for (const [k2, v2] of Object.entries(v)) {
|
|
1498
|
-
if (v2 !== void 0 && v2 !== null) out.append(`${k}[${k2}]`, String(v2));
|
|
1499
|
-
}
|
|
1500
|
-
} else {
|
|
1501
|
-
out.append(k, String(v));
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
return out.toString();
|
|
1505
|
-
}
|
|
1462
|
+
import { stripeForm, verifyStripeSignature } from "@odla-ai/stripe";
|
|
1506
1463
|
function webhookMutationId(eventId) {
|
|
1507
1464
|
return `stripe:${eventId}`;
|
|
1508
1465
|
}
|
|
@@ -1549,18 +1506,15 @@ function canceledPatch() {
|
|
|
1549
1506
|
}
|
|
1550
1507
|
|
|
1551
1508
|
// src/payments-stripe.ts
|
|
1509
|
+
import { stripeRequest, verifyStripeSignature as verifyStripeSignature2 } from "@odla-ai/stripe";
|
|
1552
1510
|
async function stripeCall(sk, method, path, params, idempotencyKey) {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
}
|
|
1561
|
-
const res = await fetch(`https://api.stripe.com${path}${qs}`, init);
|
|
1562
|
-
const body = await res.json().catch(() => ({}));
|
|
1563
|
-
return { ok: res.ok, status: res.status, body };
|
|
1511
|
+
return stripeRequest(
|
|
1512
|
+
{ secretKey: sk },
|
|
1513
|
+
method,
|
|
1514
|
+
path,
|
|
1515
|
+
params,
|
|
1516
|
+
idempotencyKey ? { idempotencyKey } : {}
|
|
1517
|
+
);
|
|
1564
1518
|
}
|
|
1565
1519
|
function fail(op, r) {
|
|
1566
1520
|
const err = new Error(`stripe ${op} failed: ${r.status}`);
|
|
@@ -1623,7 +1577,7 @@ function createStripeProvider(config) {
|
|
|
1623
1577
|
return { customerId, subscriptionId: String(sub.body.id), clientSecret };
|
|
1624
1578
|
},
|
|
1625
1579
|
async ingestWebhook(rawBody, sigHeader) {
|
|
1626
|
-
if (!webhookSecret || !await
|
|
1580
|
+
if (!webhookSecret || !await verifyStripeSignature2(rawBody, sigHeader, webhookSecret)) {
|
|
1627
1581
|
return { ok: false, reason: "bad_signature" };
|
|
1628
1582
|
}
|
|
1629
1583
|
const event = JSON.parse(rawBody);
|