@easy-cms/core 1.16.0 → 1.17.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/{chunk-WGECYA3K.js → chunk-LPIABPBA.js} +57 -18
- package/dist/{config-BODu0yjp.d.ts → config-CWTw3zFm.d.ts} +8 -3
- package/dist/{handler-DOMtk2Vi.d.ts → handler-DzAqr9gY.d.ts} +1 -1
- package/dist/index.d.ts +28 -6
- package/dist/index.js +6 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +1 -1
- package/dist/{plugin-PyUqbeK2.d.ts → plugin-BYaJUVpz.d.ts} +1 -1
- package/dist/plugin.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1079,10 +1079,10 @@ async function verifyTurnstile(secretKey, response, ip, fetcher = fetch) {
|
|
|
1079
1079
|
// src/auth/cookie.ts
|
|
1080
1080
|
var SESSION_COOKIE = "ecms-session";
|
|
1081
1081
|
var hostCookie = (name) => `__Host-${name}`;
|
|
1082
|
-
function cookieValue(
|
|
1083
|
-
if (!
|
|
1082
|
+
function cookieValue(header2, name) {
|
|
1083
|
+
if (!header2) return void 0;
|
|
1084
1084
|
let plain;
|
|
1085
|
-
for (const part of
|
|
1085
|
+
for (const part of header2.split(";")) {
|
|
1086
1086
|
const eq = part.indexOf("=");
|
|
1087
1087
|
if (eq <= 0) continue;
|
|
1088
1088
|
const key = part.slice(0, eq).trim();
|
|
@@ -3911,7 +3911,7 @@ var VersionStore = class {
|
|
|
3911
3911
|
};
|
|
3912
3912
|
|
|
3913
3913
|
// src/local-api.ts
|
|
3914
|
-
import { createHash as createHash5, createHmac as
|
|
3914
|
+
import { createHash as createHash5, createHmac as createHmac7, randomBytes as randomBytes6, randomUUID as randomUUID3, timingSafeEqual as timingSafeEqual6 } from "crypto";
|
|
3915
3915
|
|
|
3916
3916
|
// src/auth/common-passwords.ts
|
|
3917
3917
|
var LIST = `
|
|
@@ -5138,7 +5138,41 @@ var SearchIndex = class {
|
|
|
5138
5138
|
};
|
|
5139
5139
|
|
|
5140
5140
|
// src/webhooks.ts
|
|
5141
|
-
import { createHmac as
|
|
5141
|
+
import { createHmac as createHmac6, randomUUID as randomUUID2 } from "crypto";
|
|
5142
|
+
|
|
5143
|
+
// src/webhook-signature.ts
|
|
5144
|
+
import { createHmac as createHmac5, timingSafeEqual as timingSafeEqual5 } from "crypto";
|
|
5145
|
+
var TOLERANCE_SECONDS = 5 * 60;
|
|
5146
|
+
function signWebhook(secret, delivery, timestamp, body) {
|
|
5147
|
+
return `v1=${createHmac5("sha256", secret).update(`${delivery}.${timestamp}.${body}`).digest("hex")}`;
|
|
5148
|
+
}
|
|
5149
|
+
function header(headers, name) {
|
|
5150
|
+
if (headers instanceof Headers) return headers.get(name) ?? void 0;
|
|
5151
|
+
const value = Object.entries(headers).find(([key]) => key.toLowerCase() === name)?.[1];
|
|
5152
|
+
return Array.isArray(value) ? value[0] : value;
|
|
5153
|
+
}
|
|
5154
|
+
function equal(a, b) {
|
|
5155
|
+
const left = Buffer.from(a);
|
|
5156
|
+
const right = Buffer.from(b);
|
|
5157
|
+
return left.length === right.length && timingSafeEqual5(left, right);
|
|
5158
|
+
}
|
|
5159
|
+
function verifyWebhook(body, headers, secret, options = {}) {
|
|
5160
|
+
const delivery = header(headers, "x-easy-cms-delivery");
|
|
5161
|
+
const timestamp = header(headers, "x-easy-cms-timestamp");
|
|
5162
|
+
const signatures2 = header(headers, "x-easy-cms-signature-v2");
|
|
5163
|
+
if (!delivery || !timestamp || !signatures2)
|
|
5164
|
+
throw new UnauthorizedError("Webhook signature missing");
|
|
5165
|
+
const seconds = Number(timestamp);
|
|
5166
|
+
const now = (options.now ?? /* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
5167
|
+
if (!/^\d+$/.test(timestamp) || Math.abs(now - seconds) > (options.toleranceSeconds ?? TOLERANCE_SECONDS))
|
|
5168
|
+
throw new UnauthorizedError("Webhook timestamp too old or in the future");
|
|
5169
|
+
const sent = signatures2.split(/[\s,]+/).filter((s) => s.startsWith("v1="));
|
|
5170
|
+
const valid = [secret].flat().some((s) => sent.some((given) => equal(given, signWebhook(s, delivery, seconds, body))));
|
|
5171
|
+
if (!valid) throw new UnauthorizedError("Webhook signature does not match");
|
|
5172
|
+
return JSON.parse(body);
|
|
5173
|
+
}
|
|
5174
|
+
|
|
5175
|
+
// src/webhooks.ts
|
|
5142
5176
|
var WEBHOOK_EVENTS = [
|
|
5143
5177
|
"create",
|
|
5144
5178
|
"update",
|
|
@@ -5308,7 +5342,10 @@ var Webhooks = class {
|
|
|
5308
5342
|
...hook.headers
|
|
5309
5343
|
};
|
|
5310
5344
|
if (hook.secret) {
|
|
5311
|
-
|
|
5345
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
5346
|
+
headers["x-easy-cms-timestamp"] = String(timestamp);
|
|
5347
|
+
headers["x-easy-cms-signature-v2"] = signWebhook(hook.secret, delivery, timestamp, body);
|
|
5348
|
+
headers["x-easy-cms-signature"] = `sha256=${createHmac6("sha256", hook.secret).update(body).digest("hex")}`;
|
|
5312
5349
|
}
|
|
5313
5350
|
try {
|
|
5314
5351
|
const response = await this.fetcher(hook.url, {
|
|
@@ -7025,11 +7062,11 @@ function cacheTimes(config, container) {
|
|
|
7025
7062
|
staleWhileRevalidate: own?.staleWhileRevalidate ?? config.httpCache?.staleWhileRevalidate ?? 300
|
|
7026
7063
|
};
|
|
7027
7064
|
}
|
|
7028
|
-
function matches2(
|
|
7029
|
-
if (!
|
|
7030
|
-
if (
|
|
7065
|
+
function matches2(header2, etag) {
|
|
7066
|
+
if (!header2) return false;
|
|
7067
|
+
if (header2.trim() === "*") return true;
|
|
7031
7068
|
const bare = (tag) => tag.trim().replace(/^W\//, "");
|
|
7032
|
-
return
|
|
7069
|
+
return header2.split(",").some((tag) => bare(tag) === bare(etag));
|
|
7033
7070
|
}
|
|
7034
7071
|
function cacheableResponse(request, body, status, headers, times, tags) {
|
|
7035
7072
|
headers.set(
|
|
@@ -7046,7 +7083,7 @@ function cacheableResponse(request, body, status, headers, times, tags) {
|
|
|
7046
7083
|
}
|
|
7047
7084
|
|
|
7048
7085
|
// src/version.ts
|
|
7049
|
-
var VERSION = true ? "1.
|
|
7086
|
+
var VERSION = true ? "1.17.0" : "0.0.0-dev";
|
|
7050
7087
|
|
|
7051
7088
|
// src/telemetry.ts
|
|
7052
7089
|
var DB_CALLS = /* @__PURE__ */ new Set([
|
|
@@ -7710,7 +7747,7 @@ var EasyCMS = class {
|
|
|
7710
7747
|
/** A value with its HMAC (`secret`), for `purpose` only: `<base64url JSON>.<signature>`. */
|
|
7711
7748
|
sign(purpose, value) {
|
|
7712
7749
|
const payload = Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
7713
|
-
const mac =
|
|
7750
|
+
const mac = createHmac7("sha256", this.config.secret).update(`${purpose}:${payload}`);
|
|
7714
7751
|
return `${payload}.${mac.digest("base64url")}`;
|
|
7715
7752
|
}
|
|
7716
7753
|
/** The value of a token made by `sign`, or `undefined` when it isn't genuine. */
|
|
@@ -7718,10 +7755,10 @@ var EasyCMS = class {
|
|
|
7718
7755
|
const [payload, signature] = String(token).split(".");
|
|
7719
7756
|
if (!payload || !signature) return void 0;
|
|
7720
7757
|
const expected = Buffer.from(
|
|
7721
|
-
|
|
7758
|
+
createHmac7("sha256", this.config.secret).update(`${purpose}:${payload}`).digest("base64url")
|
|
7722
7759
|
);
|
|
7723
7760
|
const given = Buffer.from(signature);
|
|
7724
|
-
if (expected.length !== given.length || !
|
|
7761
|
+
if (expected.length !== given.length || !timingSafeEqual6(expected, given)) return void 0;
|
|
7725
7762
|
try {
|
|
7726
7763
|
return JSON.parse(Buffer.from(payload, "base64url").toString());
|
|
7727
7764
|
} catch {
|
|
@@ -7840,10 +7877,10 @@ var EasyCMS = class {
|
|
|
7840
7877
|
if (!signature || !Number.isInteger(at) || at < Date.now() / 1e3) return false;
|
|
7841
7878
|
const expected = Buffer.from(this.mediaSignature(key, at));
|
|
7842
7879
|
const given = Buffer.from(signature);
|
|
7843
|
-
return expected.length === given.length &&
|
|
7880
|
+
return expected.length === given.length && timingSafeEqual6(expected, given);
|
|
7844
7881
|
}
|
|
7845
7882
|
mediaSignature(key, expires) {
|
|
7846
|
-
return
|
|
7883
|
+
return createHmac7("sha256", this.config.secret).update(`media:${key}:${expires}`).digest("base64url");
|
|
7847
7884
|
}
|
|
7848
7885
|
/**
|
|
7849
7886
|
* How many documents use any of these files in a top-level upload field (rich text and fields
|
|
@@ -12424,8 +12461,8 @@ async function route(cms, ctx, method, path, options) {
|
|
|
12424
12461
|
if (first === "jobs" && second === "run" && third === void 0) {
|
|
12425
12462
|
if (method !== "GET" && method !== "POST") throw methodNotAllowed(ctx, "GET, POST");
|
|
12426
12463
|
const secret = cms.config.cronSecret ?? process.env.CRON_SECRET;
|
|
12427
|
-
const
|
|
12428
|
-
const byCron = !!secret && safeEqual(
|
|
12464
|
+
const header2 = ctx.request.headers.get("authorization") ?? "";
|
|
12465
|
+
const byCron = !!secret && safeEqual(header2, `Bearer ${secret}`);
|
|
12429
12466
|
if (!byCron && !isSystemAdmin(ctx.user)) {
|
|
12430
12467
|
throw ctx.user ? new HttpError("Forbidden", 403) : new UnauthorizedError();
|
|
12431
12468
|
}
|
|
@@ -13553,6 +13590,8 @@ export {
|
|
|
13553
13590
|
checkRenamedOptions,
|
|
13554
13591
|
BUILTIN_NAV,
|
|
13555
13592
|
memorySearch,
|
|
13593
|
+
signWebhook,
|
|
13594
|
+
verifyWebhook,
|
|
13556
13595
|
WEBHOOK_EVENTS,
|
|
13557
13596
|
MIN_SECRET_LENGTH,
|
|
13558
13597
|
BUILTIN_COLLECTIONS,
|
|
@@ -2779,7 +2779,12 @@ interface WebhookConfig {
|
|
|
2779
2779
|
readonly collections?: readonly string[];
|
|
2780
2780
|
/** Globals to send events for. Default: all; `[]` for none. */
|
|
2781
2781
|
readonly globals?: readonly string[];
|
|
2782
|
-
/**
|
|
2782
|
+
/**
|
|
2783
|
+
* Signs each attempt: `x-easy-cms-timestamp` and `x-easy-cms-signature-v2` (`v1=<hex HMAC-SHA256
|
|
2784
|
+
* of "<delivery>.<timestamp>.<body>">`, checked by `verifyWebhook()`). Also, until 2.0, the
|
|
2785
|
+
* deprecated `x-easy-cms-signature: sha256=<hex HMAC-SHA256 of the body>`, which a captured
|
|
2786
|
+
* request can be replayed with.
|
|
2787
|
+
*/
|
|
2783
2788
|
readonly secret?: string;
|
|
2784
2789
|
/** Extra request headers, e.g. a token the receiver checks. */
|
|
2785
2790
|
readonly headers?: Readonly<Record<string, string>>;
|
|
@@ -3682,5 +3687,5 @@ interface ResolvedConfig extends Omit<Config, 'cors' | 'localization' | 'routes'
|
|
|
3682
3687
|
*/
|
|
3683
3688
|
declare function defineConfig<const TConfig extends Config>(config: TConfig): TConfig;
|
|
3684
3689
|
|
|
3685
|
-
export { ADAPTER_API_VERSION as A,
|
|
3686
|
-
export type {
|
|
3690
|
+
export { ADAPTER_API_VERSION as A, EasyCMS as E, AuditLog as S, Auth as V, EasyCMSError as aD, FIELD_TYPES as aK, ConfigError as al, ForbiddenError as b2, PLUGIN_API_VERSION as bB, PayloadTooLargeError as bG, QueryError as bM, ROLE_OPERATIONS as bN, Roles as bX, SchemaError as b_, NotFoundError as bv, API_KEYS as c$, WEBHOOK_EVENTS as cC, anyone as cH, consoleEmail as cI, consoleLogger as cJ, createEasyCMS as cK, defineConfig as cL, defineFieldType as cM, definePlugin as cN, diskStorage as cO, hasRows as cP, isAdmin as cQ, isHasMany as cR, isSignedIn as cS, isStaff as cT, isSystemAdmin as cU, jsonLogger as cV, memorySearch as cW, mimeAllowedBy as cX, rowFields as cY, silentLogger as cZ, uniqueWithinOf as c_, SingleSignOn as cd, TRIGRAM_LIKE_MIN as ck, TooManyRequestsError as co, UnauthorizedError as cq, ValidationError as cy, API_KEY_GLOBAL_OPERATIONS as d0, API_KEY_OPERATIONS as d1, DEFAULT_MAX_VERSIONS as d2, DEFAULT_PASSWORD_EMAILS as d3, FIELD_TYPE_BASES as d4, FOLDER_LEVELS as d5, MediaFolders as d6, SSO_COOKIE as d7, codeOfStatus as d8, isJsonLogger as d9, keyAllows as da, logFormat as db, ADMIN_ICONS as e };
|
|
3691
|
+
export type { AuthUser as $, AfterDeleteHook as B, Config as C, AfterReadHook as D, Field as F, ApiKeyContext as G, ApiKeyGlobalOperation as H, ID as I, ApiKeyOperation as J, ApiKeyPermissions as K, LocalizationConfig as L, ArrayField as M, AuditChange as N, AuditConfig as O, PaginatedDocs as P, AuditEntry as Q, ResolvedConfig as R, AuditPage as T, AuditVerification as U, WebhookPayload as W, AuthConfig as X, AuthProvider as Y, AuthProviderProfile as Z, AuthProviderRequest as _, FieldError as a, FindOptions as a$, BackupsConfig as a0, BeforeChangeHook as a1, BeforeDeleteHook as a2, BeforeValidateHook as a3, Block as a4, BlocksField as a5, BooleanField as a6, BuiltinApiKeysCollection as a7, BuiltinMediaCollection as a8, BuiltinMediaFoldersCollection as a9, DirectUpload as aA, DiskStorageOptions as aB, DocumentOf as aC, EmailAdapter as aE, EmailField as aF, EmailMessage as aG, Endpoint as aH, EndpointRequest as aI, ErrorCode as aJ, FieldAccess as aL, FieldAccessFn as aM, FieldAdmin as aN, FieldRule as aO, FieldType as aP, FieldTypeBase as aQ, FieldTypeDefinition as aR, FieldTypeValidateContext as aS, FieldValidate as aT, FieldValidateContext as aU, FieldValue as aV, FieldsInput as aW, FieldsValue as aX, FilterOptionsArgs as aY, FindAfterArgs as aZ, FindArgs as a_, BuiltinUsersCollection as aa, BundleHints as ab, CliCommand as ac, CollectionAccess as ad, CollectionAdmin as ae, CollectionConfig as af, CollectionDocument as ag, CollectionHooks as ah, CollectionListAdmin as ai, CollectionSearch as aj, CollectionSlug as ak, ConfigIssue as am, ContainerAdmin as an, CreateInput as ao, CreateMigrationResult as ap, CursorDocs as aq, CustomField as ar, CustomFieldTypes as as, DashboardWidget as at, Database as au, DatabaseAdapter as av, DatabaseInitArgs as aw, DatabaseTransfer as ax, DateField as ay, DepthOptions as az, FilterOptions as b, SchemaMode as b$, FolderLevel as b0, FolderPermissions as b1, GlobalAccess as b3, GlobalConfig as b4, GlobalDocument as b5, GlobalHooks as b6, GlobalInput as b7, GlobalSlug as b8, GroupField as b9, OutboxRow as bA, PasswordEmail as bC, PasswordEmailArgs as bD, PasswordEmailFn as bE, PasswordLinkOptions as bF, Plugin as bH, PluginInfo as bI, PluginTypes as bJ, PreviewTarget as bK, PreviewURL as bL, RawDocument as bO, ReadOptions as bP, RelationshipField as bQ, RequestContext as bR, RichTextDocument as bS, RichTextField as bT, Role as bU, RoleOperation as bV, RolePermissions as bW, RoutesConfig as bY, ScheduledPublish as bZ, ImageSize as ba, IncrementOptions as bb, InferCollection as bc, InferGlobal as bd, JobConfig as be, JsonField as bf, KeysetPage as bg, Label as bh, LayoutNode as bi, LivePreview as bj, LocaleOf as bk, LogDetails as bl, Logger as bm, LoginArgs as bn, LogsConfig as bo, MediaDocument as bp, MediaSize as bq, MembersConfig as br, MembersSignup as bs, MigrationInfo as bt, NavGroup as bu, NumberField as bw, OnRequest as bx, OnRequestArgs as by, Operation as bz, CreateEasyCMSOptions as c, SearchAdapter as c0, SearchEntry as c1, SearchHits as c2, SearchOptions as c3, SearchQuery as c4, SearchResults as c5, SearchSetting as c6, SelectField as c7, SelectOption as c8, Session as c9, VersionSummary as cA, VersionsConfig as cB, WebhookConfig as cD, WebhookEvent as cE, Where as cF, WhereOperators as cG, SidebarPanel as ca, SignupArgs as cb, SignupResult as cc, SlugField as ce, SlugOf as cf, SsoOutcome as cg, SsoProviderRef as ch, StorageAdapter as ci, StoredFile as cj, TelemetryConfig as cl, TextField as cm, TextareaField as cn, TypedPlugin as cp, UncountedDocs as cr, UpdateInput as cs, UpdateOptions as ct, UploadConfig as cu, UploadField as cv, UploadFromURLConfig as cw, UserIdentity as cx, Version as cz, EmailSetting as d, Access as f, AccessArgs as g, AccessOptions as h, AdminBrand as i, AdminCommand as j, AdminComponent as k, AdminConfig as l, AdminFieldArgs as m, AdminIcon as n, AdminLocale as o, AdminPage as p, AdminRole as q, AdminRoleChange as r, AdminRoleField as s, AdminRoleTarget as t, AdminRoleView as u, AdminRoles as v, AdminSso as w, AdminSwitcher as x, AdminViewAccess as y, AfterChangeHook as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ID,
|
|
1
|
+
import { I as ID, C as Config, E as EasyCMS, L as LocalizationConfig, F as Field, a as FieldError, b as FilterOptions, c as CreateEasyCMSOptions, R as ResolvedConfig } from './config-CWTw3zFm.js';
|
|
2
2
|
|
|
3
3
|
/** Decrypts a file from `encryptBackup`; throws for another key or a changed file. */
|
|
4
4
|
declare function decryptBackup(data: Uint8Array, encryptionKey: string): Uint8Array;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PaginatedDocs, I as ID,
|
|
2
|
-
export { A as ADAPTER_API_VERSION,
|
|
3
|
-
export { A as ADMIN_API_VERSION, a as AdminCollection, b as AdminComponentRef, c as AdminElementProps, d as AdminField, e as AdminGlobal, f as AdminLayoutNode, g as AdminNavGroup, h as AdminNavItem, i as AdminNavNode, j as AdminPageRef, k as AdminPageRoute, l as AdminSchema, m as AdminWidgetRef, S as SetFieldDetail, w as warnDeprecated } from './plugin-
|
|
4
|
-
export { A as AdminBackup, a as AdminBackups, b as ApiHandlerOptions, B as BackupState, L as LoadConfigOptions, R as RestHandler, c as RestHandlerOptions, d as createApiHandler, e as createRestHandler, l as loadConfig, r as resolveConfig, s as sharedEasyCMS, f as slugify } from './handler-
|
|
1
|
+
import { P as PaginatedDocs, I as ID, d as EmailSetting, W as WebhookPayload } from './config-CWTw3zFm.js';
|
|
2
|
+
export { A as ADAPTER_API_VERSION, e as ADMIN_ICONS, f as Access, g as AccessArgs, h as AccessOptions, i as AdminBrand, j as AdminCommand, k as AdminComponent, l as AdminConfig, m as AdminFieldArgs, n as AdminIcon, o as AdminLocale, p as AdminPage, q as AdminRole, r as AdminRoleChange, s as AdminRoleField, t as AdminRoleTarget, u as AdminRoleView, v as AdminRoles, w as AdminSso, x as AdminSwitcher, y as AdminViewAccess, z as AfterChangeHook, B as AfterDeleteHook, D as AfterReadHook, G as ApiKeyContext, H as ApiKeyGlobalOperation, J as ApiKeyOperation, K as ApiKeyPermissions, M as ArrayField, N as AuditChange, O as AuditConfig, Q as AuditEntry, S as AuditLog, T as AuditPage, U as AuditVerification, V as Auth, X as AuthConfig, Y as AuthProvider, Z as AuthProviderProfile, _ as AuthProviderRequest, $ as AuthUser, a0 as BackupsConfig, a1 as BeforeChangeHook, a2 as BeforeDeleteHook, a3 as BeforeValidateHook, a4 as Block, a5 as BlocksField, a6 as BooleanField, a7 as BuiltinApiKeysCollection, a8 as BuiltinMediaCollection, a9 as BuiltinMediaFoldersCollection, aa as BuiltinUsersCollection, ab as BundleHints, ac as CliCommand, ad as CollectionAccess, ae as CollectionAdmin, af as CollectionConfig, ag as CollectionDocument, ah as CollectionHooks, ai as CollectionListAdmin, aj as CollectionSearch, ak as CollectionSlug, C as Config, al as ConfigError, am as ConfigIssue, an as ContainerAdmin, c as CreateEasyCMSOptions, ao as CreateInput, ap as CreateMigrationResult, aq as CursorDocs, ar as CustomField, as as CustomFieldTypes, at as DashboardWidget, au as Database, av as DatabaseAdapter, aw as DatabaseInitArgs, ax as DatabaseTransfer, ay as DateField, az as DepthOptions, aA as DirectUpload, aB as DiskStorageOptions, aC as DocumentOf, E as EasyCMS, aD as EasyCMSError, aE as EmailAdapter, aF as EmailField, aG as EmailMessage, aH as Endpoint, aI as EndpointRequest, aJ as ErrorCode, aK as FIELD_TYPES, F as Field, aL as FieldAccess, aM as FieldAccessFn, aN as FieldAdmin, a as FieldError, aO as FieldRule, aP as FieldType, aQ as FieldTypeBase, aR as FieldTypeDefinition, aS as FieldTypeValidateContext, aT as FieldValidate, aU as FieldValidateContext, aV as FieldValue, aW as FieldsInput, aX as FieldsValue, b as FilterOptions, aY as FilterOptionsArgs, aZ as FindAfterArgs, a_ as FindArgs, a$ as FindOptions, b0 as FolderLevel, b1 as FolderPermissions, b2 as ForbiddenError, b3 as GlobalAccess, b4 as GlobalConfig, b5 as GlobalDocument, b6 as GlobalHooks, b7 as GlobalInput, b8 as GlobalSlug, b9 as GroupField, ba as ImageSize, bb as IncrementOptions, bc as InferCollection, bd as InferGlobal, be as JobConfig, bf as JsonField, bg as KeysetPage, bh as Label, bi as LayoutNode, bj as LivePreview, bk as LocaleOf, L as LocalizationConfig, bl as LogDetails, bm as Logger, bn as LoginArgs, bo as LogsConfig, bp as MediaDocument, bq as MediaSize, br as MembersConfig, bs as MembersSignup, bt as MigrationInfo, bu as NavGroup, bv as NotFoundError, bw as NumberField, bx as OnRequest, by as OnRequestArgs, bz as Operation, bA as OutboxRow, bB as PLUGIN_API_VERSION, bC as PasswordEmail, bD as PasswordEmailArgs, bE as PasswordEmailFn, bF as PasswordLinkOptions, bG as PayloadTooLargeError, bH as Plugin, bI as PluginInfo, bJ as PluginTypes, bK as PreviewTarget, bL as PreviewURL, bM as QueryError, bN as ROLE_OPERATIONS, bO as RawDocument, bP as ReadOptions, bQ as RelationshipField, bR as RequestContext, R as ResolvedConfig, bS as RichTextDocument, bT as RichTextField, bU as Role, bV as RoleOperation, bW as RolePermissions, bX as Roles, bY as RoutesConfig, bZ as ScheduledPublish, b_ as SchemaError, b$ as SchemaMode, c0 as SearchAdapter, c1 as SearchEntry, c2 as SearchHits, c3 as SearchOptions, c4 as SearchQuery, c5 as SearchResults, c6 as SearchSetting, c7 as SelectField, c8 as SelectOption, c9 as Session, ca as SidebarPanel, cb as SignupArgs, cc as SignupResult, cd as SingleSignOn, ce as SlugField, cf as SlugOf, cg as SsoOutcome, ch as SsoProviderRef, ci as StorageAdapter, cj as StoredFile, ck as TRIGRAM_LIKE_MIN, cl as TelemetryConfig, cm as TextField, cn as TextareaField, co as TooManyRequestsError, cp as TypedPlugin, cq as UnauthorizedError, cr as UncountedDocs, cs as UpdateInput, ct as UpdateOptions, cu as UploadConfig, cv as UploadField, cw as UploadFromURLConfig, cx as UserIdentity, cy as ValidationError, cz as Version, cA as VersionSummary, cB as VersionsConfig, cC as WEBHOOK_EVENTS, cD as WebhookConfig, cE as WebhookEvent, cF as Where, cG as WhereOperators, cH as anyone, cI as consoleEmail, cJ as consoleLogger, cK as createEasyCMS, cL as defineConfig, cM as defineFieldType, cN as definePlugin, cO as diskStorage, cP as hasRows, cQ as isAdmin, cR as isHasMany, cS as isSignedIn, cT as isStaff, cU as isSystemAdmin, cV as jsonLogger, cW as memorySearch, cX as mimeAllowedBy, cY as rowFields, cZ as silentLogger, c_ as uniqueWithinOf } from './config-CWTw3zFm.js';
|
|
3
|
+
export { A as ADMIN_API_VERSION, a as AdminCollection, b as AdminComponentRef, c as AdminElementProps, d as AdminField, e as AdminGlobal, f as AdminLayoutNode, g as AdminNavGroup, h as AdminNavItem, i as AdminNavNode, j as AdminPageRef, k as AdminPageRoute, l as AdminSchema, m as AdminWidgetRef, S as SetFieldDetail, w as warnDeprecated } from './plugin-BYaJUVpz.js';
|
|
4
|
+
export { A as AdminBackup, a as AdminBackups, b as ApiHandlerOptions, B as BackupState, L as LoadConfigOptions, R as RestHandler, c as RestHandlerOptions, d as createApiHandler, e as createRestHandler, l as loadConfig, r as resolveConfig, s as sharedEasyCMS, f as slugify } from './handler-DzAqr9gY.js';
|
|
5
5
|
export { FieldCondition, matchesCondition } from './conditions.js';
|
|
6
6
|
|
|
7
7
|
type DeliveryKind = 'webhook' | 'email';
|
|
@@ -259,5 +259,27 @@ declare const cacheTags: {
|
|
|
259
259
|
/** The version of `@easy-cms/core`, set when the package is built. */
|
|
260
260
|
declare const VERSION: string;
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
/**
|
|
263
|
+
* `x-easy-cms-signature-v2` of one attempt: `v1=<hex HMAC-SHA256 of "<delivery>.<timestamp>.<body>">`.
|
|
264
|
+
* The timestamp (`x-easy-cms-timestamp`, Unix seconds) is the attempt's, so a captured request
|
|
265
|
+
* can't be replayed later, and the delivery id can't be paired with another body.
|
|
266
|
+
*/
|
|
267
|
+
declare function signWebhook(secret: string, delivery: string, timestamp: number, body: string): string;
|
|
268
|
+
interface VerifyWebhookOptions {
|
|
269
|
+
/** How far the timestamp may be from now, in seconds. Default 300. */
|
|
270
|
+
readonly toleranceSeconds?: number;
|
|
271
|
+
/** Now, for tests. */
|
|
272
|
+
readonly now?: Date;
|
|
273
|
+
}
|
|
274
|
+
type HeaderSource = Headers | Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
275
|
+
/**
|
|
276
|
+
* Checks a webhook from Easy CMS and returns its payload: the signature (with `secret`, or any of
|
|
277
|
+
* several while one is replaced) over the delivery id, the timestamp and the raw body, and a
|
|
278
|
+
* timestamp within `toleranceSeconds` of now. Throws `UnauthorizedError` otherwise. Pass the body
|
|
279
|
+
* exactly as received, before parsing it. Also skip deliveries already handled
|
|
280
|
+
* (`x-easy-cms-delivery`): a replay within the tolerance has a valid signature.
|
|
281
|
+
*/
|
|
282
|
+
declare function verifyWebhook(body: string, headers: HeaderSource, secret: string | readonly string[], options?: VerifyWebhookOptions): WebhookPayload;
|
|
283
|
+
|
|
284
|
+
export { EmailSetting, ID, PaginatedDocs, VERSION, WebhookPayload, cacheTags, signWebhook, verifyWebhook };
|
|
285
|
+
export type { AdminAttention, AdminDeliveries, AdminDelivery, AdminEmail, AdminEmailDelivery, AdminJob, AdminJobs, AdminOutbox, AdminOutboxEntry, AdminScheduledJob, AdminStatus, AdminWebhookDelivery, BuiltInJob, DeliveryKind, DeliveryState, EmailCheck, SearchHit, VerifyWebhookOptions };
|
package/dist/index.js
CHANGED
|
@@ -24,9 +24,11 @@ import {
|
|
|
24
24
|
memorySearch,
|
|
25
25
|
resolveConfig,
|
|
26
26
|
sharedEasyCMS,
|
|
27
|
+
signWebhook,
|
|
27
28
|
silentLogger,
|
|
28
|
-
slugify
|
|
29
|
-
|
|
29
|
+
slugify,
|
|
30
|
+
verifyWebhook
|
|
31
|
+
} from "./chunk-LPIABPBA.js";
|
|
30
32
|
import {
|
|
31
33
|
matchesCondition
|
|
32
34
|
} from "./chunk-U266LV4M.js";
|
|
@@ -96,7 +98,9 @@ export {
|
|
|
96
98
|
memorySearch,
|
|
97
99
|
resolveConfig,
|
|
98
100
|
sharedEasyCMS,
|
|
101
|
+
signWebhook,
|
|
99
102
|
silentLogger,
|
|
100
103
|
slugify,
|
|
104
|
+
verifyWebhook,
|
|
101
105
|
warnDeprecated
|
|
102
106
|
};
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config, Database, EasyCMS, NavGroup, CollectionConfig, ID, RawDocument, Field, ResolvedConfig, ConfigIssue } from './index.js';
|
|
2
|
-
export { c$ as API_KEYS, d0 as API_KEY_GLOBAL_OPERATIONS, d1 as API_KEY_OPERATIONS, d2 as DEFAULT_MAX_VERSIONS, d3 as DEFAULT_PASSWORD_EMAILS, d4 as FIELD_TYPE_BASES, d5 as FOLDER_LEVELS, d6 as MediaFolders, d7 as SSO_COOKIE,
|
|
3
|
-
export { C as CONFIG_FILE_NAMES, g as CSRF_COOKIE, h as CSRF_HEADER, D as DEFAULT_ADMIN_PATH, i as DEFAULT_API_PATH, j as DEFAULT_MAX_FILE_SIZE, k as DEFAULT_TOKEN_EXPIRATION, m as applyDefaults, n as applyPlugins, o as createRootEndpointHandler, p as decryptBackup, q as fillMissing, t as findConfigFile, u as forwardedClientIp, v as generateSlugs, w as importConfig, x as isEmail, y as mergeForUpdate, z as parseId, E as platformClientIp, F as readCookie, G as validateFields, H as writeBackupFile } from './handler-
|
|
2
|
+
export { c$ as API_KEYS, d0 as API_KEY_GLOBAL_OPERATIONS, d1 as API_KEY_OPERATIONS, d2 as DEFAULT_MAX_VERSIONS, d3 as DEFAULT_PASSWORD_EMAILS, d4 as FIELD_TYPE_BASES, d5 as FOLDER_LEVELS, d6 as MediaFolders, d7 as SSO_COOKIE, ck as TRIGRAM_LIKE_MIN, d8 as codeOfStatus, cP as hasRows, cR as isHasMany, d9 as isJsonLogger, da as keyAllows, db as logFormat, cX as mimeAllowedBy, cY as rowFields, c_ as uniqueWithinOf } from './config-CWTw3zFm.js';
|
|
3
|
+
export { C as CONFIG_FILE_NAMES, g as CSRF_COOKIE, h as CSRF_HEADER, D as DEFAULT_ADMIN_PATH, i as DEFAULT_API_PATH, j as DEFAULT_MAX_FILE_SIZE, k as DEFAULT_TOKEN_EXPIRATION, m as applyDefaults, n as applyPlugins, o as createRootEndpointHandler, p as decryptBackup, q as fillMissing, t as findConfigFile, u as forwardedClientIp, v as generateSlugs, w as importConfig, x as isEmail, y as mergeForUpdate, z as parseId, E as platformClientIp, F as readCookie, G as validateFields, H as writeBackupFile } from './handler-DzAqr9gY.js';
|
|
4
4
|
export { conditionIssues } from './conditions.js';
|
|
5
5
|
|
|
6
6
|
/** The session cookie the REST API sets at login. */
|
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bh as Label, F as Field, I as ID, o as AdminLocale, x as AdminSwitcher, ch as SsoProviderRef } from './config-CWTw3zFm.js';
|
|
2
2
|
import { FieldCondition } from './conditions.js';
|
|
3
3
|
|
|
4
4
|
/** A Web Component from an admin module, with its `props` (plain JSON). */
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { A as ADMIN_API_VERSION, c as AdminElementProps, k as AdminPageRoute, S as SetFieldDetail, w as warnDeprecated } from './plugin-
|
|
1
|
+
export { e as ADMIN_ICONS, k as AdminComponent, n as AdminIcon, $ as AuthUser, ac as CliCommand, ad as CollectionAccess, af as CollectionConfig, C as Config, al as ConfigError, at as DashboardWidget, aD as EasyCMSError, aH as Endpoint, aI as EndpointRequest, aJ as ErrorCode, F as Field, aL as FieldAccess, a as FieldError, aQ as FieldTypeBase, aR as FieldTypeDefinition, aS as FieldTypeValidateContext, b2 as ForbiddenError, b4 as GlobalConfig, I as ID, be as JobConfig, bh as Label, bu as NavGroup, bv as NotFoundError, bx as OnRequest, by as OnRequestArgs, bB as PLUGIN_API_VERSION, bG as PayloadTooLargeError, bH as Plugin, bI as PluginInfo, bJ as PluginTypes, bM as QueryError, bR as RequestContext, co as TooManyRequestsError, cp as TypedPlugin, cq as UnauthorizedError, cy as ValidationError, cF as Where, cM as defineFieldType, cN as definePlugin } from './config-CWTw3zFm.js';
|
|
2
|
+
export { A as ADMIN_API_VERSION, c as AdminElementProps, k as AdminPageRoute, S as SetFieldDetail, w as warnDeprecated } from './plugin-BYaJUVpz.js';
|
|
3
3
|
import './conditions.js';
|