fix: zoominfo auth

pull/687/head
Travis Fischer 2025-02-23 00:57:36 +07:00
rodzic 3229ab2b2e
commit 7d00a7bd4d
5 zmienionych plików z 102 dodań i 17 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
import 'dotenv/config'
import { ExaClient } from '@agentic/stdlib'
import { ZoomInfoClient } from '@agentic/stdlib'
import restoreCursor from 'restore-cursor'
/**
@ -129,11 +129,19 @@ async function main() {
// json: true
// })
const exa = new ExaClient()
const res = await exa.search({
query: 'OpenAI',
category: 'linkedin profile'
// const exa = new ExaClient()
// const res = await exa.search({
// query: 'OpenAI',
// 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))
}

Wyświetl plik

@ -51,7 +51,8 @@
"turbo": "^2.4.2",
"typescript": "^5.7.3",
"vitest": "3.0.6",
"zod": "^3.24.2"
"zod": "^3.24.2",
"zoominfo-api-auth-client": "^1.0.1"
},
"lint-staged": {
"*.{ts,tsx}": [

Wyświetl plik

@ -33,7 +33,7 @@
},
"dependencies": {
"@agentic/core": "workspace:*",
"jsrsasign": "^11.1.0",
"jsrsasign": "^10.9.0",
"ky": "^1.7.5",
"p-throttle": "^6.2.0"
},

Wyświetl plik

@ -317,6 +317,44 @@ export namespace zoominfo {
label: string
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'
)
console.log('Got access token:', this.accessToken)
return
}
@ -441,9 +481,9 @@ export class ZoomInfoClient extends AIFunctionsProvider {
password
}
})
.json<{ data: { jwt: string } }>()
.json<{ jwt: string }>()
return res.data.jwt
return res.jwt
}
async getAccessTokenViaPKI({
@ -461,8 +501,8 @@ export class ZoomInfoClient extends AIFunctionsProvider {
alg: 'RS256'
}
const data = {
iss: 'zoominfo-api-auth-client-nodejs',
aud: 'enterprise_api',
iss: 'api-client@zoominfo.com',
username,
client_id: clientId,
iat: getIAT(dtNow),
@ -480,13 +520,14 @@ export class ZoomInfoClient extends AIFunctionsProvider {
const res = await this.ky
.post('authenticate', {
json: {},
headers: {
Authorization: `Bearer ${clientJWT}`
}
})
.json<{ data: { jwt: string } }>()
.json<{ jwt: string }>()
return res.data.jwt
return res.jwt
}
@aiFunction({
@ -573,6 +614,19 @@ fullName AND companyId/companyName. Combining these values effectively results i
})
.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) {

Wyświetl plik

@ -65,6 +65,9 @@ importers:
zod:
specifier: ^3.24.2
version: 3.24.2
zoominfo-api-auth-client:
specifier: ^1.0.1
version: 1.0.1
examples/ai-sdk:
dependencies:
@ -1110,8 +1113,8 @@ importers:
specifier: workspace:*
version: link:../core
jsrsasign:
specifier: ^11.1.0
version: 11.1.0
specifier: ^10.9.0
version: 10.9.0
ky:
specifier: ^1.7.5
version: 1.7.5
@ -2466,6 +2469,9 @@ packages:
resolution: {integrity: sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w==}
engines: {node: '>=4'}
axios@0.21.4:
resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==}
axios@1.7.9:
resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==}
@ -3751,8 +3757,8 @@ packages:
resolution: {integrity: sha512-SWfjz8SuQ0wZjwsxtSJ3Zy8vvLg6aO/kxcp9TWNPGwJKgTZVfhNEQBMk/vPOpYCDFWRxD6QWuI6IHR1t615f0w==}
hasBin: true
jsrsasign@11.1.0:
resolution: {integrity: sha512-Ov74K9GihaK9/9WncTe1mPmvrO7Py665TUfUKvraXBpu+xcTWitrtuOwcjf4KMU9maPaYn0OuaWy0HOzy/GBXg==}
jsrsasign@10.9.0:
resolution: {integrity: sha512-QWLUikj1SBJGuyGK8tjKSx3K7Y69KYJnrs/pQ1KZ6wvZIkHkWjZ1PJDpuvc1/28c1uP0KW9qn1eI1LzHQqDOwQ==}
jsx-ast-utils@3.3.5:
resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}
@ -5304,6 +5310,9 @@ packages:
zod@3.24.2:
resolution: {integrity: sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==}
zoominfo-api-auth-client@1.0.1:
resolution: {integrity: sha512-0MOZ5XhEo5ZOeky3jx6n2+4iI3jZd97qePOu8Z27wTQuQ6eRcRIxVbX1mosy3Wn6C7VtcbIsIyf6YDcjHwpIRg==}
snapshots:
'@ai-sdk/openai@1.1.13(zod@3.24.2)':
@ -6773,6 +6782,12 @@ snapshots:
axe-core@4.10.2: {}
axios@0.21.4:
dependencies:
follow-redirects: 1.15.9
transitivePeerDependencies:
- debug
axios@1.7.9:
dependencies:
follow-redirects: 1.15.9
@ -8246,7 +8261,7 @@ snapshots:
jsonrepair@3.12.0: {}
jsrsasign@11.1.0: {}
jsrsasign@10.9.0: {}
jsx-ast-utils@3.3.5:
dependencies:
@ -9777,3 +9792,10 @@ snapshots:
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