@mistweaverco/kulala-core 0.1.6 → 0.18.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/dist/cli.js +232 -0
- package/dist/index.d.ts +2 -33
- package/dist/index.js +236 -14763
- package/dist/install-backend.js +202 -0
- package/dist/lib/downloader/index.d.ts +15 -0
- package/dist/lib/kulala-core/index.d.ts +17 -0
- package/dist/lib/kulala-core/types.d.ts +142 -0
- package/package.json +15 -22
- package/LICENSE +0 -21
- package/README.md +0 -84
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -58
- package/dist/lib/auth/oauth2/acquisition.d.ts +0 -39
- package/dist/lib/auth/oauth2/acquisition.d.ts.map +0 -1
- package/dist/lib/auth/oauth2/browser-flow.d.ts +0 -62
- package/dist/lib/auth/oauth2/browser-flow.d.ts.map +0 -1
- package/dist/lib/auth/oauth2/config.d.ts +0 -17
- package/dist/lib/auth/oauth2/config.d.ts.map +0 -1
- package/dist/lib/auth/oauth2/continuation.d.ts +0 -10
- package/dist/lib/auth/oauth2/continuation.d.ts.map +0 -1
- package/dist/lib/auth/oauth2/manager.d.ts +0 -21
- package/dist/lib/auth/oauth2/manager.d.ts.map +0 -1
- package/dist/lib/auth/oauth2/prompt-error.d.ts +0 -10
- package/dist/lib/auth/oauth2/prompt-error.d.ts.map +0 -1
- package/dist/lib/auth/oauth2/prompt-helper.d.ts +0 -16
- package/dist/lib/auth/oauth2/prompt-helper.d.ts.map +0 -1
- package/dist/lib/auth/oauth2/types.d.ts +0 -60
- package/dist/lib/auth/oauth2/types.d.ts.map +0 -1
- package/dist/lib/helpers/index.d.ts +0 -2
- package/dist/lib/helpers/index.d.ts.map +0 -1
- package/dist/lib/parser/at-variables.d.ts +0 -17
- package/dist/lib/parser/at-variables.d.ts.map +0 -1
- package/dist/lib/parser/body.d.ts +0 -5
- package/dist/lib/parser/body.d.ts.map +0 -1
- package/dist/lib/parser/comment.d.ts +0 -3
- package/dist/lib/parser/comment.d.ts.map +0 -1
- package/dist/lib/parser/directive.d.ts +0 -15
- package/dist/lib/parser/directive.d.ts.map +0 -1
- package/dist/lib/parser/header.d.ts +0 -4
- package/dist/lib/parser/header.d.ts.map +0 -1
- package/dist/lib/parser/index.d.ts +0 -6
- package/dist/lib/parser/index.d.ts.map +0 -1
- package/dist/lib/parser/lib/helpers/index.d.ts +0 -10
- package/dist/lib/parser/lib/helpers/index.d.ts.map +0 -1
- package/dist/lib/parser/operator.d.ts +0 -4
- package/dist/lib/parser/operator.d.ts.map +0 -1
- package/dist/lib/parser/parser.d.ts +0 -3
- package/dist/lib/parser/parser.d.ts.map +0 -1
- package/dist/lib/parser/request.d.ts +0 -10
- package/dist/lib/parser/request.d.ts.map +0 -1
- package/dist/lib/parser/script.d.ts +0 -8
- package/dist/lib/parser/script.d.ts.map +0 -1
- package/dist/lib/parser/types/block.d.ts +0 -31
- package/dist/lib/parser/types/block.d.ts.map +0 -1
- package/dist/lib/parser/types/body.d.ts +0 -41
- package/dist/lib/parser/types/body.d.ts.map +0 -1
- package/dist/lib/parser/types/comment.d.ts +0 -6
- package/dist/lib/parser/types/comment.d.ts.map +0 -1
- package/dist/lib/parser/types/directive.d.ts +0 -13
- package/dist/lib/parser/types/directive.d.ts.map +0 -1
- package/dist/lib/parser/types/document.d.ts +0 -17
- package/dist/lib/parser/types/document.d.ts.map +0 -1
- package/dist/lib/parser/types/error.d.ts +0 -7
- package/dist/lib/parser/types/error.d.ts.map +0 -1
- package/dist/lib/parser/types/header.d.ts +0 -5
- package/dist/lib/parser/types/header.d.ts.map +0 -1
- package/dist/lib/parser/types/index.d.ts +0 -4
- package/dist/lib/parser/types/index.d.ts.map +0 -1
- package/dist/lib/parser/types/operator.d.ts +0 -10
- package/dist/lib/parser/types/operator.d.ts.map +0 -1
- package/dist/lib/parser/types/parser.d.ts +0 -6
- package/dist/lib/parser/types/parser.d.ts.map +0 -1
- package/dist/lib/parser/types/request.d.ts +0 -44
- package/dist/lib/parser/types/request.d.ts.map +0 -1
- package/dist/lib/parser/types/script.d.ts +0 -13
- package/dist/lib/parser/types/script.d.ts.map +0 -1
- package/dist/lib/parser/types/session.d.ts +0 -27
- package/dist/lib/parser/types/session.d.ts.map +0 -1
- package/dist/lib/parser/types/stdinparsed.d.ts +0 -31
- package/dist/lib/parser/types/stdinparsed.d.ts.map +0 -1
- package/dist/lib/parser/types/variable.d.ts +0 -4
- package/dist/lib/parser/types/variable.d.ts.map +0 -1
- package/dist/lib/persistence/cookie-store.d.ts +0 -13
- package/dist/lib/persistence/cookie-store.d.ts.map +0 -1
- package/dist/lib/persistence/data-dir.d.ts +0 -12
- package/dist/lib/persistence/data-dir.d.ts.map +0 -1
- package/dist/lib/persistence/db.d.ts +0 -44
- package/dist/lib/persistence/db.d.ts.map +0 -1
- package/dist/lib/persistence/document-store.d.ts +0 -15
- package/dist/lib/persistence/document-store.d.ts.map +0 -1
- package/dist/lib/persistence/encrypted-store.d.ts +0 -17
- package/dist/lib/persistence/encrypted-store.d.ts.map +0 -1
- package/dist/lib/persistence/history-store.d.ts +0 -26
- package/dist/lib/persistence/history-store.d.ts.map +0 -1
- package/dist/lib/persistence/index.d.ts +0 -26
- package/dist/lib/persistence/index.d.ts.map +0 -1
- package/dist/lib/persistence/keychain.d.ts +0 -24
- package/dist/lib/persistence/keychain.d.ts.map +0 -1
- package/dist/lib/persistence/prompt-store.d.ts +0 -31
- package/dist/lib/persistence/prompt-store.d.ts.map +0 -1
- package/dist/lib/persistence/replay-store.d.ts +0 -19
- package/dist/lib/persistence/replay-store.d.ts.map +0 -1
- package/dist/lib/persistence/variable-store.d.ts +0 -34
- package/dist/lib/persistence/variable-store.d.ts.map +0 -1
- package/dist/lib/runner/block.d.ts +0 -7
- package/dist/lib/runner/block.d.ts.map +0 -1
- package/dist/lib/runner/body.d.ts +0 -30
- package/dist/lib/runner/body.d.ts.map +0 -1
- package/dist/lib/runner/curl-transport.d.ts +0 -3
- package/dist/lib/runner/curl-transport.d.ts.map +0 -1
- package/dist/lib/runner/doRequest.d.ts +0 -5
- package/dist/lib/runner/doRequest.d.ts.map +0 -1
- package/dist/lib/runner/embedded-curl.d.ts +0 -2
- package/dist/lib/runner/embedded-curl.d.ts.map +0 -1
- package/dist/lib/runner/headers.d.ts +0 -14
- package/dist/lib/runner/headers.d.ts.map +0 -1
- package/dist/lib/runner/http-client.d.ts +0 -61
- package/dist/lib/runner/http-client.d.ts.map +0 -1
- package/dist/lib/runner/http-transport.d.ts +0 -5
- package/dist/lib/runner/http-transport.d.ts.map +0 -1
- package/dist/lib/runner/index.d.ts +0 -10
- package/dist/lib/runner/index.d.ts.map +0 -1
- package/dist/lib/runner/scripts.d.ts +0 -14
- package/dist/lib/runner/scripts.d.ts.map +0 -1
- package/dist/lib/runner/types.d.ts +0 -91
- package/dist/lib/runner/types.d.ts.map +0 -1
- package/dist/lib/variables/env-files.d.ts +0 -17
- package/dist/lib/variables/env-files.d.ts.map +0 -1
- package/dist/lib/variables/flatten-json.d.ts +0 -7
- package/dist/lib/variables/flatten-json.d.ts.map +0 -1
- package/dist/lib/variables/index.d.ts +0 -22
- package/dist/lib/variables/index.d.ts.map +0 -1
- package/dist/lib/variables/kuba.d.ts +0 -15
- package/dist/lib/variables/kuba.d.ts.map +0 -1
- package/dist/lib/variables/magic.d.ts +0 -7
- package/dist/lib/variables/magic.d.ts.map +0 -1
- package/dist/lib/variables/request-vars.d.ts +0 -25
- package/dist/lib/variables/request-vars.d.ts.map +0 -1
- package/dist/lib/variables/resolve.d.ts +0 -16
- package/dist/lib/variables/resolve.d.ts.map +0 -1
- package/dist/lib/variables/stable-id.d.ts +0 -6
- package/dist/lib/variables/stable-id.d.ts.map +0 -1
- package/dist/lib/variables/substitute.d.ts +0 -28
- package/dist/lib/variables/substitute.d.ts.map +0 -1
- package/scripts/ensure-vendored-curl.ts +0 -223
- package/scripts/generate-vendored-curl.ts +0 -108
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP client using node:http, node:https, and node:http2 with timing instrumentation
|
|
3
|
-
* to match the timings shape previously provided by got (dns, tcp, tls, request, firstByte, total).
|
|
4
|
-
*/
|
|
5
|
-
export type NodeHttpClientTimings = {
|
|
6
|
-
phases: {
|
|
7
|
-
dns: number;
|
|
8
|
-
tcp: number;
|
|
9
|
-
tls: number;
|
|
10
|
-
request: number;
|
|
11
|
-
/** Time from request sent to first byte (server TTFB). */
|
|
12
|
-
firstByte: number;
|
|
13
|
-
/** Time from start (t0) to first byte; matches curl time_starttransfer. */
|
|
14
|
-
startTransfer: number;
|
|
15
|
-
/** Total time spent on redirect steps (curl time_redirect). 0 if no redirects. */
|
|
16
|
-
redirect: number;
|
|
17
|
-
total: number;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export type NodeHttpClientResponse = {
|
|
21
|
-
statusCode: number;
|
|
22
|
-
headers: Record<string, string>;
|
|
23
|
-
body: string | Buffer;
|
|
24
|
-
timings: NodeHttpClientTimings;
|
|
25
|
-
/** Final resolved URL (after redirects). */
|
|
26
|
-
url: string;
|
|
27
|
-
/** performance.now() when first byte of this response was received (for startTransfer from wall start). */
|
|
28
|
-
firstByteTime: number;
|
|
29
|
-
/** Present only when at least one redirect occurred (ordered hops, including the final response). */
|
|
30
|
-
redirectChain?: Array<{
|
|
31
|
-
statusCode: number;
|
|
32
|
-
headers: Record<string, string>;
|
|
33
|
-
body: string | Buffer;
|
|
34
|
-
timings: NodeHttpClientTimings;
|
|
35
|
-
url: string;
|
|
36
|
-
}>;
|
|
37
|
-
};
|
|
38
|
-
export type NodeHttpClientOptions = {
|
|
39
|
-
url: string;
|
|
40
|
-
method: string;
|
|
41
|
-
headers: Record<string, string>;
|
|
42
|
-
/** Body: string, Buffer, or FormData (multipart). For FormData we encode with form-data-encoder. */
|
|
43
|
-
body?: string | Buffer | FormData;
|
|
44
|
-
/** When "HTTP/2", use http2 for https URLs. Otherwise use http/https. */
|
|
45
|
-
httpVersion?: "HTTP/1.0" | "HTTP/1.1" | "HTTP/2";
|
|
46
|
-
/** If true, allow insecure TLS (curl --insecure). */
|
|
47
|
-
insecure?: boolean;
|
|
48
|
-
/** Request timeout in milliseconds (best-effort; curl --max-time). */
|
|
49
|
-
timeoutMs?: number;
|
|
50
|
-
/** Connection timeout in milliseconds (best-effort; curl --connect-timeout). */
|
|
51
|
-
connectionTimeoutMs?: number;
|
|
52
|
-
/** Whether to follow redirects (default true). */
|
|
53
|
-
followRedirects?: boolean;
|
|
54
|
-
/** Whether to propagate Set-Cookie -> Cookie across redirect hops (default true). */
|
|
55
|
-
propagateCookiesOnRedirect?: boolean;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Perform an HTTP request via cURL (spawned), with timing instrumentation.
|
|
59
|
-
*/
|
|
60
|
-
export declare function nodeHttpRequest(options: NodeHttpClientOptions): Promise<NodeHttpClientResponse>;
|
|
61
|
-
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../../src/lib/runner/http-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,0DAA0D;QAC1D,SAAS,EAAE,MAAM,CAAC;QAClB,2EAA2E;QAC3E,aAAa,EAAE,MAAM,CAAC;QACtB,kFAAkF;QAClF,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,MAAM,CA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rB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC1E,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { KulalaDocument } from "../parser/types";
|
|
2
|
-
import type { KulalaStdinActionRunLimit } from "../parser/types/stdinparsed";
|
|
3
|
-
import type { KulalaRunOptions, KulalaResponseWrapper } from "./types";
|
|
4
|
-
export type { KulalaRunOptions } from "./types";
|
|
5
|
-
export type { KulalaRequestErrorResponse, KulalaRequestSuccessResponse, KulalaResponseWrapper, } from "./types";
|
|
6
|
-
export declare function runDocument(doc: KulalaDocument, limit?: KulalaStdinActionRunLimit[], options?: KulalaRunOptions): Promise<KulalaResponseWrapper>;
|
|
7
|
-
export declare const KulalaRunner: () => {
|
|
8
|
-
run: (doc: KulalaDocument, limit?: KulalaStdinActionRunLimit[], options?: KulalaRunOptions) => Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAa7E,OAAO,KAAK,EAIV,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAEjB,wBAAsB,WAAW,CAC/B,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,yBAAyB,EAAE,EACnC,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,CAAC,CA6GhC;AAED,eAAO,MAAM,YAAY;eAGd,cAAc,UACX,yBAAyB,EAAE,YACzB,gBAAgB,KACzB,OAAO,CAAC,IAAI,CAAC;CASnB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { KulalaBlock } from "./../parser/types/block";
|
|
2
|
-
import type { RunnerResponseLike } from "./types";
|
|
3
|
-
import { type KulalaScript, type KulalaScriptType } from "./../parser/types/script";
|
|
4
|
-
export type ScriptFlowContext = {
|
|
5
|
-
/** "Execution flow" local headers (not persisted). */
|
|
6
|
-
globalHeaders: Record<string, string>;
|
|
7
|
-
};
|
|
8
|
-
/** Mirrors JetBrains ContentType (Content-Type header). */
|
|
9
|
-
export type ScriptContentType = {
|
|
10
|
-
mimeType: string;
|
|
11
|
-
charset: string;
|
|
12
|
-
};
|
|
13
|
-
export declare const runScripts: (scripts: KulalaScript[], type: KulalaScriptType, block: KulalaBlock, filePath?: string, response?: RunnerResponseLike, vars?: Record<string, string>, flow?: ScriptFlowContext) => Promise<void>;
|
|
14
|
-
//# sourceMappingURL=scripts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/lib/runner/scripts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAmBlC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAQF,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAuWF,eAAO,MAAM,UAAU,GACrB,SAAS,YAAY,EAAE,EACvB,MAAM,gBAAgB,EACtB,OAAO,WAAW,EAClB,WAAW,MAAM,EACjB,WAAW,kBAAkB,EAC7B,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,OAAO,iBAAiB,KACvB,OAAO,CAAC,IAAI,CAiId,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
export type KulalaRequestSuccessResponse = {
|
|
2
|
-
success: true;
|
|
3
|
-
status: number;
|
|
4
|
-
headers: Record<string, string>;
|
|
5
|
-
/** Final resolved URL (after redirects). */
|
|
6
|
-
url: string;
|
|
7
|
-
/** Present only when at least one redirect occurred (ordered hops, including the final response). */
|
|
8
|
-
redirectChain?: Array<{
|
|
9
|
-
status: number;
|
|
10
|
-
headers: Record<string, string>;
|
|
11
|
-
url: string;
|
|
12
|
-
body: {
|
|
13
|
-
type: "text";
|
|
14
|
-
content: string;
|
|
15
|
-
} | {
|
|
16
|
-
type: "json";
|
|
17
|
-
content: Record<string, unknown>;
|
|
18
|
-
};
|
|
19
|
-
timings: {
|
|
20
|
-
dns: number;
|
|
21
|
-
tcp: number;
|
|
22
|
-
tls: number;
|
|
23
|
-
request: number;
|
|
24
|
-
redirect: number;
|
|
25
|
-
firstByte: number;
|
|
26
|
-
startTransfer: number;
|
|
27
|
-
total: number;
|
|
28
|
-
};
|
|
29
|
-
}>;
|
|
30
|
-
timings: {
|
|
31
|
-
dns: number;
|
|
32
|
-
tcp: number;
|
|
33
|
-
tls: number;
|
|
34
|
-
request: number;
|
|
35
|
-
redirect: number;
|
|
36
|
-
/** Time from request sent to first byte (server TTFB). */
|
|
37
|
-
firstByte: number;
|
|
38
|
-
/** Time from start to first byte; matches curl time_starttransfer. */
|
|
39
|
-
startTransfer: number;
|
|
40
|
-
total: number;
|
|
41
|
-
};
|
|
42
|
-
body: {
|
|
43
|
-
type: "text";
|
|
44
|
-
content: string;
|
|
45
|
-
} | {
|
|
46
|
-
type: "json";
|
|
47
|
-
content: Record<string, unknown>;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export type KulalaRequestErrorResponse = {
|
|
51
|
-
success: false;
|
|
52
|
-
error: string;
|
|
53
|
-
};
|
|
54
|
-
export type KulalaPromptResponse = {
|
|
55
|
-
success: false;
|
|
56
|
-
prompt: true;
|
|
57
|
-
promptId: string;
|
|
58
|
-
promptType: string;
|
|
59
|
-
message: string;
|
|
60
|
-
inputs: Array<{
|
|
61
|
-
id: string;
|
|
62
|
-
label: string;
|
|
63
|
-
type: "text" | "password" | "url";
|
|
64
|
-
required?: boolean;
|
|
65
|
-
}>;
|
|
66
|
-
};
|
|
67
|
-
export type KulalaResponseWrapper = {
|
|
68
|
-
type: "responses";
|
|
69
|
-
data: Array<KulalaRequestSuccessResponse | KulalaRequestErrorResponse | KulalaPromptResponse>;
|
|
70
|
-
} | {
|
|
71
|
-
type: "error";
|
|
72
|
-
data: Array<KulalaRequestErrorResponse>;
|
|
73
|
-
};
|
|
74
|
-
export type RequestHeaderType = "json" | "form-data" | "form-urlencoded" | "invalid";
|
|
75
|
-
export type VariableResolver = (name: string) => string | undefined;
|
|
76
|
-
export type KulalaRunOptions = {
|
|
77
|
-
/** Raw document content (for stable ID when filepath is absent). */
|
|
78
|
-
content?: string;
|
|
79
|
-
/** Environment name for variable resolution (kuba, etc.). Defaults to "default". */
|
|
80
|
-
env?: string;
|
|
81
|
-
};
|
|
82
|
-
/** Response-like value passed to scripts (fetch Response or compatible). */
|
|
83
|
-
export type RunnerResponseLike = {
|
|
84
|
-
body: unknown;
|
|
85
|
-
statusCode: number;
|
|
86
|
-
headers: Record<string, string>;
|
|
87
|
-
timings: {
|
|
88
|
-
phases: Record<string, number>;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.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AAC5E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CAC7C,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Collect directory paths from startDir upward to root.
|
|
3
|
-
*/
|
|
4
|
-
export declare function dirsUpward(startDir: string): string[];
|
|
5
|
-
/**
|
|
6
|
-
* Load raw JSON section from http-client.env.json or http-client.private.env.json.
|
|
7
|
-
* Returns the raw object (not flattened) for the given env key.
|
|
8
|
-
*/
|
|
9
|
-
export declare function loadHttpClientEnvJsonRaw(filePath: string, env: string): Record<string, unknown> | null;
|
|
10
|
-
/**
|
|
11
|
-
* Load environment variables from system, http-client.env.json, and .env.
|
|
12
|
-
* Order (later overrides earlier): system env → http-client.env.json (merged from dirs upward, closest wins) → http-client.private.env.json → .env.
|
|
13
|
-
* Also exposes system env as {{$env.VAR_NAME}} per JetBrains HTTP Client spec.
|
|
14
|
-
* See https://www.jetbrains.com/help/idea/http-client-variables.html
|
|
15
|
-
*/
|
|
16
|
-
export declare function loadEnvVars(env: string, startDir: string): Record<string, string>;
|
|
17
|
-
//# sourceMappingURL=env-files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-files.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/env-files.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAUrD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAWhC;AA2CD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4CxB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flatten nested JSON into dotted path keys (JetBrains-style JSONPath in variables).
|
|
3
|
-
* - client.host.url from { client: { host: { url: "example.org" } } }
|
|
4
|
-
* - client.['host.url'] for keys that contain a dot: { client: { "host.url": "example.org" } }
|
|
5
|
-
*/
|
|
6
|
-
export declare function flattenToDotPaths(obj: unknown, prefix: string, out: Record<string, string>): void;
|
|
7
|
-
//# sourceMappingURL=flatten-json.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flatten-json.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/flatten-json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,IAAI,CAwBN"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Variable resolution and substitution for HTTP requests.
|
|
3
|
-
* - Stable document ID (filepath or content hash) so variables don't leak between documents.
|
|
4
|
-
* - Kuba: traverse up for kuba.yaml, run `kuba show --env <env> --output json`.
|
|
5
|
-
* - Env files: system env, http-client.env.json, http-client.private.env.json, .env (by env name).
|
|
6
|
-
* - Persistence: global, document-scoped, and request-scoped variables from SQLite.
|
|
7
|
-
* - System env as {{$env.VAR}}: JetBrains-style (https://www.jetbrains.com/help/idea/http-client-variables.html).
|
|
8
|
-
* - Dynamic variables: $uuid, $random.uuid, $timestamp, $isoTimestamp, $date, $randomInt (0..1000).
|
|
9
|
-
* - Request variables: {{REQUEST_NAME.response.body.$.field}}, {{REQUEST_NAME.response.headers.Name}}.
|
|
10
|
-
* - JSONPath-style in env/kuba: nested JSON flattened to dotted paths (client.host.url, client.['host.url']).
|
|
11
|
-
* - Substitution: {{variableName}} or compound paths; optional spaces {{ var }} in URL, headers, body.
|
|
12
|
-
* - In-file @ variables: @name=value before the first ### or in a block preamble (JetBrains).
|
|
13
|
-
*/
|
|
14
|
-
export { getStableDocumentId } from "./stable-id";
|
|
15
|
-
export { findKubaYamlDir, getKubaEnv, isKubaInPath } from "./kuba";
|
|
16
|
-
export { loadEnvVars } from "./env-files";
|
|
17
|
-
export { getMagicVariables } from "./magic";
|
|
18
|
-
export { resolveVariables, type HttpFileVariableSources } from "./resolve";
|
|
19
|
-
export { substituteInString, substituteInStringAsync, substituteInObject, substituteInObjectAsync, } from "./substitute";
|
|
20
|
-
export { resolveRequestVariable, isRequestVariableKey, type PreviousResponse, } from "./request-vars";
|
|
21
|
-
export { OAuth2Manager } from "../auth/oauth2/manager";
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Traverse upward from startDir to find a directory containing kuba.yaml.
|
|
3
|
-
*/
|
|
4
|
-
export declare function findKubaYamlDir(startDir: string): string | null;
|
|
5
|
-
/**
|
|
6
|
-
* Check if `kuba` is available in PATH
|
|
7
|
-
*/
|
|
8
|
-
export declare function isKubaInPath(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Run `kuba show --env <env> --output json` in dir and return parsed env vars.
|
|
11
|
-
* Returns null if kuba.yaml not in dir, kuba not in PATH, or command fails.
|
|
12
|
-
* If kuba.yaml exists but kuba is not in PATH, writes a message to stderr.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getKubaEnv(env: string, dir: string): Promise<Record<string, string> | null>;
|
|
15
|
-
//# sourceMappingURL=kuba.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kuba.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/kuba.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW/D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAoCxC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dynamic variables per JetBrains HTTP Client spec.
|
|
3
|
-
* https://www.jetbrains.com/help/idea/http-client-variables.html#dynamic-variables
|
|
4
|
-
* Generated fresh per request. Optional spaces around braces kept: {{ $uuid }}.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getMagicVariables(): Record<string, string>;
|
|
7
|
-
//# sourceMappingURL=magic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"magic.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/magic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAW1D"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Request variable resolution: {{REQUEST_NAME.response.body.$.path}} and {{REQUEST_NAME.response.headers.HeaderName}}.
|
|
3
|
-
* See https://neovim.getkulala.net/docs/usage/request-variables
|
|
4
|
-
*/
|
|
5
|
-
export type PreviousResponse = {
|
|
6
|
-
body: {
|
|
7
|
-
type: "text";
|
|
8
|
-
content: string;
|
|
9
|
-
} | {
|
|
10
|
-
type: "json";
|
|
11
|
-
content: Record<string, unknown>;
|
|
12
|
-
};
|
|
13
|
-
headers: Record<string, string>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Resolve a request variable key against previous run results.
|
|
17
|
-
* Key forms: REQUEST_NAME.response.body.$.path (JSON fields on the parsed body), REQUEST_NAME.response.headers.HeaderName, REQUEST_NAME.response.headers['Header Name'].
|
|
18
|
-
* Returns string value or undefined if not found / not a request var.
|
|
19
|
-
*/
|
|
20
|
-
export declare function resolveRequestVariable(key: string, previousResults: Map<string, PreviousResponse>): string | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Check if a variable key looks like a request variable reference.
|
|
23
|
-
*/
|
|
24
|
-
export declare function isRequestVariableKey(key: string): boolean;
|
|
25
|
-
//# sourceMappingURL=request-vars.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-vars.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/request-vars.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EACA;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACjC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IACvD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,CAAC;AAgBF;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC7C,MAAM,GAAG,SAAS,CAqCpB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGzD"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type HttpFileVariableSources = {
|
|
2
|
-
/** @name=value lines before the first ### in the .http file (or imported file). */
|
|
3
|
-
fileHeader?: Record<string, string>;
|
|
4
|
-
/** @name=value lines in the current block preamble before the request line. */
|
|
5
|
-
blockPreamble?: Record<string, string>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Resolve all variables for a request.
|
|
9
|
-
* Order (later overrides earlier): kuba → @-lines from .http (file header + block preamble) →
|
|
10
|
-
* system/env files (http-client.env.json, .env) → persistence (global → document → request) →
|
|
11
|
-
* magic variables ($uuid, $timestamp, etc.).
|
|
12
|
-
* See https://neovim.getkulala.net/docs/usage/magic-variables and
|
|
13
|
-
* https://neovim.getkulala.net/docs/usage/dotenv-and-http-client.env.json-support
|
|
14
|
-
*/
|
|
15
|
-
export declare function resolveVariables(env: string, stableDocId: string, blockName: string, startDir: string, httpFileVars?: HttpFileVariableSources): Promise<Record<string, string>>;
|
|
16
|
-
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/resolve.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,uBAAuB,GAAG;IACpC,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,uBAAuB,GACrC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAqDjC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a stable document ID so variables from one HTTP document don't leak into another.
|
|
3
|
-
* When there is no physical file, we can't rely on filepath; use a hash of the content instead.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getStableDocumentId(filepath?: string, content?: string): string;
|
|
6
|
-
//# sourceMappingURL=stable-id.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stable-id.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/stable-id.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CASR"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Replace {{variableName}} or {{ variableName }} in a string with values from vars.
|
|
3
|
-
* Supports simple names (e.g. API_KEY) and compound request vars (e.g. REQUEST_ONE.response.body.$.token).
|
|
4
|
-
* Optional whitespace around the variable name is allowed.
|
|
5
|
-
* Unknown variables are replaced with empty string.
|
|
6
|
-
* If resolver is provided, it is used for missing keys (e.g. request variables).
|
|
7
|
-
*
|
|
8
|
-
* Note: For $auth.token() and $auth.idToken() calls, use substituteInStringAsync instead.
|
|
9
|
-
*/
|
|
10
|
-
export declare function substituteInString(template: string, vars: Record<string, string>, resolver?: (name: string) => string | undefined): string;
|
|
11
|
-
/**
|
|
12
|
-
* Async version that handles $auth.token() and $auth.idToken() calls.
|
|
13
|
-
* Also supports all regular variable substitution.
|
|
14
|
-
*
|
|
15
|
-
* This function properly handles multiple occurrences of the same variable.
|
|
16
|
-
*/
|
|
17
|
-
export declare function substituteInStringAsync(template: string, vars: Record<string, string>, resolver?: (name: string) => string | undefined, authResolver?: (func: "token" | "idToken", authId: string) => Promise<string | undefined>): Promise<string>;
|
|
18
|
-
/**
|
|
19
|
-
* Recursively substitute {{var}} in any string values in obj (for request body).
|
|
20
|
-
*
|
|
21
|
-
* Note: For $auth.token() and $auth.idToken() calls, use substituteInObjectAsync instead.
|
|
22
|
-
*/
|
|
23
|
-
export declare function substituteInObject(obj: unknown, vars: Record<string, string>, resolver?: (name: string) => string | undefined): unknown;
|
|
24
|
-
/**
|
|
25
|
-
* Async version that handles $auth.token() and $auth.idToken() calls.
|
|
26
|
-
*/
|
|
27
|
-
export declare function substituteInObjectAsync(obj: unknown, vars: Record<string, string>, resolver?: (name: string) => string | undefined, authResolver?: (func: "token" | "idToken", authId: string) => Promise<string | undefined>): Promise<unknown>;
|
|
28
|
-
//# sourceMappingURL=substitute.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"substitute.d.ts","sourceRoot":"","sources":["../../../src/lib/variables/substitute.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC9C,MAAM,CAmBR;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC/C,YAAY,CAAC,EAAE,CACb,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CA6CjB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC9C,OAAO,CAeT;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC/C,YAAY,CAAC,EAAE,CACb,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAC/B,OAAO,CAAC,OAAO,CAAC,CAmBlB"}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
-
import { constants as fsConstants } from "node:fs";
|
|
3
|
-
import { access } from "node:fs/promises";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
-
import { spawn } from "node:child_process";
|
|
8
|
-
import { tmpdir } from "node:os";
|
|
9
|
-
|
|
10
|
-
if (process.env.KULALA_CORE_BUILD_SKIP_VENDOR_CURL) {
|
|
11
|
-
process.stdout.write(
|
|
12
|
-
"kulala-core: skipping vendored curl download due to KULALA_CORE_SKIP_VENDOR_CURL\n",
|
|
13
|
-
);
|
|
14
|
-
process.exit(0);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Platform = "linux" | "darwin" | "win32";
|
|
18
|
-
type Arch = "x64" | "arm64";
|
|
19
|
-
|
|
20
|
-
const CURL_VERSION = "8.19.0";
|
|
21
|
-
|
|
22
|
-
type DownloadSpec = {
|
|
23
|
-
url: string;
|
|
24
|
-
expectedSha256: string;
|
|
25
|
-
archiveExeName: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Source: https://curl.se/download.html -> "Packages" table (prebuilt binaries by providers).
|
|
29
|
-
// We pin to a fixed version and hard-code URLs + SHA256 for reproducibility.
|
|
30
|
-
const DOWNLOAD_SPECS: Record<string, DownloadSpec> = {
|
|
31
|
-
"linux-x64": {
|
|
32
|
-
url: `https://github.com/stunnel/static-curl/releases/download/${CURL_VERSION}/curl-linux-x86_64-musl-${CURL_VERSION}.tar.xz`,
|
|
33
|
-
expectedSha256:
|
|
34
|
-
"3c5c62815d4a12bebd10c2884038d68102c81e5c058eaad1b3c3e66343634152",
|
|
35
|
-
archiveExeName: "curl",
|
|
36
|
-
},
|
|
37
|
-
"linux-arm64": {
|
|
38
|
-
url: `https://github.com/stunnel/static-curl/releases/download/${CURL_VERSION}/curl-linux-aarch64-musl-${CURL_VERSION}.tar.xz`,
|
|
39
|
-
expectedSha256:
|
|
40
|
-
"c60f5718765bfc83bff10e7aa8eada2e629e009738b38683164a19482dd43a53",
|
|
41
|
-
archiveExeName: "curl",
|
|
42
|
-
},
|
|
43
|
-
"darwin-arm64": {
|
|
44
|
-
url: `https://github.com/stunnel/static-curl/releases/download/${CURL_VERSION}/curl-macos-arm64-${CURL_VERSION}.tar.xz`,
|
|
45
|
-
expectedSha256:
|
|
46
|
-
"210adf449293bb55e86a7ce26e32a8b00e7fafec570c24d2fe82bec3ff4ac090",
|
|
47
|
-
archiveExeName: "curl",
|
|
48
|
-
},
|
|
49
|
-
"darwin-x64": {
|
|
50
|
-
url: `https://github.com/stunnel/static-curl/releases/download/${CURL_VERSION}/curl-macos-x86_64-${CURL_VERSION}.tar.xz`,
|
|
51
|
-
expectedSha256:
|
|
52
|
-
"732a165fd450f12bbb01170bb99a6cd00b904d1eeccbe5ecd3e25220007d73f2",
|
|
53
|
-
archiveExeName: "curl",
|
|
54
|
-
},
|
|
55
|
-
"win32-x64": {
|
|
56
|
-
url: `https://github.com/stunnel/static-curl/releases/download/${CURL_VERSION}/curl-windows-x86_64-${CURL_VERSION}.tar.xz`,
|
|
57
|
-
expectedSha256:
|
|
58
|
-
"40241a577f01e06d1ff31e9971fe5b188705f9a4ea9c26133eab237ed8c1528c",
|
|
59
|
-
archiveExeName: "curl.exe",
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
function platformVendorSubdir(): string {
|
|
64
|
-
const plat = process.platform as Platform;
|
|
65
|
-
const arch = process.arch as Arch;
|
|
66
|
-
return `${plat}-${arch}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function exeName(): string {
|
|
70
|
-
return process.platform === "win32" ? "curl.exe" : "curl";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function cacheBaseDir(): string {
|
|
74
|
-
const explicit = process.env.KULALA_CORE_CURL_CACHE_DIR;
|
|
75
|
-
if (explicit) return explicit;
|
|
76
|
-
|
|
77
|
-
// Respect XDG on any platform if explicitly set.
|
|
78
|
-
const xdg = process.env.XDG_CACHE_HOME;
|
|
79
|
-
if (xdg) return join(xdg, "kulala");
|
|
80
|
-
|
|
81
|
-
if (process.platform === "win32") {
|
|
82
|
-
const localAppData = process.env.LOCALAPPDATA;
|
|
83
|
-
if (localAppData) return join(localAppData, "kulala");
|
|
84
|
-
const appData = process.env.APPDATA;
|
|
85
|
-
if (appData) return join(appData, "kulala");
|
|
86
|
-
const userProfile = process.env.USERPROFILE;
|
|
87
|
-
if (userProfile) return join(userProfile, ".cache", "kulala");
|
|
88
|
-
return join(homedir(), ".cache", "kulala");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (process.platform === "darwin") {
|
|
92
|
-
return join(homedir(), "Library", "Caches", "kulala");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Linux and other unix-likes.
|
|
96
|
-
return join(homedir(), ".cache", "kulala");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function fileIsExecutable(path: string): Promise<boolean> {
|
|
100
|
-
try {
|
|
101
|
-
await access(path, fsConstants.X_OK);
|
|
102
|
-
return true;
|
|
103
|
-
} catch {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function downloadSpec(): DownloadSpec {
|
|
109
|
-
const plat = process.platform as Platform;
|
|
110
|
-
const arch = process.arch as Arch;
|
|
111
|
-
const key = `${plat}-${arch}`;
|
|
112
|
-
const spec = DOWNLOAD_SPECS[key];
|
|
113
|
-
if (!spec) {
|
|
114
|
-
throw new Error(
|
|
115
|
-
`Unsupported platform/arch for automatic curl download: ${key}`,
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
return spec;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function download(url: string): Promise<Uint8Array> {
|
|
122
|
-
const res = await fetch(url, {
|
|
123
|
-
redirect: "follow",
|
|
124
|
-
headers: {
|
|
125
|
-
"User-Agent": "kulala-core(postinstall)",
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
if (!res.ok) {
|
|
129
|
-
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
130
|
-
}
|
|
131
|
-
const buf = new Uint8Array(await res.arrayBuffer());
|
|
132
|
-
if (buf.byteLength < 1024 * 64) {
|
|
133
|
-
// sanity check: a curl binary shouldn't be tiny (avoids saving HTML error pages)
|
|
134
|
-
throw new Error(`Downloaded file too small (${buf.byteLength} bytes)`);
|
|
135
|
-
}
|
|
136
|
-
return buf;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function sha256Hex(bytes: Uint8Array): string {
|
|
140
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function extractTarXz(
|
|
144
|
-
archivePath: string,
|
|
145
|
-
outDir: string,
|
|
146
|
-
): Promise<void> {
|
|
147
|
-
await new Promise<void>((resolve, reject) => {
|
|
148
|
-
const child = spawn("tar", ["-xJf", archivePath, "-C", outDir], {
|
|
149
|
-
stdio: "pipe",
|
|
150
|
-
});
|
|
151
|
-
let stderr = "";
|
|
152
|
-
child.stderr.on("data", (d) => (stderr += d.toString()));
|
|
153
|
-
child.on("error", reject);
|
|
154
|
-
child.on("close", (code) => {
|
|
155
|
-
if (code === 0) resolve();
|
|
156
|
-
else reject(new Error(stderr.trim() || `tar exited with code ${code}`));
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async function main(): Promise<void> {
|
|
162
|
-
const exe = exeName();
|
|
163
|
-
const subdir = platformVendorSubdir();
|
|
164
|
-
const targetDir = join(cacheBaseDir(), "curl", subdir);
|
|
165
|
-
const targetPath = join(targetDir, exe);
|
|
166
|
-
|
|
167
|
-
if (await fileIsExecutable(targetPath)) return;
|
|
168
|
-
|
|
169
|
-
await mkdir(targetDir, { recursive: true });
|
|
170
|
-
const { url, expectedSha256, archiveExeName } = downloadSpec();
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
const tmpBase = join(tmpdir(), `kulala-core-curl-${randomUUID()}`);
|
|
174
|
-
await mkdir(tmpBase, { recursive: true });
|
|
175
|
-
const archivePath = join(tmpBase, "curl.tar.xz");
|
|
176
|
-
|
|
177
|
-
const archiveBytes = await download(url);
|
|
178
|
-
await writeFile(archivePath, archiveBytes);
|
|
179
|
-
|
|
180
|
-
await extractTarXz(archivePath, targetDir);
|
|
181
|
-
|
|
182
|
-
const extractedPath = join(targetDir, archiveExeName);
|
|
183
|
-
const extractedBytes = new Uint8Array(await readFile(extractedPath));
|
|
184
|
-
const actualSha = sha256Hex(extractedBytes);
|
|
185
|
-
if (actualSha !== expectedSha256) {
|
|
186
|
-
throw new Error(
|
|
187
|
-
`SHA256 mismatch for ${archiveExeName}: expected ${expectedSha256} got ${actualSha}`,
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Ensure final name matches what runtime expects (curl / curl.exe).
|
|
192
|
-
if (archiveExeName !== exe) {
|
|
193
|
-
// Shouldn't happen with our mapping, but keep it safe.
|
|
194
|
-
await writeFile(targetPath, extractedBytes, { mode: 0o755 });
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (process.platform !== "win32") {
|
|
198
|
-
await chmod(targetPath, 0o755);
|
|
199
|
-
}
|
|
200
|
-
// Windows tar includes a CA bundle; keep it readable.
|
|
201
|
-
// (No-op on other platforms if file isn't present.)
|
|
202
|
-
try {
|
|
203
|
-
const caPath = join(targetDir, "curl-ca-bundle.crt");
|
|
204
|
-
await chmod(caPath, 0o644);
|
|
205
|
-
} catch {
|
|
206
|
-
// ignore
|
|
207
|
-
}
|
|
208
|
-
process.stderr.write(`kulala-core: downloaded curl to ${targetPath}\n`);
|
|
209
|
-
|
|
210
|
-
await rm(tmpBase, { recursive: true, force: true });
|
|
211
|
-
} catch (err) {
|
|
212
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
213
|
-
process.stderr.write(
|
|
214
|
-
`kulala-core: could not download vendored curl (${url}): ${msg}\n`,
|
|
215
|
-
);
|
|
216
|
-
process.stderr.write(
|
|
217
|
-
`kulala-core: set KULALA_CURL_PATH to an existing curl.\n`,
|
|
218
|
-
);
|
|
219
|
-
process.exitCode = 1;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
await main();
|