@burdenoff/microfe-timecampus 2026.1124.1 → 2026.1124.2
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/generated/wspace-operations.d.ts +977 -1
- package/dist/generated/wspace-operations.js +1749 -1458
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +241 -1
- package/dist/generated/wspace-types.js +8 -6
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.js +8 -8
- package/dist/timecampus/index.js +2 -2
- package/dist/timecampus/pages/extend/AppletDeveloperPage.js +519 -245
- package/dist/timecampus/pages/extend/AppletDeveloperPage.js.map +1 -1
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js +147 -113
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js.map +1 -1
- package/dist/timecampus/pages/extend/SandboxedAppletWidget.d.ts +2 -0
- package/dist/timecampus/pages/extend/SandboxedAppletWidget.js +3 -1
- package/dist/timecampus/pages/extend/SandboxedAppletWidget.js.map +1 -1
- package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js +369 -120
- package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js.map +1 -1
- package/dist/timecampus/pages/extend/appletPublishingHelpers.d.ts +10 -0
- package/dist/timecampus/pages/extend/appletPublishingHelpers.js +74 -16
- package/dist/timecampus/pages/extend/appletPublishingHelpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TimeCampusAppletSource } from '../../../generated/wspace-types';
|
|
1
2
|
export interface AppletWidgetFrame {
|
|
2
3
|
appletKey: string;
|
|
3
4
|
appletName: string;
|
|
@@ -6,6 +7,7 @@ export interface AppletWidgetFrame {
|
|
|
6
7
|
origin: string;
|
|
7
8
|
height: number;
|
|
8
9
|
grantedScopes: string[];
|
|
10
|
+
source?: TimeCampusAppletSource | null;
|
|
9
11
|
}
|
|
10
12
|
export declare function SandboxedAppletWidget({ frame, title, }: {
|
|
11
13
|
frame: AppletWidgetFrame;
|
|
@@ -21,7 +21,8 @@ function h({ frame: h, title: g }) {
|
|
|
21
21
|
query: e,
|
|
22
22
|
variables: {
|
|
23
23
|
appletKey: h.appletKey,
|
|
24
|
-
scope: c.scope
|
|
24
|
+
scope: c.scope,
|
|
25
|
+
...h.source ? { source: h.source } : {}
|
|
25
26
|
},
|
|
26
27
|
fetchPolicy: "no-cache"
|
|
27
28
|
}).then((e) => {
|
|
@@ -36,6 +37,7 @@ function h({ frame: h, title: g }) {
|
|
|
36
37
|
b,
|
|
37
38
|
_,
|
|
38
39
|
h.appletKey,
|
|
40
|
+
h.source,
|
|
39
41
|
x
|
|
40
42
|
]), x ? /* @__PURE__ */ p("div", {
|
|
41
43
|
className: "flex flex-col gap-1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxedAppletWidget.js","names":["currentTheme","SandboxedAppletWidget","client","useApolloClient","iframeRef","useRef","rateLimiter","createRateLimiter","allowed","useMemo","frame","frameable","isFrameableUrl","useEffect","withinRate","reply","message","onMessage","own","event","request","parseAppletRequest","GetAppletBridgeDataDocument","data","result","bridgeResponse","bridgeErrorMessage","err","APPLET_IFRAME_SANDBOX","target","bridgeInit"],"sources":["../../../../src/timecampus/pages/extend/SandboxedAppletWidget.tsx"],"sourcesContent":["/**\n * Sandboxed third-party widget (BOFF-10827).\n *\n * Renders an installed third-party applet's widget in an iframe sandboxed to\n * scripts only and answers its data requests over the postMessage bridge in\n * appletBridge.ts. The iframe gets no token and no same-origin access; the\n * host checks every request's source and scope, and the service checks the\n * workspace's grant again before it returns data.\n */\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useApolloClient } from \"@apollo/client/react\";\nimport {\n GetAppletBridgeDataDocument,\n type GetAppletBridgeDataQuery,\n type GetAppletBridgeDataQueryVariables,\n} from \"@/generated/wspace-operations\";\nimport {\n APPLET_IFRAME_SANDBOX,\n bridgeErrorMessage,\n bridgeInit,\n bridgeResponse,\n createRateLimiter,\n isFrameableUrl,\n parseAppletRequest,\n} from \"./appletBridge\";\n\nexport interface AppletWidgetFrame {\n appletKey: string;\n appletName: string;\n widgetKey: string;\n url: string;\n origin: string;\n height: number;\n grantedScopes: string[];\n}\n\nfunction currentTheme(): \"light\" | \"dark\" {\n return document.documentElement.classList.contains(\"dark\") ? \"dark\" : \"light\";\n}\n\nexport function SandboxedAppletWidget({\n frame,\n title,\n}: {\n frame: AppletWidgetFrame;\n title: string;\n}) {\n const client = useApolloClient();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n // One limiter per mounted widget, so re-running the effect never resets the window.\n const rateLimiter = useRef(createRateLimiter());\n const allowed = useMemo(\n () => new Set(frame.grantedScopes),\n [frame.grantedScopes],\n );\n const frameable = isFrameableUrl(frame.url, frame.origin);\n\n useEffect(() => {\n if (!frameable) return undefined;\n const withinRate = rateLimiter.current;\n // A sandboxed frame has an opaque origin, so replies cannot be addressed\n // to an origin; they go only to this iframe's window and carry nothing\n // beyond what the workspace granted.\n const reply = (target: MessageEventSource, message: unknown) => {\n (target as Window).postMessage(message, \"*\");\n };\n\n const onMessage = (event: MessageEvent) => {\n const own = iframeRef.current?.contentWindow;\n if (!own || event.source !== own) return;\n const request = parseAppletRequest(event.data);\n if (!request) return;\n if (!withinRate()) {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: \"Too many requests; try again in a minute.\",\n }),\n );\n return;\n }\n if (!allowed.has(request.scope)) {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: \"This workspace has not granted that data scope.\",\n }),\n );\n return;\n }\n void client\n .query({\n query: GetAppletBridgeDataDocument,\n variables: {\n appletKey: frame.appletKey,\n scope: request.scope,\n } satisfies GetAppletBridgeDataQueryVariables,\n fetchPolicy: \"no-cache\",\n })\n .then((result) => {\n const data = (result.data as GetAppletBridgeDataQuery | undefined)\n ?.timeCampusAppletBridgeData;\n reply(\n own,\n bridgeResponse(\n request.requestId,\n data ? { data } : { error: \"No data was returned.\" },\n ),\n );\n })\n .catch((err: unknown) => {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: bridgeErrorMessage(err),\n }),\n );\n });\n };\n\n window.addEventListener(\"message\", onMessage);\n return () => window.removeEventListener(\"message\", onMessage);\n }, [allowed, client, frame.appletKey, frameable]);\n\n if (!frameable) {\n return (\n <p className=\"text-sm text-text-secondary\">\n This widget's address is not allowed.\n </p>\n );\n }\n\n const sendInit = () => {\n const target = iframeRef.current?.contentWindow;\n if (!target) return;\n target.postMessage(bridgeInit(frame, currentTheme()), \"*\");\n };\n\n return (\n <div className=\"flex flex-col gap-1\">\n <iframe\n ref={iframeRef}\n src={frame.url}\n title={title}\n sandbox={APPLET_IFRAME_SANDBOX}\n referrerPolicy=\"no-referrer\"\n allow=\"\"\n loading=\"lazy\"\n onLoad={sendInit}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface\"\n style={{ height: frame.height }}\n data-testid={`applet-frame-${frame.appletKey}-${frame.widgetKey}`}\n />\n <p className=\"text-xs text-text-tertiary\">\n Third-party widget by {frame.appletName}. It only sees{\" \"}\n {frame.grantedScopes.length === 0\n ? \"no TimeCampus data\"\n : \"the data scopes this workspace granted\"}\n .\n </p>\n </div>\n );\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"SandboxedAppletWidget.js","names":["currentTheme","SandboxedAppletWidget","client","useApolloClient","iframeRef","useRef","rateLimiter","createRateLimiter","allowed","useMemo","frame","frameable","isFrameableUrl","useEffect","withinRate","reply","message","onMessage","own","event","request","parseAppletRequest","GetAppletBridgeDataDocument","data","result","bridgeResponse","bridgeErrorMessage","err","APPLET_IFRAME_SANDBOX","target","bridgeInit"],"sources":["../../../../src/timecampus/pages/extend/SandboxedAppletWidget.tsx"],"sourcesContent":["/**\n * Sandboxed third-party widget (BOFF-10827).\n *\n * Renders an installed third-party applet's widget in an iframe sandboxed to\n * scripts only and answers its data requests over the postMessage bridge in\n * appletBridge.ts. The iframe gets no token and no same-origin access; the\n * host checks every request's source and scope, and the service checks the\n * workspace's grant again before it returns data.\n */\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useApolloClient } from \"@apollo/client/react\";\nimport {\n GetAppletBridgeDataDocument,\n type GetAppletBridgeDataQuery,\n type GetAppletBridgeDataQueryVariables,\n} from \"@/generated/wspace-operations\";\nimport type { TimeCampusAppletSource } from \"@/generated/wspace-types\";\nimport {\n APPLET_IFRAME_SANDBOX,\n bridgeErrorMessage,\n bridgeInit,\n bridgeResponse,\n createRateLimiter,\n isFrameableUrl,\n parseAppletRequest,\n} from \"./appletBridge\";\n\nexport interface AppletWidgetFrame {\n appletKey: string;\n appletName: string;\n widgetKey: string;\n url: string;\n origin: string;\n height: number;\n grantedScopes: string[];\n source?: TimeCampusAppletSource | null;\n}\n\nfunction currentTheme(): \"light\" | \"dark\" {\n return document.documentElement.classList.contains(\"dark\") ? \"dark\" : \"light\";\n}\n\nexport function SandboxedAppletWidget({\n frame,\n title,\n}: {\n frame: AppletWidgetFrame;\n title: string;\n}) {\n const client = useApolloClient();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n // One limiter per mounted widget, so re-running the effect never resets the window.\n const rateLimiter = useRef(createRateLimiter());\n const allowed = useMemo(\n () => new Set(frame.grantedScopes),\n [frame.grantedScopes],\n );\n const frameable = isFrameableUrl(frame.url, frame.origin);\n\n useEffect(() => {\n if (!frameable) return undefined;\n const withinRate = rateLimiter.current;\n // A sandboxed frame has an opaque origin, so replies cannot be addressed\n // to an origin; they go only to this iframe's window and carry nothing\n // beyond what the workspace granted.\n const reply = (target: MessageEventSource, message: unknown) => {\n (target as Window).postMessage(message, \"*\");\n };\n\n const onMessage = (event: MessageEvent) => {\n const own = iframeRef.current?.contentWindow;\n if (!own || event.source !== own) return;\n const request = parseAppletRequest(event.data);\n if (!request) return;\n if (!withinRate()) {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: \"Too many requests; try again in a minute.\",\n }),\n );\n return;\n }\n if (!allowed.has(request.scope)) {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: \"This workspace has not granted that data scope.\",\n }),\n );\n return;\n }\n void client\n .query({\n query: GetAppletBridgeDataDocument,\n variables: {\n appletKey: frame.appletKey,\n scope: request.scope,\n ...(frame.source ? { source: frame.source } : {}),\n } satisfies GetAppletBridgeDataQueryVariables,\n fetchPolicy: \"no-cache\",\n })\n .then((result) => {\n const data = (result.data as GetAppletBridgeDataQuery | undefined)\n ?.timeCampusAppletBridgeData;\n reply(\n own,\n bridgeResponse(\n request.requestId,\n data ? { data } : { error: \"No data was returned.\" },\n ),\n );\n })\n .catch((err: unknown) => {\n reply(\n own,\n bridgeResponse(request.requestId, {\n error: bridgeErrorMessage(err),\n }),\n );\n });\n };\n\n window.addEventListener(\"message\", onMessage);\n return () => window.removeEventListener(\"message\", onMessage);\n }, [allowed, client, frame.appletKey, frame.source, frameable]);\n\n if (!frameable) {\n return (\n <p className=\"text-sm text-text-secondary\">\n This widget's address is not allowed.\n </p>\n );\n }\n\n const sendInit = () => {\n const target = iframeRef.current?.contentWindow;\n if (!target) return;\n target.postMessage(bridgeInit(frame, currentTheme()), \"*\");\n };\n\n return (\n <div className=\"flex flex-col gap-1\">\n <iframe\n ref={iframeRef}\n src={frame.url}\n title={title}\n sandbox={APPLET_IFRAME_SANDBOX}\n referrerPolicy=\"no-referrer\"\n allow=\"\"\n loading=\"lazy\"\n onLoad={sendInit}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface\"\n style={{ height: frame.height }}\n data-testid={`applet-frame-${frame.appletKey}-${frame.widgetKey}`}\n />\n <p className=\"text-xs text-text-tertiary\">\n Third-party widget by {frame.appletName}. It only sees{\" \"}\n {frame.grantedScopes.length === 0\n ? \"no TimeCampus data\"\n : \"the data scopes this workspace granted\"}\n .\n </p>\n </div>\n );\n}\n"],"mappings":";;;;;;AAsCA,SAASA,IAAiC;CACxC,OAAO,SAAS,gBAAgB,UAAU,SAAS,MAAM,IAAI,SAAS;AACxE;AAEA,SAAgBC,EAAsB,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