@zackbart/connecta 0.29.0 → 0.30.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/CHANGELOG.md +67 -0
- package/README.md +123 -134
- package/bin/connecta.mjs +13 -2
- package/bin/version.mjs +1 -1
- package/dist/argument-redaction.js +230 -0
- package/dist/auth-elicitation.js +14 -9
- package/dist/authorization-handoff.js +111 -0
- package/dist/catalog-cache.js +2 -2
- package/dist/catalog-service.js +103 -63
- package/dist/config.d.ts +2 -0
- package/dist/config.js +12 -7
- package/dist/connectors/guarded-fetch.js +3 -3
- package/dist/connectors/negotiation-cache.js +1 -1
- package/dist/downstream-input-context.js +9 -0
- package/dist/downstream-input.js +13 -11
- package/dist/errors.d.ts +36 -12
- package/dist/errors.js +19 -9
- package/dist/execute.js +375 -43
- package/dist/executor-result.js +11 -9
- package/dist/executors/quickjs-child.js +12 -5
- package/dist/executors/quickjs-protocol.js +5 -6
- package/dist/executors/quickjs-runtime.js +6 -1
- package/dist/executors/quickjs.js +20 -4
- package/dist/guest-runtime.js +52 -2
- package/dist/guest-types.d.ts +47 -5
- package/dist/index.d.ts +1 -1
- package/dist/invocation.js +40 -14
- package/dist/meta-output.js +0 -15
- package/dist/meta-tools.js +166 -95
- package/dist/oauth-handoff.js +88 -11
- package/dist/program-result.js +5 -0
- package/dist/program-writes.js +5 -1
- package/dist/provider.d.ts +1 -1
- package/dist/providers/_shared/google/workspace.d.ts +1 -1
- package/dist/providers/_shared/request-token.js +83 -0
- package/dist/providers/infisical/index.d.ts +7 -0
- package/dist/providers/infisical/index.js +713 -0
- package/dist/providers/infisical/skill.generated.js +8 -0
- package/dist/registry.d.ts +8 -6
- package/dist/registry.js +134 -61
- package/dist/resource-read.js +4 -1
- package/dist/routes/mcp.js +11 -2
- package/dist/sent-secrets.d.ts +54 -13
- package/dist/sent-secrets.js +770 -231
- package/dist/skills.js +26 -16
- package/dist/sqlite.js +21 -6
- package/dist/storage/keys.js +20 -5
- package/dist/storage/memory.js +9 -4
- package/dist/storage/sql.js +18 -9
- package/dist/types.d.ts +17 -3
- package/dist/usage-guide.js +49 -40
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker.js +2 -1
- package/documentation/README.md +63 -0
- package/documentation/architecture.md +121 -89
- package/documentation/auth.md +138 -5
- package/documentation/code-mode.md +224 -107
- package/documentation/deploying.md +146 -0
- package/documentation/integrating.md +159 -0
- package/documentation/meta-tools.md +135 -30
- package/documentation/operating.md +135 -0
- package/documentation/operator-tests.md +4 -0
- package/documentation/operator-ui.md +132 -0
- package/documentation/provider-migration-0.29.md +5 -0
- package/examples/worker/README.md +7 -0
- package/package.json +7 -1
- package/templates/node/README.md +7 -0
- package/templates/node/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** In-memory tokens and credential-bound login flights shared only inside one request. */
|
|
2
|
+
import { ConnectorCallError } from "../../errors.js";
|
|
3
|
+
const LOGIN_TIMEOUT_MS = 15_000;
|
|
4
|
+
const MAX_CACHED_TOKENS = 512;
|
|
5
|
+
/** Each provider instance owns its cache, so no credential crosses an API origin. */
|
|
6
|
+
export function requestTokenCache(source) {
|
|
7
|
+
const tokens = new Map();
|
|
8
|
+
const requests = new WeakMap();
|
|
9
|
+
function start(auth, ctx) {
|
|
10
|
+
const controller = new AbortController();
|
|
11
|
+
const timer = setTimeout(() => controller.abort(new ConnectorCallError("unavailable", "Machine identity login timed out.")), LOGIN_TIMEOUT_MS);
|
|
12
|
+
const flight = { controller, waiters: 0, settled: false, promise: Promise.resolve("") };
|
|
13
|
+
flight.promise = auth
|
|
14
|
+
.mint({ ...ctx, signal: controller.signal })
|
|
15
|
+
.then((minted) => {
|
|
16
|
+
// An abandoned login must not seed a token after cancellation.
|
|
17
|
+
controller.signal.throwIfAborted();
|
|
18
|
+
tokens.delete(auth.key);
|
|
19
|
+
tokens.set(auth.key, minted);
|
|
20
|
+
while (tokens.size > MAX_CACHED_TOKENS)
|
|
21
|
+
tokens.delete(tokens.keys().next().value);
|
|
22
|
+
return minted.accessToken;
|
|
23
|
+
})
|
|
24
|
+
.finally(() => {
|
|
25
|
+
flight.settled = true;
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
});
|
|
28
|
+
// All waiters may cancel before the transport observes its abort.
|
|
29
|
+
void flight.promise.catch(() => { });
|
|
30
|
+
return flight;
|
|
31
|
+
}
|
|
32
|
+
async function follow(flight, signal) {
|
|
33
|
+
signal?.throwIfAborted();
|
|
34
|
+
flight.waiters++;
|
|
35
|
+
let onAbort;
|
|
36
|
+
try {
|
|
37
|
+
const aborted = new Promise((_, reject) => {
|
|
38
|
+
if (!signal)
|
|
39
|
+
return;
|
|
40
|
+
onAbort = () => reject(signal.reason);
|
|
41
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
42
|
+
});
|
|
43
|
+
return await Promise.race([flight.promise, aborted]);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
if (onAbort)
|
|
47
|
+
signal?.removeEventListener("abort", onAbort);
|
|
48
|
+
flight.waiters--;
|
|
49
|
+
if (!flight.settled && flight.waiters === 0)
|
|
50
|
+
flight.controller.abort();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
async token(ctx, rejected) {
|
|
55
|
+
ctx.signal?.throwIfAborted();
|
|
56
|
+
const auth = await source(ctx);
|
|
57
|
+
ctx.signal?.throwIfAborted();
|
|
58
|
+
const cached = tokens.get(auth.key);
|
|
59
|
+
if (cached && cached.accessToken !== rejected && cached.expiresAt > Date.now())
|
|
60
|
+
return cached.accessToken;
|
|
61
|
+
const scope = ctx.requestScope ?? ctx;
|
|
62
|
+
let perCredential = requests.get(scope);
|
|
63
|
+
if (!perCredential) {
|
|
64
|
+
perCredential = new Map();
|
|
65
|
+
requests.set(scope, perCredential);
|
|
66
|
+
}
|
|
67
|
+
let request = perCredential.get(auth.key);
|
|
68
|
+
if (!request) {
|
|
69
|
+
request = {};
|
|
70
|
+
perCredential.set(auth.key, request);
|
|
71
|
+
}
|
|
72
|
+
if (rejected !== undefined) {
|
|
73
|
+
// Keep the recovery outcome for the request, including failures. Later
|
|
74
|
+
// 401s can never turn this into a fresh-login loop.
|
|
75
|
+
request.recovery ??= start(auth, ctx);
|
|
76
|
+
return await follow(request.recovery, ctx.signal);
|
|
77
|
+
}
|
|
78
|
+
if (!request.initial || request.initial.settled || request.initial.controller.signal.aborted)
|
|
79
|
+
request.initial = start(auth, ctx);
|
|
80
|
+
return await follow(request.initial, ctx.signal);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ProviderOptions } from "../../provider.js";
|
|
2
|
+
export declare const INFISICAL_API_BASE_URL = "https://app.infisical.com/api";
|
|
3
|
+
export interface InfisicalOptions extends ProviderOptions {
|
|
4
|
+
/** API base including /api; US cloud by default, EU cloud or self-hosted HTTPS allowed. */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const infisical: import("../../provider.js").ProviderFactory<InfisicalOptions>;
|