@ekanos/harness 0.4.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 +21 -7
- package/dist/internal/components/dev-toolbar.js +1 -1
- package/dist/internal/components/harness-providers.js +61 -17
- package/dist/internal/routes/activation-page.js +3 -2
- package/dist/internal/server/api-router.d.ts +3 -1
- package/dist/internal/server/api-router.js +70 -1
- 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/package.json +5 -5
package/README.md
CHANGED
|
@@ -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
|
|
|
@@ -934,6 +927,27 @@ 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
|
|
@@ -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,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";
|
|
@@ -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
|
)
|
|
@@ -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
|
|
@@ -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";
|
|
@@ -67,7 +68,8 @@ const ROUTES = {
|
|
|
67
68
|
"oauth/status": { methods: ["GET"], handle: oauthStatus },
|
|
68
69
|
storage: { methods: ["GET"], handle: storage },
|
|
69
70
|
trigger: { methods: ["POST"], handle: trigger },
|
|
70
|
-
"local-setup": { methods: ["GET", "PUT"], handle: localSetup }
|
|
71
|
+
"local-setup": { methods: ["GET", "PUT"], handle: localSetup },
|
|
72
|
+
activation: { methods: ["POST", "DELETE"], handle: activation }
|
|
71
73
|
};
|
|
72
74
|
function createHarnessApiRouter(registry, deps = {}) {
|
|
73
75
|
const env = deps.env ?? process.env;
|
|
@@ -158,6 +160,7 @@ function createHarnessApiRouter(registry, deps = {}) {
|
|
|
158
160
|
integration,
|
|
159
161
|
definition,
|
|
160
162
|
adminSecrets: secrets.values,
|
|
163
|
+
accountSecrets: secrets.activation,
|
|
161
164
|
secretsFingerprint: secrets.fingerprint
|
|
162
165
|
});
|
|
163
166
|
const url = new URL(request.url);
|
|
@@ -569,10 +572,76 @@ async function localSetup(ctx) {
|
|
|
569
572
|
integration: ctx.integration,
|
|
570
573
|
definition: ctx.definition,
|
|
571
574
|
adminSecrets: reread.values,
|
|
575
|
+
accountSecrets: reread.activation,
|
|
572
576
|
secretsFingerprint: reread.fingerprint
|
|
573
577
|
});
|
|
574
578
|
return json(localSetupResponse(ctx, reread, state.connection !== null));
|
|
575
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
|
+
}
|
|
576
645
|
export {
|
|
577
646
|
createHarnessApiRouter
|
|
578
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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekanos/harness",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
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.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"email": "npm@govastly.com"
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"tw-animate-css": "1.4.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@ekanos/sdk": "0.
|
|
67
|
-
"@ekanos/ui": "0.
|
|
66
|
+
"@ekanos/sdk": "0.5.0",
|
|
67
|
+
"@ekanos/ui": "0.5.0",
|
|
68
68
|
"@kit/tsconfig": "0.1.0",
|
|
69
69
|
"@tailwindcss/postcss": "4.3.3",
|
|
70
70
|
"@tanstack/react-query": "5.103.2",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"zod": "4.6.5"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@ekanos/sdk": "^0.
|
|
87
|
-
"@ekanos/ui": "^0.
|
|
86
|
+
"@ekanos/sdk": "^0.5.0",
|
|
87
|
+
"@ekanos/ui": "^0.5.0",
|
|
88
88
|
"@tanstack/react-query": "^5.101.4",
|
|
89
89
|
"next": "^16.0.0",
|
|
90
90
|
"next-intl": "^4.14.7",
|