@socketsecurity/cli-with-sentry 0.14.61 → 0.14.63

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.
@@ -0,0 +1,4 @@
1
+ declare function cmdFlagsToString(args: string[]): string;
2
+ declare function cmdPrefixMessage(cmdName: string, text: string): string;
3
+ declare function isHelpFlag(cmdArg: string): boolean;
4
+ export { cmdFlagsToString, cmdPrefixMessage, isHelpFlag };
@@ -0,0 +1,22 @@
1
+ /// <reference types="node" />
2
+ import { Remap } from '@socketsecurity/registry/lib/objects';
3
+ import { Abortable } from 'node:events';
4
+ import { ObjectEncodingOptions, OpenMode, PathLike, PathOrFileDescriptor } from 'node:fs';
5
+ import { FileHandle } from 'node:fs/promises';
6
+ type FindUpOptions = {
7
+ cwd?: string | undefined;
8
+ signal?: AbortSignal | undefined;
9
+ };
10
+ declare function findUp(name: string | string[], { cwd, signal }: FindUpOptions): Promise<string | undefined>;
11
+ type ReadFileOptions = Remap<ObjectEncodingOptions & Abortable & {
12
+ flag?: OpenMode | undefined;
13
+ }>;
14
+ declare function readFileBinary(filepath: PathLike | FileHandle, options?: ReadFileOptions | undefined): Promise<Buffer>;
15
+ declare function readFileUtf8(filepath: PathLike | FileHandle, options?: ReadFileOptions | undefined): Promise<string>;
16
+ declare function safeReadFile(filepath: PathLike | FileHandle, options?: 'utf8' | 'utf-8' | {
17
+ encoding: 'utf8' | 'utf-8';
18
+ } | undefined): Promise<string | undefined>;
19
+ declare function safeReadFileSync(filepath: PathOrFileDescriptor, options?: 'utf8' | 'utf-8' | {
20
+ encoding: 'utf8' | 'utf-8';
21
+ } | undefined): string | undefined;
22
+ export { FindUpOptions, findUp, ReadFileOptions, readFileBinary, readFileUtf8, safeReadFile, safeReadFileSync };
@@ -0,0 +1,56 @@
1
+ import { Logger } from '@socketsecurity/registry/lib/logger';
2
+ import { Remap } from '@socketsecurity/registry/lib/objects';
3
+ import { EditablePackageJson } from '@socketsecurity/registry/lib/packages';
4
+ import { SemVer } from 'semver';
5
+ declare const AGENTS: readonly ["bun", "npm", "pnpm", "yarn/berry", "yarn/classic", "vlt"];
6
+ type Agent = (typeof AGENTS)[number];
7
+ type StringKeyValueObject = {
8
+ [key: string]: string;
9
+ };
10
+ type DetectOptions = {
11
+ cwd?: string | undefined;
12
+ onUnknown?: (pkgManager: string | undefined) => void;
13
+ };
14
+ type EnvBase = {
15
+ agent: Agent;
16
+ agentExecPath: string;
17
+ agentSupported: boolean;
18
+ features: {
19
+ npmBuggyOverrides: boolean;
20
+ };
21
+ nodeSupported: boolean;
22
+ nodeVersion: SemVer;
23
+ npmExecPath: string;
24
+ pkgRequirements: {
25
+ agent: string;
26
+ node: string;
27
+ };
28
+ pkgSupports: {
29
+ agent: boolean;
30
+ node: boolean;
31
+ };
32
+ };
33
+ type EnvDetails = Readonly<Remap<EnvBase & {
34
+ agentVersion: SemVer;
35
+ lockName: string;
36
+ lockPath: string;
37
+ lockSrc: string;
38
+ pkgJson: EditablePackageJson;
39
+ pkgPath: string;
40
+ }>>;
41
+ type PartialEnvDetails = Readonly<Remap<EnvBase & {
42
+ agentVersion: SemVer | undefined;
43
+ lockName: string | undefined;
44
+ lockPath: string | undefined;
45
+ lockSrc: string | undefined;
46
+ pkgJson: EditablePackageJson | undefined;
47
+ pkgPath: string | undefined;
48
+ }>>;
49
+ declare function detectPackageEnvironment({ cwd, onUnknown }?: DetectOptions): Promise<EnvDetails | PartialEnvDetails>;
50
+ type DetectAndValidateOptions = {
51
+ cmdName?: string | undefined;
52
+ logger?: Logger | undefined;
53
+ prod?: boolean | undefined;
54
+ };
55
+ declare function detectAndValidatePackageEnvironment(cwd: string, options?: DetectAndValidateOptions | undefined): Promise<void | EnvDetails>;
56
+ export { AGENTS, Agent, StringKeyValueObject, DetectOptions, EnvDetails, PartialEnvDetails, detectPackageEnvironment, DetectAndValidateOptions, detectAndValidatePackageEnvironment };
@@ -9,6 +9,7 @@ function _socketInterop(e) {
9
9
  return c ? e.default : e
10
10
  }
11
11
 
12
+ var shadowNpmPaths = require('./shadow-npm-paths.js');
12
13
  var process$1 = require('node:process');
13
14
  var logger = require('@socketsecurity/registry/lib/logger');
14
15
  var prompts = require('@socketsecurity/registry/lib/prompts');
@@ -19,7 +20,6 @@ var registry = require('@socketsecurity/registry');
19
20
  var arrays = require('@socketsecurity/registry/lib/arrays');
20
21
  var debug = require('@socketsecurity/registry/lib/debug');
21
22
  var objects = require('@socketsecurity/registry/lib/objects');
22
- var shadowNpmPaths = require('./shadow-npm-paths.js');
23
23
  var npa = _socketInterop(require('npm-package-arg'));
24
24
  var events = require('node:events');
25
25
  var https = require('node:https');
@@ -142,18 +142,25 @@ function safeReadFileSync(filepath, options) {
142
142
  return undefined;
143
143
  }
144
144
 
145
+ // Default app data folder env var on Win
145
146
  const LOCALAPPDATA = 'LOCALAPPDATA';
147
+ // Default app data folder env var on Mac/Linux
148
+ const XDG_DATA_HOME = 'XDG_DATA_HOME';
149
+ const SOCKET_APP_DIR = 'socket/settings';
146
150
  const supportedApiKeys = new Set(['apiBaseUrl', 'apiKey', 'apiProxy', 'enforcedOrgs']);
147
- let _settings;
151
+ let settings;
152
+ let settingsPath;
153
+ let warnedSettingPathWin32Missing = false;
154
+ let pendingSave = false;
148
155
  function getSettings() {
149
- if (_settings === undefined) {
150
- _settings = {};
156
+ if (settings === undefined) {
157
+ settings = {};
151
158
  const settingsPath = getSettingsPath();
152
159
  if (settingsPath) {
153
160
  const raw = safeReadFileSync(settingsPath);
154
161
  if (raw) {
155
162
  try {
156
- Object.assign(_settings, JSON.parse(Buffer.from(raw, 'base64').toString()));
163
+ Object.assign(settings, JSON.parse(Buffer.from(raw, 'base64').toString()));
157
164
  } catch {
158
165
  logger.logger.warn(`Failed to parse settings at ${settingsPath}`);
159
166
  }
@@ -164,30 +171,40 @@ function getSettings() {
164
171
  }
165
172
  }
166
173
  }
167
- return _settings;
174
+ return settings;
168
175
  }
169
- let _settingsPath;
170
- let _warnedSettingPathWin32Missing = false;
171
176
  function getSettingsPath() {
172
- if (_settingsPath === undefined) {
177
+ // Get the OS app data folder:
178
+ // - Win: %LOCALAPPDATA% or fail?
179
+ // - Mac: %XDG_DATA_HOME% or fallback to "~/Library/Application Support/"
180
+ // - Linux: %XDG_DATA_HOME% or fallback to "~/.local/share/"
181
+ // Note: LOCALAPPDATA is typically: C:\Users\USERNAME\AppData
182
+ // Note: XDG stands for "X Desktop Group", nowadays "freedesktop.org"
183
+ // On most systems that path is: $HOME/.local/share
184
+ // Then append `socket/settings`, so:
185
+ // - Win: %LOCALAPPDATA%\socket\settings or return undefined
186
+ // - Mac: %XDG_DATA_HOME%/socket/settings or "~/Library/Application Support/socket/settings"
187
+ // - Linux: %XDG_DATA_HOME%/socket/settings or "~/.local/share/socket/settings"
188
+
189
+ if (settingsPath === undefined) {
173
190
  // Lazily access constants.WIN32.
174
191
  const {
175
192
  WIN32
176
193
  } = constants;
177
- let dataHome = WIN32 ? process$1.env[LOCALAPPDATA] : process$1.env['XDG_DATA_HOME'];
194
+ let dataHome = WIN32 ? process$1.env[LOCALAPPDATA] : process$1.env[XDG_DATA_HOME];
178
195
  if (!dataHome) {
179
196
  if (WIN32) {
180
- if (!_warnedSettingPathWin32Missing) {
181
- _warnedSettingPathWin32Missing = true;
197
+ if (!warnedSettingPathWin32Missing) {
198
+ warnedSettingPathWin32Missing = true;
182
199
  logger.logger.warn(`Missing %${LOCALAPPDATA}%`);
183
200
  }
184
201
  } else {
185
202
  dataHome = path.join(os.homedir(), ...(process$1.platform === 'darwin' ? ['Library', 'Application Support'] : ['.local', 'share']));
186
203
  }
187
204
  }
188
- _settingsPath = dataHome ? path.join(dataHome, 'socket/settings') : undefined;
205
+ settingsPath = dataHome ? path.join(dataHome, SOCKET_APP_DIR) : undefined;
189
206
  }
190
- return _settingsPath;
207
+ return settingsPath;
191
208
  }
192
209
  function normalizeSettingsKey(key) {
193
210
  const normalizedKey = key === 'apiToken' ? 'apiKey' : key;
@@ -224,7 +241,6 @@ function findSocketYmlSync() {
224
241
  function getSetting(key) {
225
242
  return getSettings()[normalizeSettingsKey(key)];
226
243
  }
227
- let pendingSave = false;
228
244
  function updateSetting(key, value) {
229
245
  const settings = getSettings();
230
246
  settings[normalizeSettingsKey(key)] = value;
@@ -285,20 +301,15 @@ async function setupSdk(apiToken = getDefaultToken(), apiBaseUrl = getDefaultApi
285
301
  throw new AuthError('You need to provide an API key');
286
302
  }
287
303
  return new sdk.SocketSdk(apiToken, {
288
- agent: proxy ? {
289
- http: new hpagent.HttpProxyAgent({
290
- proxy
291
- }),
292
- https: new hpagent.HttpsProxyAgent({
293
- proxy
294
- })
295
- } : undefined,
304
+ agent: proxy ? new hpagent.HttpsProxyAgent({
305
+ proxy
306
+ }) : undefined,
296
307
  baseUrl: apiBaseUrl,
297
308
  userAgent: sdk.createUserAgentFromPkgJson({
298
309
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_NAME']".
299
310
  name: "@socketsecurity/cli",
300
311
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
301
- version: "0.14.61",
312
+ version: "0.14.63",
302
313
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_HOMEPAGE']".
303
314
  homepage: "https://github.com/SocketDev/socket-cli"
304
315
  })
@@ -1899,7 +1910,7 @@ const {
1899
1910
  SOCKET_CLI_SAFE_WRAPPER,
1900
1911
  kInternalsSymbol,
1901
1912
  [kInternalsSymbol]: {
1902
- getIPC
1913
+ getIpc
1903
1914
  }
1904
1915
  } = constants;
1905
1916
  const SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES = {
@@ -1948,7 +1959,7 @@ class SafeArborist extends Arborist {
1948
1959
  __proto__: null,
1949
1960
  ...(args.length ? args[0] : undefined)
1950
1961
  };
1951
- const safeWrapperName = options.dryRun ? undefined : await getIPC(SOCKET_CLI_SAFE_WRAPPER);
1962
+ const safeWrapperName = options.dryRun ? undefined : await getIpc(SOCKET_CLI_SAFE_WRAPPER);
1952
1963
  const isSafeNpm = safeWrapperName === NPM;
1953
1964
  const isSafeNpx = safeWrapperName === NPX;
1954
1965
  if (!safeWrapperName || isSafeNpx && options['yes']) {
@@ -2038,5 +2049,5 @@ exports.safeReadFile = safeReadFile;
2038
2049
  exports.setupSdk = setupSdk;
2039
2050
  exports.updateNode = updateNode;
2040
2051
  exports.updateSetting = updateSetting;
2041
- //# debugId=c70e3a7b-6bac-4f16-808f-210cbd4abf84
2052
+ //# debugId=2af8fb11-075f-445a-9006-b004c848e12b
2042
2053
  //# sourceMappingURL=shadow-npm-inject.js.map