@larkup/cli 0.2.25 → 0.2.26
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 +8 -0
- package/dist/{analytics-store-KI3NXDYV.js → analytics-store-4NYU7DMO.js} +2 -2
- package/dist/api-X4PHQJTH.js +6943 -0
- package/dist/bowser-GZLEN3PD.js +2821 -0
- package/dist/{chroma-BCASZNMJ.js → chroma-RJVBZZMP.js} +2 -11
- package/dist/chunk-3EBUYTA7.js +136 -0
- package/dist/chunk-4XN2IRCG.js +46 -0
- package/dist/{chunk-FM6HYXZ5.js → chunk-5UWKP64Q.js} +24 -72
- package/dist/chunk-65EVYGDT.js +2904 -0
- package/dist/chunk-A7HMSODH.js +126 -0
- package/dist/chunk-BDMLJQRN.js +534 -0
- package/dist/chunk-FUTLPXFR.js +921 -0
- package/dist/chunk-HAABLEPO.js +1570 -0
- package/dist/chunk-HOPZALAP.js +449 -0
- package/dist/{chunk-L34L3RDQ.js → chunk-JZ3UCEGF.js} +157 -197
- package/dist/chunk-MACWQEJS.js +2091 -0
- package/dist/chunk-MYOADNR2.js +515 -0
- package/dist/chunk-N6IF5QLH.js +1850 -0
- package/dist/chunk-ODWAFTDP.js +1711 -0
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/chunk-S5DCG3CZ.js +41 -0
- package/dist/{chunk-I6JJWCUQ.js → chunk-V3VNCOZ6.js} +118 -29
- package/dist/dist-es-5DTOPEBY.js +322 -0
- package/dist/dist-es-BM4STLL5.js +70 -0
- package/dist/dist-es-DS5SFRTK.js +377 -0
- package/dist/dist-es-F6WXDZQY.js +88 -0
- package/dist/dist-es-KMHWFNXI.js +295 -0
- package/dist/dist-es-LRDDK5LI.js +11761 -0
- package/dist/dist-es-LWW2DNRF.js +139 -0
- package/dist/dist-es-NEADJWQM.js +176 -0
- package/dist/dist-es-S5FAFKBD.js +23 -0
- package/dist/dist-es-YD724GH3.js +221 -0
- package/dist/event-streams-NPIZBVLJ.js +43 -0
- package/dist/index.js +2074 -1768
- package/dist/{lancedb-UB2EPDCN.js → lancedb-TCUZKSHN.js} +1 -1
- package/dist/lexer-DQCqS3nf-CGRGK47I.js +62 -0
- package/dist/loadSso-HXXA5UNF.js +584 -0
- package/dist/{pinecone-OHOY4YYM.js → pinecone-ME3YOCQJ.js} +3 -21
- package/dist/signin-7FUGJFG3.js +822 -0
- package/dist/sso-oidc-EPMF7LMF.js +838 -0
- package/dist/sts-RBEOIBEJ.js +1118 -0
- package/dist/{tool-loader-KKODIWEV.js → tool-loader-PEQZZWTB.js} +3 -3
- package/dist/{tool-registry-CXCFMOWA.js → tool-registry-VJYLRXKJ.js} +2 -2
- package/package.json +20 -16
- package/dist/chunk-3RG5ZIWI.js +0 -10
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
__require,
|
|
35
|
+
__commonJS,
|
|
36
|
+
__toESM
|
|
37
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildQueryString
|
|
3
|
+
} from "./chunk-HAABLEPO.js";
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/.pnpm/@aws-sdk+core@3.977.9/node_modules/@aws-sdk/core/dist-es/submodules/util/util-format-url/format-url.js
|
|
6
|
+
function formatUrl(request) {
|
|
7
|
+
const { port, query } = request;
|
|
8
|
+
let { protocol, path, hostname } = request;
|
|
9
|
+
if (protocol && protocol.slice(-1) !== ":") {
|
|
10
|
+
protocol += ":";
|
|
11
|
+
}
|
|
12
|
+
if (port) {
|
|
13
|
+
hostname += `:${port}`;
|
|
14
|
+
}
|
|
15
|
+
if (path && path.charAt(0) !== "/") {
|
|
16
|
+
path = `/${path}`;
|
|
17
|
+
}
|
|
18
|
+
let queryString = query ? buildQueryString(query) : "";
|
|
19
|
+
if (queryString && queryString[0] !== "?") {
|
|
20
|
+
queryString = `?${queryString}`;
|
|
21
|
+
}
|
|
22
|
+
let auth = "";
|
|
23
|
+
if (request.username != null || request.password != null) {
|
|
24
|
+
const username = request.username ?? "";
|
|
25
|
+
const password = request.password ?? "";
|
|
26
|
+
auth = `${username}:${password}@`;
|
|
27
|
+
}
|
|
28
|
+
let fragment = "";
|
|
29
|
+
if (request.fragment) {
|
|
30
|
+
fragment = `#${request.fragment}`;
|
|
31
|
+
}
|
|
32
|
+
return `${protocol}//${auth}${hostname}${path}${queryString}${fragment}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ../../node_modules/.pnpm/@aws-sdk+core@3.977.9/node_modules/@aws-sdk/core/dist-es/submodules/util/util-arn-parser/arn.js
|
|
36
|
+
var validate = (str) => typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6;
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
validate,
|
|
40
|
+
formatUrl
|
|
41
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getToolById,
|
|
3
3
|
invalidateRegistryCache
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5UWKP64Q.js";
|
|
5
5
|
import {
|
|
6
6
|
__require
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QGM4M3NI.js";
|
|
8
8
|
|
|
9
9
|
// ../../packages/marketplace/src/tool-loader.ts
|
|
10
10
|
import { promises as fs2 } from "fs";
|
|
@@ -16,6 +16,8 @@ import { promises as fs } from "fs";
|
|
|
16
16
|
import path from "path";
|
|
17
17
|
import { exec as execCb } from "child_process";
|
|
18
18
|
import { promisify } from "util";
|
|
19
|
+
var installingTools = /* @__PURE__ */ new Set();
|
|
20
|
+
var uninstallingTools = /* @__PURE__ */ new Set();
|
|
19
21
|
var execAsync = promisify(execCb);
|
|
20
22
|
var packageMutationChain = Promise.resolve();
|
|
21
23
|
function serializePackageMutation(fn) {
|
|
@@ -312,11 +314,41 @@ async function resolveWorkspaceToolPath(packageName) {
|
|
|
312
314
|
await fs.readFile(path.join(packageRoot, "package.json"), "utf8")
|
|
313
315
|
);
|
|
314
316
|
return manifest.name === packageName && !packageRoot.includes(`${path.sep}node_modules${path.sep}`) ? packageRoot : void 0;
|
|
317
|
+
} catch {
|
|
318
|
+
}
|
|
319
|
+
let workspaceRoot = process.cwd();
|
|
320
|
+
while (true) {
|
|
321
|
+
try {
|
|
322
|
+
await fs.access(path.join(workspaceRoot, "pnpm-workspace.yaml"));
|
|
323
|
+
break;
|
|
324
|
+
} catch {
|
|
325
|
+
const parent = path.dirname(workspaceRoot);
|
|
326
|
+
if (parent === workspaceRoot) return void 0;
|
|
327
|
+
workspaceRoot = parent;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const toolsRoot = path.join(workspaceRoot, "packages", "marketplace-tools");
|
|
331
|
+
let entries;
|
|
332
|
+
try {
|
|
333
|
+
entries = await fs.readdir(toolsRoot, { withFileTypes: true });
|
|
315
334
|
} catch {
|
|
316
335
|
return void 0;
|
|
317
336
|
}
|
|
337
|
+
for (const entry of entries) {
|
|
338
|
+
if (!entry.isDirectory()) continue;
|
|
339
|
+
const packageRoot = path.join(toolsRoot, entry.name);
|
|
340
|
+
try {
|
|
341
|
+
const manifest = JSON.parse(
|
|
342
|
+
await fs.readFile(path.join(packageRoot, "package.json"), "utf8")
|
|
343
|
+
);
|
|
344
|
+
if (manifest.name === packageName) return packageRoot;
|
|
345
|
+
} catch {
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return void 0;
|
|
318
349
|
}
|
|
319
|
-
async function installTool(toolId, onProgress) {
|
|
350
|
+
async function installTool(toolId, onProgress, initialConfig = {}) {
|
|
351
|
+
installingTools.add(toolId);
|
|
320
352
|
const report = (stage, percent, message) => {
|
|
321
353
|
onProgress?.({ toolId, stage, percent, message });
|
|
322
354
|
};
|
|
@@ -380,7 +412,7 @@ async function installTool(toolId, onProgress) {
|
|
|
380
412
|
packageName: descriptor.packageName,
|
|
381
413
|
resolvedPath,
|
|
382
414
|
source,
|
|
383
|
-
config: buildDefaultConfig(descriptor)
|
|
415
|
+
config: { ...buildDefaultConfig(descriptor), ...initialConfig }
|
|
384
416
|
};
|
|
385
417
|
if (existing >= 0) {
|
|
386
418
|
manifest.tools[existing] = entry;
|
|
@@ -397,26 +429,33 @@ async function installTool(toolId, onProgress) {
|
|
|
397
429
|
const message = err instanceof Error ? err.message : "Installation failed.";
|
|
398
430
|
report("failed", 0, message);
|
|
399
431
|
throw err;
|
|
432
|
+
} finally {
|
|
433
|
+
installingTools.delete(toolId);
|
|
400
434
|
}
|
|
401
435
|
}
|
|
402
436
|
async function uninstallTool(toolId) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
437
|
+
uninstallingTools.add(toolId);
|
|
438
|
+
try {
|
|
439
|
+
const manifest = await readManifest();
|
|
440
|
+
const tool = manifest.tools.find((t) => t.id === toolId);
|
|
441
|
+
manifest.tools = manifest.tools.filter((t) => t.id !== toolId);
|
|
442
|
+
await writeManifest(manifest);
|
|
443
|
+
if (tool?.source === "registry" && tool.packageName) {
|
|
444
|
+
try {
|
|
445
|
+
const toolsDir = getToolsDir();
|
|
446
|
+
await execAsync(`npm uninstall ${tool.packageName} --prefix "${toolsDir}"`, {
|
|
447
|
+
cwd: toolsDir,
|
|
448
|
+
timeout: 3e4
|
|
449
|
+
});
|
|
450
|
+
} catch {
|
|
451
|
+
}
|
|
415
452
|
}
|
|
453
|
+
invalidateRegistryCache();
|
|
454
|
+
const { unloadTool: unloadTool2 } = await import("./tool-loader-PEQZZWTB.js");
|
|
455
|
+
unloadTool2(toolId);
|
|
456
|
+
} finally {
|
|
457
|
+
uninstallingTools.delete(toolId);
|
|
416
458
|
}
|
|
417
|
-
invalidateRegistryCache();
|
|
418
|
-
const { unloadTool: unloadTool2 } = await import("./tool-loader-KKODIWEV.js");
|
|
419
|
-
unloadTool2(toolId);
|
|
420
459
|
}
|
|
421
460
|
async function notifyHubInstall(toolId) {
|
|
422
461
|
const hubUrl = process.env.LARKUP_HUB_URL ?? "https://hub.larkup.de";
|
|
@@ -444,27 +483,77 @@ function buildDefaultConfig(descriptor) {
|
|
|
444
483
|
|
|
445
484
|
// ../../packages/marketplace/src/tool-loader.ts
|
|
446
485
|
var moduleCache = /* @__PURE__ */ new Map();
|
|
486
|
+
var scopedImports = /* @__PURE__ */ new Map();
|
|
487
|
+
async function getScopedImport(revision) {
|
|
488
|
+
const namespace = `larkup-marketplace-tools${revision === "fixed" ? "" : `-${revision}`}`;
|
|
489
|
+
const existing = scopedImports.get(namespace);
|
|
490
|
+
if (existing) return existing;
|
|
491
|
+
const { register } = await import(
|
|
492
|
+
/* webpackIgnore: true */
|
|
493
|
+
"./api-X4PHQJTH.js"
|
|
494
|
+
);
|
|
495
|
+
const importer = register({ namespace }).import;
|
|
496
|
+
if (scopedImports.size >= 8) {
|
|
497
|
+
scopedImports.delete(scopedImports.keys().next().value);
|
|
498
|
+
}
|
|
499
|
+
scopedImports.set(namespace, importer);
|
|
500
|
+
return importer;
|
|
501
|
+
}
|
|
447
502
|
async function loadTool(toolId) {
|
|
448
|
-
if (moduleCache.has(toolId)) return moduleCache.get(toolId);
|
|
449
503
|
const installed = await getInstalledTool(toolId);
|
|
450
504
|
if (!installed) return null;
|
|
505
|
+
const importPath = await resolveImportPath(installed);
|
|
506
|
+
const revision = await entryRevision(installed, importPath);
|
|
507
|
+
const installationKey = `${installed.source}:${installed.resolvedPath}:${installed.version}:${installed.installedAt}:${revision}`;
|
|
508
|
+
const cached = moduleCache.get(toolId);
|
|
509
|
+
if (cached?.installationKey === installationKey) return cached.module;
|
|
451
510
|
try {
|
|
452
|
-
const
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
);
|
|
457
|
-
moduleCache.set(toolId, mod);
|
|
511
|
+
const busted = cacheBustFileImport(importPath, installationKey);
|
|
512
|
+
const importer = await getScopedImport(revision);
|
|
513
|
+
const mod = await importer(busted, import.meta.url);
|
|
514
|
+
moduleCache.set(toolId, { installationKey, module: mod });
|
|
458
515
|
return mod;
|
|
459
516
|
} catch (err) {
|
|
460
517
|
console.error(`[marketplace] Failed to load tool "${toolId}":`, err);
|
|
461
518
|
return null;
|
|
462
519
|
}
|
|
463
520
|
}
|
|
521
|
+
async function entryRevision(installed, importPath) {
|
|
522
|
+
if (installed.source !== "local" || !importPath.startsWith("file:")) return "fixed";
|
|
523
|
+
try {
|
|
524
|
+
const directory = path2.dirname(new URL(importPath).pathname);
|
|
525
|
+
const files = await fs2.readdir(directory, { withFileTypes: true });
|
|
526
|
+
let newest = 0;
|
|
527
|
+
let total = 0;
|
|
528
|
+
for (const file of files) {
|
|
529
|
+
if (!file.isFile()) continue;
|
|
530
|
+
const { mtimeMs, size } = await fs2.stat(path2.join(directory, file.name));
|
|
531
|
+
newest = Math.max(newest, mtimeMs);
|
|
532
|
+
total += size;
|
|
533
|
+
}
|
|
534
|
+
return newest > 0 ? `${newest}-${total}` : "fixed";
|
|
535
|
+
} catch {
|
|
536
|
+
return "fixed";
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
function cacheBustFileImport(importPath, installationKey) {
|
|
540
|
+
if (!importPath.startsWith("file:")) return importPath;
|
|
541
|
+
const url = new URL(importPath);
|
|
542
|
+
url.searchParams.set("larkup-installation", installationKey);
|
|
543
|
+
return url.href;
|
|
544
|
+
}
|
|
464
545
|
async function resolveImportPath(installed) {
|
|
465
546
|
switch (installed.source) {
|
|
466
|
-
case "local":
|
|
467
|
-
|
|
547
|
+
case "local": {
|
|
548
|
+
try {
|
|
549
|
+
await fs2.access(path2.join(installed.resolvedPath, "package.json"));
|
|
550
|
+
return resolvePackageEntry(installed.resolvedPath);
|
|
551
|
+
} catch {
|
|
552
|
+
const workspacePath = await resolveWorkspaceToolPath(installed.packageName);
|
|
553
|
+
if (workspacePath) return resolvePackageEntry(workspacePath);
|
|
554
|
+
return installed.packageName;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
468
557
|
case "registry":
|
|
469
558
|
case "sandbox":
|
|
470
559
|
return resolvePackageEntry(installed.resolvedPath);
|
|
@@ -486,7 +575,7 @@ function unloadTool(toolId) {
|
|
|
486
575
|
moduleCache.delete(toolId);
|
|
487
576
|
}
|
|
488
577
|
async function hasCapability(capability) {
|
|
489
|
-
const { getToolsWithCapability } = await import("./tool-registry-
|
|
578
|
+
const { getToolsWithCapability } = await import("./tool-registry-VJYLRXKJ.js");
|
|
490
579
|
const tools = await getToolsWithCapability(capability);
|
|
491
580
|
for (const t of tools) {
|
|
492
581
|
const installed = await getInstalledTool(t.id);
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setCredentialFeature
|
|
3
|
+
} from "./chunk-N6IF5QLH.js";
|
|
4
|
+
import "./chunk-ODWAFTDP.js";
|
|
5
|
+
import {
|
|
6
|
+
CredentialsProviderError,
|
|
7
|
+
TokenProviderError,
|
|
8
|
+
getProfileName,
|
|
9
|
+
getSSOTokenFilepath,
|
|
10
|
+
getSSOTokenFromFile,
|
|
11
|
+
loadSsoSessionData,
|
|
12
|
+
parseKnownFiles
|
|
13
|
+
} from "./chunk-HAABLEPO.js";
|
|
14
|
+
import "./chunk-MACWQEJS.js";
|
|
15
|
+
import "./chunk-QGM4M3NI.js";
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.973.14/node_modules/@aws-sdk/credential-provider-sso/dist-es/isSsoProfile.js
|
|
18
|
+
var isSsoProfile = (arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string");
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1116.0/node_modules/@aws-sdk/token-providers/dist-es/constants.js
|
|
21
|
+
var EXPIRE_WINDOW_MS = 5 * 60 * 1e3;
|
|
22
|
+
var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
|
|
23
|
+
|
|
24
|
+
// ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1116.0/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js
|
|
25
|
+
var getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
|
|
26
|
+
const { SSOOIDCClient } = await import("./sso-oidc-EPMF7LMF.js");
|
|
27
|
+
const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
|
|
28
|
+
const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
|
|
29
|
+
region: ssoRegion ?? init.clientConfig?.region,
|
|
30
|
+
logger: coalesce("logger"),
|
|
31
|
+
userAgentAppId: coalesce("userAgentAppId")
|
|
32
|
+
}));
|
|
33
|
+
return ssoOidcClient;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1116.0/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js
|
|
37
|
+
var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
|
|
38
|
+
const { CreateTokenCommand } = await import("./sso-oidc-EPMF7LMF.js");
|
|
39
|
+
const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
|
|
40
|
+
return ssoOidcClient.send(new CreateTokenCommand({
|
|
41
|
+
clientId: ssoToken.clientId,
|
|
42
|
+
clientSecret: ssoToken.clientSecret,
|
|
43
|
+
refreshToken: ssoToken.refreshToken,
|
|
44
|
+
grantType: "refresh_token"
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1116.0/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js
|
|
49
|
+
var validateTokenExpiry = (token) => {
|
|
50
|
+
if (token.expiration && token.expiration.getTime() < Date.now()) {
|
|
51
|
+
throw new TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1116.0/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js
|
|
56
|
+
var validateTokenKey = (key, value, forRefresh = false) => {
|
|
57
|
+
if (typeof value === "undefined") {
|
|
58
|
+
throw new TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1116.0/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js
|
|
63
|
+
import { promises as fsPromises } from "fs";
|
|
64
|
+
var { writeFile } = fsPromises;
|
|
65
|
+
var writeSSOTokenToFile = (id, ssoToken) => {
|
|
66
|
+
const tokenFilepath = getSSOTokenFilepath(id);
|
|
67
|
+
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
68
|
+
return writeFile(tokenFilepath, tokenString);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1116.0/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js
|
|
72
|
+
var lastRefreshAttemptTimes = /* @__PURE__ */ new Map();
|
|
73
|
+
var fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
74
|
+
init.logger?.debug("@aws-sdk/token-providers - fromSso");
|
|
75
|
+
const profiles = await parseKnownFiles(init);
|
|
76
|
+
const profileName = getProfileName({
|
|
77
|
+
profile: init.profile ?? callerClientConfig?.profile
|
|
78
|
+
});
|
|
79
|
+
const profile = profiles[profileName];
|
|
80
|
+
if (!profile) {
|
|
81
|
+
throw new TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
82
|
+
} else if (!profile["sso_session"]) {
|
|
83
|
+
throw new TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
84
|
+
}
|
|
85
|
+
const ssoSessionName = profile["sso_session"];
|
|
86
|
+
const ssoSessions = await loadSsoSessionData(init);
|
|
87
|
+
const ssoSession = ssoSessions[ssoSessionName];
|
|
88
|
+
if (!ssoSession) {
|
|
89
|
+
throw new TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
|
|
90
|
+
}
|
|
91
|
+
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
92
|
+
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
93
|
+
throw new TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const ssoStartUrl = ssoSession["sso_start_url"];
|
|
97
|
+
const ssoRegion = ssoSession["sso_region"];
|
|
98
|
+
let ssoToken;
|
|
99
|
+
try {
|
|
100
|
+
ssoToken = await getSSOTokenFromFile(ssoSessionName);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
throw new TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
|
|
103
|
+
}
|
|
104
|
+
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
105
|
+
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
106
|
+
const { accessToken, expiresAt } = ssoToken;
|
|
107
|
+
const existingToken = {
|
|
108
|
+
token: accessToken,
|
|
109
|
+
expiration: new Date(expiresAt)
|
|
110
|
+
};
|
|
111
|
+
if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
|
|
112
|
+
return existingToken;
|
|
113
|
+
}
|
|
114
|
+
const lastRefreshAttemptTime = lastRefreshAttemptTimes.get(ssoSessionName) ?? 0;
|
|
115
|
+
if (Date.now() - lastRefreshAttemptTime < 30 * 1e3) {
|
|
116
|
+
validateTokenExpiry(existingToken);
|
|
117
|
+
return existingToken;
|
|
118
|
+
}
|
|
119
|
+
validateTokenKey("clientId", ssoToken.clientId, true);
|
|
120
|
+
validateTokenKey("clientSecret", ssoToken.clientSecret, true);
|
|
121
|
+
validateTokenKey("refreshToken", ssoToken.refreshToken, true);
|
|
122
|
+
try {
|
|
123
|
+
lastRefreshAttemptTimes.set(ssoSessionName, Date.now());
|
|
124
|
+
const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
|
|
125
|
+
validateTokenKey("accessToken", newSsoOidcToken.accessToken);
|
|
126
|
+
validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
|
|
127
|
+
const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1e3);
|
|
128
|
+
try {
|
|
129
|
+
await writeSSOTokenToFile(ssoSessionName, {
|
|
130
|
+
...ssoToken,
|
|
131
|
+
accessToken: newSsoOidcToken.accessToken,
|
|
132
|
+
expiresAt: newTokenExpiration.toISOString(),
|
|
133
|
+
refreshToken: newSsoOidcToken.refreshToken
|
|
134
|
+
});
|
|
135
|
+
} catch (error) {
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
token: newSsoOidcToken.accessToken,
|
|
139
|
+
expiration: newTokenExpiration
|
|
140
|
+
};
|
|
141
|
+
} catch (error) {
|
|
142
|
+
validateTokenExpiry(existingToken);
|
|
143
|
+
return existingToken;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.973.14/node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js
|
|
148
|
+
var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
|
|
149
|
+
var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger }) => {
|
|
150
|
+
let token;
|
|
151
|
+
const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
|
|
152
|
+
if (ssoSession) {
|
|
153
|
+
try {
|
|
154
|
+
const _token = await fromSso({
|
|
155
|
+
profile,
|
|
156
|
+
filepath,
|
|
157
|
+
configFilepath,
|
|
158
|
+
ignoreCache,
|
|
159
|
+
clientConfig,
|
|
160
|
+
parentClientConfig,
|
|
161
|
+
logger
|
|
162
|
+
})({ callerClientConfig });
|
|
163
|
+
token = {
|
|
164
|
+
accessToken: _token.token,
|
|
165
|
+
expiresAt: new Date(_token.expiration).toISOString()
|
|
166
|
+
};
|
|
167
|
+
} catch (e) {
|
|
168
|
+
throw new CredentialsProviderError(e.message, {
|
|
169
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
170
|
+
logger
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
try {
|
|
175
|
+
token = await getSSOTokenFromFile(ssoStartUrl);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
throw new CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
178
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
179
|
+
logger
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
184
|
+
throw new CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
185
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
186
|
+
logger
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
const { accessToken } = token;
|
|
190
|
+
const { SSOClient, GetRoleCredentialsCommand } = await import("./loadSso-HXXA5UNF.js");
|
|
191
|
+
const sso = ssoClient || new SSOClient(Object.assign({}, clientConfig ?? {}, {
|
|
192
|
+
logger: clientConfig?.logger ?? callerClientConfig?.logger ?? parentClientConfig?.logger,
|
|
193
|
+
region: clientConfig?.region ?? ssoRegion,
|
|
194
|
+
userAgentAppId: clientConfig?.userAgentAppId ?? callerClientConfig?.userAgentAppId ?? parentClientConfig?.userAgentAppId
|
|
195
|
+
}));
|
|
196
|
+
let ssoResp;
|
|
197
|
+
try {
|
|
198
|
+
ssoResp = await sso.send(new GetRoleCredentialsCommand({
|
|
199
|
+
accountId: ssoAccountId,
|
|
200
|
+
roleName: ssoRoleName,
|
|
201
|
+
accessToken
|
|
202
|
+
}));
|
|
203
|
+
} catch (e) {
|
|
204
|
+
throw new CredentialsProviderError(e, {
|
|
205
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
206
|
+
logger
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
|
|
210
|
+
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
211
|
+
throw new CredentialsProviderError("SSO returns an invalid temporary credential.", {
|
|
212
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
213
|
+
logger
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const credentials = {
|
|
217
|
+
accessKeyId,
|
|
218
|
+
secretAccessKey,
|
|
219
|
+
sessionToken,
|
|
220
|
+
expiration: new Date(expiration),
|
|
221
|
+
...credentialScope && { credentialScope },
|
|
222
|
+
...accountId && { accountId }
|
|
223
|
+
};
|
|
224
|
+
if (ssoSession) {
|
|
225
|
+
setCredentialFeature(credentials, "CREDENTIALS_SSO", "s");
|
|
226
|
+
} else {
|
|
227
|
+
setCredentialFeature(credentials, "CREDENTIALS_SSO_LEGACY", "u");
|
|
228
|
+
}
|
|
229
|
+
return credentials;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.973.14/node_modules/@aws-sdk/credential-provider-sso/dist-es/validateSsoProfile.js
|
|
233
|
+
var validateSsoProfile = (profile, logger) => {
|
|
234
|
+
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
235
|
+
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
236
|
+
throw new CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}
|
|
237
|
+
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger });
|
|
238
|
+
}
|
|
239
|
+
return profile;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.973.14/node_modules/@aws-sdk/credential-provider-sso/dist-es/fromSSO.js
|
|
243
|
+
var fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
244
|
+
init.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");
|
|
245
|
+
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
246
|
+
const { ssoClient } = init;
|
|
247
|
+
const profileName = getProfileName({
|
|
248
|
+
profile: init.profile ?? callerClientConfig?.profile
|
|
249
|
+
});
|
|
250
|
+
if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
|
|
251
|
+
const profiles = await parseKnownFiles(init);
|
|
252
|
+
const profile = profiles[profileName];
|
|
253
|
+
if (!profile) {
|
|
254
|
+
throw new CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
|
|
255
|
+
}
|
|
256
|
+
if (!isSsoProfile(profile)) {
|
|
257
|
+
throw new CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
|
|
258
|
+
logger: init.logger
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (profile?.sso_session) {
|
|
262
|
+
const ssoSessions = await loadSsoSessionData(init);
|
|
263
|
+
const session = ssoSessions[profile.sso_session];
|
|
264
|
+
const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
|
|
265
|
+
if (ssoRegion && ssoRegion !== session.sso_region) {
|
|
266
|
+
throw new CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
|
|
267
|
+
tryNextLink: false,
|
|
268
|
+
logger: init.logger
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
|
|
272
|
+
throw new CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
|
|
273
|
+
tryNextLink: false,
|
|
274
|
+
logger: init.logger
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
profile.sso_region = session.sso_region;
|
|
278
|
+
profile.sso_start_url = session.sso_start_url;
|
|
279
|
+
}
|
|
280
|
+
const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(profile, init.logger);
|
|
281
|
+
return resolveSSOCredentials({
|
|
282
|
+
ssoStartUrl: sso_start_url,
|
|
283
|
+
ssoSession: sso_session,
|
|
284
|
+
ssoAccountId: sso_account_id,
|
|
285
|
+
ssoRegion: sso_region,
|
|
286
|
+
ssoRoleName: sso_role_name,
|
|
287
|
+
ssoClient,
|
|
288
|
+
clientConfig: init.clientConfig,
|
|
289
|
+
parentClientConfig: init.parentClientConfig,
|
|
290
|
+
callerClientConfig: init.callerClientConfig,
|
|
291
|
+
profile: profileName,
|
|
292
|
+
filepath: init.filepath,
|
|
293
|
+
configFilepath: init.configFilepath,
|
|
294
|
+
ignoreCache: init.ignoreCache,
|
|
295
|
+
logger: init.logger
|
|
296
|
+
});
|
|
297
|
+
} else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
|
|
298
|
+
throw new CredentialsProviderError('Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
|
|
299
|
+
} else {
|
|
300
|
+
return resolveSSOCredentials({
|
|
301
|
+
ssoStartUrl,
|
|
302
|
+
ssoSession,
|
|
303
|
+
ssoAccountId,
|
|
304
|
+
ssoRegion,
|
|
305
|
+
ssoRoleName,
|
|
306
|
+
ssoClient,
|
|
307
|
+
clientConfig: init.clientConfig,
|
|
308
|
+
parentClientConfig: init.parentClientConfig,
|
|
309
|
+
callerClientConfig: init.callerClientConfig,
|
|
310
|
+
profile: profileName,
|
|
311
|
+
filepath: init.filepath,
|
|
312
|
+
configFilepath: init.configFilepath,
|
|
313
|
+
ignoreCache: init.ignoreCache,
|
|
314
|
+
logger: init.logger
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
export {
|
|
319
|
+
fromSSO,
|
|
320
|
+
isSsoProfile,
|
|
321
|
+
validateSsoProfile
|
|
322
|
+
};
|