Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9698318a30 | |||
| c8e2d11556 |
@@ -9,17 +9,18 @@ if (!API_KEY) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function api(method, path, body) {
|
async function api(method, path, body) {
|
||||||
const separator = path.includes('?') ? '&' : '?'
|
const url = `${BASE_URL}${path}`
|
||||||
const url = `${BASE_URL}${path}${separator}api_key=${API_KEY}`
|
const headers = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'x-api-key': API_KEY,
|
||||||
|
}
|
||||||
if (args['dry-run']) {
|
if (args['dry-run']) {
|
||||||
return { _dry_run: true, method, url: url.replace(API_KEY, '***'), headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }
|
return { _dry_run: true, method, url, headers: { ...headers, 'x-api-key': '***' }, body: body || undefined }
|
||||||
}
|
}
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers,
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Accept': 'application/json',
|
|
||||||
},
|
|
||||||
body: body ? JSON.stringify(body) : undefined,
|
body: body ? JSON.stringify(body) : undefined,
|
||||||
})
|
})
|
||||||
const text = await res.text()
|
const text = await res.text()
|
||||||
|
|||||||
@@ -92,7 +92,14 @@ async function main() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
const token = await authenticate()
|
const token = await authenticate()
|
||||||
result = { jwt: token }
|
if (args['show-token']) {
|
||||||
|
result = { jwt: token }
|
||||||
|
} else {
|
||||||
|
const masked = token.length > 12
|
||||||
|
? token.slice(0, 6) + '…' + token.slice(-6)
|
||||||
|
: '***'
|
||||||
|
result = { jwt: masked, hint: 'Use --show-token to reveal full JWT' }
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +195,7 @@ async function main() {
|
|||||||
result = {
|
result = {
|
||||||
error: 'Unknown command',
|
error: 'Unknown command',
|
||||||
usage: {
|
usage: {
|
||||||
auth: 'auth — authenticate and get JWT token',
|
auth: 'auth [--show-token] — authenticate and get JWT token (masked by default)',
|
||||||
contacts: {
|
contacts: {
|
||||||
search: 'contacts search [--job-title <t>] [--company <c>] [--location <l>] [--seniority <s>] [--department <d>] [--page <n>]',
|
search: 'contacts search [--job-title <t>] [--company <c>] [--location <l>] [--seniority <s>] [--department <d>] [--page <n>]',
|
||||||
enrich: 'contacts enrich --email <email> | --person-id <id>',
|
enrich: 'contacts enrich --email <email> | --person-id <id>',
|
||||||
|
|||||||
Reference in New Issue
Block a user