kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
fix: zoominfo auth
rodzic
3229ab2b2e
commit
7d00a7bd4d
|
@ -1,6 +1,6 @@
|
||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
|
|
||||||
import { ExaClient } from '@agentic/stdlib'
|
import { ZoomInfoClient } from '@agentic/stdlib'
|
||||||
import restoreCursor from 'restore-cursor'
|
import restoreCursor from 'restore-cursor'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,11 +129,19 @@ async function main() {
|
||||||
// json: true
|
// json: true
|
||||||
// })
|
// })
|
||||||
|
|
||||||
const exa = new ExaClient()
|
// const exa = new ExaClient()
|
||||||
const res = await exa.search({
|
// const res = await exa.search({
|
||||||
query: 'OpenAI',
|
// query: 'OpenAI',
|
||||||
category: 'linkedin profile'
|
// category: 'linkedin profile'
|
||||||
|
// })
|
||||||
|
|
||||||
|
const zoomInfo = new ZoomInfoClient()
|
||||||
|
const res = await zoomInfo.enrichContact({
|
||||||
|
emailAddress: 'crabfisher@gmail.com'
|
||||||
})
|
})
|
||||||
|
// const res = await zoomInfo.searchContacts({
|
||||||
|
// fullName: 'Kevin Raheja'
|
||||||
|
// })
|
||||||
|
|
||||||
console.log(JSON.stringify(res, null, 2))
|
console.log(JSON.stringify(res, null, 2))
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,8 @@
|
||||||
"turbo": "^2.4.2",
|
"turbo": "^2.4.2",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"vitest": "3.0.6",
|
"vitest": "3.0.6",
|
||||||
"zod": "^3.24.2"
|
"zod": "^3.24.2",
|
||||||
|
"zoominfo-api-auth-client": "^1.0.1"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{ts,tsx}": [
|
"*.{ts,tsx}": [
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@agentic/core": "workspace:*",
|
"@agentic/core": "workspace:*",
|
||||||
"jsrsasign": "^11.1.0",
|
"jsrsasign": "^10.9.0",
|
||||||
"ky": "^1.7.5",
|
"ky": "^1.7.5",
|
||||||
"p-throttle": "^6.2.0"
|
"p-throttle": "^6.2.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -317,6 +317,44 @@ export namespace zoominfo {
|
||||||
label: string
|
label: string
|
||||||
employeeCount: number
|
employeeCount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SearchResult<T> {
|
||||||
|
maxResults: number
|
||||||
|
totalResults: number
|
||||||
|
currentPage: number
|
||||||
|
data: T[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SearchContactsResponse = SearchResult<ContactSearchResult>
|
||||||
|
|
||||||
|
export interface ContactSearchResult {
|
||||||
|
id: number
|
||||||
|
firstName: string
|
||||||
|
middleName: string
|
||||||
|
lastName: string
|
||||||
|
validDate: string
|
||||||
|
lastUpdatedDate: string
|
||||||
|
jobTitle: string
|
||||||
|
contactAccuracyScore: number
|
||||||
|
hasEmail: boolean
|
||||||
|
hasSupplementalEmail: boolean
|
||||||
|
hasDirectPhone: boolean
|
||||||
|
hasMobilePhone: boolean
|
||||||
|
hasCompanyIndustry: boolean
|
||||||
|
hasCompanyPhone: boolean
|
||||||
|
hasCompanyStreet: boolean
|
||||||
|
hasCompanyState: boolean
|
||||||
|
hasCompanyZipCode: boolean
|
||||||
|
hasCompanyCountry: boolean
|
||||||
|
hasCompanyRevenue: boolean
|
||||||
|
hasCompanyEmployeeCount: boolean
|
||||||
|
company: BasicCompany
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BasicCompany {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -419,6 +457,8 @@ export class ZoomInfoClient extends AIFunctionsProvider {
|
||||||
'ZoomInfo failed to get access token via PKI auth'
|
'ZoomInfo failed to get access token via PKI auth'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
console.log('Got access token:', this.accessToken)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,9 +481,9 @@ export class ZoomInfoClient extends AIFunctionsProvider {
|
||||||
password
|
password
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.json<{ data: { jwt: string } }>()
|
.json<{ jwt: string }>()
|
||||||
|
|
||||||
return res.data.jwt
|
return res.jwt
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAccessTokenViaPKI({
|
async getAccessTokenViaPKI({
|
||||||
|
@ -461,8 +501,8 @@ export class ZoomInfoClient extends AIFunctionsProvider {
|
||||||
alg: 'RS256'
|
alg: 'RS256'
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
iss: 'zoominfo-api-auth-client-nodejs',
|
|
||||||
aud: 'enterprise_api',
|
aud: 'enterprise_api',
|
||||||
|
iss: 'api-client@zoominfo.com',
|
||||||
username,
|
username,
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
iat: getIAT(dtNow),
|
iat: getIAT(dtNow),
|
||||||
|
@ -480,13 +520,14 @@ export class ZoomInfoClient extends AIFunctionsProvider {
|
||||||
|
|
||||||
const res = await this.ky
|
const res = await this.ky
|
||||||
.post('authenticate', {
|
.post('authenticate', {
|
||||||
|
json: {},
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${clientJWT}`
|
Authorization: `Bearer ${clientJWT}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.json<{ data: { jwt: string } }>()
|
.json<{ jwt: string }>()
|
||||||
|
|
||||||
return res.data.jwt
|
return res.jwt
|
||||||
}
|
}
|
||||||
|
|
||||||
@aiFunction({
|
@aiFunction({
|
||||||
|
@ -573,6 +614,19 @@ fullName AND companyId/companyName. Combining these values effectively results i
|
||||||
})
|
})
|
||||||
.json<zoominfo.EnrichCompanyResponse>()
|
.json<zoominfo.EnrichCompanyResponse>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async searchContacts(opts: { fullName?: string; emailAddress?: string }) {
|
||||||
|
await this.authenticate()
|
||||||
|
|
||||||
|
return this.ky
|
||||||
|
.post('search/contact', {
|
||||||
|
json: opts,
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${this.accessToken}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.json<zoominfo.SearchContactsResponse>()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIAT(dtNow: number) {
|
function getIAT(dtNow: number) {
|
||||||
|
|
|
@ -65,6 +65,9 @@ importers:
|
||||||
zod:
|
zod:
|
||||||
specifier: ^3.24.2
|
specifier: ^3.24.2
|
||||||
version: 3.24.2
|
version: 3.24.2
|
||||||
|
zoominfo-api-auth-client:
|
||||||
|
specifier: ^1.0.1
|
||||||
|
version: 1.0.1
|
||||||
|
|
||||||
examples/ai-sdk:
|
examples/ai-sdk:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1110,8 +1113,8 @@ importers:
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../core
|
version: link:../core
|
||||||
jsrsasign:
|
jsrsasign:
|
||||||
specifier: ^11.1.0
|
specifier: ^10.9.0
|
||||||
version: 11.1.0
|
version: 10.9.0
|
||||||
ky:
|
ky:
|
||||||
specifier: ^1.7.5
|
specifier: ^1.7.5
|
||||||
version: 1.7.5
|
version: 1.7.5
|
||||||
|
@ -2466,6 +2469,9 @@ packages:
|
||||||
resolution: {integrity: sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w==}
|
resolution: {integrity: sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
|
||||||
|
axios@0.21.4:
|
||||||
|
resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==}
|
||||||
|
|
||||||
axios@1.7.9:
|
axios@1.7.9:
|
||||||
resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==}
|
resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==}
|
||||||
|
|
||||||
|
@ -3751,8 +3757,8 @@ packages:
|
||||||
resolution: {integrity: sha512-SWfjz8SuQ0wZjwsxtSJ3Zy8vvLg6aO/kxcp9TWNPGwJKgTZVfhNEQBMk/vPOpYCDFWRxD6QWuI6IHR1t615f0w==}
|
resolution: {integrity: sha512-SWfjz8SuQ0wZjwsxtSJ3Zy8vvLg6aO/kxcp9TWNPGwJKgTZVfhNEQBMk/vPOpYCDFWRxD6QWuI6IHR1t615f0w==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
jsrsasign@11.1.0:
|
jsrsasign@10.9.0:
|
||||||
resolution: {integrity: sha512-Ov74K9GihaK9/9WncTe1mPmvrO7Py665TUfUKvraXBpu+xcTWitrtuOwcjf4KMU9maPaYn0OuaWy0HOzy/GBXg==}
|
resolution: {integrity: sha512-QWLUikj1SBJGuyGK8tjKSx3K7Y69KYJnrs/pQ1KZ6wvZIkHkWjZ1PJDpuvc1/28c1uP0KW9qn1eI1LzHQqDOwQ==}
|
||||||
|
|
||||||
jsx-ast-utils@3.3.5:
|
jsx-ast-utils@3.3.5:
|
||||||
resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}
|
resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}
|
||||||
|
@ -5304,6 +5310,9 @@ packages:
|
||||||
zod@3.24.2:
|
zod@3.24.2:
|
||||||
resolution: {integrity: sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==}
|
resolution: {integrity: sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==}
|
||||||
|
|
||||||
|
zoominfo-api-auth-client@1.0.1:
|
||||||
|
resolution: {integrity: sha512-0MOZ5XhEo5ZOeky3jx6n2+4iI3jZd97qePOu8Z27wTQuQ6eRcRIxVbX1mosy3Wn6C7VtcbIsIyf6YDcjHwpIRg==}
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
'@ai-sdk/openai@1.1.13(zod@3.24.2)':
|
'@ai-sdk/openai@1.1.13(zod@3.24.2)':
|
||||||
|
@ -6773,6 +6782,12 @@ snapshots:
|
||||||
|
|
||||||
axe-core@4.10.2: {}
|
axe-core@4.10.2: {}
|
||||||
|
|
||||||
|
axios@0.21.4:
|
||||||
|
dependencies:
|
||||||
|
follow-redirects: 1.15.9
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- debug
|
||||||
|
|
||||||
axios@1.7.9:
|
axios@1.7.9:
|
||||||
dependencies:
|
dependencies:
|
||||||
follow-redirects: 1.15.9
|
follow-redirects: 1.15.9
|
||||||
|
@ -8246,7 +8261,7 @@ snapshots:
|
||||||
|
|
||||||
jsonrepair@3.12.0: {}
|
jsonrepair@3.12.0: {}
|
||||||
|
|
||||||
jsrsasign@11.1.0: {}
|
jsrsasign@10.9.0: {}
|
||||||
|
|
||||||
jsx-ast-utils@3.3.5:
|
jsx-ast-utils@3.3.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -9777,3 +9792,10 @@ snapshots:
|
||||||
zod: 3.24.2
|
zod: 3.24.2
|
||||||
|
|
||||||
zod@3.24.2: {}
|
zod@3.24.2: {}
|
||||||
|
|
||||||
|
zoominfo-api-auth-client@1.0.1:
|
||||||
|
dependencies:
|
||||||
|
axios: 0.21.4
|
||||||
|
jsrsasign: 10.9.0
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- debug
|
||||||
|
|
Ładowanie…
Reference in New Issue