@socketsecurity/sdk
Advanced tools
+22
-0
@@ -7,2 +7,24 @@ # Changelog | ||
| ## [3.3.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.3.0) - 2026-01-25 | ||
| ### Added | ||
| - New SDK convenience methods for OpenAPI v3.3.0 endpoints: | ||
| - `batchOrgPackageFetch(orgSlug, components, options)` - Organization-scoped PURL batch lookup with security policy label support | ||
| - `exportOpenVEX(orgSlug, id, options)` - Export vulnerability exploitability data as OpenVEX v0.2.0 documents (includes patch data and reachability analysis) | ||
| - `getOrgAlertFullScans(orgSlug, options)` - List full scans associated with specific alerts | ||
| - `rescanFullScan(orgSlug, fullScanId, options)` - Rescan existing full scans with shallow (policy reapplication) or deep (dependency resolution rerun) modes | ||
| - Repository endpoints now support optional `workspace` parameter for workspace-scoped operations: | ||
| - `createRepository(orgSlug, params, { workspace })` | ||
| - `deleteRepository(orgSlug, repoSlug, { workspace })` | ||
| - `getRepository(orgSlug, repoSlug, { workspace })` | ||
| - `updateRepository(orgSlug, repoSlug, params, { workspace })` | ||
| ### Changed | ||
| - Updated `@socketsecurity/lib` to v5.5.3 | ||
| - TypeScript: Auto-generated strict types from OpenAPI schema for improved type safety | ||
| - TypeScript: All optional properties now explicitly include `| undefined` for better null checking | ||
| - Synced OpenAPI type definitions with latest API specification | ||
| ## [3.2.0](https://github.com/SocketDev/socket-sdk-js/releases/tag/v3.2.0) - 2025-12-08 | ||
@@ -9,0 +31,0 @@ |
@@ -16,2 +16,2 @@ import type { ALERT_ACTION } from './types'; | ||
| export declare const httpAgentNames: Set<string>; | ||
| export declare const publicPolicy: Map<"ambiguousClassifier" | "badEncoding" | "badSemver" | "badSemverDependency" | "bidi" | "binScriptConfusion" | "chromeContentScript" | "chromeHostPermission" | "chromePermission" | "chromeWildcardHostPermission" | "chronoAnomaly" | "compromisedSSHKey" | "copyleftLicense" | "criticalCVE" | "cve" | "debugAccess" | "deprecated" | "deprecatedException" | "deprecatedLicense" | "didYouMean" | "dynamicRequire" | "emptyPackage" | "envVars" | "explicitlyUnlicensedItem" | "extraneousDependency" | "fileDependency" | "filesystemAccess" | "floatingDependency" | "generic" | "ghaArgToEnv" | "ghaArgToOutput" | "ghaArgToSink" | "ghaContextToEnv" | "ghaContextToOutput" | "ghaContextToSink" | "ghaEnvToSink" | "gitDependency" | "gitHubDependency" | "gptAnomaly" | "gptDidYouMean" | "gptMalware" | "gptSecurity" | "hasNativeCode" | "highEntropyStrings" | "homoglyphs" | "httpDependency" | "installScripts" | "invalidPackageJSON" | "invisibleChars" | "licenseChange" | "licenseException" | "licenseSpdxDisj" | "longStrings" | "majorRefactor" | "malware" | "manifestConfusion" | "mediumCVE" | "mildCVE" | "minifiedFile" | "miscLicenseIssues" | "missingAuthor" | "missingDependency" | "missingLicense" | "missingTarball" | "mixedLicense" | "modifiedException" | "modifiedLicense" | "networkAccess" | "newAuthor" | "noAuthorData" | "noBugTracker" | "noLicenseFound" | "noREADME" | "noRepository" | "noTests" | "noV1" | "noWebsite" | "nonOSILicense" | "nonSPDXLicense" | "nonpermissiveLicense" | "notice" | "obfuscatedFile" | "obfuscatedRequire" | "peerDependency" | "potentialVulnerability" | "semverAnomaly" | "shellAccess" | "shellScriptOverride" | "shrinkwrap" | "socketUpgradeAvailable" | "suspiciousStarActivity" | "suspiciousString" | "telemetry" | "trivialPackage" | "troll" | "typeModuleCompatibility" | "uncaughtOptionalDependency" | "unclearLicense" | "unidentifiedLicense" | "unmaintained" | "unpopularPackage" | "unpublished" | "unresolvedRequire" | "unsafeCopyright" | "unstableOwnership" | "unusedDependency" | "urlStrings" | "usesEval" | "vsxActivationWildcard" | "vsxDebuggerContribution" | "vsxExtensionDependency" | "vsxExtensionPack" | "vsxProposedApiUsage" | "vsxUntrustedWorkspaceSupported" | "vsxVirtualWorkspaceSupported" | "vsxWebviewContribution" | "vsxWorkspaceContainsActivation" | "zeroWidth", ALERT_ACTION>; | ||
| export declare const publicPolicy: Map<"ambiguousClassifier" | "badEncoding" | "badSemver" | "badSemverDependency" | "bidi" | "binScriptConfusion" | "chromeContentScript" | "chromeHostPermission" | "chromePermission" | "chromeWildcardHostPermission" | "chronoAnomaly" | "compromisedSSHKey" | "copyleftLicense" | "criticalCVE" | "cve" | "debugAccess" | "deprecated" | "deprecatedException" | "deprecatedLicense" | "didYouMean" | "dynamicRequire" | "emptyPackage" | "envVars" | "explicitlyUnlicensedItem" | "extraneousDependency" | "fileDependency" | "filesystemAccess" | "floatingDependency" | "generic" | "ghaArgToEnv" | "ghaArgToOutput" | "ghaArgToSink" | "ghaContextToEnv" | "ghaContextToOutput" | "ghaContextToSink" | "ghaEnvToSink" | "gitDependency" | "gitHubDependency" | "gptAnomaly" | "gptDidYouMean" | "gptMalware" | "gptSecurity" | "hasNativeCode" | "highEntropyStrings" | "homoglyphs" | "httpDependency" | "installScripts" | "invalidPackageJSON" | "invisibleChars" | "licenseChange" | "licenseException" | "licenseSpdxDisj" | "longStrings" | "majorRefactor" | "malware" | "manifestConfusion" | "mediumCVE" | "mildCVE" | "minifiedFile" | "miscLicenseIssues" | "missingAuthor" | "missingDependency" | "missingLicense" | "missingTarball" | "mixedLicense" | "modifiedException" | "modifiedLicense" | "networkAccess" | "newAuthor" | "noAuthorData" | "noBugTracker" | "noLicenseFound" | "noREADME" | "noRepository" | "noTests" | "noV1" | "noWebsite" | "nonOSILicense" | "nonSPDXLicense" | "nonpermissiveLicense" | "notice" | "obfuscatedFile" | "obfuscatedRequire" | "peerDependency" | "potentialVulnerability" | "recentlyPublished" | "semverAnomaly" | "shellAccess" | "shellScriptOverride" | "shrinkwrap" | "socketUpgradeAvailable" | "suspiciousStarActivity" | "suspiciousString" | "telemetry" | "tooManyFiles" | "trivialPackage" | "troll" | "typeModuleCompatibility" | "uncaughtOptionalDependency" | "unclearLicense" | "unidentifiedLicense" | "unmaintained" | "unpopularPackage" | "unpublished" | "unresolvedRequire" | "unsafeCopyright" | "unstableOwnership" | "unusedDependency" | "urlStrings" | "usesEval" | "vsxActivationWildcard" | "vsxDebuggerContribution" | "vsxExtensionDependency" | "vsxExtensionPack" | "vsxProposedApiUsage" | "vsxUntrustedWorkspaceSupported" | "vsxVirtualWorkspaceSupported" | "vsxWebviewContribution" | "vsxWorkspaceContainsActivation" | "zeroWidth", ALERT_ACTION>; |
+21
-21
@@ -79,22 +79,9 @@ /** | ||
| /** | ||
| * Check if HTTP response has a successful status code (2xx range). | ||
| * Returns true for status codes between 200-299, false otherwise. | ||
| */ | ||
| export declare function isResponseOk(response: IncomingMessage): boolean; | ||
| /** | ||
| * Transform artifact data based on authentication status. | ||
| * Filters and compacts response data for public/free-tier users. | ||
| */ | ||
| export declare function reshapeArtifactForPublicPolicy<T extends Record<string, unknown>>(data: T, isAuthenticated: boolean, actions?: string | undefined): T; | ||
| /** | ||
| * Retry helper for HTTP requests with exponential backoff. | ||
| * Wraps any async HTTP function and retries on failure. | ||
| * Create DELETE request with automatic retry logic. | ||
| * Retries on network errors and 5xx responses. | ||
| * | ||
| * @param fn - Async function to retry | ||
| * @param retries - Number of retry attempts (default: 0, retries disabled) | ||
| * @param retryDelay - Initial delay in ms (default: 100) | ||
| * @returns Result of the function call | ||
| * @throws {Error} Last error if all retries exhausted | ||
| */ | ||
| export declare function withRetry<T>(fn: () => Promise<T>, retries?: number, retryDelay?: number): Promise<T>; | ||
| export declare function createDeleteRequestWithRetry(baseUrl: string, urlPath: string, options?: RequestOptionsWithHooks | undefined, retries?: number, retryDelay?: number): Promise<IncomingMessage>; | ||
| /** | ||
@@ -109,3 +96,3 @@ * Create GET request with automatic retry logic. | ||
| /** | ||
| * Create DELETE request with automatic retry logic. | ||
| * Create request with JSON payload and automatic retry logic. | ||
| * Retries on network errors and 5xx responses. | ||
@@ -116,10 +103,23 @@ * | ||
| */ | ||
| export declare function createDeleteRequestWithRetry(baseUrl: string, urlPath: string, options?: RequestOptionsWithHooks | undefined, retries?: number, retryDelay?: number): Promise<IncomingMessage>; | ||
| export declare function createRequestWithJsonAndRetry(method: SendMethod, baseUrl: string, urlPath: string, json: unknown, options?: RequestOptionsWithHooks | undefined, retries?: number, retryDelay?: number): Promise<IncomingMessage>; | ||
| /** | ||
| * Create request with JSON payload and automatic retry logic. | ||
| * Retries on network errors and 5xx responses. | ||
| * Check if HTTP response has a successful status code (2xx range). | ||
| * Returns true for status codes between 200-299, false otherwise. | ||
| */ | ||
| export declare function isResponseOk(response: IncomingMessage): boolean; | ||
| /** | ||
| * Transform artifact data based on authentication status. | ||
| * Filters and compacts response data for public/free-tier users. | ||
| */ | ||
| export declare function reshapeArtifactForPublicPolicy<T extends Record<string, unknown>>(data: T, isAuthenticated: boolean, actions?: string | undefined): T; | ||
| /** | ||
| * Retry helper for HTTP requests with exponential backoff. | ||
| * Wraps any async HTTP function and retries on failure. | ||
| * | ||
| * @param fn - Async function to retry | ||
| * @param retries - Number of retry attempts (default: 0, retries disabled) | ||
| * @param retryDelay - Initial delay in ms (default: 100) | ||
| * @returns Result of the function call | ||
| * @throws {Error} Last error if all retries exhausted | ||
| */ | ||
| export declare function createRequestWithJsonAndRetry(method: SendMethod, baseUrl: string, urlPath: string, json: unknown, options?: RequestOptionsWithHooks | undefined, retries?: number, retryDelay?: number): Promise<IncomingMessage>; | ||
| export declare function withRetry<T>(fn: () => Promise<T>, retries?: number, retryDelay?: number): Promise<T>; |
+1
-1
@@ -12,5 +12,5 @@ /** | ||
| export type { ALERT_ACTION, ALERT_TYPE, Agent, ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CompactSocketArtifact, CompactSocketArtifactAlert, CreateDependenciesSnapshotOptions, CreateOrgFullScanOptions, CreateScanFromFilepathsOptions, CustomResponseType, Entitlement, EntitlementsResponse, FileValidationCallback, FileValidationResult, GetOptions, GotOptions, HeadersRecord, PatchFile, PatchRecord, PatchViewResponse, TelemetryConfig, PostOrgTelemetryPayload, PostOrgTelemetryResponse, QueryParams, RequestInfo, RequestOptions, RequestOptionsWithHooks, ResponseInfo, SecurityAlert, SendMethod, SendOptions, SocketArtifact, SocketArtifactAlert, SocketArtifactWithExtras, SocketId, SocketMetricSchema, SocketSdkArrayElement, SocketSdkData, SocketSdkErrorResult, SocketSdkGenericResult, SocketSdkOperations, SocketSdkOptions, SocketSdkResult, SocketSdkSuccessResult, StreamOrgFullScanOptions, UploadManifestFilesError, UploadManifestFilesOptions, UploadManifestFilesResponse, UploadManifestFilesReturnType, Vulnerability, } from './types'; | ||
| export type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanItem, FullScanListData, FullScanListResult, FullScanResult, ListFullScansOptions, ListRepositoriesOptions, OrganizationItem, OrganizationsResult, RepositoriesListData, RepositoriesListResult, RepositoryItem, RepositoryLabelItem, RepositoryLabelResult, RepositoryLabelsListData, RepositoryLabelsListResult, RepositoryResult, StreamFullScanOptions, StrictErrorResult, StrictResult, } from './types-strict'; | ||
| export type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanItem, FullScanListData, FullScanListResult, FullScanResult, GetRepositoryOptions, ListFullScansOptions, ListRepositoriesOptions, OrganizationItem, OrganizationsResult, RepositoriesListData, RepositoriesListResult, RepositoryItem, RepositoryLabelItem, RepositoryLabelResult, RepositoryLabelsListData, RepositoryLabelsListResult, RepositoryResult, StreamFullScanOptions, StrictErrorResult, StrictResult, } from './types-strict'; | ||
| export { createUserAgentFromPkgJson } from './user-agent'; | ||
| export { calculateWordSetSimilarity, filterRedundantCause, normalizeBaseUrl, promiseWithResolvers, queryToSearchParams, resolveAbsPaths, resolveBasePath, shouldOmitReason, }; | ||
| export { DEFAULT_USER_AGENT, httpAgentNames, publicPolicy }; |
@@ -12,3 +12,8 @@ export declare class PromiseQueue { | ||
| constructor(maxConcurrency: number, maxQueueLength?: number | undefined); | ||
| private runNext; | ||
| /** | ||
| * Get the number of tasks currently running | ||
| */ | ||
| get activeCount(): number; | ||
| /** | ||
| * Add a task to the queue | ||
@@ -19,4 +24,7 @@ * @param fn - Async function to execute | ||
| add<T>(fn: () => Promise<T>): Promise<T>; | ||
| private runNext; | ||
| /** | ||
| * Clear all pending tasks from the queue (does not affect running tasks) | ||
| */ | ||
| clear(): void; | ||
| /** | ||
| * Wait for all queued and running tasks to complete | ||
@@ -26,13 +34,5 @@ */ | ||
| /** | ||
| * Get the number of tasks currently running | ||
| */ | ||
| get activeCount(): number; | ||
| /** | ||
| * Get the number of tasks waiting in the queue | ||
| */ | ||
| get pendingCount(): number; | ||
| /** | ||
| * Clear all pending tasks from the queue (does not affect running tasks) | ||
| */ | ||
| clear(): void; | ||
| } |
+518
-370
| import type { ArtifactPatches, BatchPackageFetchResultType, BatchPackageStreamOptions, CreateDependenciesSnapshotOptions, Entitlement, GetOptions, PatchViewResponse, PostOrgTelemetryPayload, PostOrgTelemetryResponse, QueryParams, SendOptions, SocketSdkGenericResult, SocketSdkOptions, SocketSdkResult, StreamOrgFullScanOptions, UploadManifestFilesError, UploadManifestFilesOptions, UploadManifestFilesReturnType } from './types'; | ||
| import type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanListResult, FullScanResult, ListFullScansOptions, ListRepositoriesOptions, OrganizationsResult, RepositoriesListResult, RepositoryLabelResult, RepositoryLabelsListResult, RepositoryResult, StrictErrorResult } from './types-strict'; | ||
| import type { CreateFullScanOptions, DeleteRepositoryLabelResult, DeleteResult, FullScanListResult, FullScanResult, GetRepositoryOptions, ListFullScansOptions, ListRepositoriesOptions, OrganizationsResult, RepositoriesListResult, RepositoryLabelResult, RepositoryLabelsListResult, RepositoryResult, StrictErrorResult } from './types-strict'; | ||
| import type { IncomingMessage } from 'node:http'; | ||
@@ -16,2 +16,41 @@ /** | ||
| /** | ||
| * Get package metadata and alerts by PURL strings for a specific organization. | ||
| * Organization-scoped version of batchPackageFetch with security policy label support. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param componentsObj - Object containing array of components with PURL strings | ||
| * @param queryParams - Optional query parameters including labels, alerts, compact, etc. | ||
| * @returns Package metadata and alerts for the requested PURLs | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.batchOrgPackageFetch('my-org', | ||
| * { | ||
| * components: [ | ||
| * { purl: 'pkg:npm/express@4.19.2' }, | ||
| * { purl: 'pkg:pypi/django@5.0.6' } | ||
| * ] | ||
| * }, | ||
| * { labels: ['production'], alerts: true } | ||
| * ) | ||
| * | ||
| * if (result.success) { | ||
| * for (const artifact of result.data) { | ||
| * console.log(`${artifact.name}@${artifact.version}`) | ||
| * } | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/batchpackagefetchbyorg | ||
| * @apiEndpoint POST /orgs/{org_slug}/purl | ||
| * @quota 100 units | ||
| * @scopes packages:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| batchOrgPackageFetch(orgSlug: string, componentsObj: { | ||
| components: Array<{ | ||
| purl: string; | ||
| }>; | ||
| }, queryParams?: QueryParams | undefined): Promise<SocketSdkResult<'batchPackageFetchByOrg'>>; | ||
| /** | ||
| * Fetch package analysis data for multiple packages in a single batch request. | ||
@@ -46,9 +85,2 @@ * Returns all results at once after processing is complete. | ||
| /** | ||
| * Create a diff scan from two full scan IDs. | ||
| * Compares two existing full scans to identify changes. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| createOrgDiffScanFromIds(orgSlug: string, queryParams?: QueryParams | undefined): Promise<SocketSdkResult<'createOrgDiffScanFromIds'>>; | ||
| /** | ||
| * Create a full security scan for an organization. | ||
@@ -91,2 +123,56 @@ * | ||
| /** | ||
| * Create a diff scan from two full scan IDs. | ||
| * Compares two existing full scans to identify changes. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| createOrgDiffScanFromIds(orgSlug: string, queryParams?: QueryParams | undefined): Promise<SocketSdkResult<'createOrgDiffScanFromIds'>>; | ||
| /** | ||
| * Create a full scan from an archive file (.tar, .tar.gz/.tgz, or .zip). | ||
| * Uploads and scans a compressed archive of project files. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param archivePath - Path to the archive file to upload | ||
| * @param options - Scan configuration options including repo, branch, and metadata | ||
| * @returns Created full scan details with scan ID and status | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes or file cannot be read | ||
| */ | ||
| createOrgFullScanFromArchive(orgSlug: string, archivePath: string, options: { | ||
| branch?: string | undefined; | ||
| commit_hash?: string | undefined; | ||
| commit_message?: string | undefined; | ||
| committers?: string | undefined; | ||
| integration_org_slug?: string | undefined; | ||
| integration_type?: 'api' | 'azure' | 'bitbucket' | 'github' | 'gitlab' | 'web' | undefined; | ||
| make_default_branch?: boolean | undefined; | ||
| pull_request?: number | undefined; | ||
| repo: string; | ||
| scan_type?: string | undefined; | ||
| set_as_pending_head?: boolean | undefined; | ||
| tmp?: boolean | undefined; | ||
| workspace?: string | undefined; | ||
| }): Promise<SocketSdkResult<'CreateOrgFullScanArchive'>>; | ||
| /** | ||
| * Create a new webhook for an organization. | ||
| * Webhooks allow you to receive HTTP POST notifications when specific events occur. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param webhookData - Webhook configuration including name, URL, secret, and events | ||
| * @returns Created webhook details including webhook ID | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| createOrgWebhook(orgSlug: string, webhookData: { | ||
| description?: null | string | undefined; | ||
| events: string[]; | ||
| filters?: { | ||
| repositoryIds: null | string[]; | ||
| } | null | undefined; | ||
| headers?: null | Record<string, unknown> | undefined; | ||
| name: string; | ||
| secret: string; | ||
| url: string; | ||
| }): Promise<SocketSdkResult<'createOrgWebhook'>>; | ||
| /** | ||
| * Create a new repository in an organization. | ||
@@ -147,35 +233,2 @@ * | ||
| /** | ||
| * Create a full scan from an archive file (.tar, .tar.gz/.tgz, or .zip). | ||
| * Uploads and scans a compressed archive of project files. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param archivePath - Path to the archive file to upload | ||
| * @param options - Scan configuration options including repo, branch, and metadata | ||
| * @returns Created full scan details with scan ID and status | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes or file cannot be read | ||
| */ | ||
| createOrgFullScanFromArchive(orgSlug: string, archivePath: string, options: { | ||
| branch?: string | undefined; | ||
| commit_hash?: string | undefined; | ||
| commit_message?: string | undefined; | ||
| committers?: string | undefined; | ||
| integration_org_slug?: string | undefined; | ||
| integration_type?: 'api' | 'azure' | 'bitbucket' | 'github' | 'gitlab' | 'web' | undefined; | ||
| make_default_branch?: boolean | undefined; | ||
| pull_request?: number | undefined; | ||
| repo: string; | ||
| scan_type?: string | undefined; | ||
| set_as_pending_head?: boolean | undefined; | ||
| tmp?: boolean | undefined; | ||
| workspace?: string | undefined; | ||
| }): Promise<SocketSdkResult<'CreateOrgFullScanArchive'>>; | ||
| /** | ||
| * Delete a diff scan from an organization. | ||
| * Permanently removes diff scan data and results. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| deleteOrgDiffScan(orgSlug: string, diffScanId: string): Promise<SocketSdkResult<'deleteOrgDiffScan'>>; | ||
| /** | ||
| * Delete a full scan from an organization. | ||
@@ -206,2 +259,20 @@ * | ||
| /** | ||
| * Delete a diff scan from an organization. | ||
| * Permanently removes diff scan data and results. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| deleteOrgDiffScan(orgSlug: string, diffScanId: string): Promise<SocketSdkResult<'deleteOrgDiffScan'>>; | ||
| /** | ||
| * Delete a webhook from an organization. | ||
| * This will stop all future webhook deliveries to the webhook URL. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param webhookId - Webhook ID to delete | ||
| * @returns Success status | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| deleteOrgWebhook(orgSlug: string, webhookId: string): Promise<SocketSdkResult<'deleteOrgWebhook'>>; | ||
| /** | ||
| * Delete a repository from an organization. | ||
@@ -213,2 +284,3 @@ * | ||
| * @param repoSlug - Repository slug/name to delete | ||
| * @param options - Optional parameters including workspace | ||
| * @returns Success confirmation | ||
@@ -231,3 +303,3 @@ * | ||
| */ | ||
| deleteRepository(orgSlug: string, repoSlug: string): Promise<DeleteResult | StrictErrorResult>; | ||
| deleteRepository(orgSlug: string, repoSlug: string, options?: GetRepositoryOptions | undefined): Promise<DeleteResult | StrictErrorResult>; | ||
| /** | ||
@@ -260,3 +332,52 @@ * Delete a repository label from an organization. | ||
| * Delete a legacy scan report permanently. | ||
| /** | ||
| * Download patch file content by hash. | ||
| * | ||
| * Downloads the actual patched file content from the public Socket blob store. | ||
| * This is used after calling viewPatch() to get the patch metadata. | ||
| * No authentication is required as patch blobs are publicly accessible. | ||
| * | ||
| * @param hash - The blob hash in SSRI (sha256-base64) or hex format | ||
| * @param options - Optional configuration | ||
| * @param options.baseUrl - Override blob store URL (for testing) | ||
| * @returns Promise<string> - The patch file content as UTF-8 string | ||
| * @throws Error if blob not found (404) or download fails | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const sdk = new SocketSdk('your-api-token') | ||
| * // First get patch metadata | ||
| * const patch = await sdk.viewPatch('my-org', 'patch-uuid') | ||
| * // Then download the actual patched file | ||
| * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob) | ||
| * ``` | ||
| */ | ||
| downloadOrgFullScanFilesAsTar(orgSlug: string, fullScanId: string, outputPath: string): Promise<SocketSdkResult<'downloadOrgFullScanFilesAsTar'>>; | ||
| /** | ||
| * Download patch file content from Socket blob storage. | ||
| * Retrieves patched file contents using SSRI hash or hex hash. | ||
| * | ||
| * This is a low-level utility method - you'll typically use this after calling | ||
| * `viewPatch()` to get patch metadata, then download individual patched files. | ||
| * | ||
| * @param hash - The blob hash in SSRI (sha256-base64) or hex format | ||
| * @param options - Optional configuration | ||
| * @param options.baseUrl - Override blob store URL (for testing) | ||
| * @returns Promise<string> - The patch file content as UTF-8 string | ||
| * @throws Error if blob not found (404) or download fails | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const sdk = new SocketSdk('your-api-token') | ||
| * // First get patch metadata | ||
| * const patch = await sdk.viewPatch('my-org', 'patch-uuid') | ||
| * // Then download the actual patched file | ||
| * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob) | ||
| * ``` | ||
| */ | ||
| downloadPatch(hash: string, options?: { | ||
| baseUrl?: string | undefined; | ||
| } | undefined): Promise<string>; | ||
| /** | ||
| * Export scan results in CycloneDX SBOM format. | ||
@@ -269,2 +390,35 @@ * Returns Software Bill of Materials compliant with CycloneDX standard. | ||
| /** | ||
| * Export vulnerability exploitability data as an OpenVEX v0.2.0 document. | ||
| * Includes patch data and reachability analysis for vulnerability assessment. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param id - Full scan or SBOM report ID | ||
| * @param options - Optional parameters including author, role, and document_id | ||
| * @returns OpenVEX document with vulnerability exploitability information | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.exportOpenVEX('my-org', 'scan-id', { | ||
| * author: 'Security Team', | ||
| * role: 'VEX Generator' | ||
| * }) | ||
| * | ||
| * if (result.success) { | ||
| * console.log('VEX Version:', result.data.version) | ||
| * console.log('Statements:', result.data.statements.length) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/exportopenvex | ||
| * @apiEndpoint GET /orgs/{org_slug}/export/openvex/{id} | ||
| * @quota 1 unit | ||
| * @scopes report:read | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| exportOpenVEX(orgSlug: string, id: string, options?: { | ||
| author?: string | undefined; | ||
| document_id?: string | undefined; | ||
| role?: string | undefined; | ||
| } | undefined): Promise<SocketSdkResult<'exportOpenVEX'>>; | ||
| /** | ||
| * Export scan results in SPDX SBOM format. | ||
@@ -320,2 +474,56 @@ * Returns Software Bill of Materials compliant with SPDX standard. | ||
| /** | ||
| * Get complete full scan results buffered in memory. | ||
| * | ||
| * Returns entire scan data as JSON for programmatic processing. | ||
| * For large scans, consider using streamFullScan() instead. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param scanId - Full scan identifier | ||
| * @returns Complete full scan data including all artifacts | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.getFullScan('my-org', 'scan_123') | ||
| * | ||
| * if (result.success) { | ||
| * console.log('Scan status:', result.data.scan_state) | ||
| * console.log('Repository:', result.data.repository_slug) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorgfullscan | ||
| * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id} | ||
| * @quota 1 unit | ||
| * @scopes full-scans:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getFullScan(orgSlug: string, scanId: string): Promise<FullScanResult | StrictErrorResult>; | ||
| /** | ||
| * Get metadata for a specific full scan. | ||
| * | ||
| * Returns scan configuration, status, and summary information without full artifact data. | ||
| * Useful for checking scan status without downloading complete results. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param scanId - Full scan identifier | ||
| * @returns Scan metadata including status and configuration | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.getFullScanMetadata('my-org', 'scan_123') | ||
| * | ||
| * if (result.success) { | ||
| * console.log('Scan state:', result.data.scan_state) | ||
| * console.log('Branch:', result.data.branch) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorgfullscanmetadata | ||
| * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}/metadata | ||
| * @quota 1 unit | ||
| * @scopes full-scans:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getFullScanMetadata(orgSlug: string, scanId: string): Promise<FullScanResult | StrictErrorResult>; | ||
| /** | ||
| * Get security issues for a specific npm package and version. | ||
@@ -328,2 +536,37 @@ * Returns detailed vulnerability and security alert information. | ||
| /** | ||
| * List full scans associated with a specific alert. | ||
| * Returns paginated full scan references for alert investigation. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param options - Query parameters including alertKey, range, pagination | ||
| * @returns Paginated array of full scans associated with the alert | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.getOrgAlertFullScans('my-org', { | ||
| * alertKey: 'npm/lodash/cve-2021-23337', | ||
| * range: '-7d', | ||
| * per_page: 50 | ||
| * }) | ||
| * | ||
| * if (result.success) { | ||
| * for (const item of result.data.items) { | ||
| * console.log('Full Scan ID:', item.fullScanId) | ||
| * } | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/alertfullscans | ||
| * @apiEndpoint GET /orgs/{org_slug}/alert-full-scan-search | ||
| * @quota 10 units | ||
| * @scopes alerts:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgAlertFullScans(orgSlug: string, options: { | ||
| alertKey: string; | ||
| per_page?: number | undefined; | ||
| range?: string | undefined; | ||
| startAfterCursor?: string | undefined; | ||
| }): Promise<SocketSdkResult<'alertFullScans'>>; | ||
| /** | ||
| * List latest alerts for an organization (Beta). | ||
@@ -380,3 +623,3 @@ * Returns paginated alerts with comprehensive filtering options. | ||
| startAfterCursor?: string | undefined; | ||
| }): Promise<SocketSdkResult<'alertsList'>>; | ||
| } | undefined): Promise<SocketSdkResult<'alertsList'>>; | ||
| /** | ||
@@ -390,137 +633,95 @@ * Get analytics data for organization usage patterns and security metrics. | ||
| /** | ||
| * List all organizations accessible to the current user. | ||
| * Fetch available fixes for vulnerabilities in a repository or scan. | ||
| * Returns fix recommendations including version upgrades and update types. | ||
| * | ||
| * Returns organization details and access permissions with guaranteed required fields. | ||
| * @param orgSlug - Organization identifier | ||
| * @param options - Fix query options including repo_slug or full_scan_id, vulnerability IDs, and preferences | ||
| * @returns Fix details for requested vulnerabilities with upgrade recommendations | ||
| * | ||
| * @returns List of organizations with metadata | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgFixes(orgSlug: string, options: { | ||
| allow_major_updates: boolean; | ||
| full_scan_id?: string | undefined; | ||
| include_details?: boolean | undefined; | ||
| include_responsible_direct_dependencies?: boolean | undefined; | ||
| minimum_release_age?: string | undefined; | ||
| repo_slug?: string | undefined; | ||
| vulnerability_ids: string; | ||
| }): Promise<SocketSdkResult<'fetch-fixes'>>; | ||
| /** | ||
| * Get organization's license policy configuration.* Returns allowed, restricted, and monitored license types. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.listOrganizations() | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgLicensePolicy(orgSlug: string): Promise<SocketSdkResult<'getOrgLicensePolicy'>>; | ||
| /** | ||
| * Get organization's security policy configuration.* Returns alert rules, severity thresholds, and enforcement settings. | ||
| * | ||
| * if (result.success) { | ||
| * result.data.organizations.forEach(org => { | ||
| * console.log(org.name, org.slug) // Guaranteed fields | ||
| * }) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorganizations | ||
| * @apiEndpoint GET /organizations | ||
| * @quota 1 unit | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| listOrganizations(): Promise<OrganizationsResult | StrictErrorResult>; | ||
| getOrgSecurityPolicy(orgSlug: string): Promise<SocketSdkResult<'getOrgSecurityPolicy'>>; | ||
| /** | ||
| * Get complete full scan results buffered in memory. | ||
| * Get organization's telemetry configuration. | ||
| * Returns whether telemetry is enabled for the organization. | ||
| * | ||
| * Returns entire scan data as JSON for programmatic processing. | ||
| * For large scans, consider using streamFullScan() instead. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param scanId - Full scan identifier | ||
| * @returns Complete full scan data including all artifacts | ||
| * @returns Telemetry configuration with enabled status | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.getFullScan('my-org', 'scan_123') | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgTelemetryConfig(orgSlug: string): Promise<SocketSdkResult<'getOrgTelemetryConfig'>>; | ||
| /** | ||
| * Get organization triage settings and status. | ||
| * Returns alert triage configuration and current state. | ||
| * | ||
| * if (result.success) { | ||
| * console.log('Scan status:', result.data.scan_state) | ||
| * console.log('Repository:', result.data.repository_slug) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorgfullscan | ||
| * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id} | ||
| * @quota 1 unit | ||
| * @scopes full-scans:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getFullScan(orgSlug: string, scanId: string): Promise<FullScanResult | StrictErrorResult>; | ||
| getOrgTriage(orgSlug: string): Promise<SocketSdkResult<'getOrgTriage'>>; | ||
| /** | ||
| * List all full scans for an organization. | ||
| * Get details of a specific webhook. | ||
| * Returns webhook configuration including events, URL, and filters. | ||
| * | ||
| * Returns paginated list of full scan metadata with guaranteed required fields | ||
| * for improved TypeScript autocomplete. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param options - Filtering and pagination options | ||
| * @returns List of full scans with metadata | ||
| * @param webhookId - Webhook ID to retrieve | ||
| * @returns Webhook details | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.listFullScans('my-org', { | ||
| * branch: 'main', | ||
| * per_page: 50, | ||
| * use_cursor: true | ||
| * }) | ||
| * | ||
| * if (result.success) { | ||
| * result.data.results.forEach(scan => { | ||
| * console.log(scan.id, scan.created_at) // Guaranteed fields | ||
| * }) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorgfullscanlist | ||
| * @apiEndpoint GET /orgs/{org_slug}/full-scans | ||
| * @quota 1 unit | ||
| * @scopes full-scans:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| listFullScans(orgSlug: string, options?: ListFullScansOptions | undefined): Promise<FullScanListResult | StrictErrorResult>; | ||
| getOrgWebhook(orgSlug: string, webhookId: string): Promise<SocketSdkResult<'getOrgWebhook'>>; | ||
| /** | ||
| * Get metadata for a specific full scan. | ||
| * List all webhooks for an organization. | ||
| * Supports pagination and sorting options. | ||
| * | ||
| * Returns scan configuration, status, and summary information without full artifact data. | ||
| * Useful for checking scan status without downloading complete results. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param scanId - Full scan identifier | ||
| * @returns Scan metadata including status and configuration | ||
| * @param options - Optional query parameters for pagination and sorting | ||
| * @returns List of webhooks with pagination info | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.getFullScanMetadata('my-org', 'scan_123') | ||
| * | ||
| * if (result.success) { | ||
| * console.log('Scan state:', result.data.scan_state) | ||
| * console.log('Branch:', result.data.branch) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorgfullscanmetadata | ||
| * @apiEndpoint GET /orgs/{org_slug}/full-scans/{full_scan_id}/metadata | ||
| * @quota 1 unit | ||
| * @scopes full-scans:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getFullScanMetadata(orgSlug: string, scanId: string): Promise<FullScanResult | StrictErrorResult>; | ||
| getOrgWebhooksList(orgSlug: string, options?: { | ||
| direction?: string | undefined; | ||
| page?: number | undefined; | ||
| per_page?: number | undefined; | ||
| sort?: string | undefined; | ||
| } | undefined): Promise<SocketSdkResult<'getOrgWebhooksList'>>; | ||
| /** | ||
| * Fetch available fixes for vulnerabilities in a repository or scan. | ||
| * Returns fix recommendations including version upgrades and update types. | ||
| * Get current API quota usage and limits. | ||
| * Returns remaining requests, rate limits, and quota reset times. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param options - Fix query options including repo_slug or full_scan_id, vulnerability IDs, and preferences | ||
| * @returns Fix details for requested vulnerabilities with upgrade recommendations | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgFixes(orgSlug: string, options: { | ||
| allow_major_updates: boolean; | ||
| full_scan_id?: string | undefined; | ||
| include_details?: boolean | undefined; | ||
| include_responsible_direct_dependencies?: boolean | undefined; | ||
| minimum_release_age?: string | undefined; | ||
| repo_slug?: string | undefined; | ||
| vulnerability_ids: string; | ||
| }): Promise<SocketSdkResult<'fetch-fixes'>>; | ||
| getQuota(): Promise<SocketSdkResult<'getQuota'>>; | ||
| /** | ||
| * Get organization's license policy configuration.* Returns allowed, restricted, and monitored license types. | ||
| * Get analytics data for a specific repository. | ||
| * Returns security metrics, dependency trends, and vulnerability statistics. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgLicensePolicy(orgSlug: string): Promise<SocketSdkResult<'getOrgLicensePolicy'>>; | ||
| getRepoAnalytics(repo: string, time: string): Promise<SocketSdkResult<'getRepoAnalytics'>>; | ||
| /** | ||
| * Get detailed results for a legacy scan report. | ||
| /** | ||
| /** | ||
| * Get details for a specific repository. | ||
@@ -532,2 +733,3 @@ * | ||
| * @param repoSlug - Repository slug/name | ||
| * @param options - Optional parameters including workspace | ||
| * @returns Repository details with configuration | ||
@@ -552,3 +754,3 @@ * | ||
| */ | ||
| getRepository(orgSlug: string, repoSlug: string): Promise<RepositoryResult | StrictErrorResult>; | ||
| getRepository(orgSlug: string, repoSlug: string, options?: GetRepositoryOptions | undefined): Promise<RepositoryResult | StrictErrorResult>; | ||
| /** | ||
@@ -582,18 +784,36 @@ * Get details for a specific repository label. | ||
| /** | ||
| * List all repository labels for an organization. | ||
| * Get security score for a specific npm package and version. | ||
| * Returns numerical security rating and scoring breakdown. | ||
| * | ||
| * Returns paginated list of labels configured for repository organization and policy management. | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getScoreByNpmPackage(pkgName: string, version: string): Promise<SocketSdkResult<'getScoreByNPMPackage'>>; | ||
| /** | ||
| * Get list of file types and formats supported for scanning. | ||
| * Returns supported manifest files, lockfiles, and configuration formats. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getSupportedScanFiles(): Promise<SocketSdkResult<'getReportSupportedFiles'>>; | ||
| /** | ||
| * List all full scans for an organization. | ||
| * | ||
| * Returns paginated list of full scan metadata with guaranteed required fields | ||
| * for improved TypeScript autocomplete. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param options - Pagination options | ||
| * @returns List of labels with guaranteed id and name fields | ||
| * @param options - Filtering and pagination options | ||
| * @returns List of full scans with metadata | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.listRepositoryLabels('my-org', { per_page: 50, page: 1 }) | ||
| * const result = await sdk.listFullScans('my-org', { | ||
| * branch: 'main', | ||
| * per_page: 50, | ||
| * use_cursor: true | ||
| * }) | ||
| * | ||
| * if (result.success) { | ||
| * result.data.results.forEach(label => { | ||
| * console.log('Label:', label.name) | ||
| * console.log('Associated repos:', label.repository_ids?.length || 0) | ||
| * result.data.results.forEach(scan => { | ||
| * console.log(scan.id, scan.created_at) // Guaranteed fields | ||
| * }) | ||
@@ -603,10 +823,41 @@ * } | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorgrepolabellist | ||
| * @apiEndpoint GET /orgs/{org_slug}/repos/labels | ||
| * @see https://docs.socket.dev/reference/getorgfullscanlist | ||
| * @apiEndpoint GET /orgs/{org_slug}/full-scans | ||
| * @quota 1 unit | ||
| * @scopes repo-label:list | ||
| * @scopes full-scans:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| listRepositoryLabels(orgSlug: string, options?: QueryParams | undefined): Promise<RepositoryLabelsListResult | StrictErrorResult>; | ||
| listFullScans(orgSlug: string, options?: ListFullScansOptions | undefined): Promise<FullScanListResult | StrictErrorResult>; | ||
| /** | ||
| * List all organizations accessible to the current user. | ||
| * | ||
| * Returns organization details and access permissions with guaranteed required fields. | ||
| * | ||
| * @returns List of organizations with metadata | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.listOrganizations() | ||
| * | ||
| * if (result.success) { | ||
| * result.data.organizations.forEach(org => { | ||
| * console.log(org.name, org.slug) // Guaranteed fields | ||
| * }) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorganizations | ||
| * @apiEndpoint GET /organizations | ||
| * @quota 1 unit | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| listOrganizations(): Promise<OrganizationsResult | StrictErrorResult>; | ||
| /** | ||
| * List all diff scans for an organization. | ||
| * Returns paginated list of diff scan metadata and status. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| listOrgDiffScans(orgSlug: string): Promise<SocketSdkResult<'listOrgDiffScans'>>; | ||
| /** | ||
| * List all repositories in an organization. | ||
@@ -643,53 +894,30 @@ * | ||
| /** | ||
| * Get organization's security policy configuration.* Returns alert rules, severity thresholds, and enforcement settings. | ||
| * List all repository labels for an organization. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgSecurityPolicy(orgSlug: string): Promise<SocketSdkResult<'getOrgSecurityPolicy'>>; | ||
| /** | ||
| * Get organization triage settings and status. | ||
| * Returns alert triage configuration and current state. | ||
| * Returns paginated list of labels configured for repository organization and policy management. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgTriage(orgSlug: string): Promise<SocketSdkResult<'getOrgTriage'>>; | ||
| /** | ||
| * Get current API quota usage and limits. | ||
| * Returns remaining requests, rate limits, and quota reset times. | ||
| * @param orgSlug - Organization identifier | ||
| * @param options - Pagination options | ||
| * @returns List of labels with guaranteed id and name fields | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getQuota(): Promise<SocketSdkResult<'getQuota'>>; | ||
| /** | ||
| * Get analytics data for a specific repository. | ||
| * Returns security metrics, dependency trends, and vulnerability statistics. | ||
| * @example | ||
| * ```typescript | ||
| * const result = await sdk.listRepositoryLabels('my-org', { per_page: 50, page: 1 }) | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getRepoAnalytics(repo: string, time: string): Promise<SocketSdkResult<'getRepoAnalytics'>>; | ||
| /** | ||
| * Get detailed results for a legacy scan report. | ||
| /** | ||
| /** | ||
| * Get security score for a specific npm package and version. | ||
| * Returns numerical security rating and scoring breakdown. | ||
| * if (result.success) { | ||
| * result.data.results.forEach(label => { | ||
| * console.log('Label:', label.name) | ||
| * console.log('Associated repos:', label.repository_ids?.length || 0) | ||
| * }) | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/getorgrepolabellist | ||
| * @apiEndpoint GET /orgs/{org_slug}/repos/labels | ||
| * @quota 1 unit | ||
| * @scopes repo-label:list | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getScoreByNpmPackage(pkgName: string, version: string): Promise<SocketSdkResult<'getScoreByNPMPackage'>>; | ||
| listRepositoryLabels(orgSlug: string, options?: QueryParams | undefined): Promise<RepositoryLabelsListResult | StrictErrorResult>; | ||
| /** | ||
| * Get list of file types and formats supported for scanning. | ||
| * Returns supported manifest files, lockfiles, and configuration formats. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getSupportedScanFiles(): Promise<SocketSdkResult<'getReportSupportedFiles'>>; | ||
| /** | ||
| * List all diff scans for an organization. | ||
| * Returns paginated list of diff scan metadata and status. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| listOrgDiffScans(orgSlug: string): Promise<SocketSdkResult<'listOrgDiffScans'>>; | ||
| /** | ||
| * Create a new API token for an organization. | ||
@@ -723,2 +951,13 @@ * Generates API token with specified scopes and metadata. | ||
| /** | ||
| * Post telemetry data for an organization. | ||
| * Sends telemetry events and analytics data for monitoring and analysis. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param telemetryData - Telemetry payload containing events and metrics | ||
| * @returns Empty object on successful submission | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| postOrgTelemetry(orgSlug: string, telemetryData: PostOrgTelemetryPayload): Promise<SocketSdkGenericResult<PostOrgTelemetryResponse>>; | ||
| /** | ||
| * Update user or organization settings. | ||
@@ -733,2 +972,38 @@ * Configures preferences, notifications, and security policies. | ||
| /** | ||
| * Create a new full scan by rescanning an existing scan. | ||
| * Supports shallow (policy reapplication) and deep (dependency resolution rerun) modes. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param fullScanId - Full scan ID to rescan | ||
| * @param options - Rescan options including mode (shallow or deep) | ||
| * @returns New scan ID and status | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Shallow rescan (reapply policies to cached data) | ||
| * const result = await sdk.rescanFullScan('my-org', 'scan_123', { | ||
| * mode: 'shallow' | ||
| * }) | ||
| * | ||
| * if (result.success) { | ||
| * console.log('New Scan ID:', result.data.id) | ||
| * console.log('Status:', result.data.status) | ||
| * } | ||
| * | ||
| * // Deep rescan (rerun dependency resolution) | ||
| * const deepResult = await sdk.rescanFullScan('my-org', 'scan_123', { | ||
| * mode: 'deep' | ||
| * }) | ||
| * ``` | ||
| * | ||
| * @see https://docs.socket.dev/reference/rescanorgfullscan | ||
| * @apiEndpoint POST /orgs/{org_slug}/full-scans/{full_scan_id}/rescan | ||
| * @quota 1 unit | ||
| * @scopes full-scans:create | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| rescanFullScan(orgSlug: string, fullScanId: string, options?: { | ||
| mode?: 'shallow' | 'deep' | undefined; | ||
| } | undefined): Promise<SocketSdkResult<'rescanOrgFullScan'>>; | ||
| /** | ||
| * Search for dependencies across monitored projects. | ||
@@ -805,2 +1080,43 @@ * Returns matching packages with security information and usage patterns. | ||
| /** | ||
| * Update organization's security policy configuration.* Modifies alert rules, severity thresholds, and enforcement settings. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| updateOrgSecurityPolicy(orgSlug: string, policyData: QueryParams): Promise<SocketSdkResult<'updateOrgSecurityPolicy'>>; | ||
| /** | ||
| * Update organization's telemetry configuration. | ||
| * Enables or disables telemetry for the organization. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param telemetryData - Telemetry configuration with enabled flag | ||
| * @returns Updated telemetry configuration | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| updateOrgTelemetryConfig(orgSlug: string, telemetryData: { | ||
| enabled?: boolean | undefined; | ||
| }): Promise<SocketSdkResult<'updateOrgTelemetryConfig'>>; | ||
| /** | ||
| * Update an existing webhook's configuration. | ||
| * All fields are optional - only provided fields will be updated. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param webhookId - Webhook ID to update | ||
| * @param webhookData - Updated webhook configuration | ||
| * @returns Updated webhook details | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| updateOrgWebhook(orgSlug: string, webhookId: string, webhookData: { | ||
| description?: null | string | undefined; | ||
| events?: string[] | undefined; | ||
| filters?: { | ||
| repositoryIds: null | string[]; | ||
| } | null | undefined; | ||
| headers?: null | Record<string, unknown> | undefined; | ||
| name?: string | undefined; | ||
| secret?: null | string | undefined; | ||
| url?: string | undefined; | ||
| }): Promise<SocketSdkResult<'updateOrgWebhook'>>; | ||
| /** | ||
| * Update configuration for a repository. | ||
@@ -813,2 +1129,3 @@ * | ||
| * @param params - Configuration updates (description, homepage, default_branch, etc.) | ||
| * @param options - Optional parameters including workspace | ||
| * @returns Updated repository details | ||
@@ -834,3 +1151,3 @@ * | ||
| */ | ||
| updateRepository(orgSlug: string, repoSlug: string, params?: QueryParams | undefined): Promise<RepositoryResult | StrictErrorResult>; | ||
| updateRepository(orgSlug: string, repoSlug: string, params?: QueryParams | undefined, options?: GetRepositoryOptions | undefined): Promise<RepositoryResult | StrictErrorResult>; | ||
| /** | ||
@@ -864,8 +1181,2 @@ * Update a repository label for an organization. | ||
| /** | ||
| * Update organization's security policy configuration.* Modifies alert rules, severity thresholds, and enforcement settings. | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| updateOrgSecurityPolicy(orgSlug: string, policyData: QueryParams): Promise<SocketSdkResult<'updateOrgSecurityPolicy'>>; | ||
| /** | ||
| * Upload manifest files for dependency analysis. | ||
@@ -884,165 +1195,2 @@ * Processes package files to create dependency snapshots and security analysis. | ||
| viewPatch(orgSlug: string, uuid: string): Promise<PatchViewResponse>; | ||
| /** | ||
| * Download patch file content by hash. | ||
| * | ||
| * Downloads the actual patched file content from the public Socket blob store. | ||
| * This is used after calling viewPatch() to get the patch metadata. | ||
| * No authentication is required as patch blobs are publicly accessible. | ||
| * | ||
| * @param hash - The blob hash in SSRI (sha256-base64) or hex format | ||
| * @param options - Optional configuration | ||
| * @param options.baseUrl - Override blob store URL (for testing) | ||
| * @returns Promise<string> - The patch file content as UTF-8 string | ||
| * @throws Error if blob not found (404) or download fails | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const sdk = new SocketSdk('your-api-token') | ||
| * // First get patch metadata | ||
| * const patch = await sdk.viewPatch('my-org', 'patch-uuid') | ||
| * // Then download the actual patched file | ||
| * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob) | ||
| * ``` | ||
| */ | ||
| downloadOrgFullScanFilesAsTar(orgSlug: string, fullScanId: string, outputPath: string): Promise<SocketSdkResult<'downloadOrgFullScanFilesAsTar'>>; | ||
| /** | ||
| * Download patch file content from Socket blob storage. | ||
| * Retrieves patched file contents using SSRI hash or hex hash. | ||
| * | ||
| * This is a low-level utility method - you'll typically use this after calling | ||
| * `viewPatch()` to get patch metadata, then download individual patched files. | ||
| * | ||
| * @param hash - The blob hash in SSRI (sha256-base64) or hex format | ||
| * @param options - Optional configuration | ||
| * @param options.baseUrl - Override blob store URL (for testing) | ||
| * @returns Promise<string> - The patch file content as UTF-8 string | ||
| * @throws Error if blob not found (404) or download fails | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const sdk = new SocketSdk('your-api-token') | ||
| * // First get patch metadata | ||
| * const patch = await sdk.viewPatch('my-org', 'patch-uuid') | ||
| * // Then download the actual patched file | ||
| * const fileContent = await sdk.downloadPatch(patch.files['index.js'].socketBlob) | ||
| * ``` | ||
| */ | ||
| downloadPatch(hash: string, options?: { | ||
| baseUrl?: string; | ||
| }): Promise<string>; | ||
| /** | ||
| * Update organization's telemetry configuration. | ||
| * Enables or disables telemetry for the organization. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param telemetryData - Telemetry configuration with enabled flag | ||
| * @returns Updated telemetry configuration | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| updateOrgTelemetryConfig(orgSlug: string, telemetryData: { | ||
| enabled?: boolean | undefined; | ||
| }): Promise<SocketSdkResult<'updateOrgTelemetryConfig'>>; | ||
| /** | ||
| * Get organization's telemetry configuration. | ||
| * Returns whether telemetry is enabled for the organization. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @returns Telemetry configuration with enabled status | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgTelemetryConfig(orgSlug: string): Promise<SocketSdkResult<'getOrgTelemetryConfig'>>; | ||
| /** | ||
| * Post telemetry data for an organization. | ||
| * Sends telemetry events and analytics data for monitoring and analysis. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param telemetryData - Telemetry payload containing events and metrics | ||
| * @returns Empty object on successful submission | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| postOrgTelemetry(orgSlug: string, telemetryData: PostOrgTelemetryPayload): Promise<SocketSdkGenericResult<PostOrgTelemetryResponse>>; | ||
| /** | ||
| * Create a new webhook for an organization. | ||
| * Webhooks allow you to receive HTTP POST notifications when specific events occur. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param webhookData - Webhook configuration including name, URL, secret, and events | ||
| * @returns Created webhook details including webhook ID | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| createOrgWebhook(orgSlug: string, webhookData: { | ||
| description?: null | string | undefined; | ||
| events: string[]; | ||
| filters?: { | ||
| repositoryIds: null | string[]; | ||
| } | null | undefined; | ||
| headers?: null | Record<string, unknown> | undefined; | ||
| name: string; | ||
| secret: string; | ||
| url: string; | ||
| }): Promise<SocketSdkResult<'createOrgWebhook'>>; | ||
| /** | ||
| * Delete a webhook from an organization. | ||
| * This will stop all future webhook deliveries to the webhook URL. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param webhookId - Webhook ID to delete | ||
| * @returns Success status | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| deleteOrgWebhook(orgSlug: string, webhookId: string): Promise<SocketSdkResult<'deleteOrgWebhook'>>; | ||
| /** | ||
| * Get details of a specific webhook. | ||
| * Returns webhook configuration including events, URL, and filters. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param webhookId - Webhook ID to retrieve | ||
| * @returns Webhook details | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgWebhook(orgSlug: string, webhookId: string): Promise<SocketSdkResult<'getOrgWebhook'>>; | ||
| /** | ||
| * List all webhooks for an organization. | ||
| * Supports pagination and sorting options. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param options - Optional query parameters for pagination and sorting | ||
| * @returns List of webhooks with pagination info | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| getOrgWebhooksList(orgSlug: string, options?: { | ||
| direction?: string | undefined; | ||
| page?: number | undefined; | ||
| per_page?: number | undefined; | ||
| sort?: string | undefined; | ||
| }): Promise<SocketSdkResult<'getOrgWebhooksList'>>; | ||
| /** | ||
| * Update an existing webhook's configuration. | ||
| * All fields are optional - only provided fields will be updated. | ||
| * | ||
| * @param orgSlug - Organization identifier | ||
| * @param webhookId - Webhook ID to update | ||
| * @param webhookData - Updated webhook configuration | ||
| * @returns Updated webhook details | ||
| * | ||
| * @throws {Error} When server returns 5xx status codes | ||
| */ | ||
| updateOrgWebhook(orgSlug: string, webhookId: string, webhookData: { | ||
| description?: null | string | undefined; | ||
| events?: string[] | undefined; | ||
| filters?: { | ||
| repositoryIds: null | string[]; | ||
| } | null | undefined; | ||
| headers?: null | Record<string, unknown> | undefined; | ||
| name?: string | undefined; | ||
| secret?: null | string | undefined; | ||
| url?: string | undefined; | ||
| }): Promise<SocketSdkResult<'updateOrgWebhook'>>; | ||
| } |
@@ -36,3 +36,3 @@ /** | ||
| */ | ||
| export declare function mockErrorResponse<T>(error: string, status?: number, cause?: string): SocketSdkGenericResult<T>; | ||
| export declare function mockErrorResponse<T>(error: string, status?: number, cause?: string | undefined): SocketSdkGenericResult<T>; | ||
| /** | ||
@@ -52,6 +52,6 @@ * Create a mock Socket API error response body. | ||
| */ | ||
| export declare function mockApiErrorBody(message: string, details?: Record<string, unknown>): { | ||
| export declare function mockApiErrorBody(message: string, details?: Record<string, unknown> | undefined): { | ||
| error: { | ||
| message: string; | ||
| details?: Record<string, unknown>; | ||
| details?: Record<string, unknown> | undefined; | ||
| }; | ||
@@ -398,4 +398,4 @@ }; | ||
| */ | ||
| export declare function mockSdkResult<T extends SocketSdkOperations>(success: true, data: SocketSdkSuccessResult<T>['data'], status?: number): SocketSdkSuccessResult<T>; | ||
| export declare function mockSdkResult<T extends SocketSdkOperations>(success: false, error: string, status?: number, cause?: string): SocketSdkErrorResult<T>; | ||
| export declare function mockSdkResult<T extends SocketSdkOperations>(success: true, data: SocketSdkSuccessResult<T>['data'], status?: number | undefined): SocketSdkSuccessResult<T>; | ||
| export declare function mockSdkResult<T extends SocketSdkOperations>(success: false, error: string, status?: number | undefined, cause?: string | undefined): SocketSdkErrorResult<T>; | ||
| /** | ||
@@ -416,8 +416,8 @@ * Create a mock SDK error with proper structure. | ||
| export declare function mockSdkError(type: 'NOT_FOUND' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'SERVER_ERROR' | 'TIMEOUT', options?: { | ||
| cause?: string; | ||
| message?: string; | ||
| status?: number; | ||
| cause?: string | undefined; | ||
| message?: string | undefined; | ||
| status?: number | undefined; | ||
| }): Error & { | ||
| status: number; | ||
| cause?: string; | ||
| cause?: string | undefined; | ||
| }; | ||
@@ -424,0 +424,0 @@ /** |
+180
-144
| /** | ||
| * @fileoverview Strict type definitions for Socket SDK v3. | ||
| * AUTO-GENERATED from OpenAPI definitions using AST parsing - DO NOT EDIT MANUALLY. | ||
| * These types provide better TypeScript DX by marking guaranteed fields as required | ||
| * and only keeping truly optional fields as optional. This improves IntelliSense autocomplete. | ||
| * and only keeping truly optional fields as optional. | ||
| * | ||
| * Generated by: scripts/generate-strict-types.mjs | ||
| */ | ||
| /** | ||
| * Strict type for full scan metadata item. | ||
| * Represents a single full scan with guaranteed fields marked as required. | ||
| * Options for create full scan. | ||
| */ | ||
| export type CreateFullScanOptions = { | ||
| branch?: string | undefined; | ||
| commit_hash?: string | undefined; | ||
| commit_message?: string | undefined; | ||
| committers?: string | undefined; | ||
| integration_org_slug?: string | undefined; | ||
| integration_type?: 'api' | 'github' | 'gitlab' | 'bitbucket' | 'azure' | 'web' | undefined; | ||
| make_default_branch?: boolean | undefined; | ||
| pathsRelativeTo?: string | undefined; | ||
| pull_request?: number | undefined; | ||
| repo: string; | ||
| scan_type?: string | undefined; | ||
| set_as_pending_head?: boolean | undefined; | ||
| tmp?: boolean | undefined; | ||
| workspace?: string | undefined; | ||
| }; | ||
| /** | ||
| * Strict type for full scan item. | ||
| */ | ||
| export type FullScanItem = { | ||
| api_url: string | null; | ||
| branch?: string | null | undefined; | ||
| commit_hash?: string | null | undefined; | ||
| commit_message?: string | null | undefined; | ||
| committers?: string[] | undefined; | ||
| created_at: string; | ||
| html_report_url: string; | ||
| html_url?: string | null | undefined; | ||
| id: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| integration_branch_url?: string | null | undefined; | ||
| integration_commit_url?: string | null | undefined; | ||
| integration_pull_request_url?: string | null | undefined; | ||
| integration_repo_url: string; | ||
| integration_type: string | null; | ||
| organization_id: string; | ||
| organization_slug: string; | ||
| pull_request?: number | null | undefined; | ||
| repo: string; | ||
| repository_id: string; | ||
| repository_slug: string; | ||
| repo: string; | ||
| html_report_url: string; | ||
| api_url: string; | ||
| integration_type: string; | ||
| integration_repo_url: string; | ||
| branch: string | null; | ||
| commit_message: string | null; | ||
| commit_hash: string | null; | ||
| pull_request: number | null; | ||
| committers: string[]; | ||
| html_url: string | null; | ||
| integration_branch_url: string | null; | ||
| integration_commit_url: string | null; | ||
| integration_pull_request_url: string | null; | ||
| scan_state: 'pending' | 'precrawl' | 'resolve' | 'scan' | null; | ||
| unmatchedFiles?: string[]; | ||
| scan_state?: 'pending' | 'precrawl' | 'resolve' | 'scan' | null | undefined; | ||
| updated_at: string; | ||
| workspace?: string | undefined; | ||
| }; | ||
| /** | ||
| * Strict type for full scan list response. | ||
| * Strict type for full scan list data. | ||
| */ | ||
| export type FullScanListData = { | ||
| nextPage?: number | null | undefined; | ||
| nextPageCursor?: string | null | undefined; | ||
| results: FullScanItem[]; | ||
| nextPageCursor: string | null; | ||
| nextPage: number | null; | ||
| }; | ||
| /** | ||
| * Strict type for full scan list result. | ||
| * Options for get repository. | ||
| */ | ||
| export type FullScanListResult = { | ||
| cause?: undefined; | ||
| data: FullScanListData; | ||
| error?: undefined; | ||
| status: number; | ||
| success: true; | ||
| export type GetRepositoryOptions = { | ||
| workspace?: string | undefined; | ||
| }; | ||
| /** | ||
| * Strict type for single full scan result. | ||
| * Options for list full scans. | ||
| */ | ||
| export type FullScanResult = { | ||
| cause?: undefined; | ||
| data: FullScanItem; | ||
| error?: undefined; | ||
| status: number; | ||
| success: true; | ||
| export type ListFullScansOptions = { | ||
| branch?: string | undefined; | ||
| commit_hash?: string | undefined; | ||
| direction?: 'asc' | 'desc' | undefined; | ||
| from?: string | undefined; | ||
| page?: number | undefined; | ||
| per_page?: number | undefined; | ||
| pull_request?: string | undefined; | ||
| repo?: string | undefined; | ||
| sort?: 'name' | 'created_at' | undefined; | ||
| startAfterCursor?: string | undefined; | ||
| use_cursor?: boolean | undefined; | ||
| workspace?: string | undefined; | ||
| }; | ||
| /** | ||
| * Options for listing full scans. | ||
| * Options for list repositories. | ||
| */ | ||
| export type ListFullScansOptions = { | ||
| sort?: 'name' | 'created_at'; | ||
| direction?: 'asc' | 'desc'; | ||
| per_page?: number; | ||
| page?: number; | ||
| startAfterCursor?: string; | ||
| use_cursor?: boolean; | ||
| from?: string; | ||
| repo?: string; | ||
| branch?: string; | ||
| pull_request?: string; | ||
| commit_hash?: string; | ||
| export type ListRepositoriesOptions = { | ||
| direction?: string | undefined; | ||
| include_archived?: boolean | undefined; | ||
| page?: number | undefined; | ||
| per_page?: number | undefined; | ||
| sort?: string | undefined; | ||
| }; | ||
| /** | ||
| * Options for creating a full scan. | ||
| * Strict type for organization item. | ||
| */ | ||
| export type CreateFullScanOptions = { | ||
| pathsRelativeTo?: string; | ||
| repo: string; | ||
| branch?: string; | ||
| commit_message?: string; | ||
| commit_hash?: string; | ||
| pull_request?: number; | ||
| committers?: string; | ||
| integration_type?: 'api' | 'github' | 'gitlab' | 'bitbucket' | 'azure'; | ||
| integration_org_slug?: string; | ||
| make_default_branch?: boolean; | ||
| set_as_pending_head?: boolean; | ||
| tmp?: boolean; | ||
| scan_type?: string; | ||
| export type OrganizationItem = { | ||
| id: string; | ||
| image?: string | null | undefined; | ||
| name?: string | null | undefined; | ||
| plan: string; | ||
| slug: string; | ||
| }; | ||
| /** | ||
| * Options for streaming a full scan. | ||
| * Strict type for repositories list data. | ||
| */ | ||
| export type StreamFullScanOptions = { | ||
| output?: boolean | string; | ||
| export type RepositoriesListData = { | ||
| nextPage?: number | null | undefined; | ||
| results: RepositoryItem[]; | ||
| }; | ||
| /** | ||
| * Strict type for repository item. | ||
| */ | ||
| export type RepositoryItem = { | ||
| archived: boolean; | ||
| created_at: string; | ||
| default_branch: string | null; | ||
| description: string | null; | ||
| head_full_scan_id: string | null; | ||
| homepage: string | null; | ||
| id: string; | ||
| integration_meta: { | ||
| /** @enum {string} */ | ||
| type?: 'github'; | ||
| value?: { | ||
| /** | ||
| * @description The GitHub installation_id of the active associated Socket GitHub App | ||
| * @default | ||
| */ | ||
| installation_id: string; | ||
| /** | ||
| * @description The GitHub login name that the active Socket GitHub App installation is installed to | ||
| * @default | ||
| */ | ||
| installation_login: string; | ||
| /** | ||
| * @description The name of the associated GitHub repo. | ||
| * @default | ||
| */ | ||
| repo_name: string | null; | ||
| /** | ||
| * @description The id of the associated GitHub repo. | ||
| * @default | ||
| */ | ||
| repo_id: string | null; | ||
| }; | ||
| } | null; | ||
| name: string; | ||
| slig?: string | undefined; | ||
| slug: string; | ||
| updated_at: string; | ||
| visibility: 'public' | 'private'; | ||
| workspace: string; | ||
| }; | ||
| /** | ||
| * Strict type for repository label item. | ||
| */ | ||
| export type RepositoryLabelItem = { | ||
| has_license_policy?: boolean | undefined; | ||
| has_security_policy?: boolean | undefined; | ||
| id: string; | ||
| name: string; | ||
| repository_ids?: string[] | undefined; | ||
| }; | ||
| /** | ||
| * Strict type for repository labels list data. | ||
| */ | ||
| export type RepositoryLabelsListData = { | ||
| nextPage?: number | null | undefined; | ||
| results: RepositoryLabelItem[]; | ||
| }; | ||
| /** | ||
| * Error result type for all SDK operations. | ||
@@ -108,3 +180,3 @@ */ | ||
| cause?: string | undefined; | ||
| data?: undefined; | ||
| data?: undefined | undefined; | ||
| error: string; | ||
@@ -118,5 +190,5 @@ status: number; | ||
| export type StrictResult<T> = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: T; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -126,21 +198,18 @@ success: true; | ||
| /** | ||
| * Strict type for organization item. | ||
| * Strict type for full scan list result. | ||
| */ | ||
| export type OrganizationItem = { | ||
| id: string; | ||
| name: string; | ||
| slug: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| plan: string; | ||
| export type FullScanListResult = { | ||
| cause?: undefined | undefined; | ||
| data: FullScanListData; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
| success: true; | ||
| }; | ||
| /** | ||
| * Strict type for organizations list result. | ||
| * Strict type for single full scan result. | ||
| */ | ||
| export type OrganizationsResult = { | ||
| cause?: undefined; | ||
| data: { | ||
| organizations: OrganizationItem[]; | ||
| }; | ||
| error?: undefined; | ||
| export type FullScanResult = { | ||
| cause?: undefined | undefined; | ||
| data: FullScanItem; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -150,23 +219,18 @@ success: true; | ||
| /** | ||
| * Strict type for repository item. | ||
| * Options for streaming a full scan. | ||
| */ | ||
| export type RepositoryItem = { | ||
| id: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| name: string; | ||
| organization_id: string; | ||
| organization_slug: string; | ||
| default_branch: string | null; | ||
| homepage: string | null; | ||
| archived: boolean; | ||
| visibility: 'public' | 'private' | 'internal'; | ||
| export type StreamFullScanOptions = { | ||
| output?: boolean | string | undefined; | ||
| }; | ||
| /** | ||
| * Strict type for repositories list data. | ||
| * Strict type for organizations list result. | ||
| */ | ||
| export type RepositoriesListData = { | ||
| results: RepositoryItem[]; | ||
| nextPageCursor: string | null; | ||
| nextPage: number | null; | ||
| export type OrganizationsResult = { | ||
| cause?: undefined | undefined; | ||
| data: { | ||
| organizations: OrganizationItem[]; | ||
| }; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
| success: true; | ||
| }; | ||
@@ -177,5 +241,5 @@ /** | ||
| export type RepositoriesListResult = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: RepositoriesListData; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -185,21 +249,10 @@ success: true; | ||
| /** | ||
| * Options for listing repositories. | ||
| */ | ||
| export type ListRepositoriesOptions = { | ||
| sort?: 'name' | 'created_at'; | ||
| direction?: 'asc' | 'desc'; | ||
| per_page?: number; | ||
| page?: number; | ||
| startAfterCursor?: string; | ||
| use_cursor?: boolean; | ||
| }; | ||
| /** | ||
| * Strict type for delete operation result. | ||
| */ | ||
| export type DeleteResult = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: { | ||
| success: boolean; | ||
| }; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -212,5 +265,5 @@ success: true; | ||
| export type RepositoryResult = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: RepositoryItem; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -220,25 +273,8 @@ success: true; | ||
| /** | ||
| * Strict type for repository label item. | ||
| */ | ||
| export type RepositoryLabelItem = { | ||
| id: string; | ||
| name: string; | ||
| repository_ids?: string[]; | ||
| has_security_policy?: boolean; | ||
| has_license_policy?: boolean; | ||
| }; | ||
| /** | ||
| * Strict type for repository labels list data. | ||
| */ | ||
| export type RepositoryLabelsListData = { | ||
| results: RepositoryLabelItem[]; | ||
| nextPage: number | null; | ||
| }; | ||
| /** | ||
| * Strict type for repository labels list result. | ||
| */ | ||
| export type RepositoryLabelsListResult = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: RepositoryLabelsListData; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -251,5 +287,5 @@ success: true; | ||
| export type RepositoryLabelResult = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: RepositoryLabelItem; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -262,9 +298,9 @@ success: true; | ||
| export type DeleteRepositoryLabelResult = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: { | ||
| status: string; | ||
| }; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
| success: true; | ||
| }; |
+14
-14
@@ -111,4 +111,4 @@ /** | ||
| hooks?: { | ||
| onRequest?: (info: RequestInfo) => void; | ||
| onResponse?: (info: ResponseInfo) => void; | ||
| onRequest?: ((info: RequestInfo) => void) | undefined; | ||
| onResponse?: ((info: ResponseInfo) => void) | undefined; | ||
| } | undefined; | ||
@@ -132,5 +132,5 @@ }; | ||
| export type SocketSdkSuccessResult<T extends SocketSdkOperations> = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: OpReturnType<operations[T]>; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -141,7 +141,7 @@ success: true; | ||
| cause?: string | undefined; | ||
| data?: undefined; | ||
| data?: undefined | undefined; | ||
| error: string; | ||
| status: number; | ||
| success: false; | ||
| _operation?: T; | ||
| _operation?: T | undefined; | ||
| }; | ||
@@ -163,5 +163,5 @@ export type SocketSdkResult<T extends SocketSdkOperations> = SocketSdkSuccessResult<T> | SocketSdkErrorResult<T>; | ||
| export type SocketSdkGenericResult<T> = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: T; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: number; | ||
@@ -171,3 +171,3 @@ success: true; | ||
| cause?: string | undefined; | ||
| data?: undefined; | ||
| data?: undefined | undefined; | ||
| error: string; | ||
@@ -272,4 +272,4 @@ status: number; | ||
| hooks?: { | ||
| onRequest?: (info: RequestInfo) => void; | ||
| onResponse?: (info: ResponseInfo) => void; | ||
| onRequest?: ((info: RequestInfo) => void) | undefined; | ||
| onResponse?: ((info: ResponseInfo) => void) | undefined; | ||
| } | undefined; | ||
@@ -297,5 +297,5 @@ /** | ||
| export type UploadManifestFilesReturnType = { | ||
| cause?: undefined; | ||
| cause?: undefined | undefined; | ||
| data: UploadManifestFilesResponse; | ||
| error?: undefined; | ||
| error?: undefined | undefined; | ||
| status: 200; | ||
@@ -306,3 +306,3 @@ success: true; | ||
| cause?: string | undefined; | ||
| data?: undefined; | ||
| data?: undefined | undefined; | ||
| error: string; | ||
@@ -309,0 +309,0 @@ status: number; |
+42
-42
| import type { QueryParams } from './types'; | ||
| export { createUserAgentFromPkgJson } from './user-agent'; | ||
| /** | ||
| * Normalize base URL by ensuring it ends with a trailing slash. | ||
| * Required for proper URL joining with relative paths. | ||
| * Memoized for performance since base URLs are typically reused. | ||
| */ | ||
| export declare const normalizeBaseUrl: (baseUrl: string) => string; | ||
| /** | ||
| * Create a promise with externally accessible resolve/reject functions. | ||
| * Polyfill for Promise.withResolvers() on older Node.js versions. | ||
| */ | ||
| export declare function promiseWithResolvers<T>(): ReturnType<typeof Promise.withResolvers<T>>; | ||
| /** | ||
| * Convert query parameters to URLSearchParams with API-compatible key normalization. | ||
| * Transforms camelCase keys to snake_case and filters out empty values. | ||
| */ | ||
| export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams; | ||
| /** | ||
| * Convert relative file paths to absolute paths. | ||
| * Resolves paths relative to specified base directory or current working directory. | ||
| */ | ||
| export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: string | undefined): string[]; | ||
| /** | ||
| * Resolve base path to an absolute directory path. | ||
| * Converts relative paths to absolute using current working directory as reference. | ||
| */ | ||
| export declare function resolveBasePath(pathsRelativeTo?: string): string; | ||
| /** | ||
| * Calculate Jaccard similarity coefficient between two strings based on word sets. | ||
@@ -48,18 +22,2 @@ * Returns a value between 0 (no overlap) and 1 (identical word sets). | ||
| /** | ||
| * Determine if a "reason" string should be omitted due to high similarity with error message. | ||
| * Uses Jaccard similarity to detect redundant phrasing. | ||
| * | ||
| * @param errorMessage - Main error message | ||
| * @param reason - Detailed reason/cause string | ||
| * @param threshold - Similarity threshold (0-1), defaults to 0.6 | ||
| * @returns true if reason should be omitted (too similar) | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * shouldOmitReason('Invalid token', 'The token is invalid') // true (high overlap) | ||
| * shouldOmitReason('Request failed', 'Rate limit exceeded') // false (low overlap) | ||
| * ``` | ||
| */ | ||
| export declare function shouldOmitReason(errorMessage: string, reason: string | undefined, threshold?: number): boolean; | ||
| /** | ||
| * Filter error cause based on similarity to error message. | ||
@@ -91,1 +49,43 @@ * Returns undefined if the cause should be omitted due to redundancy. | ||
| export declare function filterRedundantCause(errorMessage: string, errorCause: string | undefined, threshold?: number): string | undefined; | ||
| /** | ||
| * Normalize base URL by ensuring it ends with a trailing slash. | ||
| * Required for proper URL joining with relative paths. | ||
| * Memoized for performance since base URLs are typically reused. | ||
| */ | ||
| export declare const normalizeBaseUrl: (baseUrl: string) => string; | ||
| /** | ||
| * Create a promise with externally accessible resolve/reject functions. | ||
| * Polyfill for Promise.withResolvers() on older Node.js versions. | ||
| */ | ||
| export declare function promiseWithResolvers<T>(): ReturnType<typeof Promise.withResolvers<T>>; | ||
| /** | ||
| * Convert query parameters to URLSearchParams with API-compatible key normalization. | ||
| * Transforms camelCase keys to snake_case and filters out empty values. | ||
| */ | ||
| export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams; | ||
| /** | ||
| * Convert relative file paths to absolute paths. | ||
| * Resolves paths relative to specified base directory or current working directory. | ||
| */ | ||
| export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: string | undefined): string[]; | ||
| /** | ||
| * Resolve base path to an absolute directory path. | ||
| * Converts relative paths to absolute using current working directory as reference. | ||
| */ | ||
| export declare function resolveBasePath(pathsRelativeTo?: string): string; | ||
| /** | ||
| * Determine if a "reason" string should be omitted due to high similarity with error message. | ||
| * Uses Jaccard similarity to detect redundant phrasing. | ||
| * | ||
| * @param errorMessage - Main error message | ||
| * @param reason - Detailed reason/cause string | ||
| * @param threshold - Similarity threshold (0-1), defaults to 0.6 | ||
| * @returns true if reason should be omitted (too similar) | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * shouldOmitReason('Invalid token', 'The token is invalid') // true (high overlap) | ||
| * shouldOmitReason('Request failed', 'Rate limit exceeded') // false (low overlap) | ||
| * ``` | ||
| */ | ||
| export declare function shouldOmitReason(errorMessage: string, reason: string | undefined, threshold?: number): boolean; |
+6
-4
| { | ||
| "name": "@socketsecurity/sdk", | ||
| "version": "3.2.0", | ||
| "packageManager": "pnpm@10.25.0", | ||
| "version": "3.3.0", | ||
| "packageManager": "pnpm@10.28.1", | ||
| "license": "MIT", | ||
@@ -60,3 +60,3 @@ "description": "SDK for the Socket API client", | ||
| "@socketregistry/packageurl-js": "1.3.5", | ||
| "@socketsecurity/lib": "5.0.0", | ||
| "@socketsecurity/lib": "5.5.3", | ||
| "form-data": "4.0.5" | ||
@@ -70,3 +70,3 @@ }, | ||
| "@biomejs/biome": "2.2.4", | ||
| "@dotenvx/dotenvx": "^1.51.1", | ||
| "@dotenvx/dotenvx": "^1.51.4", | ||
| "@eslint/compat": "1.3.2", | ||
@@ -78,2 +78,4 @@ "@eslint/js": "9.35.0", | ||
| "@vitest/coverage-v8": "4.0.3", | ||
| "@sveltejs/acorn-typescript": "1.0.8", | ||
| "acorn": "8.15.0", | ||
| "del": "8.0.1", | ||
@@ -80,0 +82,0 @@ "dev-null-cli": "2.0.0", |
+1
-1
@@ -5,3 +5,3 @@ # @socketsecurity/sdk | ||
| [](https://github.com/SocketDev/socket-sdk-js/actions/workflows/ci.yml) | ||
|  | ||
|  | ||
@@ -8,0 +8,0 @@ [](https://twitter.com/SocketSecurity) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
942700
4.52%25386
4.34%79
-5.95%37
5.71%22
4.76%+ Added
- Removed
Updated