@ekanos/harness 0.3.0 → 0.4.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/README.md +27 -13
- package/dist/app.js +2 -2
- package/dist/internal/components/dev-toolbar.js +1 -1
- package/dist/internal/components/harness-providers.js +61 -17
- package/dist/internal/components/harness-widget-provider.d.ts +1 -1
- package/dist/internal/components/i18n-provider.d.ts +3 -3
- package/dist/internal/components/i18n-provider.js +3 -3
- package/dist/internal/components/viewport-frame.js +2 -2
- package/dist/internal/components/widget-boundary.d.ts +1 -1
- package/dist/internal/components/widget-surface.js +2 -0
- package/dist/internal/lib/actions-transport.d.ts +1 -1
- package/dist/internal/lib/harness-live-fetch.d.ts +1 -1
- package/dist/internal/lib/harness-query-client.d.ts +1 -1
- package/dist/internal/lib/toolbar-context.d.ts +4 -4
- package/dist/internal/routes/activation-page.js +5 -4
- package/dist/internal/routes/index-page.js +1 -1
- package/dist/internal/routes/root-layout.js +1 -1
- package/dist/internal/routes/triggers-page.js +24 -4
- package/dist/internal/server/actions-fixtures-context.js +6 -2
- package/dist/internal/server/api-router.d.ts +4 -2
- package/dist/internal/server/api-router.js +75 -3
- package/dist/internal/server/live-context.d.ts +8 -1
- package/dist/internal/server/live-context.js +4 -1
- package/dist/internal/server/local-secrets.d.ts +36 -3
- package/dist/internal/server/local-secrets.js +48 -3
- package/dist/internal/server/oauth-loop.d.ts +1 -1
- package/dist/internal/server/storage-read.d.ts +1 -1
- package/dist/registry.d.ts +7 -7
- package/dist/styles.css +2 -2
- package/package.json +36 -41
- package/dist/internal/lib/i18n.d.ts +0 -2
- package/dist/internal/lib/i18n.js +0 -17
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @ekanos/harness
|
|
2
2
|
|
|
3
3
|
The Ekanos integration dev harness: every surface of an integration rendered in
|
|
4
|
-
real
|
|
4
|
+
real Ekanos chrome — the actual dashboard grid, the actual `Widget.*` compound
|
|
5
5
|
components, the actual design tokens — from fixtures, with no Supabase, no auth
|
|
6
6
|
and no network.
|
|
7
7
|
|
|
@@ -10,13 +10,6 @@ reference for everything you declare (widgets, tools, webhooks, schedules,
|
|
|
10
10
|
OAuth, storage, egress). This document covers only the local dev harness that
|
|
11
11
|
renders those surfaces.
|
|
12
12
|
|
|
13
|
-
> **Not published yet.** `@ekanos/harness` and `@ekanos/cli` are not on npm, so
|
|
14
|
-
> the commands below do not resolve today. `@ekanos/sdk`, `@ekanos/ui` and
|
|
15
|
-
> `@ekanos/integration-schema` are (`0.1.2`), and everything in the SDK README
|
|
16
|
-
> works without this package — `defineIntegration()` validates at import and
|
|
17
|
-
> the testing helpers need only vitest. What you cannot do until this ships is
|
|
18
|
-
> _see_ your surfaces rendered. This document describes what will ship.
|
|
19
|
-
|
|
20
13
|
You do not normally install this by hand. `ekanos dev` scaffolds a shell around
|
|
21
14
|
it and adds it to your `package.json`.
|
|
22
15
|
|
|
@@ -589,7 +582,7 @@ on it to write a fixture.
|
|
|
589
582
|
|
|
590
583
|
## Live mode — real requests to your own API
|
|
591
584
|
|
|
592
|
-
The harness mocks
|
|
585
|
+
The harness mocks Ekanos, not your vendor. Declare a `live` block and the
|
|
593
586
|
toolbar grows a fixtures ⇄ live switch: in live mode the harness stops seeding
|
|
594
587
|
your data keys, your widgets' own query functions run, and their requests reach
|
|
595
588
|
the real API. There is still no Supabase, no auth and no server actions in
|
|
@@ -642,11 +635,11 @@ work to do. A definition declaring more than live mode exercises is fine; the
|
|
|
642
635
|
reverse is the fault, and while it stands the harness forces fixtures mode and
|
|
643
636
|
says so on the surface.
|
|
644
637
|
|
|
645
|
-
**`seeds` are the keys that stay mocked in live mode.**
|
|
638
|
+
**`seeds` are the keys that stay mocked in live mode.** Ekanos-side state your
|
|
646
639
|
widgets read before they can call anything: a saved location, an account
|
|
647
640
|
preference, whatever your own host route would have returned. Everything not
|
|
648
641
|
listed runs its real query function. That one line is the whole boundary the
|
|
649
|
-
design draws:
|
|
642
|
+
design draws: Ekanos mocked, vendor real.
|
|
650
643
|
|
|
651
644
|
An integration with no `live` block is fixtures-only; the toolbar control is
|
|
652
645
|
disabled for it and says why. One WITH a `live` block still opens in fixtures
|
|
@@ -934,11 +927,32 @@ renders with zero traffic and you do not hand-write that fixture:
|
|
|
934
927
|
oauth: { connected: { empty: false } }, // show the Connect prompt on `empty`
|
|
935
928
|
```
|
|
936
929
|
|
|
930
|
+
### Credential-form integrations — an API token, no OAuth
|
|
931
|
+
|
|
932
|
+
An integration whose credential is a field in its activation form (an API
|
|
933
|
+
token, a site id) needs no OAuth and no entry in `local-secrets.json` by hand.
|
|
934
|
+
In **live** mode, submitting the form does what the host does with the
|
|
935
|
+
activation row: **every string field of the submitted `activationData` becomes
|
|
936
|
+
`ctx.secrets.get('<that exact field name>')`** for your live handlers, actions
|
|
937
|
+
and tools (non-string fields do not). There is no secret marker to declare —
|
|
938
|
+
the host has none either, and a definition cannot name form fields because the
|
|
939
|
+
form is a component.
|
|
940
|
+
|
|
941
|
+
The shell stores those fields under an `activationData` object in your slug's
|
|
942
|
+
block of **`.ekanos/local-secrets.json`** (same file, mode `0600`, gitignored),
|
|
943
|
+
so they survive a dev-server restart; Disconnect removes them. A later
|
|
944
|
+
submission replaces the previous one, as the host replaces the row. A field
|
|
945
|
+
that collides with an admin-tier name (an OAuth client secret, a webhook key)
|
|
946
|
+
wins, again as on the host. The values go from your form to the local dev
|
|
947
|
+
server only, are never logged, and are never sent back — the route answers
|
|
948
|
+
with field names. **Fixtures** mode is unchanged: nothing is stored and nothing
|
|
949
|
+
leaves the browser.
|
|
950
|
+
|
|
937
951
|
### `triggerMocks`
|
|
938
952
|
|
|
939
953
|
The mock context is derived from the definition — slug, storage schemas, egress
|
|
940
954
|
— and from your `fixtures`, which answer `ctx.fetch` here exactly as they answer
|
|
941
|
-
a widget. `triggerMocks` supplies the rest: whatever
|
|
955
|
+
a widget. `triggerMocks` supplies the rest: whatever Ekanos-side state your
|
|
942
956
|
handlers need to run a happy path.
|
|
943
957
|
|
|
944
958
|
**So do not re-author your vendor payloads as `fetchHandlers`.** That was the
|
|
@@ -1144,4 +1158,4 @@ published tarball, in a clean room outside the workspace.
|
|
|
1144
1158
|
|
|
1145
1159
|
MIT. Font Awesome is the consuming app's responsibility: this package ships no
|
|
1146
1160
|
icon-font data, and the generated shell loads Font Awesome **Free**, because
|
|
1147
|
-
|
|
1161
|
+
Ekanos's own Pro webfonts are commercially licensed and cannot be redistributed.
|
package/dist/app.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RootLayout } from "./internal/routes/root-layout.js";
|
|
2
2
|
import { IndexPage } from "./internal/routes/index-page.js";
|
|
3
3
|
const harnessMetadata = {
|
|
4
|
-
title: "
|
|
5
|
-
description: "Render integration widgets, marketplace tiles and activation forms in real
|
|
4
|
+
title: "Ekanos Integration Harness",
|
|
5
|
+
description: "Render integration widgets, marketplace tiles and activation forms in real Ekanos chrome, from fixtures, with no Supabase, auth or network."
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
IndexPage,
|
|
@@ -155,7 +155,7 @@ function DevToolbar() {
|
|
|
155
155
|
"aria-hidden": "true",
|
|
156
156
|
className: cn("hidden items-center dark:flex"),
|
|
157
157
|
children: [
|
|
158
|
-
/* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-sun
|
|
158
|
+
/* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-sun", className: "mr-2 h-4 w-4" }),
|
|
159
159
|
"Light"
|
|
160
160
|
]
|
|
161
161
|
}
|
|
@@ -30,24 +30,64 @@ import {
|
|
|
30
30
|
import { redactSensitive } from "../lib/redact.js";
|
|
31
31
|
import { AskAssistantBridge } from "./ask-assistant-bridge.js";
|
|
32
32
|
installHarnessFetch();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
function activationUrl(slug) {
|
|
34
|
+
return `/api/integrations/${slug}/activation`;
|
|
35
|
+
}
|
|
36
|
+
async function syncLiveActivation(slug, init) {
|
|
37
|
+
try {
|
|
38
|
+
const response = await globalThis.fetch(activationUrl(slug), {
|
|
39
|
+
method: init.method,
|
|
40
|
+
headers: { "content-type": "application/json" },
|
|
41
|
+
...init.method === "POST" ? { body: JSON.stringify({ activationData: init.activationData }) } : {}
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
errorMessage: `The harness could not store the activation fields locally (${response.status}).`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
48
49
|
return { success: true };
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(`[harness:${slug}] activation sync failed:`, error);
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
errorMessage: "The harness could not reach its own server to store the activation fields."
|
|
55
|
+
};
|
|
49
56
|
}
|
|
50
|
-
}
|
|
57
|
+
}
|
|
58
|
+
function createActivationActions(mode) {
|
|
59
|
+
return {
|
|
60
|
+
activate: async (input) => {
|
|
61
|
+
console.info(
|
|
62
|
+
mode === "live" ? "[harness] activate (live: stored in .ekanos/local-secrets.json):" : "[harness] activate (fixture, not persisted):",
|
|
63
|
+
redactSensitive(input)
|
|
64
|
+
);
|
|
65
|
+
if (mode === "live") {
|
|
66
|
+
const synced = await syncLiveActivation(input.integrationSlug, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
activationData: input.activationData ?? {}
|
|
69
|
+
});
|
|
70
|
+
if (!synced.success) return synced;
|
|
71
|
+
}
|
|
72
|
+
setLiveActivationData(
|
|
73
|
+
input.integrationSlug,
|
|
74
|
+
input.activationData ?? null
|
|
75
|
+
);
|
|
76
|
+
return { success: true };
|
|
77
|
+
},
|
|
78
|
+
deactivate: async (input) => {
|
|
79
|
+
console.info(
|
|
80
|
+
"[harness] deactivate (fixture, not persisted):",
|
|
81
|
+
redactSensitive(input)
|
|
82
|
+
);
|
|
83
|
+
clearLiveActivationData(input.integrationSlug);
|
|
84
|
+
if (mode === "live") {
|
|
85
|
+
return syncLiveActivation(input.integrationSlug, { method: "DELETE" });
|
|
86
|
+
}
|
|
87
|
+
return { success: true };
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
51
91
|
function HarnessProviders({
|
|
52
92
|
seeds,
|
|
53
93
|
mode = "fixtures",
|
|
@@ -90,8 +130,12 @@ function HarnessProviders({
|
|
|
90
130
|
}
|
|
91
131
|
});
|
|
92
132
|
}, [mode, variant, httpFixtures, egress, slug]);
|
|
133
|
+
const activationActions = useMemo(
|
|
134
|
+
() => createActivationActions(mode),
|
|
135
|
+
[mode]
|
|
136
|
+
);
|
|
93
137
|
const FetchProvider = live?.FetchProvider;
|
|
94
|
-
const tree = /* @__PURE__ */ jsx(IntegrationFetchProvider, { fetch: harnessFetch, children: /* @__PURE__ */ jsx(IntegrationActivationDataProvider, { value: activationData, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(TeamAccountWorkspaceContextProvider, { children: /* @__PURE__ */ jsx(IntegrationActivationProvider, { actions:
|
|
138
|
+
const tree = /* @__PURE__ */ jsx(IntegrationFetchProvider, { fetch: harnessFetch, children: /* @__PURE__ */ jsx(IntegrationActivationDataProvider, { value: activationData, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(TeamAccountWorkspaceContextProvider, { children: /* @__PURE__ */ jsx(IntegrationActivationProvider, { actions: activationActions, children: /* @__PURE__ */ jsx(WidgetEventProvider, { children: /* @__PURE__ */ jsxs(AskAssistantProvider, { children: [
|
|
95
139
|
/* @__PURE__ */ jsx(AskAssistantBridge, {}),
|
|
96
140
|
/* @__PURE__ */ jsx(Suspense, { fallback: null, children })
|
|
97
141
|
] }) }) }) }) }) }) });
|
|
@@ -12,7 +12,7 @@ import { type WidgetHealth, type WidgetRenderState } from '@ekanos/sdk/component
|
|
|
12
12
|
* from `WidgetContext`, and something has to PROVIDE it. In the real app that is
|
|
13
13
|
* `DashboardWidgetProvider`, which lives in the host's own package and is not
|
|
14
14
|
* part of the published `@ekanos/sdk` surface — on purpose. It is coupled to
|
|
15
|
-
* things that only exist inside
|
|
15
|
+
* things that only exist inside Ekanos: `'use server'` persistence callbacks
|
|
16
16
|
* for the widget-config hierarchy, and the Supabase rows behind them. The SDK
|
|
17
17
|
* inversion drew the line exactly there: the SDK exports the CONSUMER side
|
|
18
18
|
* (`WidgetContext` plus `WidgetContextValue` / `WidgetState` / `WidgetActions` /
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import '../lib/i18n.js';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* The next-intl provider `@ekanos/ui/trans` reads. The harness ships no
|
|
4
|
+
* translations: every SDK `<Trans>` carries `defaults`, which is what renders
|
|
5
|
+
* when a key is missing, so empty messages are all it needs.
|
|
6
6
|
*/
|
|
7
7
|
export declare function I18nProvider({ children }: {
|
|
8
8
|
children: ReactNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import "
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { NextIntlClientProvider } from "next-intl";
|
|
4
4
|
function I18nProvider({ children }) {
|
|
5
|
-
return /* @__PURE__ */ jsx(
|
|
5
|
+
return /* @__PURE__ */ jsx(NextIntlClientProvider, { locale: "en", messages: {}, timeZone: "UTC", children });
|
|
6
6
|
}
|
|
7
7
|
export {
|
|
8
8
|
I18nProvider
|
|
@@ -15,8 +15,8 @@ function ViewportFrame({ children }) {
|
|
|
15
15
|
/* @__PURE__ */ jsx(
|
|
16
16
|
"div",
|
|
17
17
|
{
|
|
18
|
-
className: "w-full overflow-hidden rounded-lg border p-5",
|
|
19
|
-
style: {
|
|
18
|
+
className: "w-full max-w-(--viewport-width) overflow-hidden rounded-lg border p-5",
|
|
19
|
+
style: { "--viewport-width": `${width}px` },
|
|
20
20
|
children
|
|
21
21
|
}
|
|
22
22
|
)
|
|
@@ -20,6 +20,6 @@ export declare class WidgetBoundary extends Component<Props, State> {
|
|
|
20
20
|
static getDerivedStateFromError(error: Error): State;
|
|
21
21
|
componentDidUpdate(previous: Props): void;
|
|
22
22
|
componentDidCatch(error: Error): void;
|
|
23
|
-
render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean |
|
|
23
|
+
render(): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
24
24
|
}
|
|
25
25
|
export {};
|
|
@@ -32,6 +32,8 @@ function toWidgetConfig(widget, productSlug, unhealthy) {
|
|
|
32
32
|
integrationMetadata: {
|
|
33
33
|
productId: productSlug,
|
|
34
34
|
productSlug,
|
|
35
|
+
// The harness previews a partner package, which is always an integration.
|
|
36
|
+
kind: "integration",
|
|
35
37
|
integrationName: productSlug,
|
|
36
38
|
description: "",
|
|
37
39
|
category: "harness",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* through, and read by `internal/server/api-router.ts`'s action handler.
|
|
24
24
|
* Neither is a production concept — they never leave this process, an
|
|
25
25
|
* absent or garbled value on the server side falls back to fixtures (never
|
|
26
|
-
* to live), and no real
|
|
26
|
+
* to live), and no real Ekanos host route reads either header because a
|
|
27
27
|
* real host route has no "mode" to be told.
|
|
28
28
|
*/
|
|
29
29
|
export declare const HARNESS_ACTIONS_MODE_HEADER = "x-ekanos-harness-data-mode";
|
|
@@ -4,7 +4,7 @@ import type { IntegrationFetch } from '@ekanos/sdk';
|
|
|
4
4
|
* THE HARNESS'S `ctx.fetch`
|
|
5
5
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
6
6
|
*
|
|
7
|
-
* The harness mocks
|
|
7
|
+
* The harness mocks Ekanos. It does NOT mock your vendor's API — and in live
|
|
8
8
|
* mode it stops standing between you and it. What it does instead is enforce
|
|
9
9
|
* the one rule that matters: an integration may only reach the origins it
|
|
10
10
|
* DECLARED in `defineIntegration({ egress })`.
|
|
@@ -33,7 +33,7 @@ export declare class MissingFixtureError extends Error {
|
|
|
33
33
|
*
|
|
34
34
|
* LIVE mode installs no override at all, so react-query falls through to each
|
|
35
35
|
* widget's own `queryFn` — the real one, reaching the real vendor API through
|
|
36
|
-
* the allowlisted fetch.
|
|
36
|
+
* the allowlisted fetch. Ekanos-side keys are still pre-seeded, so a widget
|
|
37
37
|
* that needs an account setting before it can call anything still gets one.
|
|
38
38
|
*
|
|
39
39
|
* `retry: false` matters as much as the rest: the default three retries with
|
|
@@ -4,19 +4,19 @@ import { type DataMode, type FixtureVariant } from '../../registry.js';
|
|
|
4
4
|
export declare const RENDER_STATES: readonly ["active", "loading", "error", "inactive", "disabled"];
|
|
5
5
|
export declare const VIEWPORTS: {
|
|
6
6
|
readonly mobile: {
|
|
7
|
-
readonly label:
|
|
7
|
+
readonly label: 'Mobile';
|
|
8
8
|
readonly width: 390;
|
|
9
9
|
};
|
|
10
10
|
readonly tablet: {
|
|
11
|
-
readonly label:
|
|
11
|
+
readonly label: 'Tablet';
|
|
12
12
|
readonly width: 820;
|
|
13
13
|
};
|
|
14
14
|
readonly desktop: {
|
|
15
|
-
readonly label:
|
|
15
|
+
readonly label: 'Desktop';
|
|
16
16
|
readonly width: 1280;
|
|
17
17
|
};
|
|
18
18
|
readonly full: {
|
|
19
|
-
readonly label:
|
|
19
|
+
readonly label: 'Full';
|
|
20
20
|
readonly width: null;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
DialogHeader,
|
|
13
13
|
DialogTitle
|
|
14
14
|
} from "@ekanos/ui/dialog";
|
|
15
|
+
import { StatusBadge } from "@ekanos/ui/status-badge";
|
|
15
16
|
import { HARNESS_ACCOUNT_ID } from "../../registry.js";
|
|
16
17
|
import { LocalOAuthPanel } from "../components/local-oauth-panel.js";
|
|
17
18
|
import { useDefinitionMockContext } from "../lib/definition-mock-context.js";
|
|
@@ -68,7 +69,7 @@ function ActivationPage() {
|
|
|
68
69
|
/* @__PURE__ */ jsx(AlertTitle, { children: mode === "live" ? "Submissions run onActivate on the dev server" : "Submissions go nowhere" }),
|
|
69
70
|
/* @__PURE__ */ jsxs(AlertDescription, { children: [
|
|
70
71
|
/* @__PURE__ */ jsxs("p", { children: [
|
|
71
|
-
"The harness has no
|
|
72
|
+
"The harness has no Ekanos backend. Submitting shows you the",
|
|
72
73
|
" ",
|
|
73
74
|
/* @__PURE__ */ jsx("code", { children: "ActivationResult" }),
|
|
74
75
|
" your form handed back instead of persisting it \u2014 which is the part worth checking, since that payload is what the real activation action would store. The dialog, the capability and permission sections and the connected state are the real ones, rendered from your ",
|
|
@@ -295,9 +296,9 @@ function PermissionList({
|
|
|
295
296
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
296
297
|
/* @__PURE__ */ jsx("span", { className: "text-foreground text-sm font-medium", children: permission.label }),
|
|
297
298
|
/* @__PURE__ */ jsx(
|
|
298
|
-
|
|
299
|
+
StatusBadge,
|
|
299
300
|
{
|
|
300
|
-
|
|
301
|
+
tone: permission.type === "write" ? "warning" : "neutral",
|
|
301
302
|
children: permission.type === "write" ? "Write" : "Read"
|
|
302
303
|
}
|
|
303
304
|
)
|
|
@@ -322,7 +323,7 @@ function ConnectedState({
|
|
|
322
323
|
{
|
|
323
324
|
className: "text-muted-foreground text-sm",
|
|
324
325
|
"data-test": "activation-mode-notice",
|
|
325
|
-
children: mode === "live" ? hasLiveActivationData ? "The toolbar is on Live API \u2014 this activation data is available to live-mode widgets on this visit." : "The toolbar is on Live API. This activation submitted no data of its own; an OAuth integration\u2019s credentials live on the dev server, where onTokens stored them." : "This surface is
|
|
326
|
+
children: mode === "live" ? hasLiveActivationData ? "The toolbar is on Live API \u2014 this activation data is available to live-mode widgets on this visit." : "The toolbar is on Live API. This activation submitted no data of its own; an OAuth integration\u2019s credentials live on the dev server, where onTokens stored them." : "This surface is Ekanos-mocked; widgets read fixtures \u2014 switch the toolbar to Live API to exercise real requests."
|
|
326
327
|
}
|
|
327
328
|
),
|
|
328
329
|
/* @__PURE__ */ jsx(
|
|
@@ -8,7 +8,7 @@ function IndexPage({
|
|
|
8
8
|
return /* @__PURE__ */ jsxs("main", { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 px-6 py-10", children: [
|
|
9
9
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-2", children: [
|
|
10
10
|
/* @__PURE__ */ jsx("h1", { className: "font-heading text-3xl tracking-tight", children: "Integration harness" }),
|
|
11
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: "Every registered integration, rendered in real
|
|
11
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: "Every registered integration, rendered in real Ekanos chrome from fixtures. No Supabase, no auth, no network." })
|
|
12
12
|
] }),
|
|
13
13
|
integrations.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "bg-card flex flex-col items-center gap-3 rounded-lg border p-6 text-center", children: [
|
|
14
14
|
/* @__PURE__ */ jsx(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import "@fortawesome/fontawesome-free/css/all.min.css";
|
|
3
4
|
import { IconStyleOverrideProvider } from "@ekanos/ui/icon";
|
|
4
5
|
import { cn } from "@ekanos/ui/utils";
|
|
5
|
-
import "@fortawesome/fontawesome-free/css/all.min.css";
|
|
6
6
|
import { ThemeProvider } from "next-themes";
|
|
7
7
|
import { DevToolbar } from "../components/dev-toolbar.js";
|
|
8
8
|
import { I18nProvider } from "../components/i18n-provider.js";
|
|
@@ -3,6 +3,9 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
import { notFound } from "next/navigation";
|
|
5
5
|
import { isEgressAllowed } from "@ekanos/sdk/context";
|
|
6
|
+
import {
|
|
7
|
+
DEFAULT_SIGNATURE_TOLERANCE_SECONDS
|
|
8
|
+
} from "@ekanos/sdk/integration";
|
|
6
9
|
import { Alert, AlertDescription, AlertTitle } from "@ekanos/ui/alert";
|
|
7
10
|
import { Badge } from "@ekanos/ui/badge";
|
|
8
11
|
import { Button } from "@ekanos/ui/button";
|
|
@@ -16,6 +19,22 @@ import {
|
|
|
16
19
|
createServerTriggerRunner
|
|
17
20
|
} from "../lib/trigger-runner.js";
|
|
18
21
|
import { useHarnessIntegration } from "../registry-context.js";
|
|
22
|
+
function describeSignatureScheme(scheme) {
|
|
23
|
+
const parts = [`HMAC-${(scheme.algorithm ?? "sha256").toUpperCase()}`];
|
|
24
|
+
parts.push(`over ${scheme.signedPayload ?? "{body}"}`);
|
|
25
|
+
if (scheme.format === "keyed") {
|
|
26
|
+
parts.push(
|
|
27
|
+
`keyed (${scheme.digestKey}${scheme.timestampKey ? `, t=${scheme.timestampKey}` : ""})`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (scheme.timestampHeader)
|
|
31
|
+
parts.push(`timestamp header ${scheme.timestampHeader}`);
|
|
32
|
+
if (scheme.timestampKey || scheme.timestampHeader) {
|
|
33
|
+
const tolerance = scheme.toleranceSeconds ?? DEFAULT_SIGNATURE_TOLERANCE_SECONDS;
|
|
34
|
+
parts.push(tolerance === 0 ? "no replay window" : `\xB1${tolerance}s`);
|
|
35
|
+
}
|
|
36
|
+
return parts.join(" \xB7 ");
|
|
37
|
+
}
|
|
19
38
|
function OutcomePanel({ outcome }) {
|
|
20
39
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", "data-test": "trigger-outcome", children: [
|
|
21
40
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -77,7 +96,8 @@ function WebhookCard({
|
|
|
77
96
|
' \u21D0 secret "',
|
|
78
97
|
webhook.signature.secretName,
|
|
79
98
|
'"'
|
|
80
|
-
] })
|
|
99
|
+
] }),
|
|
100
|
+
webhook.signature !== "none" && webhook.signature.scheme ? /* @__PURE__ */ jsx(Badge, { variant: "outline", "data-test": `webhook-${webhook.id}-scheme`, children: describeSignatureScheme(webhook.signature.scheme) }) : null
|
|
81
101
|
] }),
|
|
82
102
|
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: webhook.description }),
|
|
83
103
|
webhook.signature !== "none" ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: "Signature verification is the transport's job \u2014 the harness skips it (and says so in the handler logs); the host ingress will enforce it before your handler ever runs." }) : null,
|
|
@@ -223,17 +243,17 @@ function OAuthCard({
|
|
|
223
243
|
" via",
|
|
224
244
|
" ",
|
|
225
245
|
/* @__PURE__ */ jsx("code", { children: "ctx.secrets" }),
|
|
226
|
-
". The hosted transport runs it in
|
|
246
|
+
". The hosted transport runs it in Ekanos; in live mode the generated shell runs the same loop here, on localhost, against your own developer app \u2014 see Local OAuth below."
|
|
227
247
|
] }),
|
|
228
248
|
/* @__PURE__ */ jsxs("p", { children: [
|
|
229
249
|
/* @__PURE__ */ jsx("strong", { children: "Redirect URI \u2014 host-derived, and not something you declare." }),
|
|
230
250
|
" ",
|
|
231
251
|
"Whichever host runs the flow builds it from its own origin, so there is no field for it in ",
|
|
232
252
|
/* @__PURE__ */ jsx("code", { children: "defineIntegration()" }),
|
|
233
|
-
". You register one per environment with your provider: the harness's (below, in live mode) and the
|
|
253
|
+
". You register one per environment with your provider: the harness's (below, in live mode) and the Ekanos host's,",
|
|
234
254
|
" ",
|
|
235
255
|
/* @__PURE__ */ jsxs("code", { children: [
|
|
236
|
-
"https://<your-
|
|
256
|
+
"https://<your-ekanos-host>/api/integrations/",
|
|
237
257
|
definition.slug,
|
|
238
258
|
"/oauth/callback"
|
|
239
259
|
] }),
|
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
HARNESS_ACCOUNT_ID,
|
|
6
6
|
resolveEgress
|
|
7
7
|
} from "../../registry.js";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
compileFixtures,
|
|
10
|
+
fixturesToMockHandlers,
|
|
11
|
+
needsSelfOrigin
|
|
12
|
+
} from "../lib/http-fixtures.js";
|
|
9
13
|
const STORE = /* @__PURE__ */ Symbol.for("ekanos.harness.fixtures-actions-state");
|
|
10
14
|
function getStore() {
|
|
11
15
|
const carrier = globalThis;
|
|
@@ -23,7 +27,7 @@ function getFixturesActionsState(input) {
|
|
|
23
27
|
const definition = input.definition;
|
|
24
28
|
const mocks = input.integration.triggerMocks ?? {};
|
|
25
29
|
const egress = resolveEgress(input.integration);
|
|
26
|
-
const declaredFixtures = input.integration.fixtures?.[input.variant] ?? [];
|
|
30
|
+
const declaredFixtures = (input.integration.fixtures?.[input.variant] ?? []).filter((fixture) => !needsSelfOrigin(fixture));
|
|
27
31
|
const ctx = createMockContext({
|
|
28
32
|
accountId: HARNESS_ACCOUNT_ID,
|
|
29
33
|
integration: { slug: definition.slug },
|
|
@@ -4,7 +4,7 @@ import { type HarnessIntegration } from '../../registry.js';
|
|
|
4
4
|
* THE HARNESS API — `/api/integrations/[slug]/…`, served by the shell
|
|
5
5
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Eight routes per registered integration, behind one catch-all the CLI
|
|
8
8
|
* scaffolds (`app/api/integrations/[slug]/[...path]/route.ts`):
|
|
9
9
|
*
|
|
10
10
|
* GET oauth/connect start the real authorize → callback → exchange loop
|
|
@@ -13,6 +13,8 @@ import { type HarnessIntegration } from '../../registry.js';
|
|
|
13
13
|
* GET storage the SDK's generic storage bridge, over the live ctx
|
|
14
14
|
* POST trigger run a webhook / schedule / onActivate on the live ctx
|
|
15
15
|
* GET local-setup what to fill in and what to register — never values
|
|
16
|
+
* POST activation live mode: persist the activation form's string fields
|
|
17
|
+
* DELETE activation live mode: Disconnect — forget them
|
|
16
18
|
* POST actions/:name run a declared `actions[name]` handler — see below
|
|
17
19
|
*
|
|
18
20
|
* `actions/:name` is the one route reached in BOTH fixtures and live mode
|
|
@@ -26,7 +28,7 @@ import { type HarnessIntegration } from '../../registry.js';
|
|
|
26
28
|
* `trigger`) or a dedicated per-variant fixtures ctx
|
|
27
29
|
* (`getFixturesActionsState`, network-free).
|
|
28
30
|
*
|
|
29
|
-
* Contracts mirror the
|
|
31
|
+
* Contracts mirror the Ekanos host's own partner routes — the hosted OAuth
|
|
30
32
|
* transport and the generic storage route — so the SDK's client
|
|
31
33
|
* helpers (`createPartnerConnectionCheck`, `fetchIntegrationStorage`,
|
|
32
34
|
* `partnerOAuthErrorParam`) work against either unchanged. Where the harness
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
LOCAL_SECRETS_RELATIVE_PATH,
|
|
24
24
|
declaredSecretNames,
|
|
25
25
|
readLocalSecrets,
|
|
26
|
+
writeActivationSecrets,
|
|
26
27
|
writeLocalSecrets
|
|
27
28
|
} from "./local-secrets.js";
|
|
28
29
|
import { loopbackRefusal } from "./loopback-guard.js";
|
|
@@ -38,6 +39,9 @@ import {
|
|
|
38
39
|
} from "./oauth-loop.js";
|
|
39
40
|
import { resolveProjectRoot } from "./project-root.js";
|
|
40
41
|
import { parseStorageQuery, readClientReadableStorage } from "./storage-read.js";
|
|
42
|
+
function asSafeParseSchema(schema) {
|
|
43
|
+
return schema;
|
|
44
|
+
}
|
|
41
45
|
function json(body, init = {}) {
|
|
42
46
|
return new Response(JSON.stringify(body), {
|
|
43
47
|
...init,
|
|
@@ -64,7 +68,8 @@ const ROUTES = {
|
|
|
64
68
|
"oauth/status": { methods: ["GET"], handle: oauthStatus },
|
|
65
69
|
storage: { methods: ["GET"], handle: storage },
|
|
66
70
|
trigger: { methods: ["POST"], handle: trigger },
|
|
67
|
-
"local-setup": { methods: ["GET", "PUT"], handle: localSetup }
|
|
71
|
+
"local-setup": { methods: ["GET", "PUT"], handle: localSetup },
|
|
72
|
+
activation: { methods: ["POST", "DELETE"], handle: activation }
|
|
68
73
|
};
|
|
69
74
|
function createHarnessApiRouter(registry, deps = {}) {
|
|
70
75
|
const env = deps.env ?? process.env;
|
|
@@ -155,6 +160,7 @@ function createHarnessApiRouter(registry, deps = {}) {
|
|
|
155
160
|
integration,
|
|
156
161
|
definition,
|
|
157
162
|
adminSecrets: secrets.values,
|
|
163
|
+
accountSecrets: secrets.activation,
|
|
158
164
|
secretsFingerprint: secrets.fingerprint
|
|
159
165
|
});
|
|
160
166
|
const url = new URL(request.url);
|
|
@@ -434,7 +440,7 @@ async function actionInvoke(ctx, actionName) {
|
|
|
434
440
|
{ status: 400 }
|
|
435
441
|
);
|
|
436
442
|
}
|
|
437
|
-
const parsed = action.input.safeParse(
|
|
443
|
+
const parsed = asSafeParseSchema(action.input).safeParse(
|
|
438
444
|
body?.input
|
|
439
445
|
);
|
|
440
446
|
if (!parsed.success) {
|
|
@@ -458,7 +464,7 @@ async function actionInvoke(ctx, actionName) {
|
|
|
458
464
|
}).ctx;
|
|
459
465
|
const data = await action.handler(executionCtx, parsed.data);
|
|
460
466
|
if (action.output) {
|
|
461
|
-
const validated = action.output.safeParse(data);
|
|
467
|
+
const validated = asSafeParseSchema(action.output).safeParse(data);
|
|
462
468
|
if (!validated.success) {
|
|
463
469
|
console.error(
|
|
464
470
|
`[harness:${ctx.slug}] action "${actionName}" resolved a value that fails its own declared \`output\` schema:`,
|
|
@@ -566,10 +572,76 @@ async function localSetup(ctx) {
|
|
|
566
572
|
integration: ctx.integration,
|
|
567
573
|
definition: ctx.definition,
|
|
568
574
|
adminSecrets: reread.values,
|
|
575
|
+
accountSecrets: reread.activation,
|
|
569
576
|
secretsFingerprint: reread.fingerprint
|
|
570
577
|
});
|
|
571
578
|
return json(localSetupResponse(ctx, reread, state.connection !== null));
|
|
572
579
|
}
|
|
580
|
+
async function activation(ctx) {
|
|
581
|
+
const names = declaredSecretNames(ctx.definition);
|
|
582
|
+
const isDelete = ctx.request.method.toUpperCase() === "DELETE";
|
|
583
|
+
let activationData = {};
|
|
584
|
+
if (!isDelete) {
|
|
585
|
+
try {
|
|
586
|
+
const body = await ctx.request.json();
|
|
587
|
+
activationData = body?.activationData;
|
|
588
|
+
} catch {
|
|
589
|
+
return json({ error: "invalid_json" }, { status: 400 });
|
|
590
|
+
}
|
|
591
|
+
if (typeof activationData !== "object" || activationData === null || Array.isArray(activationData)) {
|
|
592
|
+
return json(
|
|
593
|
+
{
|
|
594
|
+
error: "invalid_activation",
|
|
595
|
+
hint: 'Expected { activationData: { "<field name>": "<value>" } }.'
|
|
596
|
+
},
|
|
597
|
+
{ status: 400 }
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
const written = writeActivationSecrets({
|
|
602
|
+
projectRoot: ctx.projectRoot,
|
|
603
|
+
slug: ctx.slug,
|
|
604
|
+
activationData
|
|
605
|
+
});
|
|
606
|
+
if (!written.ok) {
|
|
607
|
+
return json(
|
|
608
|
+
{ error: "local_secrets_rejected", message: written.message },
|
|
609
|
+
{ status: 400 }
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
const reread = readLocalSecrets({
|
|
613
|
+
projectRoot: ctx.projectRoot,
|
|
614
|
+
slug: ctx.slug,
|
|
615
|
+
names
|
|
616
|
+
});
|
|
617
|
+
if (!reread.ok) {
|
|
618
|
+
return json(
|
|
619
|
+
{ error: "local_secrets_unreadable", message: reread.message },
|
|
620
|
+
{ status: 500 }
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
const dropped = Object.keys(ctx.secrets.activation).some(
|
|
624
|
+
(name) => !(name in reread.activation)
|
|
625
|
+
);
|
|
626
|
+
const adminNames = /* @__PURE__ */ new Set([...names, ...Object.keys(ctx.secrets.values)]);
|
|
627
|
+
const shadows = Object.keys(reread.activation).some(
|
|
628
|
+
(name) => adminNames.has(name)
|
|
629
|
+
);
|
|
630
|
+
if (!dropped && !shadows) {
|
|
631
|
+
for (const [name, value] of Object.entries(reread.activation)) {
|
|
632
|
+
await ctx.state.ctx.secrets.set(name, value);
|
|
633
|
+
}
|
|
634
|
+
ctx.state.secretsFingerprint = reread.fingerprint;
|
|
635
|
+
}
|
|
636
|
+
getLiveState({
|
|
637
|
+
integration: ctx.integration,
|
|
638
|
+
definition: ctx.definition,
|
|
639
|
+
adminSecrets: reread.values,
|
|
640
|
+
accountSecrets: reread.activation,
|
|
641
|
+
secretsFingerprint: reread.fingerprint
|
|
642
|
+
});
|
|
643
|
+
return json({ success: true, names: Object.keys(reread.activation).sort() });
|
|
644
|
+
}
|
|
573
645
|
export {
|
|
574
646
|
createHarnessApiRouter
|
|
575
647
|
};
|
|
@@ -24,7 +24,9 @@ import { type NonceStore } from './nonce-store.js';
|
|
|
24
24
|
* production. A partner's own `triggerMocks.fetchHandlers` sit ahead of
|
|
25
25
|
* the passthrough, so an endpoint they deliberately mocked stays mocked;
|
|
26
26
|
* - admin-tier secrets come from `.ekanos/local-secrets.json`; account-tier
|
|
27
|
-
* secrets
|
|
27
|
+
* secrets are the activation form's submitted string fields (persisted in
|
|
28
|
+
* the same file, as the host persists the activation row) plus whatever the
|
|
29
|
+
* partner's own handlers wrote, and so is storage. No
|
|
28
30
|
* storage seeds: live means real data only.
|
|
29
31
|
*
|
|
30
32
|
* Kept on `globalThis` under a `Symbol.for` key so a dev-server recompile of
|
|
@@ -69,6 +71,11 @@ export interface LiveStateInput {
|
|
|
69
71
|
definition: IntegrationDefinition;
|
|
70
72
|
/** Declared secret names → filled values, from `local-secrets.json`. */
|
|
71
73
|
adminSecrets: Record<string, string>;
|
|
74
|
+
/**
|
|
75
|
+
* What the activation form submitted in live mode — the account tier, which
|
|
76
|
+
* wins over an admin-issued name exactly as the host resolves it.
|
|
77
|
+
*/
|
|
78
|
+
accountSecrets?: Record<string, string>;
|
|
72
79
|
secretsFingerprint: string;
|
|
73
80
|
/** Test seam for the passthrough's network fetch. */
|
|
74
81
|
networkFetch?: () => typeof globalThis.fetch;
|
|
@@ -37,7 +37,10 @@ function getLiveState(input) {
|
|
|
37
37
|
integration: { slug: definition.slug },
|
|
38
38
|
...definition.storage ? { storageSchemas: definition.storage } : {},
|
|
39
39
|
egress: definition.egress ?? [],
|
|
40
|
-
secrets: {
|
|
40
|
+
secrets: {
|
|
41
|
+
admin: input.adminSecrets,
|
|
42
|
+
account: input.accountSecrets ?? {}
|
|
43
|
+
},
|
|
41
44
|
fetchHandlers: [
|
|
42
45
|
...input.integration.triggerMocks?.fetchHandlers ?? [],
|
|
43
46
|
createNetworkPassthrough(input.networkFetch)
|
|
@@ -26,9 +26,20 @@ import type { IntegrationDefinition } from '@ekanos/sdk/integration';
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const LOCAL_SECRETS_RELATIVE_PATH: string;
|
|
28
28
|
/**
|
|
29
|
-
* The
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* The block key holding what the activation form submitted in live mode.
|
|
30
|
+
*
|
|
31
|
+
* The host has no "this field is a secret" marker: every STRING field of the
|
|
32
|
+
* submitted `activationData` becomes `ctx.secrets.get('<field name>')` for
|
|
33
|
+
* that account, under the exact field name (non-strings do not). A definition
|
|
34
|
+
* cannot list those names — the form is a component, not data — so they are
|
|
35
|
+
* not declared names. They are persisted here verbatim as the account tier,
|
|
36
|
+
* beside (never among) the admin-tier names the operator fills in.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ACTIVATION_BLOCK_KEY = "activationData";
|
|
39
|
+
/**
|
|
40
|
+
* The secret names a definition declares statically — the admin tier: OAuth
|
|
41
|
+
* client credentials and webhook signing keys. Activation-form fields are the
|
|
42
|
+
* account tier and are not declared anywhere; see `ACTIVATION_BLOCK_KEY`.
|
|
32
43
|
*/
|
|
33
44
|
export declare function declaredSecretNames(definition: Pick<IntegrationDefinition, 'oauth' | 'webhooks'>): string[];
|
|
34
45
|
export type LocalSecretsRead = {
|
|
@@ -39,6 +50,11 @@ export type LocalSecretsRead = {
|
|
|
39
50
|
values: Record<string, string>;
|
|
40
51
|
/** Declared names with no non-empty value. */
|
|
41
52
|
missing: string[];
|
|
53
|
+
/**
|
|
54
|
+
* What the activation form submitted in live mode — every string field,
|
|
55
|
+
* by exact name (the host's account tier). Never part of `missing`.
|
|
56
|
+
*/
|
|
57
|
+
activation: Record<string, string>;
|
|
42
58
|
/** Changes when any declared VALUE changes — the live-context rebuild key. */
|
|
43
59
|
fingerprint: string;
|
|
44
60
|
/** True when this call created the file or added the slug's block. */
|
|
@@ -82,3 +98,20 @@ export declare function writeLocalSecrets(args: {
|
|
|
82
98
|
names: readonly string[];
|
|
83
99
|
values: Record<string, string>;
|
|
84
100
|
}): LocalSecretsWrite;
|
|
101
|
+
/**
|
|
102
|
+
* Persist what the activation form submitted in LIVE mode, replacing the
|
|
103
|
+
* previous submission — the host replaces the activation row wholesale, so a
|
|
104
|
+
* field the user dropped is gone, not kept. Only string fields are stored
|
|
105
|
+
* (the host's rule). An empty object clears the block, which is what
|
|
106
|
+
* Disconnect does.
|
|
107
|
+
*
|
|
108
|
+
* Everything else in the file — other slugs, the admin-tier names, the help
|
|
109
|
+
* line — is preserved, and the file keeps its 0600 mode. Values are stored
|
|
110
|
+
* exactly as submitted: unlike a pasted client secret, the form already
|
|
111
|
+
* validated them, and the host would not trim them either.
|
|
112
|
+
*/
|
|
113
|
+
export declare function writeActivationSecrets(args: {
|
|
114
|
+
projectRoot: string;
|
|
115
|
+
slug: string;
|
|
116
|
+
activationData: unknown;
|
|
117
|
+
}): LocalSecretsWrite;
|
|
@@ -5,7 +5,8 @@ const LOCAL_SECRETS_RELATIVE_PATH = path.join(
|
|
|
5
5
|
".ekanos",
|
|
6
6
|
"local-secrets.json"
|
|
7
7
|
);
|
|
8
|
-
const HELP = 'Local dev credentials for `ekanos dev` live mode \u2014 one block per integration slug, one key per secret name the definition declares. Fill the values from your provider\u2019s DEVELOPER app. Never commit this file (.ekanos/ is gitignored). The redirect URI to register is shown on the harness Activation page under "Local OAuth".';
|
|
8
|
+
const HELP = 'Local dev credentials for `ekanos dev` live mode \u2014 one block per integration slug, one key per secret name the definition declares, plus an "activationData" object the harness fills when you submit the activation form in live mode (every string field, by exact name). Fill the values from your provider\u2019s DEVELOPER app. Never commit this file (.ekanos/ is gitignored). The redirect URI to register is shown on the harness Activation page under "Local OAuth".';
|
|
9
|
+
const ACTIVATION_BLOCK_KEY = "activationData";
|
|
9
10
|
function declaredSecretNames(definition) {
|
|
10
11
|
const names = /* @__PURE__ */ new Set();
|
|
11
12
|
if (definition.oauth) {
|
|
@@ -47,7 +48,7 @@ function writeDocument(file, doc) {
|
|
|
47
48
|
mode: 384
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
function fingerprintOf(values) {
|
|
51
|
+
function fingerprintOf(values, activation) {
|
|
51
52
|
const hash = createHash("sha256");
|
|
52
53
|
for (const name of Object.keys(values).sort()) {
|
|
53
54
|
hash.update(name);
|
|
@@ -55,8 +56,26 @@ function fingerprintOf(values) {
|
|
|
55
56
|
hash.update(values[name] ?? "");
|
|
56
57
|
hash.update("\0");
|
|
57
58
|
}
|
|
59
|
+
hash.update("activation");
|
|
60
|
+
for (const name of Object.keys(activation).sort()) {
|
|
61
|
+
hash.update(name);
|
|
62
|
+
hash.update("\0");
|
|
63
|
+
hash.update(activation[name] ?? "");
|
|
64
|
+
hash.update("\0");
|
|
65
|
+
}
|
|
58
66
|
return hash.digest("hex").slice(0, 16);
|
|
59
67
|
}
|
|
68
|
+
function isRecord(value) {
|
|
69
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
70
|
+
}
|
|
71
|
+
function stringFields(value) {
|
|
72
|
+
if (!isRecord(value)) return {};
|
|
73
|
+
return Object.fromEntries(
|
|
74
|
+
Object.entries(value).filter(
|
|
75
|
+
(entry) => typeof entry[1] === "string"
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
60
79
|
function readLocalSecrets(args) {
|
|
61
80
|
const file = path.join(args.projectRoot, LOCAL_SECRETS_RELATIVE_PATH);
|
|
62
81
|
const existing = readDocument(file);
|
|
@@ -95,12 +114,14 @@ function readLocalSecrets(args) {
|
|
|
95
114
|
missing.push(name);
|
|
96
115
|
}
|
|
97
116
|
}
|
|
117
|
+
const activation = stringFields(block[ACTIVATION_BLOCK_KEY]);
|
|
98
118
|
return {
|
|
99
119
|
ok: true,
|
|
100
120
|
file,
|
|
101
121
|
values,
|
|
102
122
|
missing,
|
|
103
|
-
|
|
123
|
+
activation,
|
|
124
|
+
fingerprint: fingerprintOf(values, activation),
|
|
104
125
|
generated
|
|
105
126
|
};
|
|
106
127
|
}
|
|
@@ -136,9 +157,33 @@ function writeLocalSecrets(args) {
|
|
|
136
157
|
writeDocument(file, doc);
|
|
137
158
|
return { ok: true };
|
|
138
159
|
}
|
|
160
|
+
function writeActivationSecrets(args) {
|
|
161
|
+
const file = path.join(args.projectRoot, LOCAL_SECRETS_RELATIVE_PATH);
|
|
162
|
+
const existing = readDocument(file);
|
|
163
|
+
if (existing.kind === "corrupt") {
|
|
164
|
+
return {
|
|
165
|
+
ok: false,
|
|
166
|
+
message: `${file} is not a JSON object; fix or delete it by hand first.`
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const doc = existing.kind === "ok" ? { ...existing.doc } : { "//": HELP };
|
|
170
|
+
const currentBlock = doc[args.slug];
|
|
171
|
+
const block = isRecord(currentBlock) ? { ...currentBlock } : {};
|
|
172
|
+
const fields = stringFields(args.activationData);
|
|
173
|
+
if (Object.keys(fields).length > 0) {
|
|
174
|
+
block[ACTIVATION_BLOCK_KEY] = fields;
|
|
175
|
+
} else {
|
|
176
|
+
delete block[ACTIVATION_BLOCK_KEY];
|
|
177
|
+
}
|
|
178
|
+
doc[args.slug] = block;
|
|
179
|
+
writeDocument(file, doc);
|
|
180
|
+
return { ok: true };
|
|
181
|
+
}
|
|
139
182
|
export {
|
|
183
|
+
ACTIVATION_BLOCK_KEY,
|
|
140
184
|
LOCAL_SECRETS_RELATIVE_PATH,
|
|
141
185
|
declaredSecretNames,
|
|
142
186
|
readLocalSecrets,
|
|
187
|
+
writeActivationSecrets,
|
|
143
188
|
writeLocalSecrets
|
|
144
189
|
};
|
|
@@ -5,7 +5,7 @@ import type { OAuthProviderDeclaration, OAuthTokens } from '@ekanos/sdk/integrat
|
|
|
5
5
|
* THE LOCALHOST OAUTH LOOP — pure helpers
|
|
6
6
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
7
7
|
*
|
|
8
|
-
* The REFERENCE implementation is the
|
|
8
|
+
* The REFERENCE implementation is the Ekanos host's hosted OAuth transport
|
|
9
9
|
* (its `oauth-transport` module). These helpers mirror its pure half — PKCE, the authorize URL, the return-path check, the
|
|
10
10
|
* code exchange and its token mapping — so a flow that works here works
|
|
11
11
|
* there. They are duplicated rather than shared because that module is host
|
|
@@ -2,7 +2,7 @@ import type { IntegrationContext } from '@ekanos/sdk';
|
|
|
2
2
|
import type { IntegrationDefinition } from '@ekanos/sdk/integration';
|
|
3
3
|
/**
|
|
4
4
|
* The read half of `GET /api/integrations/[slug]/storage`, mirroring the
|
|
5
|
-
*
|
|
5
|
+
* Ekanos host's generic storage route so `fetchIntegrationStorage()` in `@ekanos/sdk` — and therefore every
|
|
6
6
|
* partner widget built on it — works against the harness unchanged:
|
|
7
7
|
*
|
|
8
8
|
* - `?accountId=…&keys=a,b`, at most 20 keys, 400 on a malformed request;
|
package/dist/registry.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { MockFetchHandler } from '@ekanos/sdk/testing';
|
|
|
8
8
|
* supply at least `default`; the others are optional and fall back to
|
|
9
9
|
* "nothing seeded", which surfaces as the widget's own error state.
|
|
10
10
|
*/
|
|
11
|
-
export declare const FIXTURE_VARIANTS: readonly [
|
|
11
|
+
export declare const FIXTURE_VARIANTS: readonly ['default', 'empty', 'error'];
|
|
12
12
|
export type FixtureVariant = (typeof FIXTURE_VARIANTS)[number];
|
|
13
13
|
/**
|
|
14
14
|
* One programmed outcome for one react-query key.
|
|
@@ -104,12 +104,12 @@ export interface HarnessWidget {
|
|
|
104
104
|
* LIVE MODE — opting your integration into real third-party requests
|
|
105
105
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
106
106
|
*
|
|
107
|
-
* The harness mocks
|
|
107
|
+
* The harness mocks Ekanos, not your vendor. Declare this and the toolbar grows
|
|
108
108
|
* a fixtures ⇄ live switch for your integration: in live mode the harness stops
|
|
109
109
|
* seeding your data keys, your widgets' own query functions run, and the
|
|
110
110
|
* requests they make reach the real API.
|
|
111
111
|
*
|
|
112
|
-
*
|
|
112
|
+
* Ekanos stays mocked either way. There is still no Supabase, no auth and no
|
|
113
113
|
* server action — which is what `seeds` below is for.
|
|
114
114
|
*
|
|
115
115
|
* What you write is three fields:
|
|
@@ -279,7 +279,7 @@ export interface HarnessLiveMode {
|
|
|
279
279
|
children: ReactNode;
|
|
280
280
|
}>;
|
|
281
281
|
/**
|
|
282
|
-
* Keys that stay MOCKED in live mode:
|
|
282
|
+
* Keys that stay MOCKED in live mode: Ekanos-side state your widgets read
|
|
283
283
|
* before they can call anything — a saved location, an account preference,
|
|
284
284
|
* whatever your own host route would have returned. Seeded exactly like a
|
|
285
285
|
* fixture, and for exactly the same reason: the harness has no Supabase.
|
|
@@ -297,7 +297,7 @@ export interface HarnessLiveMode {
|
|
|
297
297
|
* schedules against ONE `createMockContext()` per visit (state accumulates
|
|
298
298
|
* across invocations, like a real account). The context is derived from the
|
|
299
299
|
* definition itself — slug, storage schemas, egress — and these seeds are the
|
|
300
|
-
* only extra input: whatever
|
|
300
|
+
* only extra input: whatever Ekanos-side state your handlers need to run a
|
|
301
301
|
* happy path (a stored config row, a seeded API key, a programmed response
|
|
302
302
|
* for `ctx.fetch`). There is no Supabase and no network in here either way.
|
|
303
303
|
*/
|
|
@@ -398,7 +398,7 @@ export interface HarnessIntegration {
|
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
/** The two data sources a surface can render from. */
|
|
401
|
-
export declare const DATA_MODES: readonly [
|
|
401
|
+
export declare const DATA_MODES: readonly ['fixtures', 'live'];
|
|
402
402
|
export type DataMode = (typeof DATA_MODES)[number];
|
|
403
403
|
/**
|
|
404
404
|
* The account/product identifiers every surface is rendered with. These are
|
|
@@ -469,7 +469,7 @@ export declare function collectSeeds(integration: HarnessIntegration, variant: F
|
|
|
469
469
|
* The seeds for one integration in one mode.
|
|
470
470
|
*
|
|
471
471
|
* Fixtures mode seeds everything the widgets declare. Live mode seeds ONLY the
|
|
472
|
-
*
|
|
472
|
+
* Ekanos-side keys, so every other query function runs for real — that one
|
|
473
473
|
* difference is the whole fixtures ⇄ live switch.
|
|
474
474
|
*/
|
|
475
475
|
export declare function seedsForMode(integration: HarnessIntegration, variant: FixtureVariant, mode: DataMode): FixtureSeed[];
|
package/dist/styles.css
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
@import 'tailwindcss';
|
|
18
18
|
|
|
19
|
-
/*
|
|
19
|
+
/* Ekanos design tokens + the Tailwind v4 @theme preset, consumed from the
|
|
20
20
|
* published package instead of a hand-maintained fork. This single import
|
|
21
21
|
* pulls in the token values, the base rules, the `dark:` variant and the full
|
|
22
22
|
* semantic @theme map. Resolves to `@ekanos/ui/dist/theme.css`, so that
|
|
@@ -156,7 +156,7 @@ i:is(.fa-light, .fa-thin, .fa-duotone, .fa-sharp) {
|
|
|
156
156
|
* Aliasing those by codepoint here is strictly better than the question mark
|
|
157
157
|
* and strictly honest about what it is: an APPROXIMATION for the Free build.
|
|
158
158
|
* `fa-cloud` is not `fa-clouds` and `fa-sun` is not `fa-sun-bright` — in
|
|
159
|
-
* production, where
|
|
159
|
+
* production, where Ekanos loads Font Awesome Pro, the real Pro rule is (0,1,0)
|
|
160
160
|
* and lives in an unlayered vendor sheet, so it wins over the `i.fa-*` selectors
|
|
161
161
|
* below and the authored Pro glyph renders exactly as designed. Nothing here
|
|
162
162
|
* changes what a correctly licensed host shows.
|
package/package.json
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekanos/harness",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "The Ekanos integration dev harness — every surface of an integration rendered in real Fusion chrome, from fixtures, with no Supabase or auth; and, in live mode, a real localhost OAuth loop over your own dev-app credentials.",
|
|
6
|
-
"license": "MIT",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "The Ekanos integration dev harness — every surface of an integration rendered in real Ekanos chrome, from fixtures, with no Supabase or auth; and, in live mode, a real localhost OAuth loop over your own dev-app credentials.",
|
|
7
5
|
"bugs": {
|
|
8
6
|
"email": "npm@govastly.com"
|
|
9
7
|
},
|
|
10
|
-
"
|
|
11
|
-
"**/*.css",
|
|
12
|
-
"**/i18n.js"
|
|
13
|
-
],
|
|
14
|
-
"ekanos": {
|
|
15
|
-
"shellContract": 2
|
|
16
|
-
},
|
|
8
|
+
"license": "MIT",
|
|
17
9
|
"files": [
|
|
18
10
|
"dist",
|
|
19
11
|
"README.md",
|
|
20
12
|
"LICENSE"
|
|
21
13
|
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"**/*.css",
|
|
17
|
+
"**/i18n.js"
|
|
18
|
+
],
|
|
19
|
+
"typesVersions": {
|
|
20
|
+
"*": {
|
|
21
|
+
"*": [
|
|
22
|
+
"dist/*"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
22
26
|
"exports": {
|
|
23
27
|
"./registry": {
|
|
24
28
|
"types": "./dist/registry.d.ts",
|
|
@@ -55,55 +59,46 @@
|
|
|
55
59
|
},
|
|
56
60
|
"dependencies": {
|
|
57
61
|
"@fortawesome/fontawesome-free": "^7.3.1",
|
|
58
|
-
"i18next": "^25.10.10",
|
|
59
62
|
"next-themes": "0.4.6",
|
|
60
|
-
"react-i18next": "^16.6.6",
|
|
61
63
|
"tw-animate-css": "1.4.0"
|
|
62
64
|
},
|
|
63
|
-
"peerDependencies": {
|
|
64
|
-
"@ekanos/sdk": "^0.3.0",
|
|
65
|
-
"@ekanos/ui": "^0.3.0",
|
|
66
|
-
"@tanstack/react-query": "^5.101.4",
|
|
67
|
-
"next": "^16.0.0",
|
|
68
|
-
"react": "^19.2.8",
|
|
69
|
-
"react-dom": "^19.2.8",
|
|
70
|
-
"react-hook-form": "^7.68.0",
|
|
71
|
-
"tailwindcss": "^4.0.0"
|
|
72
|
-
},
|
|
73
65
|
"devDependencies": {
|
|
74
|
-
"@ekanos/sdk": "0.
|
|
75
|
-
"@ekanos/ui": "0.
|
|
76
|
-
"@kit/eslint-config": "0.2.0",
|
|
77
|
-
"@kit/prettier-config": "0.1.0",
|
|
66
|
+
"@ekanos/sdk": "0.5.0",
|
|
67
|
+
"@ekanos/ui": "0.5.0",
|
|
78
68
|
"@kit/tsconfig": "0.1.0",
|
|
79
69
|
"@tailwindcss/postcss": "4.3.3",
|
|
80
|
-
"@tanstack/react-query": "5.
|
|
70
|
+
"@tanstack/react-query": "5.103.2",
|
|
81
71
|
"@types/node": "25.0.1",
|
|
82
72
|
"@types/react": "19.2.18",
|
|
83
73
|
"@types/react-dom": "19.2.5",
|
|
84
|
-
"next": "16.3.
|
|
74
|
+
"next": "16.3.6",
|
|
75
|
+
"next-intl": "^4.14.7",
|
|
85
76
|
"react": "19.2.8",
|
|
86
77
|
"react-dom": "19.2.8",
|
|
87
|
-
"react-hook-form": "^7.
|
|
78
|
+
"react-hook-form": "^7.88.0",
|
|
88
79
|
"tailwindcss": "4.3.3",
|
|
89
80
|
"tsup": "8.5.1",
|
|
90
|
-
"typescript": "^
|
|
81
|
+
"typescript": "^7.0.2",
|
|
91
82
|
"vitest": "4.1.10",
|
|
92
|
-
"zod": "
|
|
83
|
+
"zod": "4.6.5"
|
|
93
84
|
},
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"@ekanos/sdk": "^0.5.0",
|
|
87
|
+
"@ekanos/ui": "^0.5.0",
|
|
88
|
+
"@tanstack/react-query": "^5.101.4",
|
|
89
|
+
"next": "^16.0.0",
|
|
90
|
+
"next-intl": "^4.14.7",
|
|
91
|
+
"react": "^19.2.8",
|
|
92
|
+
"react-dom": "^19.2.8",
|
|
93
|
+
"react-hook-form": "^7.68.0",
|
|
94
|
+
"tailwindcss": "^4.0.0"
|
|
95
|
+
},
|
|
96
|
+
"ekanos": {
|
|
97
|
+
"shellContract": 2
|
|
101
98
|
},
|
|
102
99
|
"scripts": {
|
|
103
100
|
"build": "tsup && tsc -p tsconfig.build.json && node scripts/rewrite-esm-specifiers.mjs && node scripts/build-css.mjs",
|
|
104
101
|
"clean": "git clean -xdf .turbo node_modules dist",
|
|
105
|
-
"format": "prettier --check \"**/*.{ts,tsx,mjs}\"",
|
|
106
|
-
"lint": "eslint .",
|
|
107
102
|
"typecheck": "tsc --noEmit",
|
|
108
103
|
"test": "vitest run --config vitest.config.ts",
|
|
109
104
|
"pack:test": "node scripts/pack-test.mjs"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import i18next from "i18next";
|
|
3
|
-
import { initReactI18next } from "react-i18next";
|
|
4
|
-
if (!i18next.isInitialized) {
|
|
5
|
-
void i18next.use(initReactI18next).init({
|
|
6
|
-
lng: "en",
|
|
7
|
-
fallbackLng: "en",
|
|
8
|
-
supportedLngs: ["en"],
|
|
9
|
-
resources: { en: {} },
|
|
10
|
-
interpolation: { escapeValue: false },
|
|
11
|
-
react: { useSuspense: false }
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
var i18n_default = i18next;
|
|
15
|
-
export {
|
|
16
|
-
i18n_default as default
|
|
17
|
-
};
|