@larkup/cli 0.2.24 → 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.
Files changed (45) hide show
  1. package/README.md +8 -0
  2. package/dist/{analytics-store-KI3NXDYV.js → analytics-store-4NYU7DMO.js} +2 -2
  3. package/dist/api-X4PHQJTH.js +6943 -0
  4. package/dist/bowser-GZLEN3PD.js +2821 -0
  5. package/dist/{chroma-BCASZNMJ.js → chroma-RJVBZZMP.js} +2 -11
  6. package/dist/chunk-3EBUYTA7.js +136 -0
  7. package/dist/chunk-4XN2IRCG.js +46 -0
  8. package/dist/{chunk-FM6HYXZ5.js → chunk-5UWKP64Q.js} +24 -72
  9. package/dist/chunk-65EVYGDT.js +2904 -0
  10. package/dist/chunk-A7HMSODH.js +126 -0
  11. package/dist/chunk-BDMLJQRN.js +534 -0
  12. package/dist/chunk-FUTLPXFR.js +921 -0
  13. package/dist/chunk-HAABLEPO.js +1570 -0
  14. package/dist/chunk-HOPZALAP.js +449 -0
  15. package/dist/{chunk-L34L3RDQ.js → chunk-JZ3UCEGF.js} +157 -197
  16. package/dist/chunk-MACWQEJS.js +2091 -0
  17. package/dist/chunk-MYOADNR2.js +515 -0
  18. package/dist/chunk-N6IF5QLH.js +1850 -0
  19. package/dist/chunk-ODWAFTDP.js +1711 -0
  20. package/dist/chunk-QGM4M3NI.js +37 -0
  21. package/dist/chunk-S5DCG3CZ.js +41 -0
  22. package/dist/{chunk-I6JJWCUQ.js → chunk-V3VNCOZ6.js} +118 -29
  23. package/dist/dist-es-5DTOPEBY.js +322 -0
  24. package/dist/dist-es-BM4STLL5.js +70 -0
  25. package/dist/dist-es-DS5SFRTK.js +377 -0
  26. package/dist/dist-es-F6WXDZQY.js +88 -0
  27. package/dist/dist-es-KMHWFNXI.js +295 -0
  28. package/dist/dist-es-LRDDK5LI.js +11761 -0
  29. package/dist/dist-es-LWW2DNRF.js +139 -0
  30. package/dist/dist-es-NEADJWQM.js +176 -0
  31. package/dist/dist-es-S5FAFKBD.js +23 -0
  32. package/dist/dist-es-YD724GH3.js +221 -0
  33. package/dist/event-streams-NPIZBVLJ.js +43 -0
  34. package/dist/index.js +2163 -1798
  35. package/dist/{lancedb-UB2EPDCN.js → lancedb-TCUZKSHN.js} +1 -1
  36. package/dist/lexer-DQCqS3nf-CGRGK47I.js +62 -0
  37. package/dist/loadSso-HXXA5UNF.js +584 -0
  38. package/dist/{pinecone-OHOY4YYM.js → pinecone-ME3YOCQJ.js} +3 -21
  39. package/dist/signin-7FUGJFG3.js +822 -0
  40. package/dist/sso-oidc-EPMF7LMF.js +838 -0
  41. package/dist/sts-RBEOIBEJ.js +1118 -0
  42. package/dist/{tool-loader-KKODIWEV.js → tool-loader-PEQZZWTB.js} +3 -3
  43. package/dist/{tool-registry-CXCFMOWA.js → tool-registry-VJYLRXKJ.js} +2 -2
  44. package/package.json +20 -16
  45. package/dist/chunk-3RG5ZIWI.js +0 -10
@@ -0,0 +1,295 @@
1
+ import {
2
+ setCredentialFeature
3
+ } from "./chunk-N6IF5QLH.js";
4
+ import "./chunk-ODWAFTDP.js";
5
+ import {
6
+ CredentialsProviderError,
7
+ getProfileName,
8
+ parseKnownFiles
9
+ } from "./chunk-HAABLEPO.js";
10
+ import {
11
+ HttpRequest
12
+ } from "./chunk-MACWQEJS.js";
13
+ import "./chunk-QGM4M3NI.js";
14
+
15
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.77/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
16
+ import { createHash, createPrivateKey, createPublicKey, sign } from "crypto";
17
+ import { promises as fs } from "fs";
18
+ import { homedir } from "os";
19
+ import { dirname, join } from "path";
20
+ var LoginCredentialsFetcher = class _LoginCredentialsFetcher {
21
+ profileData;
22
+ init;
23
+ callerClientConfig;
24
+ static REFRESH_THRESHOLD = 5 * 60 * 1e3;
25
+ constructor(profileData, init, callerClientConfig) {
26
+ this.profileData = profileData;
27
+ this.init = init;
28
+ this.callerClientConfig = callerClientConfig;
29
+ }
30
+ async loadCredentials() {
31
+ const token = await this.loadToken();
32
+ if (!token) {
33
+ throw new CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
34
+ }
35
+ const accessToken = token.accessToken;
36
+ const now = Date.now();
37
+ const expiryTime = new Date(accessToken.expiresAt).getTime();
38
+ const timeUntilExpiry = expiryTime - now;
39
+ if (timeUntilExpiry <= _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
40
+ return this.refresh(token);
41
+ }
42
+ return this.toCredentials(token.accessToken);
43
+ }
44
+ get logger() {
45
+ return this.init?.logger;
46
+ }
47
+ get loginSession() {
48
+ return this.profileData.login_session;
49
+ }
50
+ toCredentials(token) {
51
+ return {
52
+ accessKeyId: token.accessKeyId,
53
+ secretAccessKey: token.secretAccessKey,
54
+ sessionToken: token.sessionToken,
55
+ accountId: token.accountId,
56
+ expiration: new Date(token.expiresAt)
57
+ };
58
+ }
59
+ async refresh(token) {
60
+ const diskToken = await this.loadToken().catch(() => token);
61
+ const now = Date.now();
62
+ const diskExpiry = new Date(diskToken.accessToken.expiresAt).getTime();
63
+ const tokenExpiry = new Date(token.accessToken.expiresAt).getTime();
64
+ const freshToken = diskExpiry <= now && tokenExpiry > now ? token : diskToken;
65
+ const freshExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
66
+ if (freshExpiry - Date.now() > _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
67
+ return this.toCredentials(freshToken.accessToken);
68
+ }
69
+ const { SigninClient, CreateOAuth2TokenCommand } = await import("./signin-7FUGJFG3.js");
70
+ const { logger, userAgentAppId } = this.callerClientConfig ?? {};
71
+ const isH2 = (requestHandler2) => {
72
+ return requestHandler2?.metadata?.handlerProtocol === "h2";
73
+ };
74
+ const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? void 0 : this.callerClientConfig?.requestHandler;
75
+ const region = this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION;
76
+ const client = new SigninClient({
77
+ credentials: {
78
+ accessKeyId: "",
79
+ secretAccessKey: ""
80
+ },
81
+ region,
82
+ requestHandler,
83
+ logger,
84
+ userAgentAppId,
85
+ ...this.init?.clientConfig
86
+ });
87
+ this.createDPoPInterceptor(client.middlewareStack);
88
+ const commandInput = {
89
+ tokenInput: {
90
+ clientId: freshToken.clientId,
91
+ refreshToken: freshToken.refreshToken,
92
+ grantType: "refresh_token"
93
+ }
94
+ };
95
+ try {
96
+ const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
97
+ const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
98
+ const { refreshToken, expiresIn } = response.tokenOutput ?? {};
99
+ if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
100
+ throw new CredentialsProviderError("Token refresh response missing required fields", {
101
+ logger: this.logger,
102
+ tryNextLink: false
103
+ });
104
+ }
105
+ const expiresInMs = (expiresIn ?? 900) * 1e3;
106
+ const expiration = new Date(Date.now() + expiresInMs);
107
+ const updatedToken = {
108
+ ...freshToken,
109
+ accessToken: {
110
+ ...freshToken.accessToken,
111
+ accessKeyId,
112
+ secretAccessKey,
113
+ sessionToken,
114
+ expiresAt: expiration.toISOString()
115
+ },
116
+ refreshToken
117
+ };
118
+ await this.saveToken(updatedToken);
119
+ return this.toCredentials(updatedToken.accessToken);
120
+ } catch (error) {
121
+ if (error.name === "AccessDeniedException") {
122
+ const errorType = error.error;
123
+ let message;
124
+ switch (errorType) {
125
+ case "TOKEN_EXPIRED":
126
+ message = "Your session has expired. Please reauthenticate.";
127
+ break;
128
+ case "USER_CREDENTIALS_CHANGED":
129
+ message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
130
+ break;
131
+ case "INSUFFICIENT_PERMISSIONS":
132
+ message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
133
+ break;
134
+ default:
135
+ message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
136
+ }
137
+ throw new CredentialsProviderError(message, {
138
+ logger: this.logger,
139
+ tryNextLink: false
140
+ });
141
+ }
142
+ const tokenExpiry2 = new Date(freshToken.accessToken.expiresAt).getTime();
143
+ if (tokenExpiry2 > Date.now()) {
144
+ this.logger?.warn?.(`Failed to refresh token: ${String(error)}. Using existing token until expiry.`);
145
+ return this.toCredentials(freshToken.accessToken);
146
+ }
147
+ throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
148
+ }
149
+ }
150
+ async loadToken() {
151
+ const tokenFilePath = this.getTokenFilePath();
152
+ try {
153
+ const tokenData = await fs.readFile(tokenFilePath, "utf8");
154
+ const token = JSON.parse(tokenData);
155
+ const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
156
+ if (!token.accessToken?.accountId) {
157
+ missingFields.push("accountId");
158
+ }
159
+ if (missingFields.length > 0) {
160
+ throw new CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
161
+ logger: this.logger,
162
+ tryNextLink: false
163
+ });
164
+ }
165
+ return token;
166
+ } catch (error) {
167
+ throw new CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
168
+ logger: this.logger,
169
+ tryNextLink: false
170
+ });
171
+ }
172
+ }
173
+ async saveToken(token) {
174
+ const tokenFilePath = this.getTokenFilePath();
175
+ const directory = dirname(tokenFilePath);
176
+ try {
177
+ await fs.mkdir(directory, { recursive: true });
178
+ } catch (error) {
179
+ }
180
+ await fs.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
181
+ }
182
+ getTokenFilePath() {
183
+ const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join(homedir(), ".aws", "login", "cache");
184
+ const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
185
+ const loginSessionSha256 = createHash("sha256").update(loginSessionBytes).digest("hex");
186
+ return join(directory, `${loginSessionSha256}.json`);
187
+ }
188
+ derToRawSignature(derSignature) {
189
+ let offset = 2;
190
+ if (derSignature[offset] !== 2) {
191
+ throw new Error("Invalid DER signature");
192
+ }
193
+ offset++;
194
+ const rLength = derSignature[offset++];
195
+ let r = derSignature.subarray(offset, offset + rLength);
196
+ offset += rLength;
197
+ if (derSignature[offset] !== 2) {
198
+ throw new Error("Invalid DER signature");
199
+ }
200
+ offset++;
201
+ const sLength = derSignature[offset++];
202
+ let s = derSignature.subarray(offset, offset + sLength);
203
+ r = r[0] === 0 ? r.subarray(1) : r;
204
+ s = s[0] === 0 ? s.subarray(1) : s;
205
+ const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
206
+ const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
207
+ return Buffer.concat([rPadded, sPadded]);
208
+ }
209
+ createDPoPInterceptor(middlewareStack) {
210
+ middlewareStack.add((next) => async (args) => {
211
+ if (HttpRequest.isInstance(args.request)) {
212
+ const request = args.request;
213
+ const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
214
+ const dpop = await this.generateDpop(request.method, actualEndpoint);
215
+ request.headers = {
216
+ ...request.headers,
217
+ DPoP: dpop
218
+ };
219
+ }
220
+ return next(args);
221
+ }, {
222
+ step: "finalizeRequest",
223
+ name: "dpopInterceptor",
224
+ override: true
225
+ });
226
+ }
227
+ async generateDpop(method = "POST", endpoint) {
228
+ const token = await this.loadToken();
229
+ try {
230
+ const privateKey = createPrivateKey({
231
+ key: token.dpopKey,
232
+ format: "pem",
233
+ type: "sec1"
234
+ });
235
+ const publicKey = createPublicKey(privateKey);
236
+ const publicDer = publicKey.export({ format: "der", type: "spki" });
237
+ let pointStart = -1;
238
+ for (let i = 0; i < publicDer.length; i++) {
239
+ if (publicDer[i] === 4) {
240
+ pointStart = i;
241
+ break;
242
+ }
243
+ }
244
+ const x = publicDer.slice(pointStart + 1, pointStart + 33);
245
+ const y = publicDer.slice(pointStart + 33, pointStart + 65);
246
+ const header = {
247
+ alg: "ES256",
248
+ typ: "dpop+jwt",
249
+ jwk: {
250
+ kty: "EC",
251
+ crv: "P-256",
252
+ x: x.toString("base64url"),
253
+ y: y.toString("base64url")
254
+ }
255
+ };
256
+ const payload = {
257
+ jti: crypto.randomUUID(),
258
+ htm: method,
259
+ htu: endpoint,
260
+ iat: Math.floor(Date.now() / 1e3)
261
+ };
262
+ const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
263
+ const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
264
+ const message = `${headerB64}.${payloadB64}`;
265
+ const asn1Signature = sign("sha256", Buffer.from(message), privateKey);
266
+ const rawSignature = this.derToRawSignature(asn1Signature);
267
+ const signatureB64 = rawSignature.toString("base64url");
268
+ return `${message}.${signatureB64}`;
269
+ } catch (error) {
270
+ throw new CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
271
+ }
272
+ }
273
+ };
274
+
275
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.77/node_modules/@aws-sdk/credential-provider-login/dist-es/fromLoginCredentials.js
276
+ var fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
277
+ init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
278
+ const profiles = await parseKnownFiles(init || {});
279
+ const profileName = getProfileName({
280
+ profile: init?.profile ?? callerClientConfig?.profile
281
+ });
282
+ const profile = profiles[profileName];
283
+ if (!profile?.login_session) {
284
+ throw new CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
285
+ tryNextLink: true,
286
+ logger: init?.logger
287
+ });
288
+ }
289
+ const fetcher = new LoginCredentialsFetcher(profile, init, callerClientConfig);
290
+ const credentials = await fetcher.loadCredentials();
291
+ return setCredentialFeature(credentials, "CREDENTIALS_LOGIN", "AD");
292
+ };
293
+ export {
294
+ fromLoginCredentials
295
+ };