@ekanos/harness 0.1.5 → 0.3.0
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 +243 -79
- package/dist/api.d.ts +42 -0
- package/dist/api.js +17 -0
- package/dist/internal/components/dev-toolbar.js +4 -2
- package/dist/internal/components/harness-providers.d.ts +8 -2
- package/dist/internal/components/harness-providers.js +4 -1
- package/dist/internal/components/local-oauth-panel.d.ts +29 -0
- package/dist/internal/components/local-oauth-panel.js +355 -0
- package/dist/internal/lib/actions-transport.d.ts +30 -0
- package/dist/internal/lib/actions-transport.js +6 -0
- package/dist/internal/lib/harness-fetch-interceptor.d.ts +53 -14
- package/dist/internal/lib/harness-fetch-interceptor.js +96 -0
- package/dist/internal/lib/oauth-setup-guide.d.ts +43 -0
- package/dist/internal/lib/oauth-setup-guide.js +28 -0
- package/dist/internal/lib/original-fetch.d.ts +36 -0
- package/dist/internal/lib/original-fetch.js +23 -0
- package/dist/internal/lib/run-activation-hook.d.ts +2 -8
- package/dist/internal/lib/toolbar-context.d.ts +7 -3
- package/dist/internal/lib/toolbar-context.js +10 -5
- package/dist/internal/lib/trigger-contract.d.ts +99 -0
- package/dist/internal/lib/trigger-contract.js +25 -0
- package/dist/internal/lib/trigger-runner.d.ts +55 -0
- package/dist/internal/lib/trigger-runner.js +153 -0
- package/dist/internal/routes/activation-page.js +42 -28
- package/dist/internal/routes/integration-layout.js +6 -1
- package/dist/internal/routes/triggers-page.js +121 -147
- package/dist/internal/server/actions-fixtures-context.d.ts +57 -0
- package/dist/internal/server/actions-fixtures-context.js +52 -0
- package/dist/internal/server/api-router.d.ts +54 -0
- package/dist/internal/server/api-router.js +575 -0
- package/dist/internal/server/live-context.d.ts +93 -0
- package/dist/internal/server/live-context.js +93 -0
- package/dist/internal/server/local-secrets.d.ts +84 -0
- package/dist/internal/server/local-secrets.js +144 -0
- package/dist/internal/server/loopback-guard.d.ts +33 -0
- package/dist/internal/server/loopback-guard.js +38 -0
- package/dist/internal/server/nonce-store.d.ts +38 -0
- package/dist/internal/server/nonce-store.js +40 -0
- package/dist/internal/server/oauth-loop.d.ts +114 -0
- package/dist/internal/server/oauth-loop.js +141 -0
- package/dist/internal/server/project-root.d.ts +29 -0
- package/dist/internal/server/project-root.js +31 -0
- package/dist/internal/server/storage-read.d.ts +34 -0
- package/dist/internal/server/storage-read.js +53 -0
- package/dist/registry.d.ts +73 -1
- package/dist/registry.js +21 -1
- package/package.json +13 -7
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
2
|
+
function generateCodeVerifier() {
|
|
3
|
+
return randomBytes(32).toString("base64url");
|
|
4
|
+
}
|
|
5
|
+
function generateCodeChallenge(verifier) {
|
|
6
|
+
return createHash("sha256").update(verifier).digest("base64url");
|
|
7
|
+
}
|
|
8
|
+
function generateNonce() {
|
|
9
|
+
return randomBytes(24).toString("base64url");
|
|
10
|
+
}
|
|
11
|
+
function callbackUrl(origin, integrationSlug) {
|
|
12
|
+
return `${origin}/api/integrations/${integrationSlug}/oauth/callback`;
|
|
13
|
+
}
|
|
14
|
+
function safeReturnPath(raw, fallback) {
|
|
15
|
+
const candidatePath = raw?.trim() || fallback;
|
|
16
|
+
if (!candidatePath.startsWith("/") || candidatePath.startsWith("//") || candidatePath.includes("\\")) {
|
|
17
|
+
return fallback;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const probeOrigin = "https://return-path.invalid";
|
|
21
|
+
const candidate = new URL(candidatePath, probeOrigin);
|
|
22
|
+
if (candidate.origin !== probeOrigin) return fallback;
|
|
23
|
+
return candidate.pathname + candidate.search;
|
|
24
|
+
} catch {
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function errorRedirectUrl(args) {
|
|
29
|
+
const url = new URL(args.returnPath, args.origin);
|
|
30
|
+
url.searchParams.set(`${args.integrationSlug}_oauth_error`, args.code);
|
|
31
|
+
return url;
|
|
32
|
+
}
|
|
33
|
+
function successRedirectUrl(args) {
|
|
34
|
+
const url = new URL(args.returnPath, args.origin);
|
|
35
|
+
url.searchParams.set("oauth_success", "true");
|
|
36
|
+
return url;
|
|
37
|
+
}
|
|
38
|
+
function buildAuthorizeUrl(input) {
|
|
39
|
+
const url = new URL(input.provider.authorizationUrl);
|
|
40
|
+
url.searchParams.set("response_type", "code");
|
|
41
|
+
url.searchParams.set("client_id", input.clientId);
|
|
42
|
+
url.searchParams.set("redirect_uri", input.redirectUri);
|
|
43
|
+
url.searchParams.set("scope", input.provider.scopes.join(" "));
|
|
44
|
+
url.searchParams.set("state", input.state);
|
|
45
|
+
if (input.codeChallenge) {
|
|
46
|
+
url.searchParams.set("code_challenge", input.codeChallenge);
|
|
47
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
48
|
+
}
|
|
49
|
+
return url.toString();
|
|
50
|
+
}
|
|
51
|
+
function optionalString(value) {
|
|
52
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
53
|
+
}
|
|
54
|
+
function optionalPositiveNumber(value) {
|
|
55
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
56
|
+
const parsed = typeof value === "number" ? value : Number(value);
|
|
57
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
58
|
+
}
|
|
59
|
+
function parseTokenResponse(payload, now) {
|
|
60
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const record = payload;
|
|
64
|
+
const accessToken = optionalString(record.access_token);
|
|
65
|
+
if (!accessToken) return null;
|
|
66
|
+
const refreshToken = optionalString(record.refresh_token);
|
|
67
|
+
const expiresIn = optionalPositiveNumber(record.expires_in);
|
|
68
|
+
const scope = optionalString(record.scope);
|
|
69
|
+
const tokenType = optionalString(record.token_type);
|
|
70
|
+
return {
|
|
71
|
+
accessToken,
|
|
72
|
+
...refreshToken ? { refreshToken } : {},
|
|
73
|
+
...expiresIn !== void 0 ? {
|
|
74
|
+
expiresAt: new Date(
|
|
75
|
+
now.getTime() + Math.floor(expiresIn * 1e3)
|
|
76
|
+
).toISOString()
|
|
77
|
+
} : {},
|
|
78
|
+
...scope ? { scope } : {},
|
|
79
|
+
...tokenType ? { tokenType } : {},
|
|
80
|
+
// Parsed JSON is JSON by construction; the cast records that.
|
|
81
|
+
raw: record
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function exchangeAuthorizationCode(input) {
|
|
85
|
+
const body = new URLSearchParams({
|
|
86
|
+
grant_type: "authorization_code",
|
|
87
|
+
code: input.code,
|
|
88
|
+
redirect_uri: input.redirectUri
|
|
89
|
+
});
|
|
90
|
+
if (input.codeVerifier) {
|
|
91
|
+
body.set("code_verifier", input.codeVerifier);
|
|
92
|
+
}
|
|
93
|
+
const basic = Buffer.from(
|
|
94
|
+
`${input.clientId}:${input.clientSecret}`,
|
|
95
|
+
"utf8"
|
|
96
|
+
).toString("base64");
|
|
97
|
+
let response;
|
|
98
|
+
try {
|
|
99
|
+
response = await input.ctx.fetch(input.provider.tokenUrl, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: {
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
104
|
+
Authorization: `Basic ${basic}`
|
|
105
|
+
},
|
|
106
|
+
body: body.toString()
|
|
107
|
+
});
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
ok: false,
|
|
111
|
+
reason: "fetch_failed",
|
|
112
|
+
message: error instanceof Error ? error.message : String(error)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
return { ok: false, reason: "http_error", status: response.status };
|
|
117
|
+
}
|
|
118
|
+
let payload;
|
|
119
|
+
try {
|
|
120
|
+
payload = await response.json();
|
|
121
|
+
} catch {
|
|
122
|
+
return { ok: false, reason: "invalid_response" };
|
|
123
|
+
}
|
|
124
|
+
const tokens = parseTokenResponse(payload, input.now?.() ?? /* @__PURE__ */ new Date());
|
|
125
|
+
if (!tokens) {
|
|
126
|
+
return { ok: false, reason: "invalid_response" };
|
|
127
|
+
}
|
|
128
|
+
return { ok: true, tokens };
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
buildAuthorizeUrl,
|
|
132
|
+
callbackUrl,
|
|
133
|
+
errorRedirectUrl,
|
|
134
|
+
exchangeAuthorizationCode,
|
|
135
|
+
generateCodeChallenge,
|
|
136
|
+
generateCodeVerifier,
|
|
137
|
+
generateNonce,
|
|
138
|
+
parseTokenResponse,
|
|
139
|
+
safeReturnPath,
|
|
140
|
+
successRedirectUrl
|
|
141
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the partner's project is, seen from inside the generated shell.
|
|
3
|
+
*
|
|
4
|
+
* `ekanos dev` spawns `next dev` with cwd `<project>/.ekanos/harness`, so the
|
|
5
|
+
* project root is two directories up — and `ekanos.json` is the one file that
|
|
6
|
+
* proves a directory IS the project root rather than merely a parent. An
|
|
7
|
+
* explicit `EKANOS_PROJECT_ROOT` wins when set, for a partner who starts Next
|
|
8
|
+
* some other way, and is held to the same proof.
|
|
9
|
+
*
|
|
10
|
+
* Refuses rather than guesses: a wrong root would put the local-secrets file
|
|
11
|
+
* somewhere the partner never looks, which reads as "the harness lost my
|
|
12
|
+
* credentials".
|
|
13
|
+
*/
|
|
14
|
+
export declare const PROJECT_ROOT_ENV = "EKANOS_PROJECT_ROOT";
|
|
15
|
+
export type ProjectRootResolution = {
|
|
16
|
+
ok: true;
|
|
17
|
+
root: string;
|
|
18
|
+
source: 'env' | 'cwd';
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
message: string;
|
|
22
|
+
hint: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function resolveProjectRoot(args: {
|
|
25
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
26
|
+
cwd: string;
|
|
27
|
+
/** Test seam. Defaults to a real `fs.existsSync`. */
|
|
28
|
+
exists?: (candidate: string) => boolean;
|
|
29
|
+
}): ProjectRootResolution;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
const PROJECT_ROOT_ENV = "EKANOS_PROJECT_ROOT";
|
|
4
|
+
function resolveProjectRoot(args) {
|
|
5
|
+
const exists = args.exists ?? fs.existsSync;
|
|
6
|
+
const configured = args.env[PROJECT_ROOT_ENV]?.trim();
|
|
7
|
+
if (configured) {
|
|
8
|
+
const root = path.resolve(configured);
|
|
9
|
+
if (exists(path.join(root, "ekanos.json"))) {
|
|
10
|
+
return { ok: true, root, source: "env" };
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
ok: false,
|
|
14
|
+
message: `${PROJECT_ROOT_ENV}=${configured} does not contain an ekanos.json.`,
|
|
15
|
+
hint: 'Point it at the directory that holds ekanos.json, or unset it and start the harness with "ekanos dev".'
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const fromCwd = path.resolve(args.cwd, "..", "..");
|
|
19
|
+
if (exists(path.join(fromCwd, "ekanos.json"))) {
|
|
20
|
+
return { ok: true, root: fromCwd, source: "cwd" };
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
ok: false,
|
|
24
|
+
message: `Could not find the project root: no ekanos.json at ${fromCwd} (two directories above the server's cwd, ${args.cwd}).`,
|
|
25
|
+
hint: `Start the harness with "ekanos dev" so it runs from .ekanos/harness, or set ${PROJECT_ROOT_ENV} to the directory that holds ekanos.json.`
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
PROJECT_ROOT_ENV,
|
|
30
|
+
resolveProjectRoot
|
|
31
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IntegrationContext } from '@ekanos/sdk';
|
|
2
|
+
import type { IntegrationDefinition } from '@ekanos/sdk/integration';
|
|
3
|
+
/**
|
|
4
|
+
* The read half of `GET /api/integrations/[slug]/storage`, mirroring the
|
|
5
|
+
* Fusion host's generic storage route so `fetchIntegrationStorage()` in `@ekanos/sdk` — and therefore every
|
|
6
|
+
* partner widget built on it — works against the harness unchanged:
|
|
7
|
+
*
|
|
8
|
+
* - `?accountId=…&keys=a,b`, at most 20 keys, 400 on a malformed request;
|
|
9
|
+
* - the response is `{ [key]: value }` with no envelope;
|
|
10
|
+
* - a key is served only when its declaration says `clientReadable: true`.
|
|
11
|
+
* An undeclared key, a declared-but-private key, and a key with no stored
|
|
12
|
+
* row are all simply ABSENT — the route must not become an existence
|
|
13
|
+
* oracle over a partner's private key names;
|
|
14
|
+
* - one key whose stored row no longer parses against its schema is omitted
|
|
15
|
+
* and logged, and does not take the other keys down with it.
|
|
16
|
+
*/
|
|
17
|
+
/** Mirrors the host route's own per-request cap. */
|
|
18
|
+
export declare const MAX_KEYS_PER_REQUEST = 20;
|
|
19
|
+
export type StorageQuery = {
|
|
20
|
+
ok: true;
|
|
21
|
+
accountId: string;
|
|
22
|
+
keys: string[];
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
error: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function parseStorageQuery(url: URL): StorageQuery;
|
|
28
|
+
export declare function readClientReadableStorage(args: {
|
|
29
|
+
ctx: Pick<IntegrationContext, 'storage'>;
|
|
30
|
+
definition: Pick<IntegrationDefinition, 'storage' | 'slug'>;
|
|
31
|
+
keys: readonly string[];
|
|
32
|
+
/** Test seam; defaults to `console.warn`. */
|
|
33
|
+
warn?: (message: string, error: unknown) => void;
|
|
34
|
+
}): Promise<Record<string, unknown>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isStorageKeyClientReadable } from "@ekanos/sdk/context";
|
|
2
|
+
const MAX_KEYS_PER_REQUEST = 20;
|
|
3
|
+
function parseStorageQuery(url) {
|
|
4
|
+
const accountId = url.searchParams.get("accountId");
|
|
5
|
+
if (!accountId) {
|
|
6
|
+
return { ok: false, error: "accountId query parameter is required" };
|
|
7
|
+
}
|
|
8
|
+
const keys = Array.from(
|
|
9
|
+
new Set(
|
|
10
|
+
(url.searchParams.get("keys") ?? "").split(",").map((key) => key.trim()).filter((key) => key.length > 0)
|
|
11
|
+
)
|
|
12
|
+
);
|
|
13
|
+
if (keys.length === 0) {
|
|
14
|
+
return {
|
|
15
|
+
ok: false,
|
|
16
|
+
error: "keys query parameter is required (comma-separated)"
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (keys.length > MAX_KEYS_PER_REQUEST) {
|
|
20
|
+
return {
|
|
21
|
+
ok: false,
|
|
22
|
+
error: `A single request may read at most ${MAX_KEYS_PER_REQUEST} storage keys`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return { ok: true, accountId, keys };
|
|
26
|
+
}
|
|
27
|
+
async function readClientReadableStorage(args) {
|
|
28
|
+
const warn = args.warn ?? ((message, error) => console.warn(message, error));
|
|
29
|
+
const schemas = args.definition.storage?.account;
|
|
30
|
+
const readable = args.keys.filter(
|
|
31
|
+
(key) => isStorageKeyClientReadable({ key, schemas })
|
|
32
|
+
);
|
|
33
|
+
const entries = await Promise.all(
|
|
34
|
+
readable.map(async (key) => {
|
|
35
|
+
try {
|
|
36
|
+
const entry = await args.ctx.storage.account.get(key);
|
|
37
|
+
return entry ? [key, entry.data] : null;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
warn(
|
|
40
|
+
`[harness:${args.definition.slug}] storage: declared clientReadable key "${key}" failed to read`,
|
|
41
|
+
error
|
|
42
|
+
);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
return Object.fromEntries(entries.filter((entry) => entry !== null));
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
MAX_KEYS_PER_REQUEST,
|
|
51
|
+
parseStorageQuery,
|
|
52
|
+
readClientReadableStorage
|
|
53
|
+
};
|
package/dist/registry.d.ts
CHANGED
|
@@ -145,6 +145,17 @@ export interface HarnessLiveMode {
|
|
|
145
145
|
* production.
|
|
146
146
|
*/
|
|
147
147
|
egress?: readonly string[];
|
|
148
|
+
/**
|
|
149
|
+
* The mode this integration STARTS in, before the person at the toolbar has
|
|
150
|
+
* picked one. `'fixtures'` (the default) keeps the harness's promise that
|
|
151
|
+
* opening it never fires a request at a vendor. Declare `'live'` when your
|
|
152
|
+
* widgets never call the vendor from the browser — they talk only to the
|
|
153
|
+
* harness's own `/api/integrations/<slug>/…` routes and every vendor call
|
|
154
|
+
* runs server-side behind `ctx.fetch`, the OAuth shape — so starting live
|
|
155
|
+
* costs nothing and saves hunting for the switch. A choice made at the
|
|
156
|
+
* toolbar always wins over this, and is remembered.
|
|
157
|
+
*/
|
|
158
|
+
default?: DataMode;
|
|
148
159
|
/**
|
|
149
160
|
* @deprecated The SDK now ships this pattern: `useIntegrationFetch()` /
|
|
150
161
|
* `useActivationData()` from `@ekanos/sdk/hooks`. A NEW integration should
|
|
@@ -340,6 +351,51 @@ export interface HarnessIntegration {
|
|
|
340
351
|
definition?: IntegrationDefinition;
|
|
341
352
|
/** Seeds for the Triggers surface's mock context. */
|
|
342
353
|
triggerMocks?: HarnessTriggerMocks;
|
|
354
|
+
/**
|
|
355
|
+
* The OAuth CONNECTION STATE fixtures mode presents, for an integration
|
|
356
|
+
* whose definition declares `oauth`.
|
|
357
|
+
*
|
|
358
|
+
* The SDK's `OAuthActivationForm` and `useOAuthWidgetGate` poll
|
|
359
|
+
* `GET /api/integrations/<slug>/oauth/status`; in fixtures mode the harness
|
|
360
|
+
* answers that route itself from this field, so you do not hand-write a
|
|
361
|
+
* status fixture. Connected by default — fixtures mode exists to render
|
|
362
|
+
* widgets, and an unconnected integration renders a Connect prompt instead.
|
|
363
|
+
* Set `false`, or per variant (`{ empty: false }`), to see that prompt.
|
|
364
|
+
*
|
|
365
|
+
* Live mode ignores this: there the status is real — whether the loop has
|
|
366
|
+
* actually run on this server since it started.
|
|
367
|
+
*/
|
|
368
|
+
oauth?: {
|
|
369
|
+
connected?: boolean | Partial<Record<FixtureVariant, boolean>>;
|
|
370
|
+
/**
|
|
371
|
+
* What a HUMAN has to do in the provider's developer console before the
|
|
372
|
+
* loop can run — the part no code can do for them. The harness already
|
|
373
|
+
* derives the checklist it can from the declaration (provider host,
|
|
374
|
+
* redirect URI, scopes, PKCE, which secret name is which); this adds the
|
|
375
|
+
* two things it cannot: where the console is, and the provider's own
|
|
376
|
+
* words for each step.
|
|
377
|
+
*
|
|
378
|
+
* ```ts HarnessIntegration
|
|
379
|
+
* oauth: {
|
|
380
|
+
* setup: {
|
|
381
|
+
* consoleUrl: 'https://admindemo.docusign.com/apps-and-keys',
|
|
382
|
+
* consoleLabel: 'DocuSign Admin (demo) → Apps and Keys',
|
|
383
|
+
* notes: [
|
|
384
|
+
* 'Integration Key is the client id; add a Secret Key under Authentication — it is shown once.',
|
|
385
|
+
* ],
|
|
386
|
+
* },
|
|
387
|
+
* },
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
setup?: {
|
|
391
|
+
/** Where to create or open the OAuth app. Rendered as a link. */
|
|
392
|
+
consoleUrl?: string;
|
|
393
|
+
/** Link text. Defaults to the console URL's host. */
|
|
394
|
+
consoleLabel?: string;
|
|
395
|
+
/** Provider-specific steps, one per line, in the provider's own terms. */
|
|
396
|
+
notes?: string[];
|
|
397
|
+
};
|
|
398
|
+
};
|
|
343
399
|
}
|
|
344
400
|
/** The two data sources a surface can render from. */
|
|
345
401
|
export declare const DATA_MODES: readonly ["fixtures", "live"];
|
|
@@ -417,6 +473,20 @@ export declare function collectSeeds(integration: HarnessIntegration, variant: F
|
|
|
417
473
|
* difference is the whole fixtures ⇄ live switch.
|
|
418
474
|
*/
|
|
419
475
|
export declare function seedsForMode(integration: HarnessIntegration, variant: FixtureVariant, mode: DataMode): FixtureSeed[];
|
|
476
|
+
/**
|
|
477
|
+
* Whether fixtures mode presents `integration` as OAuth-connected in
|
|
478
|
+
* `variant`. See `HarnessIntegration.oauth`. Default: connected.
|
|
479
|
+
*/
|
|
480
|
+
export declare function resolveOAuthConnected(integration: Pick<HarnessIntegration, 'oauth'>, variant: FixtureVariant): boolean;
|
|
481
|
+
/**
|
|
482
|
+
* The SYNTHESIZED status fixture for an OAuth-declaring integration — the
|
|
483
|
+
* `ConnectionCheckResult` shape `createPartnerConnectionCheck()` in
|
|
484
|
+
* `@ekanos/sdk` expects, at the path it requests. Appended AFTER the partner's
|
|
485
|
+
* own fixtures by the layout, so a hand-written status fixture still wins
|
|
486
|
+
* (first declaration wins in `matchHttpFixture`). Empty when the definition
|
|
487
|
+
* declares no `oauth`: there is nothing to be connected to.
|
|
488
|
+
*/
|
|
489
|
+
export declare function oauthStatusFixtures(integration: Pick<HarnessIntegration, 'slug' | 'definition' | 'oauth'>, variant: FixtureVariant): HttpFixture[];
|
|
420
490
|
/**
|
|
421
491
|
* A `live.egress` that does not match the integration's own
|
|
422
492
|
* `defineIntegration({ egress })` declaration.
|
|
@@ -496,4 +566,6 @@ export declare function supportsLiveMode(integration: HarnessIntegration | null)
|
|
|
496
566
|
* each recomputing it, so there is exactly one place that decides and the
|
|
497
567
|
* hook can never report a mode other than the one that actually rendered.
|
|
498
568
|
*/
|
|
499
|
-
export declare function resolveEffectiveDataMode(integration: HarnessIntegration | null,
|
|
569
|
+
export declare function resolveEffectiveDataMode(integration: HarnessIntegration | null,
|
|
570
|
+
/** The toolbar's choice, or `null` when nobody has picked one yet. */
|
|
571
|
+
toolbarMode: DataMode | null): DataMode;
|
package/dist/registry.js
CHANGED
|
@@ -43,6 +43,24 @@ function collectSeeds(integration, variant) {
|
|
|
43
43
|
function seedsForMode(integration, variant, mode) {
|
|
44
44
|
return mode === "live" ? integration.live?.seeds ?? [] : collectSeeds(integration, variant);
|
|
45
45
|
}
|
|
46
|
+
function resolveOAuthConnected(integration, variant) {
|
|
47
|
+
const connected = integration.oauth?.connected;
|
|
48
|
+
if (connected === void 0) return true;
|
|
49
|
+
if (typeof connected === "boolean") return connected;
|
|
50
|
+
return connected[variant] ?? true;
|
|
51
|
+
}
|
|
52
|
+
function oauthStatusFixtures(integration, variant) {
|
|
53
|
+
if (!integration.definition?.oauth) return [];
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
request: `GET /api/integrations/${integration.slug}/oauth/status`,
|
|
57
|
+
response: resolveOAuthConnected(integration, variant) ? {
|
|
58
|
+
success: true,
|
|
59
|
+
data: { obtainedAt: "2026-01-01T00:00:00.000Z" }
|
|
60
|
+
} : { success: false, error: "Not connected" }
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
}
|
|
46
64
|
function findEgressMismatch(integration) {
|
|
47
65
|
const live = integration.live?.egress;
|
|
48
66
|
const declared = integration.definition?.egress;
|
|
@@ -67,7 +85,7 @@ function supportsLiveMode(integration) {
|
|
|
67
85
|
function resolveEffectiveDataMode(integration, toolbarMode) {
|
|
68
86
|
if (!supportsLiveMode(integration)) return "fixtures";
|
|
69
87
|
if (findEgressMismatch(integration)) return "fixtures";
|
|
70
|
-
return toolbarMode;
|
|
88
|
+
return toolbarMode ?? integration.live.default ?? "fixtures";
|
|
71
89
|
}
|
|
72
90
|
export {
|
|
73
91
|
DATA_MODES,
|
|
@@ -81,8 +99,10 @@ export {
|
|
|
81
99
|
findIntegration,
|
|
82
100
|
findWidget,
|
|
83
101
|
harnessWidgetsFromDefinition,
|
|
102
|
+
oauthStatusFixtures,
|
|
84
103
|
resolveEffectiveDataMode,
|
|
85
104
|
resolveEgress,
|
|
105
|
+
resolveOAuthConnected,
|
|
86
106
|
seedsForMode,
|
|
87
107
|
supportsLiveMode
|
|
88
108
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekanos/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "The Ekanos integration dev harness — every surface of an integration rendered in real Fusion chrome, from fixtures, with no Supabase
|
|
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
6
|
"license": "MIT",
|
|
7
7
|
"bugs": {
|
|
8
8
|
"email": "npm@govastly.com"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"**/i18n.js"
|
|
13
13
|
],
|
|
14
14
|
"ekanos": {
|
|
15
|
-
"shellContract":
|
|
15
|
+
"shellContract": 2
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"types": "./dist/hooks.d.ts",
|
|
41
41
|
"default": "./dist/hooks.js"
|
|
42
42
|
},
|
|
43
|
+
"./api": {
|
|
44
|
+
"types": "./dist/api.d.ts",
|
|
45
|
+
"default": "./dist/api.js"
|
|
46
|
+
},
|
|
43
47
|
"./styles.css": "./dist/styles.css",
|
|
44
48
|
"./mocks/team-account-workspace": {
|
|
45
49
|
"types": "./dist/mocks/team-account-workspace.d.ts",
|
|
@@ -57,17 +61,18 @@
|
|
|
57
61
|
"tw-animate-css": "1.4.0"
|
|
58
62
|
},
|
|
59
63
|
"peerDependencies": {
|
|
60
|
-
"@ekanos/sdk": "^0.
|
|
61
|
-
"@ekanos/ui": "^0.
|
|
64
|
+
"@ekanos/sdk": "^0.3.0",
|
|
65
|
+
"@ekanos/ui": "^0.3.0",
|
|
62
66
|
"@tanstack/react-query": "^5.101.4",
|
|
63
67
|
"next": "^16.0.0",
|
|
64
68
|
"react": "^19.2.8",
|
|
65
69
|
"react-dom": "^19.2.8",
|
|
70
|
+
"react-hook-form": "^7.68.0",
|
|
66
71
|
"tailwindcss": "^4.0.0"
|
|
67
72
|
},
|
|
68
73
|
"devDependencies": {
|
|
69
|
-
"@ekanos/sdk": "0.
|
|
70
|
-
"@ekanos/ui": "0.
|
|
74
|
+
"@ekanos/sdk": "0.3.0",
|
|
75
|
+
"@ekanos/ui": "0.3.0",
|
|
71
76
|
"@kit/eslint-config": "0.2.0",
|
|
72
77
|
"@kit/prettier-config": "0.1.0",
|
|
73
78
|
"@kit/tsconfig": "0.1.0",
|
|
@@ -79,6 +84,7 @@
|
|
|
79
84
|
"next": "16.3.3",
|
|
80
85
|
"react": "19.2.8",
|
|
81
86
|
"react-dom": "19.2.8",
|
|
87
|
+
"react-hook-form": "^7.87.0",
|
|
82
88
|
"tailwindcss": "4.3.3",
|
|
83
89
|
"tsup": "8.5.1",
|
|
84
90
|
"typescript": "^5.9.3",
|