@flamingo-stack/openframe-frontend-core 0.0.643 → 0.0.644-2208.6319.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.
- package/dist/chat-protocol/index.cjs +20 -3
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +20 -3
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/source-metadata.d.ts +7 -1
- package/dist/chat-protocol/source-metadata.d.ts.map +1 -1
- package/dist/{chunk-B42INNRA.cjs → chunk-2UA3DT5O.cjs} +199 -199
- package/dist/{chunk-B42INNRA.cjs.map → chunk-2UA3DT5O.cjs.map} +1 -1
- package/dist/{chunk-KX2FT7AS.cjs → chunk-2ZGEXLQW.cjs} +28 -28
- package/dist/{chunk-KX2FT7AS.cjs.map → chunk-2ZGEXLQW.cjs.map} +1 -1
- package/dist/{chunk-2NRLRRMR.cjs → chunk-3HSRNCDV.cjs} +226 -203
- package/dist/chunk-3HSRNCDV.cjs.map +1 -0
- package/dist/{chunk-64KDKDYC.js → chunk-5ELZ2NQ5.js} +6 -6
- package/dist/{chunk-2DJH6KHA.cjs → chunk-B46Q4DTN.cjs} +382 -386
- package/dist/chunk-B46Q4DTN.cjs.map +1 -0
- package/dist/{chunk-N7UYD57Q.js → chunk-C7RU466R.js} +3 -3
- package/dist/{chunk-2NODQ7FO.js → chunk-DSJZYRS6.js} +17 -21
- package/dist/{chunk-2NODQ7FO.js.map → chunk-DSJZYRS6.js.map} +1 -1
- package/dist/{chunk-26D6FM6L.cjs → chunk-EKSCVXA3.cjs} +6 -6
- package/dist/{chunk-26D6FM6L.cjs.map → chunk-EKSCVXA3.cjs.map} +1 -1
- package/dist/{chunk-7HL2PNQ3.js → chunk-GEGE3JXC.js} +5 -5
- package/dist/{chunk-7T673MHJ.cjs → chunk-GUB6BR26.cjs} +22 -22
- package/dist/{chunk-7T673MHJ.cjs.map → chunk-GUB6BR26.cjs.map} +1 -1
- package/dist/{chunk-3IPL6G7S.js → chunk-GXNQPCL4.js} +164 -141
- package/dist/chunk-GXNQPCL4.js.map +1 -0
- package/dist/{chunk-D6TWJEFW.cjs → chunk-GZXW5QWQ.cjs} +15 -15
- package/dist/{chunk-D6TWJEFW.cjs.map → chunk-GZXW5QWQ.cjs.map} +1 -1
- package/dist/{chunk-4TE53O6U.js → chunk-HAQRGJFL.js} +4 -4
- package/dist/{chunk-TIOHTWDA.js → chunk-INISTVWK.js} +6 -6
- package/dist/{chunk-IU3IYXMM.js → chunk-IRV2W7GN.js} +7 -7
- package/dist/{chunk-R2IU2Y2O.cjs → chunk-JWCAWGLG.cjs} +33 -33
- package/dist/{chunk-R2IU2Y2O.cjs.map → chunk-JWCAWGLG.cjs.map} +1 -1
- package/dist/{chunk-77EO26XV.cjs → chunk-LNLNPCII.cjs} +5 -5
- package/dist/{chunk-77EO26XV.cjs.map → chunk-LNLNPCII.cjs.map} +1 -1
- package/dist/{chunk-42NXGOTG.cjs → chunk-N3M56EE5.cjs} +3 -3
- package/dist/{chunk-42NXGOTG.cjs.map → chunk-N3M56EE5.cjs.map} +1 -1
- package/dist/{chunk-O7JMF5OT.js → chunk-O47SGDBV.js} +3 -3
- package/dist/{chunk-EWQI5MV6.cjs → chunk-OANRA5ML.cjs} +20 -20
- package/dist/{chunk-EWQI5MV6.cjs.map → chunk-OANRA5ML.cjs.map} +1 -1
- package/dist/{chunk-NCHLLTAR.js → chunk-PR6IR22M.js} +3 -3
- package/dist/{chunk-6MQBLFUM.js → chunk-Q7JDIDE2.js} +5 -5
- package/dist/{chunk-YG7KLZE7.js → chunk-R5EIFOW2.js} +4 -4
- package/dist/{chunk-5E6Y6766.cjs → chunk-S2E4I3WP.cjs} +29 -29
- package/dist/{chunk-5E6Y6766.cjs.map → chunk-S2E4I3WP.cjs.map} +1 -1
- package/dist/{chunk-SE6YRE3R.cjs → chunk-SAD5IUSO.cjs} +32 -32
- package/dist/{chunk-SE6YRE3R.cjs.map → chunk-SAD5IUSO.cjs.map} +1 -1
- package/dist/{chunk-3LXJEXPH.js → chunk-TAP4MJPF.js} +2 -2
- package/dist/{chunk-M3W5Y5DK.cjs → chunk-TEKH3J65.cjs} +11 -11
- package/dist/{chunk-M3W5Y5DK.cjs.map → chunk-TEKH3J65.cjs.map} +1 -1
- package/dist/{chunk-HA2U7WHU.js → chunk-TXNWDP3M.js} +3 -3
- package/dist/{chunk-IIZX3K2R.js → chunk-URGDDCJL.js} +2 -2
- package/dist/{chunk-TQ7KTANJ.js → chunk-V52INSJH.js} +3 -3
- package/dist/{chunk-FO7SD2IQ.cjs → chunk-VA6N7IVZ.cjs} +6 -6
- package/dist/{chunk-FO7SD2IQ.cjs.map → chunk-VA6N7IVZ.cjs.map} +1 -1
- package/dist/{chunk-CWHLVXUW.cjs → chunk-WYS66RIO.cjs} +10 -10
- package/dist/{chunk-CWHLVXUW.cjs.map → chunk-WYS66RIO.cjs.map} +1 -1
- package/dist/{chunk-XJLWGYL4.cjs → chunk-XVGWYNRY.cjs} +81 -81
- package/dist/{chunk-XJLWGYL4.cjs.map → chunk-XVGWYNRY.cjs.map} +1 -1
- package/dist/{chunk-ZU2JBBOE.cjs → chunk-XYJ3URIN.cjs} +59 -59
- package/dist/{chunk-ZU2JBBOE.cjs.map → chunk-XYJ3URIN.cjs.map} +1 -1
- package/dist/{chunk-FVIT23I5.js → chunk-Z5KAIEZ4.js} +3 -3
- package/dist/{chunk-YT6RGA3X.js → chunk-ZPLT4XLC.js} +3 -3
- package/dist/components/case-studies/index.cjs +16 -16
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +3 -9
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +2 -8
- package/dist/components/chat/types/entities/program-types.d.ts +29 -18
- package/dist/components/chat/types/entities/program-types.d.ts.map +1 -1
- package/dist/components/chat/utils/compact-card-classes.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +8 -8
- package/dist/components/docs/index.js +7 -7
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +5 -5
- package/dist/components/faq/index.js +4 -4
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +24 -24
- package/dist/components/help-center-pages/index.js +15 -15
- package/dist/components/index.cjs +53 -59
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +15 -21
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +34 -34
- package/dist/components/meeting-scheduler/index.js +3 -3
- package/dist/components/navigation/index.cjs +7 -7
- package/dist/components/navigation/index.js +6 -6
- package/dist/components/onboarding-guides/index.cjs +7 -7
- package/dist/components/onboarding-guides/index.js +6 -6
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/tickets/index.cjs +8 -8
- package/dist/components/tickets/index.js +7 -7
- package/dist/components/ui/index.cjs +4 -10
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +3 -9
- package/dist/index.cjs +24 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -14
- package/dist/index.js.map +1 -1
- package/dist/utils/format.d.ts +127 -4
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/index.cjs +113 -5
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +103 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/program-instant.d.ts +171 -0
- package/dist/utils/program-instant.d.ts.map +1 -0
- package/dist/utils/program-meta-renderers.d.ts +3 -0
- package/dist/utils/program-meta-renderers.d.ts.map +1 -0
- package/dist/utils/url-safety.d.ts +35 -0
- package/dist/utils/url-safety.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/chat-protocol/__tests__/source-metadata.test.ts +76 -0
- package/src/chat-protocol/source-metadata.ts +40 -6
- package/src/components/chat/entity-cards/.program-card.md +1 -1
- package/src/components/chat/entity-cards/dispatch.tsx +9 -27
- package/src/components/chat/entity-cards/program-card.tsx +42 -81
- package/src/components/chat/types/entities/program-types.ts +29 -89
- package/src/components/chat/utils/.compact-card-classes.md +1 -1
- package/src/components/chat/utils/compact-card-classes.ts +5 -3
- package/src/utils/.format.md +5 -2
- package/src/utils/__tests__/format-program-dates.test.ts +180 -0
- package/src/utils/__tests__/program-instant.test.ts +170 -0
- package/src/utils/__tests__/url-safety.test.ts +44 -0
- package/src/utils/format.ts +228 -13
- package/src/utils/index.ts +22 -0
- package/src/utils/program-instant.ts +211 -0
- package/src/utils/program-meta-renderers.ts +18 -0
- package/src/utils/url-safety.ts +45 -0
- package/dist/chunk-2DJH6KHA.cjs.map +0 -1
- package/dist/chunk-2NRLRRMR.cjs.map +0 -1
- package/dist/chunk-3IPL6G7S.js.map +0 -1
- /package/dist/{chunk-64KDKDYC.js.map → chunk-5ELZ2NQ5.js.map} +0 -0
- /package/dist/{chunk-N7UYD57Q.js.map → chunk-C7RU466R.js.map} +0 -0
- /package/dist/{chunk-7HL2PNQ3.js.map → chunk-GEGE3JXC.js.map} +0 -0
- /package/dist/{chunk-4TE53O6U.js.map → chunk-HAQRGJFL.js.map} +0 -0
- /package/dist/{chunk-TIOHTWDA.js.map → chunk-INISTVWK.js.map} +0 -0
- /package/dist/{chunk-IU3IYXMM.js.map → chunk-IRV2W7GN.js.map} +0 -0
- /package/dist/{chunk-O7JMF5OT.js.map → chunk-O47SGDBV.js.map} +0 -0
- /package/dist/{chunk-NCHLLTAR.js.map → chunk-PR6IR22M.js.map} +0 -0
- /package/dist/{chunk-6MQBLFUM.js.map → chunk-Q7JDIDE2.js.map} +0 -0
- /package/dist/{chunk-YG7KLZE7.js.map → chunk-R5EIFOW2.js.map} +0 -0
- /package/dist/{chunk-3LXJEXPH.js.map → chunk-TAP4MJPF.js.map} +0 -0
- /package/dist/{chunk-HA2U7WHU.js.map → chunk-TXNWDP3M.js.map} +0 -0
- /package/dist/{chunk-IIZX3K2R.js.map → chunk-URGDDCJL.js.map} +0 -0
- /package/dist/{chunk-TQ7KTANJ.js.map → chunk-V52INSJH.js.map} +0 -0
- /package/dist/{chunk-FVIT23I5.js.map → chunk-Z5KAIEZ4.js.map} +0 -0
- /package/dist/{chunk-YT6RGA3X.js.map → chunk-ZPLT4XLC.js.map} +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Which instant does a program render, in which zone, and does it have a clock
|
|
3
|
+
* at all" — ONE owner, shared by every surface that shows a webinar, event or
|
|
4
|
+
* podcast, in this package AND in the hub.
|
|
5
|
+
*
|
|
6
|
+
* WHY THIS EXISTS. A card must render every part of ONE timestamp in ONE zone.
|
|
7
|
+
* The date used to come from `item.date` while the time beside it came from
|
|
8
|
+
* `start_at` in the event's own IANA zone, so a webinar at
|
|
9
|
+
* `2026-03-20T01:18Z` / `America/New_York` read "Mar 20, 2026 · 9:18 PM" — a
|
|
10
|
+
* date and a time that never coexisted. That was fixed on the public card and
|
|
11
|
+
* then, because the chat card is a SEPARATE component that merely mirrors it in
|
|
12
|
+
* a comment, the chat card kept the bug — and rendered the date in the
|
|
13
|
+
* VIEWER's zone besides, which is also a React #418 hydration mismatch.
|
|
14
|
+
*
|
|
15
|
+
* Two components describing the same rule in prose is how that happens. They
|
|
16
|
+
* now call this. It lives in `utils/` rather than beside the chat cards
|
|
17
|
+
* because it is not chat-specific and because the hub's own program surfaces
|
|
18
|
+
* must be able to import it — while it sat unexported next to the cards, the
|
|
19
|
+
* hub re-derived it by hand and the copies drifted again, which is the third
|
|
20
|
+
* time this one rule has been re-stated.
|
|
21
|
+
*
|
|
22
|
+
* THE RULE:
|
|
23
|
+
*
|
|
24
|
+
* - `item.date` IS the instant to render. The host resolves it once, applying
|
|
25
|
+
* any admin display override, and hands the same value to the card, the
|
|
26
|
+
* model's context and the API wire. Preferring `start_at` looks like it buys
|
|
27
|
+
* intra-card coherence — it does, by disagreeing with everything else.
|
|
28
|
+
* - `start_at` / `end_at` remain the source for DURATION, which is elapsed time
|
|
29
|
+
* rather than a display date.
|
|
30
|
+
* - A DISPLAY OVERRIDE is a chosen date, not a moment. An admin backdating in a
|
|
31
|
+
* `datetime-local` control gets `00:00`, so "show this as March 19" is stored
|
|
32
|
+
* at UTC midnight; rendering that in a west-of-UTC zone shows March 18 at
|
|
33
|
+
* 8 PM — a day early, at a time nobody chose. Such a value renders UTC-pinned
|
|
34
|
+
* with no clock and WITHOUT A ZONE LABEL.
|
|
35
|
+
*
|
|
36
|
+
* The discriminator is "did an override supply this", NOT the value's
|
|
37
|
+
* precision. The override column is `timestamptz` and the host normalizes it
|
|
38
|
+
* through `toISOString()`, so it is always a full instant — an earlier
|
|
39
|
+
* attempt keyed on precision and could therefore never fire.
|
|
40
|
+
*
|
|
41
|
+
* THE ZONE IS NULLED RATHER THAN FLAGGED, deliberately. `timezone` here is "the
|
|
42
|
+
* zone this value renders in and may be labelled with", so a day-valued row
|
|
43
|
+
* carries none and a consumer CANNOT print `America/New_York` under a clock the
|
|
44
|
+
* rule just suppressed. Three surfaces had to remember that gate; two forgot,
|
|
45
|
+
* and one of them rendered a bare IANA string under an empty heading. A rule
|
|
46
|
+
* enforced by the shape of the data cannot be forgotten by the next call site.
|
|
47
|
+
*
|
|
48
|
+
* There is deliberately NO escape hatch back to the un-nulled zone. One was
|
|
49
|
+
* added ("for the rare consumer that needs it as data") and no consumer ever
|
|
50
|
+
* wanted it — an un-nulled copy hanging off the resolved value is just the
|
|
51
|
+
* mistake again, one property away.
|
|
52
|
+
*/
|
|
53
|
+
/** Read a string field off an item type that does not declare it. */
|
|
54
|
+
export declare const programStr: (value: unknown) => string | null;
|
|
55
|
+
export interface ProgramInstant {
|
|
56
|
+
/** The instant both the date and the time render from, or null to fall back
|
|
57
|
+
* to `utcDate`. */
|
|
58
|
+
instant: string | null;
|
|
59
|
+
/** The zone this value RENDERS IN and may be LABELLED with. Null when the row
|
|
60
|
+
* declares none, and null when the value is day-valued — see the note above
|
|
61
|
+
* on why this is nulled rather than flagged. */
|
|
62
|
+
timezone: string | null;
|
|
63
|
+
/** True when an admin display override supplied the value: render the day
|
|
64
|
+
* UTC-pinned, with no clock. */
|
|
65
|
+
dateOnly: boolean;
|
|
66
|
+
/** The row's canonical date string, used when there is no zone to render in.
|
|
67
|
+
* Kept on the resolved value so the UTC fallback is not re-derived (and
|
|
68
|
+
* re-formatted differently) at each call site. */
|
|
69
|
+
utcDate: string | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The columns this rule reads. Declared structurally rather than as a
|
|
73
|
+
* `Record<string, unknown>` so a caller holding a real `BaseProgramItem` can
|
|
74
|
+
* pass it straight in: while the parameter was a bare record, every one of the
|
|
75
|
+
* four call sites wrote `as unknown as Record<string, unknown>`, and a cast at
|
|
76
|
+
* every call site is how a producer that forgets to set the flag goes
|
|
77
|
+
* unnoticed by the compiler.
|
|
78
|
+
*/
|
|
79
|
+
export interface ProgramDateFields {
|
|
80
|
+
date?: unknown;
|
|
81
|
+
start_at?: unknown;
|
|
82
|
+
end_at?: unknown;
|
|
83
|
+
timezone?: unknown;
|
|
84
|
+
date_is_display_override?: unknown;
|
|
85
|
+
}
|
|
86
|
+
/** Resolve what a program item should render. */
|
|
87
|
+
export declare function programDateInstant(item: ProgramDateFields): ProgramInstant;
|
|
88
|
+
/**
|
|
89
|
+
* The scheduling columns the DURATION is measured from — the pair that rides
|
|
90
|
+
* beside a resolved instant.
|
|
91
|
+
*
|
|
92
|
+
* Here rather than at each surface because five call sites projected these two
|
|
93
|
+
* columns in four different shapes (`programStr`, raw reads, `?? null`, and an
|
|
94
|
+
* `in`-guarded cast), which is the same defect one field-pair down from the one
|
|
95
|
+
* this module exists to fix. They are read off the row, never off the resolved
|
|
96
|
+
* instant, because elapsed time is not a display date: an override moves the
|
|
97
|
+
* day shown, and a webinar still runs for 45 minutes.
|
|
98
|
+
*/
|
|
99
|
+
export declare function webinarTiming(item: ProgramDateFields): {
|
|
100
|
+
startAt: string | null;
|
|
101
|
+
endAt: string | null;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* THE compact meta line a program renders under its title:
|
|
105
|
+
* `"<day> · <type-specific>"` — podcast duration, event location, or webinar
|
|
106
|
+
* time + duration.
|
|
107
|
+
*
|
|
108
|
+
* The public card and the chat card built this separately, under a comment
|
|
109
|
+
* saying the second "mirrors" the first. That is the arrangement this module
|
|
110
|
+
* exists to end: the mirror drifted twice (the chat card rendered the day in
|
|
111
|
+
* the VIEWER's zone, and the two disagreed about labelling the zone on a
|
|
112
|
+
* zoneless row), each time only on the copy nobody was looking at.
|
|
113
|
+
*
|
|
114
|
+
* `kind` rather than the caller's config object, because the two callers key
|
|
115
|
+
* off differently-shaped configs for the same three types.
|
|
116
|
+
*/
|
|
117
|
+
export declare function programMetaLine(item: ProgramDateFields & {
|
|
118
|
+
status?: unknown;
|
|
119
|
+
duration_seconds?: unknown;
|
|
120
|
+
location_name?: unknown;
|
|
121
|
+
}, kind: 'podcast' | 'event' | 'webinar' | (string & {}), fmt: {
|
|
122
|
+
date: (at: ProgramInstant) => string;
|
|
123
|
+
duration: (seconds: number) => string;
|
|
124
|
+
webinarMeta: (at: ProgramInstant, opts: {
|
|
125
|
+
startAt: string | null;
|
|
126
|
+
endAt: string | null;
|
|
127
|
+
}) => string;
|
|
128
|
+
}): {
|
|
129
|
+
at: ProgramInstant;
|
|
130
|
+
typeMeta: string | null;
|
|
131
|
+
line: string;
|
|
132
|
+
};
|
|
133
|
+
/** The shape `programMetaFormatters` adapts — the three renderers a program
|
|
134
|
+
* meta line is built from, supplied by the caller so this leaf stays free of
|
|
135
|
+
* `./format`. */
|
|
136
|
+
export interface ProgramMetaRenderers {
|
|
137
|
+
date: (at: ProgramInstant, style: 'medium' | 'weekday') => string;
|
|
138
|
+
duration: (seconds: number | null) => string;
|
|
139
|
+
webinarMeta: (at: ProgramInstant, opts: {
|
|
140
|
+
startAt: string | null;
|
|
141
|
+
endAt: string | null;
|
|
142
|
+
withZoneLabel?: boolean;
|
|
143
|
+
}) => string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The formatter set `programMetaLine` needs, built once.
|
|
147
|
+
*
|
|
148
|
+
* `programMetaLine` unified the DISPATCH; the three formatters passed into it
|
|
149
|
+
* were then mirrored byte-for-byte across the two components the function
|
|
150
|
+
* exists to keep in sync, plus a second `withZoneLabel: false` variant in two
|
|
151
|
+
* more. A mirrored block in exactly those files is the arrangement this module
|
|
152
|
+
* documents as the cause of the original drift.
|
|
153
|
+
*
|
|
154
|
+
* `withZoneLabel` is the only axis: a compact density joins plain strings so
|
|
155
|
+
* the zone rides inline, while the default density renders it as its own styled
|
|
156
|
+
* span and asks for the value without it.
|
|
157
|
+
*
|
|
158
|
+
* Takes its formatters as arguments rather than importing them, so this leaf
|
|
159
|
+
* stays free of `./format` and the two can be tree-shaken apart.
|
|
160
|
+
*/
|
|
161
|
+
export declare function programMetaFormatters(fmt: ProgramMetaRenderers, opts?: {
|
|
162
|
+
withZoneLabel?: boolean;
|
|
163
|
+
}): {
|
|
164
|
+
date: (at: ProgramInstant) => string;
|
|
165
|
+
duration: (seconds: number | null) => string;
|
|
166
|
+
webinarMeta: (at: ProgramInstant, o: {
|
|
167
|
+
startAt: string | null;
|
|
168
|
+
endAt: string | null;
|
|
169
|
+
}) => string;
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=program-instant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-instant.d.ts","sourceRoot":"","sources":["../../src/utils/program-instant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,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B,EAAE,oBAIpC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL-safety primitives shared by the wire DECODER and the render-time guard.
|
|
3
|
+
*
|
|
4
|
+
* Both layers ask the same two questions — "does this string carry characters
|
|
5
|
+
* that have no business in an href" and "does this path stay on our origin" —
|
|
6
|
+
* and both used to answer them with their own copy. A security predicate kept
|
|
7
|
+
* in sync by a comment saying "same set the other one rejects" is a predicate
|
|
8
|
+
* that drifts: the copies already differed on the backslash case, which is how
|
|
9
|
+
* a path resolving to a third-party origin reached an anchor tag.
|
|
10
|
+
*
|
|
11
|
+
* Pure and dependency-free, so the server-safe `chat-protocol` leaf and the
|
|
12
|
+
* client-side card utils can both import it directly.
|
|
13
|
+
*
|
|
14
|
+
* What is NOT shared, deliberately: which SCHEMES each layer allows. The
|
|
15
|
+
* decoder is stricter (https only) because it ingests a remote MCP server's
|
|
16
|
+
* output; the renderer also permits http and mailto. That difference is a
|
|
17
|
+
* policy choice each layer states for itself.
|
|
18
|
+
*/
|
|
19
|
+
/** Control, zero-width and line-separator characters. Never legitimate in a URL
|
|
20
|
+
* we are about to render, and the classic way a payload smuggles one href past
|
|
21
|
+
* a reader's eye. */
|
|
22
|
+
export declare const UNSAFE_URL_CHARS: RegExp;
|
|
23
|
+
/**
|
|
24
|
+
* Does this candidate stay on the CURRENT origin?
|
|
25
|
+
*
|
|
26
|
+
* Decided by RESOLVING it, never by inspecting the prefix. A prefix test is
|
|
27
|
+
* what a reader reaches for — `startsWith('//')` — and it is not sufficient:
|
|
28
|
+
* the URL parser treats a backslash as a slash in the authority position, so a
|
|
29
|
+
* single-slash path can still resolve to a third-party host while passing every
|
|
30
|
+
* "starts with exactly one slash" check. Any future parser quirk falls to the
|
|
31
|
+
* same class. Asking the parser cannot disagree with what the browser will
|
|
32
|
+
* actually do with the href.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isSameOriginPath(candidate: string): boolean;
|
|
35
|
+
//# sourceMappingURL=url-safety.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-safety.d.ts","sourceRoot":"","sources":["../../src/utils/url-safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;sBAEsB;AACtB,eAAO,MAAM,gBAAgB,QAAyD,CAAC;AAKvF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAM3D"}
|
package/package.json
CHANGED
|
@@ -117,6 +117,55 @@ describe('sourceMetadataEvent', () => {
|
|
|
117
117
|
expect(event?.sources?.[0]).not.toHaveProperty('externalUrl');
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
// A same-origin href is the hub's NORMAL output when the owning platform is
|
|
121
|
+
// the serving platform. Dropping it left every guide chip with a name and no
|
|
122
|
+
// destination, before the consumer's own absolutiser could ever run.
|
|
123
|
+
it('keeps a root-relative external URL', () => {
|
|
124
|
+
const event = sourceMetadataEvent({
|
|
125
|
+
sources: [
|
|
126
|
+
{
|
|
127
|
+
index: 1,
|
|
128
|
+
name: 'Guide',
|
|
129
|
+
path: 'onboarding-guides/x',
|
|
130
|
+
documentType: 'onboarding_guide',
|
|
131
|
+
externalUrl: '/onboarding-guides/x',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
});
|
|
135
|
+
expect(event?.sources?.[0].externalUrl).toBe('/onboarding-guides/x');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('keeps a root-relative external URL on a grouped item', () => {
|
|
139
|
+
const event = sourceMetadataEvent({
|
|
140
|
+
sources: [
|
|
141
|
+
{
|
|
142
|
+
index: 1,
|
|
143
|
+
name: 'Guides',
|
|
144
|
+
items: [{ id: 'a', documentType: 'onboarding_guide', name: 'A', externalUrl: '/onboarding-guides/a' }],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
expect(event?.sources?.[0].items?.[0].externalUrl).toBe('/onboarding-guides/a');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('drops a protocol-relative URL, which is a third-party origin and not a path', () => {
|
|
152
|
+
const event = sourceMetadataEvent({
|
|
153
|
+
sources: [{ index: 1, name: 'Doc', path: 'docs/x', documentType: 'markdown', externalUrl: '//evil.test/x' }],
|
|
154
|
+
});
|
|
155
|
+
expect(event?.sources?.[0]).not.toHaveProperty('externalUrl');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('drops an href carrying control or zero-width characters', () => {
|
|
159
|
+
const event = sourceMetadataEvent({
|
|
160
|
+
sources: [
|
|
161
|
+
{ index: 1, name: 'A', externalUrl: '/docs/\u200bx' },
|
|
162
|
+
{ index: 2, name: 'B', externalUrl: 'https://x.test/\u0000y' },
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
expect(event?.sources?.[0]).not.toHaveProperty('externalUrl');
|
|
166
|
+
expect(event?.sources?.[1]).not.toHaveProperty('externalUrl');
|
|
167
|
+
});
|
|
168
|
+
|
|
120
169
|
it('preserves an explicit null targetPlatform, which means "no destination"', () => {
|
|
121
170
|
const event = sourceMetadataEvent({
|
|
122
171
|
sources: [{ index: 1, name: 'Doc', path: 'docs/x', documentType: 'markdown', targetPlatform: null }],
|
|
@@ -241,3 +290,30 @@ describe('mergeSourceMetadata', () => {
|
|
|
241
290
|
expect(mergeSourceMetadata(null, { type: 'sources' })).toEqual({});
|
|
242
291
|
});
|
|
243
292
|
});
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Origin-escape via the URL parser's backslash handling.
|
|
296
|
+
*
|
|
297
|
+
* `/\evil.test/x` starts with exactly one slash, so every prefix-based
|
|
298
|
+
* "is this same-origin" test accepts it — and then the parser resolves it to
|
|
299
|
+
* `https://evil.test/x`, because a backslash is a slash in the authority
|
|
300
|
+
* position. The href lands in a real `<a>` in the chat panel, built from a
|
|
301
|
+
* remote MCP server's output. Resolving the candidate and comparing origins is
|
|
302
|
+
* the only check that cannot disagree with what the browser will do.
|
|
303
|
+
*/
|
|
304
|
+
describe('linkUrl rejects origin escapes that look like paths', () => {
|
|
305
|
+
const escapes = ['/\\evil.test/x', '/\\\\evil.test/x', '//evil.test/x', '/\\/evil.test/x'];
|
|
306
|
+
it.each(escapes)('drops %s', href => {
|
|
307
|
+
const event = sourceMetadataEvent({
|
|
308
|
+
sources: [{ index: 1, name: 'Doc', path: 'docs/x', documentType: 'markdown', externalUrl: href }],
|
|
309
|
+
});
|
|
310
|
+
expect(event?.sources?.[0]).not.toHaveProperty('externalUrl');
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('still keeps a genuine same-origin path', () => {
|
|
314
|
+
const event = sourceMetadataEvent({
|
|
315
|
+
sources: [{ index: 1, name: 'Guide', externalUrl: '/onboarding-guides/set-up-sso' }],
|
|
316
|
+
});
|
|
317
|
+
expect(event?.sources?.[0].externalUrl).toBe('/onboarding-guides/set-up-sso');
|
|
318
|
+
});
|
|
319
|
+
});
|
|
@@ -10,13 +10,20 @@
|
|
|
10
10
|
* Everything is validated, and anything that fails is DROPPED rather than
|
|
11
11
|
* repaired: this payload is assembled from a remote MCP server's tool output,
|
|
12
12
|
* so a malformed row means an upstream contract slip, and rendering a chip with
|
|
13
|
-
* a blank title or
|
|
13
|
+
* a blank title or an unsafe href is worse than rendering nothing.
|
|
14
|
+
*
|
|
15
|
+
* "Unsafe" is the operative word, and it is not a synonym for "relative".
|
|
16
|
+
* Links go through `linkUrl` (absolute https OR a root-relative path); only
|
|
17
|
+
* MEDIA urls, which have no origin to resolve against, go through `httpsUrl`.
|
|
18
|
+
* Conflating the two is what made every same-origin source chip lose its
|
|
19
|
+
* destination while keeping its name.
|
|
14
20
|
*
|
|
15
21
|
* Server-safe: no React, no browser APIs beyond `URL`.
|
|
16
22
|
*/
|
|
17
23
|
|
|
18
24
|
import type { ChatRef } from '../components/chat/chat-ref.types';
|
|
19
25
|
import type { ChatSource } from '../components/chat/types/message.types';
|
|
26
|
+
import { UNSAFE_URL_CHARS, isSameOriginPath } from '../utils/url-safety';
|
|
20
27
|
import { CARD_REFERENCE } from './card-marker';
|
|
21
28
|
import type { SourcesEvent } from './events';
|
|
22
29
|
import { isRecord } from './wire-narrow';
|
|
@@ -44,11 +51,13 @@ function nullableText(value: unknown): string | null | undefined {
|
|
|
44
51
|
return value === null ? null : text(value);
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
/** An https URL, or nothing. Plain http and non-URLs are dropped —
|
|
48
|
-
*
|
|
54
|
+
/** An absolute https URL, or nothing. Plain http and non-URLs are dropped —
|
|
55
|
+
* these become MEDIA sources (`<video src>`, poster images), which have no
|
|
56
|
+
* origin to resolve against and so must be absolute. For a LINK, use
|
|
57
|
+
* `linkUrl` — a same-origin path is valid there and this would discard it. */
|
|
49
58
|
function httpsUrl(value: unknown): string | undefined {
|
|
50
59
|
const candidate = text(value);
|
|
51
|
-
if (!candidate) return undefined;
|
|
60
|
+
if (!candidate || UNSAFE_URL_CHARS.test(candidate)) return undefined;
|
|
52
61
|
try {
|
|
53
62
|
return new URL(candidate).protocol === 'https:' ? candidate : undefined;
|
|
54
63
|
} catch {
|
|
@@ -56,6 +65,31 @@ function httpsUrl(value: unknown): string | undefined {
|
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
|
|
68
|
+
/**
|
|
69
|
+
* A URL that is safe to render as a source chip's href: an absolute https URL,
|
|
70
|
+
* or a ROOT-RELATIVE path (`/onboarding-guides/foo`).
|
|
71
|
+
*
|
|
72
|
+
* Root-relative is the whole reason this exists separately from `httpsUrl`.
|
|
73
|
+
* The hub emits a relative href whenever the owning platform is the serving
|
|
74
|
+
* platform — correct for its own chat, and correct for any consumer that knows
|
|
75
|
+
* the hub origin (the dashboard absolutises hub-owned hrefs itself). Running
|
|
76
|
+
* `new URL()` with no base on such a path THROWS, so treating "not an absolute
|
|
77
|
+
* https URL" as hostile silently deleted every same-origin link before the code
|
|
78
|
+
* that would have resolved it ever ran, leaving a chip with a name and no
|
|
79
|
+
* destination.
|
|
80
|
+
*
|
|
81
|
+
* Deliberately STRICTER than the render-time `safeHref`, which also permits
|
|
82
|
+
* `http:` and `mailto:`. This payload is assembled from a remote MCP server's
|
|
83
|
+
* tool output, so the ingest guard stays fail-closed on scheme; the two differ
|
|
84
|
+
* on purpose, and only in the safe direction.
|
|
85
|
+
*/
|
|
86
|
+
function linkUrl(value: unknown): string | undefined {
|
|
87
|
+
const candidate = text(value);
|
|
88
|
+
if (!candidate || UNSAFE_URL_CHARS.test(candidate)) return undefined;
|
|
89
|
+
if (candidate.startsWith('/')) return isSameOriginPath(candidate) ? candidate : undefined;
|
|
90
|
+
return httpsUrl(candidate);
|
|
91
|
+
}
|
|
92
|
+
|
|
59
93
|
/**
|
|
60
94
|
* A YouTube video id, from either a bare id or any of the watch/short/embed URL
|
|
61
95
|
* shapes. Returns the ID, never a URL — the player takes an id.
|
|
@@ -89,7 +123,7 @@ function sourceItems(value: unknown): NonNullable<ChatSource['items']> | undefin
|
|
|
89
123
|
// A grouped row without these three has nothing to render OR navigate with.
|
|
90
124
|
if (!id || !documentType || !name) return [];
|
|
91
125
|
|
|
92
|
-
const externalUrl =
|
|
126
|
+
const externalUrl = linkUrl(item.externalUrl);
|
|
93
127
|
const targetPlatform = nullableText(item.targetPlatform);
|
|
94
128
|
const path = nullableText(item.path);
|
|
95
129
|
return [
|
|
@@ -133,7 +167,7 @@ function sources(value: unknown): ChatSource[] {
|
|
|
133
167
|
|
|
134
168
|
const path = text(candidate.path);
|
|
135
169
|
const documentType = text(candidate.documentType);
|
|
136
|
-
const externalUrl =
|
|
170
|
+
const externalUrl = linkUrl(candidate.externalUrl);
|
|
137
171
|
const targetPlatform = nullableText(candidate.targetPlatform);
|
|
138
172
|
const id = text(candidate.id);
|
|
139
173
|
const sourceRepo = text(candidate.sourceRepo);
|
|
@@ -11,7 +11,7 @@ Presentation-only card component for programs (podcasts, webinars, events) suppo
|
|
|
11
11
|
|
|
12
12
|
### Internal Utilities
|
|
13
13
|
|
|
14
|
-
-
|
|
14
|
+
- **Dates** — resolved by `programDateInstant` and rendered by `formatProgramDate` / `formatWebinarTimeMeta` (`../../../utils`), shared with the public page header. A local `formatUtc` twin used to live here; the UTC pin that prevents React #418 is already inside `formatDateWithTimezone` when it is given no zone.
|
|
15
15
|
- **`getHosts(hosts)`** — Normalizes `ProgramHost[]` or raw JSON string into `{ name, avatar }[]`
|
|
16
16
|
- **`MediaGallery`** — Horizontally scrollable thumbnail strip with `ImageGalleryModal` lightbox on click
|
|
17
17
|
|
|
@@ -35,12 +35,9 @@ import Image from '../../../embed-shims/next-image';
|
|
|
35
35
|
import { useRouter } from '../../../embed-shims/next-navigation';
|
|
36
36
|
import { formatDateShort } from '../../../utils/date-formatters';
|
|
37
37
|
import { faqItemAnchor } from '../../../utils/faq-anchor';
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
formatTimeWithTimezone,
|
|
42
|
-
formatDurationFromRange,
|
|
43
|
-
} from '../../../utils/format';
|
|
38
|
+
import { formatDateUTC as formatDate } from '../../../utils/format';
|
|
39
|
+
import { programMetaFormatters, programMetaLine } from '../../../utils/program-instant';
|
|
40
|
+
import { PROGRAM_META_RENDERERS } from '../../../utils/program-meta-renderers';
|
|
44
41
|
import { MingoIcon } from '../../icons';
|
|
45
42
|
import { ArrowRightUpIcon } from '../../icons-v2-generated/arrows/arrow-right-up-icon';
|
|
46
43
|
import { ClickupLogoIcon } from '../../icons-v2-generated/brand-logos/clickup-logo-icon';
|
|
@@ -1105,27 +1102,12 @@ function ProgramChatCard({
|
|
|
1105
1102
|
<MicrophoneIcon size={24} />
|
|
1106
1103
|
);
|
|
1107
1104
|
|
|
1108
|
-
//
|
|
1109
|
-
//
|
|
1110
|
-
//
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
configKey === 'podcast' &&
|
|
1115
|
-
typeof item?.duration_seconds === 'number' &&
|
|
1116
|
-
item.duration_seconds > 0 &&
|
|
1117
|
-
!isScheduled
|
|
1118
|
-
) {
|
|
1119
|
-
typeMeta = formatDurationCompact(item.duration_seconds);
|
|
1120
|
-
} else if (configKey === 'event' && typeof item?.location_name === 'string' && item.location_name.trim().length > 0) {
|
|
1121
|
-
typeMeta = item.location_name;
|
|
1122
|
-
} else if (configKey === 'webinar' && item?.start_at) {
|
|
1123
|
-
const time = formatTimeWithTimezone(item.start_at, item.timezone ?? null);
|
|
1124
|
-
const dur = formatDurationFromRange(item.start_at, item.end_at);
|
|
1125
|
-
typeMeta = dur ? `${time} · ${dur}` : time;
|
|
1126
|
-
}
|
|
1127
|
-
const itemDate = formatDate(item?.date ?? null, { fallback: '', timezone: 'local' });
|
|
1128
|
-
const meta = [itemDate, typeMeta].filter(Boolean).join(' · ');
|
|
1105
|
+
// The compact meta line, built by the SAME function the public card uses.
|
|
1106
|
+
// This block used to mirror that one in prose — and drifted twice: it rendered
|
|
1107
|
+
// the DATE in the VIEWER's zone (`timezone: 'local'`) beside a time in the
|
|
1108
|
+
// EVENT's zone, and it labelled the zone on a different condition. The type
|
|
1109
|
+
// label itself lives in the status pill, so it is omitted here.
|
|
1110
|
+
const { line: meta } = programMetaLine(item ?? {}, configKey, programMetaFormatters(PROGRAM_META_RENDERERS));
|
|
1129
1111
|
|
|
1130
1112
|
return (
|
|
1131
1113
|
<EntityMingoCard
|