@bettercms-ai/sdk 1.45.0 → 1.46.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.cjs +30 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/{read-CMasc3wt.d.ts → read-B2lJr72F.d.ts} +1 -1
- package/dist/{read-DTTdE_Xl.d.cts → read-BZq0vVvs.d.cts} +1 -1
- package/dist/{read-client-E9OHtQAW.d.cts → read-client-DQhWuKf4.d.cts} +16 -0
- package/dist/{read-client-E9OHtQAW.d.ts → read-client-DQhWuKf4.d.ts} +16 -0
- package/dist/read.cjs +16 -1
- package/dist/read.cjs.map +1 -1
- package/dist/read.d.cts +2 -2
- package/dist/read.d.ts +2 -2
- package/dist/read.js +16 -1
- package/dist/read.js.map +1 -1
- package/dist/sections.cjs +16 -1
- package/dist/sections.cjs.map +1 -1
- package/dist/sections.d.cts +1 -1
- package/dist/sections.d.ts +1 -1
- package/dist/sections.js +16 -1
- package/dist/sections.js.map +1 -1
- package/dist/webhook.cjs +38 -0
- package/dist/webhook.cjs.map +1 -0
- package/dist/webhook.d.cts +15 -0
- package/dist/webhook.d.ts +15 -0
- package/dist/webhook.js +13 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +6 -1
package/dist/index.cjs
CHANGED
|
@@ -135,7 +135,8 @@ __export(index_exports, {
|
|
|
135
135
|
updatePageModel: () => updatePageModel,
|
|
136
136
|
updateWorkspace: () => updateWorkspace,
|
|
137
137
|
uploadFormFile: () => uploadFormFile,
|
|
138
|
-
uploadMedia: () => uploadMedia
|
|
138
|
+
uploadMedia: () => uploadMedia,
|
|
139
|
+
verifyWebhookSignature: () => verifyWebhookSignature
|
|
139
140
|
});
|
|
140
141
|
module.exports = __toCommonJS(index_exports);
|
|
141
142
|
|
|
@@ -1315,10 +1316,24 @@ var BRANCH_SIGNATURE_HEADER = "X-BCMS-Branch-Signature";
|
|
|
1315
1316
|
|
|
1316
1317
|
// src/read-client.ts
|
|
1317
1318
|
var DEFAULT_TIMEOUT3 = 1e4;
|
|
1319
|
+
function listQueryParams(filter, sort) {
|
|
1320
|
+
const text = (v) => Array.isArray(v) ? v.join(",") : String(v);
|
|
1321
|
+
const out = {};
|
|
1322
|
+
for (const [field, cond] of Object.entries(filter ?? {})) {
|
|
1323
|
+
if (cond == null) continue;
|
|
1324
|
+
if (Array.isArray(cond)) out[`filter[${field}][in]`] = text(cond);
|
|
1325
|
+
else if (typeof cond === "object") {
|
|
1326
|
+
for (const [op, v] of Object.entries(cond)) if (v != null) out[`filter[${field}][${op}]`] = text(v);
|
|
1327
|
+
} else out[`filter[${field}]`] = text(cond);
|
|
1328
|
+
}
|
|
1329
|
+
const order = Array.isArray(sort) ? sort.join(",") : sort;
|
|
1330
|
+
if (order) out.sort = order;
|
|
1331
|
+
return out;
|
|
1332
|
+
}
|
|
1318
1333
|
function qs(params2) {
|
|
1319
1334
|
const sp = new URLSearchParams();
|
|
1320
1335
|
for (const [k, v] of Object.entries(params2)) {
|
|
1321
|
-
if (v !== void 0 && v !== "") sp.set(k, String(v));
|
|
1336
|
+
if (v !== void 0 && (v !== "" || k.startsWith("filter["))) sp.set(k, String(v));
|
|
1322
1337
|
}
|
|
1323
1338
|
const s = sp.toString();
|
|
1324
1339
|
return s ? `?${s}` : "";
|
|
@@ -1439,6 +1454,7 @@ function createClient(options) {
|
|
|
1439
1454
|
perPage: opts?.perPage,
|
|
1440
1455
|
depth: opts?.depth,
|
|
1441
1456
|
select: opts?.select?.join(","),
|
|
1457
|
+
...listQueryParams(opts?.filter, opts?.sort),
|
|
1442
1458
|
perspective: draft ? "draft" : void 0,
|
|
1443
1459
|
stega: draft && stega ? "1" : void 0,
|
|
1444
1460
|
projectId: defaultProjectId,
|
|
@@ -1779,6 +1795,16 @@ function resolveSeo(page, defaults = {}, location = {}) {
|
|
|
1779
1795
|
};
|
|
1780
1796
|
}
|
|
1781
1797
|
|
|
1798
|
+
// src/webhook.ts
|
|
1799
|
+
async function verifyWebhookSignature(rawBody, header, secret) {
|
|
1800
|
+
const hex = /^sha256=([0-9a-f]{64})$/.exec(header ?? "")?.[1];
|
|
1801
|
+
if (!hex || !secret) return false;
|
|
1802
|
+
const utf8 = new TextEncoder();
|
|
1803
|
+
const key = await crypto.subtle.importKey("raw", utf8.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["verify"]);
|
|
1804
|
+
const signature = Uint8Array.from(hex.match(/../g), (byte) => parseInt(byte, 16));
|
|
1805
|
+
return crypto.subtle.verify("HMAC", key, signature, utf8.encode(rawBody));
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1782
1808
|
// src/search.ts
|
|
1783
1809
|
var DEFAULT_BASE_URL4 = "https://api.bettercms.ai";
|
|
1784
1810
|
async function search(opts) {
|
|
@@ -2289,6 +2315,7 @@ function inEditor(win = globalThis.window) {
|
|
|
2289
2315
|
updatePageModel,
|
|
2290
2316
|
updateWorkspace,
|
|
2291
2317
|
uploadFormFile,
|
|
2292
|
-
uploadMedia
|
|
2318
|
+
uploadMedia,
|
|
2319
|
+
verifyWebhookSignature
|
|
2293
2320
|
});
|
|
2294
2321
|
//# sourceMappingURL=index.cjs.map
|