@composio/core 0.13.0 → 0.14.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 +62 -247
- package/dist/BaseProvider-lCxnjFKQ.d.mts +29395 -0
- package/dist/{CustomTool-D9qwyMrv.mjs → CustomTool-C_5NvBsX.mjs} +17 -15
- package/dist/{CustomTool-DrJpOhY2.d.mts → CustomTool-CmokRT9q.d.mts} +1 -1
- package/dist/{FileModifierErrors-3fSwIWoa.mjs → SsrfErrors-BQRozkeU.mjs} +33 -1
- package/dist/{Telemetry-DhGI_J4G.mjs → Telemetry-llfvticE.mjs} +40 -8
- package/dist/{jsonSchema-CFKdONpP.mjs → cancellation-W65QRyj2.mjs} +64 -19
- package/dist/{composio-DHIKRdeG.d.mts → composio-6C8kHtqc.d.mts} +1079 -1092
- package/dist/{customTool.types-CKH2R2ia.d.mts → customTool.types-kFhNYuzh.d.mts} +602 -549
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -22
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +23 -0
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +24 -0
- package/dist/{errors-DSIlYfl5.mjs → errors-B165yJUQ.mjs} +74 -74
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-BiO1JQsJ.mjs → fileUtils.node-iPFi2o4i.mjs} +182 -68
- package/dist/index.d.mts +1459 -1401
- package/dist/index.mjs +1437 -1375
- package/dist/models/Files.node.mjs +2 -2
- package/dist/platform/node.d.mts +1 -1
- package/dist/platform/node.mjs +3 -0
- package/dist/platform/workerd.d.mts +1 -1
- package/dist/platform/workerd.mjs +3 -0
- package/dist/sensitiveFileUploadPaths-B1OLsd8F.mjs +114 -0
- package/dist/{types-DdoCRzLj.d.mts → types-DY1r-kN9.d.mts} +9 -0
- package/dist/{types-D4Id3wXA.d.mts → types-yCrveqAj.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +10 -10
- package/src/errors/SsrfErrors.ts +47 -0
- package/src/errors/index.ts +3 -0
- package/src/index.ts +10 -0
- package/src/lib/toolRouterSessionDelete.ts +30 -0
- package/src/models/CustomTool.ts +1 -3
- package/src/models/ToolRouter.ts +15 -0
- package/src/models/ToolRouterSession.ts +50 -16
- package/src/models/Tools.ts +32 -2
- package/src/models/Triggers.ts +16 -76
- package/src/platform/node.ts +4 -0
- package/src/platform/types.ts +10 -0
- package/src/platform/workerd.ts +6 -0
- package/src/provider/OpenAIProvider.ts +19 -14
- package/src/telemetry/Telemetry.ts +9 -6
- package/src/telemetry/redact.ts +40 -0
- package/src/types/tool.types.ts +36 -32
- package/src/types/toolRouter.types.ts +13 -0
- package/src/utils/fileUtils.node.ts +27 -4
- package/src/utils/jsonSchema.ts +58 -0
- package/src/utils/modifiers/FileToolModifier.node.ts +2 -1
- package/src/utils/sdk.ts +5 -4
- package/src/utils/{sensitiveFileUploadPaths.node.ts → sensitiveFileUploadPaths.ts} +29 -13
- package/src/utils/ssrfGuard.node.ts +202 -0
- package/src/utils/toolkitVersion.ts +21 -2
- package/dist/BaseProvider-BBnsv9kS.d.mts +0 -29425
- package/dist/BaseProvider-Brb3o86-.d.mts +0 -29425
- package/dist/CustomTool-Dmi6ti3I.d.mts +0 -74
- package/dist/buffer-PcbMMsgm.mjs +0 -33
- package/dist/composio-vMwhASRc.d.mts +0 -5698
- package/dist/customTool.types-DXin7Cfc.d.mts +0 -2773
- package/dist/types-qTbYYBJw.d.mts +0 -12
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Blocks accidental upload of local files from well-known secret/credential locations
|
|
3
3
|
* during auto file upload (and {@link getFileDataAfterUploadingToS3}).
|
|
4
|
+
*
|
|
5
|
+
* This is the single canonical guard shared by the core SDK and downstream
|
|
6
|
+
* packages (e.g. `@composio/cli`). Filesystem access goes through the `#platform`
|
|
7
|
+
* abstraction so this module stays free of static `node:*` imports and is safe to
|
|
8
|
+
* re-export from the package root (edge/workerd builds included).
|
|
4
9
|
*/
|
|
5
|
-
import
|
|
6
|
-
import fs from 'node:fs';
|
|
10
|
+
import { platform } from '#platform';
|
|
7
11
|
import { ComposioSensitiveFilePathBlockedError } from '../errors/FileModifierErrors';
|
|
8
12
|
|
|
9
13
|
/**
|
|
@@ -26,15 +30,17 @@ const SECRET_LIKE_BASENAME = /^(\.env(\.|$)|\.netrc$|\.pgpass$)/i;
|
|
|
26
30
|
/** Default SSH private key basenames (public keys like id_rsa.pub are allowed). */
|
|
27
31
|
const DEFAULT_PRIVATE_KEY_BASENAME = /^id_(rsa|ed25519|ecdsa|dsa|ecdsa_sk)(\.old)?$/i;
|
|
28
32
|
|
|
33
|
+
const isWindows = typeof process !== 'undefined' && process.platform === 'win32';
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
* Returns normalized path segments, resolving symlinks when the path exists.
|
|
31
37
|
*/
|
|
32
38
|
function normalizePathSegments(filePath: string): string[] {
|
|
33
|
-
const absolute =
|
|
39
|
+
const absolute = platform.resolvePath(filePath);
|
|
34
40
|
let resolved = absolute;
|
|
35
41
|
try {
|
|
36
|
-
if (
|
|
37
|
-
resolved =
|
|
42
|
+
if (platform.existsSync(absolute)) {
|
|
43
|
+
resolved = platform.realpathSync(absolute);
|
|
38
44
|
}
|
|
39
45
|
} catch {
|
|
40
46
|
// If realpath fails (e.g. race), use resolved path
|
|
@@ -58,16 +64,15 @@ function getSensitiveFileUploadPathBlockReason(
|
|
|
58
64
|
additionalDenySegments?: string[]
|
|
59
65
|
): string | null {
|
|
60
66
|
const segments = normalizePathSegments(filePath);
|
|
61
|
-
const isWin = process.platform === 'win32';
|
|
62
67
|
const deny = new Set(
|
|
63
68
|
[
|
|
64
69
|
...BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS,
|
|
65
70
|
...(additionalDenySegments ?? []).map(s => s.trim()).filter(Boolean),
|
|
66
|
-
].map(s => (
|
|
71
|
+
].map(s => (isWindows ? s.toLowerCase() : s))
|
|
67
72
|
);
|
|
68
73
|
|
|
69
74
|
// Windows: compare segments case-insensitively; map once instead of toLowerCase per iteration.
|
|
70
|
-
const segmentsForMatch =
|
|
75
|
+
const segmentsForMatch = isWindows ? segments.map(s => s.toLowerCase()) : segments;
|
|
71
76
|
for (let i = 0; i < segments.length; i++) {
|
|
72
77
|
if (deny.has(segmentsForMatch[i]!)) {
|
|
73
78
|
return `path segment "${segments[i]}" is in the sensitive file upload denylist`;
|
|
@@ -86,20 +91,31 @@ function getSensitiveFileUploadPathBlockReason(
|
|
|
86
91
|
return null;
|
|
87
92
|
}
|
|
88
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Default remediation hint appended to the block message. Assumes an SDK caller
|
|
96
|
+
* that exposes `sensitiveFileUploadProtection`. Callers without such an opt-out
|
|
97
|
+
* (e.g. `@composio/cli`) should pass their own `remediation` so the message does
|
|
98
|
+
* not advertise an option the caller cannot honor.
|
|
99
|
+
*/
|
|
100
|
+
const DEFAULT_REMEDIATION =
|
|
101
|
+
`To upload from this path anyway, set sensitiveFileUploadProtection: false on Composio ` +
|
|
102
|
+
`(not recommended) or use a copy outside sensitive locations.`;
|
|
103
|
+
|
|
89
104
|
/**
|
|
90
105
|
* @throws {ComposioSensitiveFilePathBlockedError} if the path is not allowed
|
|
91
106
|
*/
|
|
92
107
|
export function assertSafeFileUploadPath(
|
|
93
108
|
filePath: string,
|
|
94
|
-
options?: { additionalDenySegments?: string[] }
|
|
109
|
+
options?: { additionalDenySegments?: string[]; remediation?: string }
|
|
95
110
|
): void {
|
|
96
111
|
const reason = getSensitiveFileUploadPathBlockReason(filePath, options?.additionalDenySegments);
|
|
97
112
|
if (reason) {
|
|
113
|
+
const remediation = options?.remediation ?? DEFAULT_REMEDIATION;
|
|
98
114
|
throw new ComposioSensitiveFilePathBlockedError(
|
|
99
|
-
`Refusing to upload: ${reason}.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
115
|
+
`Refusing to upload: ${reason}. ${remediation}`,
|
|
116
|
+
{
|
|
117
|
+
meta: { filePath, reason },
|
|
118
|
+
}
|
|
103
119
|
);
|
|
104
120
|
}
|
|
105
121
|
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { lookup } from 'node:dns/promises'; // we're in a Node.js-specific module
|
|
2
|
+
import { isIP } from 'node:net';
|
|
3
|
+
import { ComposioBlockedInternalUrlError } from '../errors/SsrfErrors';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SSRF guard for user-supplied URL file inputs.
|
|
7
|
+
*
|
|
8
|
+
* `composio.files.upload(url)` and automatic file upload during tool execution
|
|
9
|
+
* fetch arbitrary user-provided URLs. Without a guard, a caller (or a tool
|
|
10
|
+
* argument produced by an LLM) can point the SDK at internal infrastructure —
|
|
11
|
+
* loopback, RFC1918 ranges, link-local cloud-metadata endpoints
|
|
12
|
+
* (`169.254.169.254`), or a public URL that 3xx-redirects into internal space —
|
|
13
|
+
* turning the SDK into a server-side request forgery probe.
|
|
14
|
+
*
|
|
15
|
+
* This module validates the *resolved* address (not just the hostname string,
|
|
16
|
+
* which defeats decimal/octal/hex IP obfuscation) before every fetch, and
|
|
17
|
+
* follows redirects manually so each hop is re-validated.
|
|
18
|
+
*
|
|
19
|
+
* Known residual: a DNS name could resolve to a public address here and rebind
|
|
20
|
+
* to an internal one before the underlying `fetch` connects (a TOCTOU / DNS
|
|
21
|
+
* rebinding window). Closing that fully requires pinning the validated IP at
|
|
22
|
+
* connect time (a custom dispatcher), which is out of scope for this guard.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const MAX_REDIRECTS = 5;
|
|
26
|
+
|
|
27
|
+
const ipv4ToLong = (ip: string): number => {
|
|
28
|
+
const [a, b, c, d] = ip.split('.').map(Number);
|
|
29
|
+
return (((a << 24) >>> 0) | (b << 16) | (c << 8) | d) >>> 0;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Address blocks that must never be reachable from a user-supplied URL.
|
|
33
|
+
// (RFC1918 private, loopback, link-local, CGNAT, TEST-NET, benchmarking,
|
|
34
|
+
// multicast, and reserved ranges.)
|
|
35
|
+
const IPV4_BLOCKED_CIDRS: ReadonlyArray<readonly [string, number]> = [
|
|
36
|
+
['0.0.0.0', 8], // "this" network / unspecified
|
|
37
|
+
['10.0.0.0', 8], // private
|
|
38
|
+
['100.64.0.0', 10], // carrier-grade NAT
|
|
39
|
+
['127.0.0.0', 8], // loopback
|
|
40
|
+
['169.254.0.0', 16], // link-local (incl. cloud metadata 169.254.169.254)
|
|
41
|
+
['172.16.0.0', 12], // private
|
|
42
|
+
['192.0.0.0', 24], // IETF protocol assignments
|
|
43
|
+
['192.0.2.0', 24], // TEST-NET-1
|
|
44
|
+
['192.168.0.0', 16], // private
|
|
45
|
+
['198.18.0.0', 15], // benchmarking
|
|
46
|
+
['198.51.100.0', 24], // TEST-NET-2
|
|
47
|
+
['203.0.113.0', 24], // TEST-NET-3
|
|
48
|
+
['224.0.0.0', 4], // multicast
|
|
49
|
+
['240.0.0.0', 4], // reserved (incl. 255.255.255.255 broadcast)
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const isBlockedIpv4Long = (long: number): boolean =>
|
|
53
|
+
IPV4_BLOCKED_CIDRS.some(([base, bits]) => {
|
|
54
|
+
const mask = bits === 0 ? 0 : (0xffffffff << (32 - bits)) >>> 0;
|
|
55
|
+
return (long & mask) === (ipv4ToLong(base) & mask);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Expand an IPv6 string into its 8 16-bit groups, converting any trailing
|
|
60
|
+
* dotted-quad (e.g. `::ffff:1.2.3.4`) into hex groups first. Returns `null` when
|
|
61
|
+
* the input cannot be parsed.
|
|
62
|
+
*/
|
|
63
|
+
const expandIpv6 = (ip: string): number[] | null => {
|
|
64
|
+
let addr = ip;
|
|
65
|
+
const v4Match = addr.match(/^(.*:)(\d+\.\d+\.\d+\.\d+)$/);
|
|
66
|
+
if (v4Match) {
|
|
67
|
+
const long = ipv4ToLong(v4Match[2]);
|
|
68
|
+
addr = `${v4Match[1]}${((long >>> 16) & 0xffff).toString(16)}:${(long & 0xffff).toString(16)}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const halves = addr.split('::');
|
|
72
|
+
if (halves.length > 2) return null;
|
|
73
|
+
|
|
74
|
+
const head = halves[0] ? halves[0].split(':') : [];
|
|
75
|
+
const tail = halves.length === 2 ? (halves[1] ? halves[1].split(':') : []) : [];
|
|
76
|
+
|
|
77
|
+
let groups: string[];
|
|
78
|
+
if (halves.length === 2) {
|
|
79
|
+
const missing = 8 - head.length - tail.length;
|
|
80
|
+
if (missing < 0) return null;
|
|
81
|
+
groups = [...head, ...Array(missing).fill('0'), ...tail];
|
|
82
|
+
} else {
|
|
83
|
+
groups = head;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (groups.length !== 8) return null;
|
|
87
|
+
return groups.map(g => parseInt(g || '0', 16));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const isBlockedIpv6 = (ip: string): boolean => {
|
|
91
|
+
const h = expandIpv6(ip);
|
|
92
|
+
if (!h) return true; // fail closed on anything we cannot parse
|
|
93
|
+
|
|
94
|
+
// :: (unspecified) and ::1 (loopback)
|
|
95
|
+
if (h.every(x => x === 0)) return true;
|
|
96
|
+
if (h.slice(0, 7).every(x => x === 0) && h[7] === 1) return true;
|
|
97
|
+
|
|
98
|
+
// Addresses that embed an IPv4 address in their low 32 bits must be validated
|
|
99
|
+
// against the IPv4 blocklist, otherwise `::127.0.0.1` / `::169.254.169.254`
|
|
100
|
+
// (and mapped/NAT64 forms) would pass as "public" IPv6 and reach internal
|
|
101
|
+
// targets. Covers:
|
|
102
|
+
// - IPv4-mapped ::ffff:0:0/96 (h[5] === 0xffff)
|
|
103
|
+
// - IPv4-compatible ::/96 (deprecated, h[5] === 0) — incl. ::a.b.c.d
|
|
104
|
+
// - NAT64 64:ff9b::/96
|
|
105
|
+
const highBitsZero = h[0] === 0 && h[1] === 0 && h[2] === 0 && h[3] === 0 && h[4] === 0;
|
|
106
|
+
const isMappedOrCompat = highBitsZero && (h[5] === 0xffff || h[5] === 0);
|
|
107
|
+
const isNat64 =
|
|
108
|
+
h[0] === 0x0064 && h[1] === 0xff9b && h[2] === 0 && h[3] === 0 && h[4] === 0 && h[5] === 0;
|
|
109
|
+
if (isMappedOrCompat || isNat64) {
|
|
110
|
+
return isBlockedIpv4Long((((h[6] << 16) >>> 0) | h[7]) >>> 0);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if ((h[0] & 0xfe00) === 0xfc00) return true; // unique local fc00::/7
|
|
114
|
+
if ((h[0] & 0xffc0) === 0xfe80) return true; // link-local fe80::/10
|
|
115
|
+
if ((h[0] & 0xff00) === 0xff00) return true; // multicast ff00::/8
|
|
116
|
+
|
|
117
|
+
return false;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* True when `ip` is a private, loopback, link-local, or otherwise
|
|
122
|
+
* non-publicly-routable address. Fails closed (returns `true`) for anything that
|
|
123
|
+
* is not a valid IPv4/IPv6 literal.
|
|
124
|
+
*/
|
|
125
|
+
export const isBlockedIp = (ip: string): boolean => {
|
|
126
|
+
const family = isIP(ip);
|
|
127
|
+
if (family === 4) return isBlockedIpv4Long(ipv4ToLong(ip));
|
|
128
|
+
if (family === 6) return isBlockedIpv6(ip);
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Validate a single URL: it must be http(s), its host must resolve, and every
|
|
134
|
+
* resolved address must be publicly routable. Throws
|
|
135
|
+
* {@link ComposioBlockedInternalUrlError} otherwise.
|
|
136
|
+
*/
|
|
137
|
+
export const assertSafeFetchTarget = async (rawUrl: string): Promise<void> => {
|
|
138
|
+
let url: URL;
|
|
139
|
+
try {
|
|
140
|
+
url = new URL(rawUrl);
|
|
141
|
+
} catch {
|
|
142
|
+
throw new ComposioBlockedInternalUrlError('Refusing to fetch a malformed URL', { url: rawUrl });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
146
|
+
throw new ComposioBlockedInternalUrlError(
|
|
147
|
+
`Refusing to fetch a non-http(s) URL (scheme "${url.protocol}")`,
|
|
148
|
+
{ url: rawUrl }
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const host = url.hostname.replace(/^\[|\]$/g, '');
|
|
153
|
+
|
|
154
|
+
let resolved: Array<{ address: string }>;
|
|
155
|
+
try {
|
|
156
|
+
resolved = await lookup(host, { all: true, verbatim: true });
|
|
157
|
+
} catch {
|
|
158
|
+
throw new ComposioBlockedInternalUrlError(`Could not resolve host "${host}"`, { url: rawUrl });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
for (const { address } of resolved) {
|
|
162
|
+
if (isBlockedIp(address)) {
|
|
163
|
+
throw new ComposioBlockedInternalUrlError(
|
|
164
|
+
`Refusing to fetch "${host}" — it resolves to a private, loopback, or link-local address`,
|
|
165
|
+
{ url: rawUrl, resolvedIp: address }
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Drop-in replacement for `fetch` that blocks SSRF. Validates the target before
|
|
173
|
+
* connecting and re-validates every redirect hop (redirects are followed
|
|
174
|
+
* manually up to {@link MAX_REDIRECTS}). Non-redirect responses are returned
|
|
175
|
+
* unchanged.
|
|
176
|
+
*/
|
|
177
|
+
export const ssrfSafeFetch = async (
|
|
178
|
+
rawUrl: string,
|
|
179
|
+
init: RequestInit = {},
|
|
180
|
+
maxRedirects: number = MAX_REDIRECTS
|
|
181
|
+
): Promise<Response> => {
|
|
182
|
+
let currentUrl = rawUrl;
|
|
183
|
+
|
|
184
|
+
for (let hop = 0; hop <= maxRedirects; hop++) {
|
|
185
|
+
await assertSafeFetchTarget(currentUrl);
|
|
186
|
+
|
|
187
|
+
const response = await fetch(currentUrl, { ...init, redirect: 'manual' });
|
|
188
|
+
|
|
189
|
+
const isRedirect =
|
|
190
|
+
response.status >= 300 && response.status < 400 && response.headers.has('location');
|
|
191
|
+
if (!isRedirect) {
|
|
192
|
+
return response;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
currentUrl = new URL(response.headers.get('location')!, currentUrl).toString();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
throw new ComposioBlockedInternalUrlError(
|
|
199
|
+
`Refusing to fetch: too many redirects (max ${maxRedirects})`,
|
|
200
|
+
{ url: rawUrl }
|
|
201
|
+
);
|
|
202
|
+
};
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { ToolkitVersion, ToolkitVersionParam } from '../types/tool.types';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Canonicalizes a toolkit slug into the form used as a version-map key.
|
|
5
|
+
*
|
|
6
|
+
* Toolkit slugs are matched case-insensitively. This is the single source of
|
|
7
|
+
* truth for that rule: every write into a version map (env vars, user-supplied
|
|
8
|
+
* objects — see `getToolkitVersionsFromEnv`) and every read out of one MUST go
|
|
9
|
+
* through this helper so the two sides can never drift apart and silently miss a
|
|
10
|
+
* configured pin.
|
|
11
|
+
*
|
|
12
|
+
* Kept intentionally equivalent to the Python SDK's `normalize_toolkit_slug`
|
|
13
|
+
* (see python/composio/utils/toolkit_version.py).
|
|
14
|
+
*
|
|
15
|
+
* @param toolkitSlug - The slug/name of the toolkit, in any casing
|
|
16
|
+
* @returns The normalized (lowercase) slug used as a version-map key
|
|
17
|
+
*/
|
|
18
|
+
export const normalizeToolkitSlug = (toolkitSlug: string): string => toolkitSlug.toLowerCase();
|
|
19
|
+
|
|
3
20
|
/**
|
|
4
21
|
* Gets the version for a specific toolkit based on the provided toolkit versions configuration.
|
|
5
22
|
*
|
|
@@ -15,10 +32,12 @@ export const getToolkitVersion = (
|
|
|
15
32
|
if (typeof toolkitVersions === 'string') {
|
|
16
33
|
return toolkitVersions;
|
|
17
34
|
}
|
|
18
|
-
// If toolkitVersions is an object mapping, look up the specific toolkit version
|
|
35
|
+
// If toolkitVersions is an object mapping, look up the specific toolkit version.
|
|
36
|
+
// The map is keyed by normalized slugs, so normalize the lookup too
|
|
37
|
+
// (see normalizeToolkitSlug for why).
|
|
19
38
|
const hasToolkitVersion = toolkitVersions && Object.keys(toolkitVersions).length > 0;
|
|
20
39
|
if (hasToolkitVersion) {
|
|
21
|
-
return toolkitVersions[toolkitSlug] ?? 'latest';
|
|
40
|
+
return toolkitVersions[normalizeToolkitSlug(toolkitSlug)] ?? 'latest';
|
|
22
41
|
}
|
|
23
42
|
|
|
24
43
|
// Else use 'latest'
|