Skip to content

Commit e8430b5

Browse files
committed
update
1 parent 280420f commit e8430b5

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

.dep-stats.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"cli-spinners": "^2.9.2",
9999
"cross-spawn": "^7.0.3",
100100
"dot-prop": "^9.0.0",
101-
"eastasianwidth": "^0.2.0",
101+
"eastasianwidth": "^0.3.0",
102102
"emoji-regex": "^10.3.0",
103103
"fast-glob": "^3.3.2",
104104
"graceful-fs": "^4.2.6",
@@ -127,7 +127,7 @@
127127
"cli-spinners": "^2.9.2",
128128
"cross-spawn": "^7.0.3",
129129
"dot-prop": "^9.0.0",
130-
"eastasianwidth": "^0.2.0",
130+
"eastasianwidth": "^0.3.0",
131131
"emoji-regex": "^10.3.0",
132132
"fast-glob": "^3.3.2",
133133
"graceful-fs": "^4.2.6",

src/commands/diff-scan/get.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getDefaultKey } from '../../utils/sdk'
1111
import type { CliSubcommand } from '../../utils/meow-with-subcommands'
1212
import type { Ora } from 'ora'
1313
import { AuthError } from '../../utils/errors'
14-
import { handleAPIError, queryAPI } from '../../utils/api-helpers'
14+
import { handleAPIError, queryOrgsAPI } from '../../utils/api-helpers'
1515

1616
export const get: CliSubcommand = {
1717
description: 'Get a diff scan for an organization',
@@ -142,7 +142,7 @@ async function getDiffScan(
142142
spinner: Ora,
143143
apiKey: string,
144144
): Promise<void> {
145-
const response = await queryAPI(`${orgSlug}/full-scans/diff?before=${before}&after=${after}&preview`, apiKey)
145+
const response = await queryOrgsAPI(`${orgSlug}/full-scans/diff?before=${before}&after=${after}&preview`, apiKey)
146146
const data = await response.json();
147147

148148
if(!response.ok){

src/commands/threat-feed.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getDefaultKey } from '../utils/sdk'
88
import type { CliSubcommand } from '../utils/meow-with-subcommands'
99
import type { Ora } from 'ora'
1010
import { AuthError } from '../utils/errors'
11+
import { queryAPI } from '../utils/api-helpers'
1112

1213
export const threatFeed: CliSubcommand = {
1314
description: 'Look up the threat feed',
@@ -21,7 +22,7 @@ export const threatFeed: CliSubcommand = {
2122
throw new AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.")
2223
}
2324
const spinner = ora(`Looking up the threat feed \n`).start()
24-
await fetchThreatFeed(input, spinner)
25+
await fetchThreatFeed(spinner, apiKey)
2526
}
2627
}
2728
}
@@ -74,10 +75,12 @@ function setupCommand(
7475
}
7576

7677
async function fetchThreatFeed(
77-
input: CommandContext,
78-
spinner: Ora
78+
spinner: Ora,
79+
apiKey: string
7980
): Promise<void> {
80-
// const socketSdk = await setupSdk(apiKey)
81+
const response = await queryAPI(`threat-feed`, apiKey)
82+
const data = await response.json();
83+
8184
spinner.stop()
82-
console.log(input)
85+
console.log(data)
8386
}

src/utils/api-helpers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,20 @@ export async function handleAPIError(code: number) {
5656

5757
const API_V0_URL = 'https://api.socket.dev/v0'
5858

59-
export async function queryAPI(path: string, apiKey: string) {
59+
export async function queryOrgsAPI(path: string, apiKey: string) {
6060
return await fetch(`${API_V0_URL}/orgs/${path}`, {
6161
method: 'GET',
6262
headers: {
6363
'Authorization': 'Basic ' + btoa(`${apiKey}:${apiKey}`)
6464
}
6565
});
66+
}
67+
68+
export async function queryAPI(path: string, apiKey: string) {
69+
return await fetch(`${API_V0_URL}/${path}`, {
70+
method: 'GET',
71+
headers: {
72+
'Authorization': 'Basic ' + btoa(`${apiKey}:${apiKey}`)
73+
}
74+
});
6675
}

0 commit comments

Comments
 (0)