riverbankcms 0.30.0 → 0.30.1

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.
@@ -10561,5 +10561,112 @@ const OFFLINE_PAYMENT_METHOD_LABELS = {
10561
10561
  other: "Other"
10562
10562
  };
10563
10563
 
10564
+ //#endregion
10565
+ //#region ../core/src/embedHosts.ts
10566
+ const invalidAddress = {
10567
+ ok: false,
10568
+ error: { kind: "invalid_website_address" }
10569
+ };
10570
+ /** Separate input syntax from DNS validation so URL parsing cannot repair unsafe input. */
10571
+ function websiteCandidate(input) {
10572
+ if (typeof input !== "string") return null;
10573
+ const address = input.trim();
10574
+ if (!address || /[\\\s]/u.test(address) || address.startsWith("//")) return null;
10575
+ return websiteUrlCandidate(address);
10576
+ }
10577
+ /** Admit HTTP(S) or a bare host, without allowing encoded authority characters. */
10578
+ function websiteUrlCandidate(address) {
10579
+ const hasScheme = /^[a-z][a-z0-9+.-]*:/i.test(address) && !/^[^/:]+:\d+(?:[/?#]|$)/u.test(address);
10580
+ if (hasScheme && !/^https?:\/\/[^/]/i.test(address)) return null;
10581
+ const authority = (hasScheme ? address.replace(/^https?:\/\//i, "") : address).split(/[/?#]/u)[0] ?? "";
10582
+ if (authority.includes("%")) return null;
10583
+ return hasScheme ? address : `https://${address}`;
10584
+ }
10585
+ function isWebsiteHostname(host) {
10586
+ return host.includes(".") && !host.endsWith(".localhost") && host.length <= 253 && !/^(?:\d+\.){3}\d+$/u.test(host) && host.split(".").every((label$1) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u.test(label$1));
10587
+ }
10588
+ function parseWebsite(input) {
10589
+ const candidate$1 = websiteCandidate(input);
10590
+ if (candidate$1 === null) return invalidAddress;
10591
+ try {
10592
+ const url = new URL(candidate$1);
10593
+ const host = url.hostname.toLowerCase().replace(/\.$/u, "");
10594
+ if (url.username || url.password || !isWebsiteHostname(host)) return invalidAddress;
10595
+ url.protocol = "https:";
10596
+ url.hostname = host;
10597
+ url.port = "";
10598
+ url.search = "";
10599
+ url.hash = "";
10600
+ return {
10601
+ ok: true,
10602
+ value: url
10603
+ };
10604
+ } catch {
10605
+ return invalidAddress;
10606
+ }
10607
+ }
10608
+ function parseEmbedHost(input) {
10609
+ const parsed = parseWebsite(input);
10610
+ return parsed.ok ? {
10611
+ ok: true,
10612
+ value: parsed.value.hostname.replace(/^www\./u, "")
10613
+ } : parsed;
10614
+ }
10615
+ /** Preserve the supplied path and www hostname; discard tracking queries and fragments. */
10616
+ function parseExternalWebsiteUrl(input) {
10617
+ const parsed = parseWebsite(input);
10618
+ return parsed.ok ? {
10619
+ ok: true,
10620
+ value: parsed.value.href
10621
+ } : parsed;
10622
+ }
10623
+ function matchesEmbedHost(hostname, allowed) {
10624
+ const host = hostname.toLowerCase();
10625
+ return allowed.some((entry) => host === entry || host === `www.${entry}`);
10626
+ }
10627
+ function formatEmbedFrameAncestors(hosts) {
10628
+ return [...new Set(hosts.flatMap((host) => [host, `www.${host}`]))].sort().join(" ");
10629
+ }
10630
+ function canonicalHosts(hosts) {
10631
+ return [...new Set(hosts)].sort();
10632
+ }
10633
+ /** Stored facts are canonical already: reject corruption rather than widening a policy. */
10634
+ function parseStoredBookingEmbedSettings(stored) {
10635
+ const url = stored.externalWebsiteUrl === null ? null : parseExternalWebsiteUrl(stored.externalWebsiteUrl);
10636
+ if (url !== null && (!url.ok || url.value !== stored.externalWebsiteUrl)) return invalidAddress;
10637
+ const hosts = stored.embedAllowedHosts.map((host) => ({
10638
+ host,
10639
+ parsed: parseEmbedHost(host)
10640
+ }));
10641
+ if (hosts.some(({ host, parsed }) => !parsed.ok || parsed.value !== host)) return invalidAddress;
10642
+ return {
10643
+ ok: true,
10644
+ value: {
10645
+ externalWebsiteUrl: url?.ok ? url.value : null,
10646
+ allowedHosts: canonicalHosts(hosts.flatMap(({ parsed }) => parsed.ok ? [parsed.value] : []))
10647
+ }
10648
+ };
10649
+ }
10650
+ function decideBookingEmbedChange(current, change) {
10651
+ const host = parseEmbedHost(change.address);
10652
+ if (!host.ok) return host;
10653
+ if (change.kind === "remove_host") return {
10654
+ ok: true,
10655
+ value: {
10656
+ ...current,
10657
+ allowedHosts: current.allowedHosts.filter((entry) => entry !== host.value)
10658
+ }
10659
+ };
10660
+ const url = change.kind === "set_website" ? parseExternalWebsiteUrl(change.address) : null;
10661
+ if (url !== null && !url.ok) return url;
10662
+ return {
10663
+ ok: true,
10664
+ value: {
10665
+ externalWebsiteUrl: url?.ok ? url.value : current.externalWebsiteUrl,
10666
+ allowedHosts: canonicalHosts([...current.allowedHosts, host.value])
10667
+ }
10668
+ };
10669
+ }
10670
+
10564
10671
  //#endregion
10565
10672
  export { locationMapLinks as $, unsafeAsSiteId as $n, isPublicEventPricingOptionDisplayable as $t, parseMailingListContentVersionId as A, parseDatedOfferingCapacityHoldId as An, resolveBookingTimeZoneId as At, footerNavigationLayouts as B, unsafeAsSafeDownloadFilename as Bn, addIntervalPreservingMonthAnchor as Bt, resolveWholeSeriesBookingPhase as C, unsafeAsStaffMemberId as Cn, getBookingLocalDateKey as Ct, parseManagementKey as D, unsafeAsEntitlementId as Dn, parseBookingLocalDate as Dt, exposeSecret as E, parseMembershipId as En, localScheduleTimePattern as Et, parseMailingListGlobalForm as F, unsafeAsFileChecksumSha256 as Fn, BOOKING_COURSE_INSTALMENT_DEADLINES as Ft, formatOpeningHoursRows as G, unsafeAsProductId as Gn, omitZeroAmountFutureRows as Gt, DEFAULT_MAILING_LIST_TARGETING as H, unsafeAsStorageBucketName as Hn, getBookingInstalmentDepositRefundability as Ht, DEFAULT_MAILING_LIST_PRIVACY_NOTE as I, unsafeAsMediaAssetId as In, validateBookingPaymentOptionKinds as It, assertAllowedPublicUrl as J, parsePageId as Jn, resolveFlexibleBalanceInitialPaymentCents as Jt, parsePublicContactDetails as K, unsafeAsCheckoutLineId as Kn, splitAmountWithRemainderInFirst as Kt, DEFAULT_MAILING_LIST_SUCCESS_MESSAGE as L, unsafeAsOriginalFilename as Ln, isLiveOrderInstalmentPlanStatus as Lt, parseMailingListRuntimeContext as M, parseMediaAssetId as Mn, parseBookingTimeZone as Mt, assessMailingListTargeting as N, unsafeAsDeclaredMimeType as Nn, parseUtcIsoDateTimeString as Nt, slugify as O, unsafeAsPassId as On, parseLocalScheduleTime as Ot, parseConfiguredMailingListProvider as P, unsafeAsDetectedMimeType as Pn, toUtcIsoDateTimeString as Pt, stableJsonStringify as Q, parseUserId as Qn, formatEventPricing as Qt, parseMailingListProviderScope as R, unsafeAsPositiveByteCount as Rn, isSettleableFlexibleBalanceContractStatus as Rt, orderedLiveRunSessions as S, unsafeAsAppointmentResourceId as Sn, formatLocalScheduleTime as St, createSecret as T, parseSiteTermsVersionId as Tn, getLocalScheduleTime as Tt, planMailingListChoicePresentation as U, unsafeAsStoragePath as Un, getBookingInstalmentPlanIntervalCount as Ut, parseMailingListPlacementTargeting as V, unsafeAsSiteScopedStoragePath as Vn, clampConfiguredAmount as Vt, isCanonicalRichTextDoc as W, unsafeAsUploadSessionId as Wn, getBookingInstalmentProtectedDepositAmountCents as Wt, SENSITIVE_COLLECTION_MODES as X, parseApiKeyId as Xn, parseEventPageSurfaceSubject as Xt, SENSITIVE_COLLECTION_CONFIRMATION_VERSION as Y, unsafeAsSiteFontId as Yn, deriveTotalTicketQuantity as Yt, decideLocationSave as Z, parseSiteId as Zn, formatBookingPriceDisplay as Zt, WHOLE_SERIES_EVENT_PRESET_VALUES as _, parseCurrencyCode as _n, resolveBookingDisplayContext as _t, resolveEventCatalogue as a, resolvePricingOptionsPriceDisplay as an, unsafeAsEventSeriesId as ar, toLocationCoordinates as at, CANCELLED_SESSION_STATUS as b, unsafeAsBookingRequirementId as bn, compareLocalScheduleDates as bt, areConfiguredBookingVerticalConfigsEqual as c, mapReadonlyNonEmptyArray as cn, err as cr, mapDrawingSchema as ct, parseVerticalPresetId as d, parsePositiveCents as dn, formatDateRange as dt, publicEventPricingCurrency as en, unsafeAsUserId as er, locationValueSchema as et, resolveSiteVerticalBookingConfig as f, toCents as fn, formatDateTime as ft, SURFACE_EVENT_PRESET_VALUES as g, formatCurrencyAmount as gn, inferSiteDateLocale as gt, ORDINARY_EVENT_PRESET_VALUES as h, unsafeAsPositiveCents as hn, formatTimeRange as ht, authoredValuesEqual as i, resolveExactOrFreePriceDisplay as in, unsafeAsEventOfferingId as ir, publicLocationSchema as it, parseMailingListSignedSourceToken as j, unsafeAsBookingSessionId as jn, toBookingTimeZone as jt, parseMailingListBlockId as k, parseDatedOfferingCapacityHoldAuditRef as kn, resolveBookingBusinessTimeZone as kt, canonicalizeConfiguredBookingVerticalConfig as l, isNonNegativeWholeCents as ln, ok as lr, selectCategoryView as lt, EVENT_PRESET_VALUES as m, unsafeAsNonNegativeCents as mn, formatTime as mt, committedWriteProofSchema as n, publicEventPricingOptions as nn, parseRetiredCourseId as nr, parseLocationValue as nt, EVENT_PRESET_VOCABULARY as o, fromArray as on, unsafeAsOccurrenceId as or, isPresent as ot, DEFAULT_EVENT_TYPE_PRESETS as p, toNonNegativeCents as pn, formatDateTimeRange as pt, parseWeeklyOpeningHours as q, parseEditorSessionGeneration as qn, resolveFlexibleBalanceDueAt as qt, isRecord as r, publicEventPricingType as rn, unsafeAsEventInstanceId as rr, projectPublicLocation as rt, NAVIGATION_LOCATIONS as s, mapNonEmptyArray as sn, unsafeAsPricingOptionId as sr, trimmedStringOrNull as st, OFFLINE_PAYMENT_METHODS as t, publicEventPricingDisplay as tn, parseEventSeriesId as tr, normalizeLocationAddressText as tt, parseVerticalId as u, parseNonNegativeCents as un, blockInteractionContextSchema as ur, formatDate as ut, getPublicReadCachePolicy as v, assertNever as vn, toScheduledBookingDateTime as vt, resolveWholeSeriesRunLifecycle as w, parseCustomerId as wn, getLocalScheduleDate as wt, nextLiveRunSessionStartMs as x, unsafeAsDemoCapability as xn, formatLocalScheduleDate as xt, publicReadFreshnessSeconds as y, formatDurationUnitLabel as yn, buildBookingUtcDateWindow as yt, parseFooterCompositionV1 as z, unsafeAsPositiveSeconds as zn, isSettleableOrderInstalmentPlanStatus as zt };
package/dist/testing.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import "./sdk-event-upsert-mPJpEQ2x.mjs";
3
- import "./src-DOwrYdTk.mjs";
4
- import { G as syncLocalMediaForPull, Gt as applyPushConfigPlan, Jt as preparePushConfigTarget, Mn as createOutput, W as syncLocalMediaForPush, at as readEntries, ht as writeMediaManifest, o as executeEntryCommandPlanAsSyncResult, t as compileEntryPushCommands, z as calculateEntryDiffs } from "./entryCommands-DqqGit0l.mjs";
5
- import "./load-config-Dgw0C6y3.mjs";
2
+ import "./sdk-event-upsert-RMUvPiD5.mjs";
3
+ import "./src-BntuEwG8.mjs";
4
+ import { G as syncLocalMediaForPull, Gt as applyPushConfigPlan, Jt as preparePushConfigTarget, Mn as createOutput, W as syncLocalMediaForPush, at as readEntries, ht as writeMediaManifest, o as executeEntryCommandPlanAsSyncResult, t as compileEntryPushCommands, z as calculateEntryDiffs } from "./entryCommands-BdWO_ZfG.mjs";
5
+ import "./load-config-C4powIPE.mjs";
6
6
 
7
7
  export { applyPushConfigPlan, calculateEntryDiffs, compileEntryPushCommands, createOutput, executeEntryCommandPlanAsSyncResult, preparePushConfigTarget, readEntries, syncLocalMediaForPull, syncLocalMediaForPush, writeMediaManifest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "riverbankcms",
3
- "version": "0.30.0",
3
+ "version": "0.30.1",
4
4
  "description": "Riverbank CMS command-line tools for SDK site developers",
5
5
  "bin": {
6
6
  "riverbankcms": "dist/cli/index.mjs"
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { t as loadConfigFile } from "./load-config-Dgw0C6y3.mjs";
3
-
4
- export { loadConfigFile };