@trustgateai/sdk 1.0.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 +124 -0
- package/dist/chunk-R2YXTU4L.mjs +30 -0
- package/dist/chunk-SV5FTXAH.mjs +112 -0
- package/dist/chunk-UUGIIO3Q.mjs +31 -0
- package/dist/index.d.mts +75 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +314 -0
- package/dist/index.mjs +144 -0
- package/dist/middleware/langchain.d.mts +41 -0
- package/dist/middleware/langchain.d.ts +41 -0
- package/dist/middleware/langchain.js +156 -0
- package/dist/middleware/langchain.mjs +7 -0
- package/dist/middleware/vercel-ai.d.mts +59 -0
- package/dist/middleware/vercel-ai.d.ts +59 -0
- package/dist/middleware/vercel-ai.js +158 -0
- package/dist/middleware/vercel-ai.mjs +9 -0
- package/dist/types-BxyYog9f.d.mts +69 -0
- package/dist/types-BxyYog9f.d.ts +69 -0
- package/package.json +56 -0
- package/src/client.ts +125 -0
- package/src/context.ts +132 -0
- package/src/index.ts +31 -0
- package/src/middleware/langchain.ts +57 -0
- package/src/middleware/vercel-ai.ts +78 -0
- package/src/n8n.ts +51 -0
- package/src/types.ts +68 -0
- package/src/version.ts +2 -0
- package/tsconfig.json +17 -0
package/src/context.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { WorkflowContext, RuntimeMetadata } from "./types.js";
|
|
2
|
+
import { SDK_VERSION } from "./version.js";
|
|
3
|
+
|
|
4
|
+
/** Lowercase header prefix for proxy/gateway parity with Python SDK. */
|
|
5
|
+
export const HEADER_PREFIX = "x-trustgate";
|
|
6
|
+
/** Header carrying the full context JSON (structurally identical to Python SDK). */
|
|
7
|
+
export const SOURCE_TOOL_HEADER = "x-trustgate-source-tool";
|
|
8
|
+
|
|
9
|
+
/** Env keys we check for workflow/source metadata (Shadow AI context). */
|
|
10
|
+
const N8N_KEYS = [
|
|
11
|
+
"N8N_WORKFLOW_ID",
|
|
12
|
+
"N8N_EXECUTION_ID",
|
|
13
|
+
"N8N_WORKFLOW_NAME",
|
|
14
|
+
"N8N_EXECUTION_MODE",
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
const VERCEL_KEYS = [
|
|
18
|
+
"VERCEL",
|
|
19
|
+
"VERCEL_ENV",
|
|
20
|
+
"VERCEL_URL",
|
|
21
|
+
"VERCEL_GIT_COMMIT_REF",
|
|
22
|
+
"VERCEL_GIT_REPO_ID",
|
|
23
|
+
"VERCEL_GIT_COMMIT_SHA",
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
const GITHUB_KEYS = [
|
|
27
|
+
"GITHUB_ACTION",
|
|
28
|
+
"GITHUB_ACTIONS",
|
|
29
|
+
"GITHUB_WORKFLOW",
|
|
30
|
+
"GITHUB_RUN_ID",
|
|
31
|
+
"GITHUB_RUN_NUMBER",
|
|
32
|
+
"GITHUB_REPOSITORY",
|
|
33
|
+
"GITHUB_SHA",
|
|
34
|
+
] as const;
|
|
35
|
+
|
|
36
|
+
function pickEnv(keys: readonly string[]): Record<string, string> {
|
|
37
|
+
const out: Record<string, string> = {};
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
const v = process.env[key];
|
|
40
|
+
if (v !== undefined && v !== "") out[key] = v;
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Base runtime metadata (sdk_version, node_version, os, arch) for Python parity. */
|
|
46
|
+
function getBaseMetadata(): RuntimeMetadata {
|
|
47
|
+
return {
|
|
48
|
+
sdk_version: SDK_VERSION,
|
|
49
|
+
node_version: process.version,
|
|
50
|
+
os: process.platform,
|
|
51
|
+
arch: process.arch,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Searches process.env for workflow metadata from n8n, Vercel, or GitHub.
|
|
57
|
+
* If no managed environment is detected, returns context with source "local_script"
|
|
58
|
+
* so local developer usage is correctly tagged as Shadow AI in the dashboard.
|
|
59
|
+
* Never returns null.
|
|
60
|
+
*/
|
|
61
|
+
export function getWorkflowContextFromEnv(): WorkflowContext {
|
|
62
|
+
const baseMeta = getBaseMetadata();
|
|
63
|
+
|
|
64
|
+
const n8n = pickEnv(N8N_KEYS as unknown as string[]);
|
|
65
|
+
if (Object.keys(n8n).length > 0) {
|
|
66
|
+
return {
|
|
67
|
+
source: "n8n",
|
|
68
|
+
workflow_id: n8n.N8N_WORKFLOW_ID,
|
|
69
|
+
execution_id: n8n.N8N_EXECUTION_ID,
|
|
70
|
+
metadata: { ...baseMeta, ...n8n },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const vercel = pickEnv(VERCEL_KEYS as unknown as string[]);
|
|
75
|
+
if (Object.keys(vercel).length > 0) {
|
|
76
|
+
return {
|
|
77
|
+
source: "vercel",
|
|
78
|
+
workflow_id: vercel.VERCEL_GIT_REPO_ID || vercel.VERCEL_URL,
|
|
79
|
+
execution_id: vercel.VERCEL_GIT_COMMIT_SHA,
|
|
80
|
+
metadata: { ...baseMeta, ...vercel },
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const github = pickEnv(GITHUB_KEYS as unknown as string[]);
|
|
85
|
+
if (Object.keys(github).length > 0) {
|
|
86
|
+
return {
|
|
87
|
+
source: "github",
|
|
88
|
+
workflow_id: github.GITHUB_WORKFLOW || github.GITHUB_REPOSITORY,
|
|
89
|
+
execution_id: github.GITHUB_RUN_ID || github.GITHUB_RUN_NUMBER,
|
|
90
|
+
metadata: { ...baseMeta, ...github },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
source: "local_script",
|
|
96
|
+
metadata: baseMeta,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* JSON payload for x-trustgate-source-tool header (structurally identical to Python SDK).
|
|
102
|
+
*/
|
|
103
|
+
export function buildSourceToolJson(ctx: WorkflowContext): string {
|
|
104
|
+
const meta = ctx.metadata ?? getBaseMetadata();
|
|
105
|
+
const payload: Record<string, unknown> = {
|
|
106
|
+
source: ctx.source,
|
|
107
|
+
metadata: meta,
|
|
108
|
+
};
|
|
109
|
+
if (ctx.workflow_id !== undefined) payload.workflow_id = ctx.workflow_id;
|
|
110
|
+
if (ctx.execution_id !== undefined) payload.execution_id = ctx.execution_id;
|
|
111
|
+
if (ctx.workflow_step !== undefined) payload.workflow_step = ctx.workflow_step;
|
|
112
|
+
return JSON.stringify(payload);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Builds lowercase TrustGate context headers plus x-trustgate-source-tool JSON.
|
|
117
|
+
* Use for proxy/gateway parity and Python SDK contract.
|
|
118
|
+
*/
|
|
119
|
+
export function buildContextHeaders(ctx: WorkflowContext): Record<string, string> {
|
|
120
|
+
const meta = ctx.metadata ?? getBaseMetadata();
|
|
121
|
+
const h: Record<string, string> = {
|
|
122
|
+
[SOURCE_TOOL_HEADER]: buildSourceToolJson({ ...ctx, metadata: meta }),
|
|
123
|
+
[`${HEADER_PREFIX}-source`]: ctx.source,
|
|
124
|
+
};
|
|
125
|
+
if (ctx.workflow_id) h[`${HEADER_PREFIX}-workflow-id`] = ctx.workflow_id;
|
|
126
|
+
if (ctx.execution_id) h[`${HEADER_PREFIX}-execution-id`] = ctx.execution_id;
|
|
127
|
+
if (ctx.workflow_step) h[`${HEADER_PREFIX}-workflow-step`] = ctx.workflow_step;
|
|
128
|
+
for (const [k, v] of Object.entries(meta)) {
|
|
129
|
+
if (v) h[`${HEADER_PREFIX}-meta-${k.toLowerCase()}`] = String(v);
|
|
130
|
+
}
|
|
131
|
+
return h;
|
|
132
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TrustGate Node.js SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides a TypeScript client, workflow context from n8n/Vercel/GitHub env vars,
|
|
5
|
+
* middleware for Vercel AI SDK and LangChain, n8n header snippet helper, and
|
|
6
|
+
* SSE streaming with workflow_id preserved for Shadow AI detection.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { TrustGate } from "./client.js";
|
|
10
|
+
export {
|
|
11
|
+
getWorkflowContextFromEnv,
|
|
12
|
+
buildContextHeaders,
|
|
13
|
+
buildSourceToolJson,
|
|
14
|
+
HEADER_PREFIX,
|
|
15
|
+
SOURCE_TOOL_HEADER,
|
|
16
|
+
} from "./context.js";
|
|
17
|
+
export { getN8nHeaderSnippet } from "./n8n.js";
|
|
18
|
+
export {
|
|
19
|
+
getTrustGateHeaders,
|
|
20
|
+
createTrustGateOpenAIOptions,
|
|
21
|
+
type TrustGateOpenAIOptions,
|
|
22
|
+
} from "./middleware/vercel-ai.js";
|
|
23
|
+
export { createTrustGateLangChainConfig } from "./middleware/langchain.js";
|
|
24
|
+
|
|
25
|
+
export type {
|
|
26
|
+
WorkflowContext,
|
|
27
|
+
RuntimeMetadata,
|
|
28
|
+
TrustGateConfig,
|
|
29
|
+
RequestOptions,
|
|
30
|
+
N8nHeaderSnippet,
|
|
31
|
+
} from "./types.js";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain middleware: use TrustGate as the OpenAI endpoint with one line.
|
|
3
|
+
*
|
|
4
|
+
* ChatOpenAI (and other LangChain OpenAI integrations) support baseURL and
|
|
5
|
+
* defaultHeaders. Point them to your TrustGate gateway and inject workflow
|
|
6
|
+
* context so Shadow AI detection can attribute requests.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
*
|
|
10
|
+
* import { ChatOpenAI } from '@langchain/openai';
|
|
11
|
+
* import { createTrustGateLangChainConfig } from 'trustgate-node/middleware/langchain';
|
|
12
|
+
*
|
|
13
|
+
* const config = createTrustGateLangChainConfig({
|
|
14
|
+
* baseUrl: process.env.TRUSTGATE_BASE_URL!,
|
|
15
|
+
* apiKey: process.env.TRUSTGATE_API_KEY,
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const llm = new ChatOpenAI({
|
|
19
|
+
* ...config,
|
|
20
|
+
* modelName: 'gpt-4',
|
|
21
|
+
* temperature: 0,
|
|
22
|
+
* });
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { TrustGateConfig } from "../types.js";
|
|
26
|
+
import { getWorkflowContextFromEnv, buildContextHeaders } from "../context.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Configuration to pass to LangChain's ChatOpenAI (or other OpenAI-based classes).
|
|
30
|
+
* Sets baseURL and defaultHeaders (lowercase keys) so requests go through TrustGate
|
|
31
|
+
* with workflow context and x-trustgate-source-tool JSON for Shadow AI detection.
|
|
32
|
+
*/
|
|
33
|
+
export function createTrustGateLangChainConfig(config: TrustGateConfig): {
|
|
34
|
+
configuration?: { baseURL: string; defaultHeaders?: Record<string, string> };
|
|
35
|
+
baseURL?: string;
|
|
36
|
+
defaultHeaders?: Record<string, string>;
|
|
37
|
+
} {
|
|
38
|
+
const baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
39
|
+
const ctx = config.workflowContext ?? getWorkflowContextFromEnv();
|
|
40
|
+
const headers: Record<string, string> = {
|
|
41
|
+
...config.headers,
|
|
42
|
+
...buildContextHeaders(ctx),
|
|
43
|
+
};
|
|
44
|
+
if (config.apiKey) {
|
|
45
|
+
headers["authorization"] = `Bearer ${config.apiKey}`;
|
|
46
|
+
headers["x-api-key"] = config.apiKey;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
baseURL: baseUrl,
|
|
51
|
+
defaultHeaders: Object.keys(headers).length ? headers : undefined,
|
|
52
|
+
configuration: {
|
|
53
|
+
baseURL: baseUrl,
|
|
54
|
+
defaultHeaders: Object.keys(headers).length ? headers : undefined,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel AI SDK middleware: swap the provider to TrustGate with one line.
|
|
3
|
+
*
|
|
4
|
+
* Use createOpenAI from @openai/api or the AI SDK's OpenAI provider, and point
|
|
5
|
+
* baseURL to your TrustGate gateway. This ensures all LLM calls go through
|
|
6
|
+
* TrustGate with workflow context for Shadow AI detection.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
*
|
|
10
|
+
* import { createOpenAI } from '@ai-sdk/openai';
|
|
11
|
+
* import { createTrustGateOpenAI } from 'trustgate-node/middleware/vercel-ai';
|
|
12
|
+
*
|
|
13
|
+
* const openai = createTrustGateOpenAI({
|
|
14
|
+
* baseUrl: process.env.TRUSTGATE_BASE_URL!,
|
|
15
|
+
* apiKey: process.env.TRUSTGATE_API_KEY,
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Then use `openai` with streamText() as usual — requests go through TrustGate.
|
|
19
|
+
* const result = streamText({ model: openai('gpt-4'), messages, ... });
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { TrustGateConfig } from "../types.js";
|
|
23
|
+
import { getWorkflowContextFromEnv, buildContextHeaders } from "../context.js";
|
|
24
|
+
|
|
25
|
+
export interface TrustGateOpenAIOptions extends TrustGateConfig {
|
|
26
|
+
/**
|
|
27
|
+
* Optional OpenAI-compatible API key (if your gateway expects it in addition to TrustGate key).
|
|
28
|
+
*/
|
|
29
|
+
openaiApiKey?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns extra headers (lowercase keys) to pass to the Vercel AI SDK OpenAI provider
|
|
34
|
+
* so that requests sent to TrustGate include workflow context and x-trustgate-source-tool
|
|
35
|
+
* JSON for Shadow AI detection. Use with createOpenAI({ baseURL, headers: getTrustGateHeaders() }).
|
|
36
|
+
*/
|
|
37
|
+
export function getTrustGateHeaders(workflowContext?: TrustGateConfig["workflowContext"]): Record<string, string> {
|
|
38
|
+
const ctx = workflowContext ?? getWorkflowContextFromEnv();
|
|
39
|
+
return buildContextHeaders(ctx);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Creates options suitable for the Vercel AI SDK's OpenAI provider so that
|
|
44
|
+
* you can swap the provider to TrustGate in one line.
|
|
45
|
+
*
|
|
46
|
+
* Usage with AI SDK 3.x:
|
|
47
|
+
*
|
|
48
|
+
* import { createOpenAI } from '@ai-sdk/openai';
|
|
49
|
+
* import { createTrustGateOpenAIOptions } from 'trustgate-node/middleware/vercel-ai';
|
|
50
|
+
*
|
|
51
|
+
* const openaiOptions = createTrustGateOpenAIOptions({
|
|
52
|
+
* baseUrl: process.env.TRUSTGATE_BASE_URL!,
|
|
53
|
+
* apiKey: process.env.TRUSTGATE_API_KEY,
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* const openai = createOpenAI(openaiOptions);
|
|
57
|
+
* // use openai('gpt-4') with streamText()
|
|
58
|
+
*/
|
|
59
|
+
export function createTrustGateOpenAIOptions(options: TrustGateOpenAIOptions): {
|
|
60
|
+
baseURL: string;
|
|
61
|
+
apiKey?: string;
|
|
62
|
+
headers?: Record<string, string>;
|
|
63
|
+
} {
|
|
64
|
+
const baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
65
|
+
const headers: Record<string, string> = {
|
|
66
|
+
...options.headers,
|
|
67
|
+
...getTrustGateHeaders(options.workflowContext),
|
|
68
|
+
};
|
|
69
|
+
if (options.apiKey) {
|
|
70
|
+
headers["authorization"] = `Bearer ${options.apiKey}`;
|
|
71
|
+
headers["x-api-key"] = options.apiKey;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
baseURL: baseUrl,
|
|
75
|
+
apiKey: options.openaiApiKey ?? options.apiKey,
|
|
76
|
+
headers: Object.keys(headers).length ? headers : undefined,
|
|
77
|
+
};
|
|
78
|
+
}
|
package/src/n8n.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { N8nHeaderSnippet } from "./types.js";
|
|
2
|
+
import { getWorkflowContextFromEnv, buildContextHeaders, HEADER_PREFIX } from "./context.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns a pre-formatted JSON object of headers for use in n8n "HTTP Request" nodes.
|
|
6
|
+
* Header keys are lowercase for gateway parity. Includes TrustGate auth and workflow
|
|
7
|
+
* context (workflow_id, execution_id, source, x-trustgate-source-tool JSON).
|
|
8
|
+
*
|
|
9
|
+
* Use in n8n:
|
|
10
|
+
* 1. Add an "HTTP Request" node.
|
|
11
|
+
* 2. In "Send Headers" (or equivalent), use the returned `headers` array
|
|
12
|
+
* or paste the `json` string into a "JSON" header configuration.
|
|
13
|
+
*
|
|
14
|
+
* @param apiKey - Optional TrustGate API key (or use TRUSTGATE_API_KEY env).
|
|
15
|
+
* @param baseUrl - Optional gateway base URL (or use TRUSTGATE_BASE_URL env).
|
|
16
|
+
* @returns Headers as name/value list and as a JSON string for n8n.
|
|
17
|
+
*/
|
|
18
|
+
export function getN8nHeaderSnippet(
|
|
19
|
+
apiKey?: string,
|
|
20
|
+
baseUrl?: string
|
|
21
|
+
): N8nHeaderSnippet {
|
|
22
|
+
const key = apiKey ?? process.env.TRUSTGATE_API_KEY ?? "";
|
|
23
|
+
const url = baseUrl ?? process.env.TRUSTGATE_BASE_URL ?? "";
|
|
24
|
+
const ctx = getWorkflowContextFromEnv();
|
|
25
|
+
const contextHeaders = buildContextHeaders(ctx);
|
|
26
|
+
|
|
27
|
+
const headers: Array<{ name: string; value: string }> = [];
|
|
28
|
+
|
|
29
|
+
if (url) {
|
|
30
|
+
headers.push({ name: `${HEADER_PREFIX}-gateway-url`, value: url });
|
|
31
|
+
}
|
|
32
|
+
if (key) {
|
|
33
|
+
headers.push({ name: "authorization", value: `Bearer ${key}` });
|
|
34
|
+
headers.push({ name: "x-api-key", value: key });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const [name, value] of Object.entries(contextHeaders)) {
|
|
38
|
+
headers.push({ name, value });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const json = JSON.stringify(
|
|
42
|
+
headers.reduce<Record<string, string>>((acc, { name, value }) => {
|
|
43
|
+
acc[name] = value;
|
|
44
|
+
return acc;
|
|
45
|
+
}, {}),
|
|
46
|
+
null,
|
|
47
|
+
2
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return { headers, json };
|
|
51
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime metadata included in every context for parity with the Python SDK.
|
|
3
|
+
* Sent in x-trustgate-source-tool and in x-trustgate-meta-* headers.
|
|
4
|
+
*/
|
|
5
|
+
export interface RuntimeMetadata {
|
|
6
|
+
/** SDK version (e.g. "1.0.0"). */
|
|
7
|
+
sdk_version: string;
|
|
8
|
+
/** Node.js version (e.g. "v20.1.0"). */
|
|
9
|
+
node_version: string;
|
|
10
|
+
/** Operating system platform (process.platform, e.g. "win32", "darwin", "linux"). */
|
|
11
|
+
os: string;
|
|
12
|
+
/** CPU architecture (process.arch, e.g. "x64", "arm64"). */
|
|
13
|
+
arch: string;
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Workflow/source metadata for Shadow AI detection and observability.
|
|
19
|
+
* Populated from n8n, Vercel, GitHub Actions, or default "local_script".
|
|
20
|
+
* Metadata always includes sdk_version, node_version, os, arch for Python parity.
|
|
21
|
+
*/
|
|
22
|
+
export interface WorkflowContext {
|
|
23
|
+
/** Source: "n8n" | "vercel" | "github" | "local_script" | "custom". Never null. */
|
|
24
|
+
source: string;
|
|
25
|
+
/** Workflow or execution identifier */
|
|
26
|
+
workflow_id?: string;
|
|
27
|
+
/** Execution or run ID */
|
|
28
|
+
execution_id?: string;
|
|
29
|
+
/** Step identifier; key for generating Gantt chart bars in the Agent Intelligence dashboard. */
|
|
30
|
+
workflow_step?: string;
|
|
31
|
+
/** Runtime + environment metadata. When omitted, SDK fills sdk_version, node_version, os, arch. */
|
|
32
|
+
metadata?: RuntimeMetadata;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* TrustGate client configuration.
|
|
37
|
+
*/
|
|
38
|
+
export interface TrustGateConfig {
|
|
39
|
+
/** TrustGate gateway base URL (e.g. https://gateway.example.com) */
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
/** API key for gateway authentication (if required) */
|
|
42
|
+
apiKey?: string;
|
|
43
|
+
/** Override workflow context; if not set, context is derived from process.env (never null). */
|
|
44
|
+
workflowContext?: WorkflowContext;
|
|
45
|
+
/** Extra headers sent with every request */
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Options for a single request (merge with client config).
|
|
51
|
+
*/
|
|
52
|
+
export interface RequestOptions {
|
|
53
|
+
/** Override workflow context for this request only */
|
|
54
|
+
workflowContext?: WorkflowContext;
|
|
55
|
+
/** Additional headers for this request */
|
|
56
|
+
headers?: Record<string, string>;
|
|
57
|
+
/** Request timeout in ms */
|
|
58
|
+
timeout?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Pre-formatted headers for n8n HTTP Request node (name/value pairs).
|
|
63
|
+
*/
|
|
64
|
+
export interface N8nHeaderSnippet {
|
|
65
|
+
headers: Array<{ name: string; value: string }>;
|
|
66
|
+
/** JSON string suitable for pasting into n8n */
|
|
67
|
+
json: string;
|
|
68
|
+
}
|
package/src/version.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2020"],
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"outDir": "dist",
|
|
13
|
+
"rootDir": "src"
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": ["node_modules", "dist"]
|
|
17
|
+
}
|