@fingerprintjs/fingerprintjs-pro-server-api
Advanced tools
Comparing version 1.2.1 to 1.3.0
/** | ||
* FingerprintJS Server API Node.js SDK v1.2.0 - Copyright (c) FingerprintJS, Inc, 2022 (https://fingerprint.com) | ||
* FingerprintJS Server API Node.js SDK v1.2.1 - Copyright (c) FingerprintJS, Inc, 2022 (https://fingerprint.com) | ||
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. | ||
@@ -13,34 +13,9 @@ */ | ||
interface paths { | ||
'/events/{request_id}': { | ||
/** This endpoint allows you to get events with all the information from each activated product - BOTD and Fingerprinting. Use the requestId as a URL path :request_id parameter. This API method is scoped to a request, i.e. all returned information is by requestId. */ | ||
get: operations['getEvent']; | ||
}; | ||
'/visitors/{visitor_id}': { | ||
/** This endpoint allows you to get a history of visits with all available information. Use the visitorID as a URL path parameter. This API method is scoped to a visitor, i.e. all returned information is by visitorId. */ | ||
get: { | ||
parameters: { | ||
path: { | ||
visitor_id: string; | ||
}; | ||
query: { | ||
/** Filter events by requestId */ | ||
request_id?: string; | ||
/** Filter events by custom identifier */ | ||
linked_id?: string; | ||
/** Limit scanned results */ | ||
limit?: number; | ||
/** Used to paginate results */ | ||
before?: number; | ||
}; | ||
}; | ||
responses: { | ||
/** Auto generated using Swagger Inspector */ | ||
200: { | ||
content: { | ||
'application/json': components['schemas']['Response']; | ||
}; | ||
}; | ||
429: { | ||
content: { | ||
'application/json': components['schemas']['ManyRequestsResponse']; | ||
}; | ||
}; | ||
}; | ||
}; | ||
/** This endpoint allows you to get a history of visits with all available information. Use the visitorId as a URL path parameter. This API method is scoped to a visitor, i.e. all returned information is by visitorId. */ | ||
get: operations['getVisits']; | ||
}; | ||
@@ -54,8 +29,2 @@ '/webhook': { | ||
schemas: { | ||
Response: components['schemas']['BaseResponse'] | components['schemas']['PaginatedResponse']; | ||
/** BaseResponse */ | ||
BaseResponse: { | ||
visitorId: string; | ||
visits: components['schemas']['Visit'][]; | ||
}; | ||
/** | ||
@@ -65,15 +34,91 @@ * PaginatedResponse | ||
*/ | ||
PaginatedResponse: { | ||
Response: { | ||
visitorId: string; | ||
visits: components['schemas']['Visit'][]; | ||
visits: { | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
/** | ||
* Format: ipv4 | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
ipLocation: components['schemas']['IPLocation']; | ||
/** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
*/ | ||
timestamp: number; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag: { | ||
[key: string]: unknown; | ||
}; | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
/** | ||
* @example { | ||
* "global": "2022-05-05T18:28:54.535Z", | ||
* "subscription": "2022-06-09T22:58:05.576Z" | ||
* } | ||
*/ | ||
firstSeenAt: components['schemas']['StSeenAt']; | ||
/** | ||
* @example { | ||
* "global": "2022-06-09T22:58:35.795Z", | ||
* "subscription": null | ||
* } | ||
*/ | ||
lastSeenAt: components['schemas']['StSeenAt']; | ||
}[]; | ||
/** | ||
* Format: int64 | ||
* @description When more results are available (e.g., you scanned 200 results using `limit` parameter, but a total of 600 results are available), a special `lastTimestamp` top-level attribute is added to the response. If you want to paginate the results further in the past, you should use the value of this attribute. | ||
* @example 1654815517198 | ||
*/ | ||
lastTimestamp: number; | ||
/** @example 1654815517198.azN4IZ */ | ||
paginationKey: string; | ||
lastTimestamp?: number; | ||
/** | ||
* @description Visit's `requestId` of the last visit in the current page. | ||
* @example 1654815517198.azN4IZ | ||
*/ | ||
paginationKey?: string; | ||
}; | ||
ErrorResponse: { | ||
/** ErrorResponseError */ | ||
error?: { | ||
/** @example TokenRequired */ | ||
code?: string; | ||
/** @example secret key is required */ | ||
message?: string; | ||
}; | ||
}; | ||
ManyRequestsResponse: { | ||
/** @example request throttled */ | ||
/** | ||
* @description Error text. | ||
* @example request throttled | ||
*/ | ||
error: string; | ||
@@ -84,8 +129,71 @@ }; | ||
clientReferrer?: string; | ||
} & components['schemas']['Visit']; | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
/** | ||
* Format: ipv4 | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
ipLocation: components['schemas']['IPLocation']; | ||
/** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
*/ | ||
timestamp: number; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag?: { | ||
[key: string]: unknown; | ||
}; | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
/** | ||
* @example { | ||
* "global": "2022-05-05T18:28:54.535Z", | ||
* "subscription": "2022-06-09T22:58:05.576Z" | ||
* } | ||
*/ | ||
firstSeenAt: components['schemas']['StSeenAt']; | ||
/** | ||
* @example { | ||
* "global": "2022-06-09T22:58:35.795Z", | ||
* "subscription": null | ||
* } | ||
*/ | ||
lastSeenAt: components['schemas']['StSeenAt']; | ||
}; | ||
/** Visit */ | ||
Visit: { | ||
/** @example 1654815516083.OX6kx8 */ | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
@@ -100,2 +208,3 @@ /** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
@@ -105,3 +214,5 @@ */ | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
@@ -112,11 +223,17 @@ */ | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
tag: { | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag?: { | ||
[key: string]: unknown; | ||
}; | ||
/** @example someID */ | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
@@ -158,3 +275,6 @@ /** | ||
Confidence: { | ||
/** Format: float */ | ||
/** | ||
* Format: float | ||
* @description The confidence score is a floating-point number between 0 and 1 that represents the probability of accurate identification. | ||
*/ | ||
score: number; | ||
@@ -165,3 +285,3 @@ }; | ||
/** Format: date-time */ | ||
global: string; | ||
global: string | null; | ||
/** Format: date-time */ | ||
@@ -191,2 +311,3 @@ subscription: string | null; | ||
timezone: string; | ||
/** IPLocationCity */ | ||
city?: { | ||
@@ -212,3 +333,3 @@ /** @example Prague */ | ||
}; | ||
/** Continent */ | ||
/** Location */ | ||
Location: { | ||
@@ -226,4 +347,192 @@ /** @example US */ | ||
}; | ||
/** @description Contains all the information from each activated product - BOTD and Identification */ | ||
ProductsResponse: { | ||
/** ProductsResponseIdentification */ | ||
identification?: { | ||
/** ProductsResponseIdentificationData */ | ||
data?: { | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
/** | ||
* Format: ipv4 | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
ipLocation: components['schemas']['IPLocation']; | ||
/** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
*/ | ||
timestamp: number; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag?: { | ||
[key: string]: unknown; | ||
}; | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
/** | ||
* @example { | ||
* "global": "2022-05-05T18:28:54.535Z", | ||
* "subscription": "2022-06-09T22:58:05.576Z" | ||
* } | ||
*/ | ||
firstSeenAt: components['schemas']['StSeenAt']; | ||
/** | ||
* @example { | ||
* "global": "2022-06-09T22:58:35.795Z", | ||
* "subscription": null | ||
* } | ||
*/ | ||
lastSeenAt: components['schemas']['StSeenAt']; | ||
visitorId: string; | ||
}; | ||
}; | ||
/** ProductsResponseBotd */ | ||
botd?: { | ||
data?: components['schemas']['BotdResult']; | ||
}; | ||
}; | ||
/** @description Contains event from activated products - BOTD and Identification */ | ||
EventResponse: { | ||
products?: components['schemas']['ProductsResponse']; | ||
}; | ||
/** @description Contains all the information from BOTD product */ | ||
BotdResult: { | ||
/** | ||
* Format: ipv4 | ||
* @description IP address of the requesting browser or bot. | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time in UTC when the request from the JS agent was made. We recommend to treat requests that are older than 2 minutes as malicious. Otherwise, request replay attacks are possible | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* @example { | ||
* "result": "notDetected" | ||
* } | ||
*/ | ||
bot: components['schemas']['BotdDetectionResult']; | ||
}; | ||
/** @description Stores bot detection result */ | ||
BotdDetectionResult: { | ||
/** | ||
* @description Bot detection result: | ||
* * `notDetected` - the visitor is not a bot | ||
* * `good` - good bot detected, such as Google bot, Baidu Spider, AlexaBot and so on | ||
* * `bad` - bad bot detected, such as Selenium, Puppeteer, Playwright, headless browsers, and so on | ||
* | ||
* @enum {string} | ||
*/ | ||
result: 'notDetected' | 'good' | 'bad'; | ||
}; | ||
}; | ||
} | ||
interface operations { | ||
/** This endpoint allows you to get events with all the information from each activated product - BOTD and Fingerprinting. Use the requestId as a URL path :request_id parameter. This API method is scoped to a request, i.e. all returned information is by requestId. */ | ||
getEvent: { | ||
parameters: { | ||
path: { | ||
/** Request ID */ | ||
request_id: string; | ||
}; | ||
}; | ||
responses: { | ||
/** OK */ | ||
200: { | ||
content: { | ||
'application/json': components['schemas']['EventResponse']; | ||
}; | ||
}; | ||
/** Bad Request */ | ||
400: { | ||
content: { | ||
'application/json': components['schemas']['ErrorResponse']; | ||
}; | ||
}; | ||
/** Forbidden */ | ||
403: { | ||
content: { | ||
'application/json': components['schemas']['ErrorResponse']; | ||
}; | ||
}; | ||
/** Too Many Requests */ | ||
429: { | ||
headers: { | ||
/** Indicates how long the user should wait before making a follow-up request. */ | ||
'Retry-After'?: number; | ||
}; | ||
content: { | ||
'application/json': components['schemas']['ManyRequestsResponse']; | ||
}; | ||
}; | ||
}; | ||
}; | ||
/** This endpoint allows you to get a history of visits with all available information. Use the visitorId as a URL path parameter. This API method is scoped to a visitor, i.e. all returned information is by visitorId. */ | ||
getVisits: { | ||
parameters: { | ||
path: { | ||
visitor_id: string; | ||
}; | ||
query: { | ||
/** Filter events by requestId */ | ||
request_id?: string; | ||
/** Filter events by custom identifier */ | ||
linked_id?: string; | ||
/** Limit scanned results */ | ||
limit?: number; | ||
/** Used to paginate results */ | ||
before?: number; | ||
}; | ||
}; | ||
responses: { | ||
/** OK */ | ||
200: { | ||
content: { | ||
'application/json': components['schemas']['Response']; | ||
}; | ||
}; | ||
/** Too Many Requests */ | ||
429: { | ||
headers: { | ||
/** Indicates how long the user should wait before making a follow-up request. */ | ||
'Retry-After'?: number; | ||
}; | ||
content: { | ||
'application/json': components['schemas']['ManyRequestsResponse']; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} | ||
@@ -269,2 +578,3 @@ declare enum Region { | ||
declare type VisitorsResponse = paths['/visitors/{visitor_id}']['get']['responses']['200']['content']['application/json']; | ||
declare type EventResponse = paths['/events/{request_id}']['get']['responses']['200']['content']['application/json']; | ||
/** | ||
@@ -275,2 +585,3 @@ * More info: https://dev.fingerprintjs.com/docs/webhooks#identification-webhook-object-format | ||
declare function getEventUrl(requestId: string, region: Region, apiKey?: string): string; | ||
declare function getVisitorsUrl(region: Region, visitorId: string, filter?: VisitorHistoryFilter, apiKey?: string): string; | ||
@@ -289,2 +600,74 @@ | ||
constructor(options: Readonly<Options>); | ||
getEvent(requestId: string): Promise<{ | ||
products?: { | ||
identification?: { | ||
data?: { | ||
requestId: string; | ||
browserDetails: { | ||
browserName: string; | ||
browserMajorVersion: string; | ||
browserFullVersion: string; | ||
os: string; | ||
osVersion: string; | ||
device: string; | ||
userAgent: string; | ||
botProbability?: number | undefined; | ||
}; | ||
incognito: boolean; | ||
ip: string; | ||
ipLocation: { | ||
accuracyRadius: number; | ||
latitude: number; | ||
longitude: number; | ||
postalCode?: string | undefined; | ||
timezone: string; | ||
city?: { | ||
name?: string | undefined; | ||
} | undefined; | ||
country: { | ||
code: string; | ||
name: string; | ||
}; | ||
continent: { | ||
code: string; | ||
name: string; | ||
}; | ||
subdivisions?: { | ||
isoCode?: string | undefined; | ||
name?: string | undefined; | ||
}[] | undefined; | ||
}; | ||
timestamp: number; | ||
time: string; | ||
url: string; | ||
tag?: { | ||
[key: string]: unknown; | ||
} | undefined; | ||
linkedId?: string | undefined; | ||
confidence: { | ||
score: number; | ||
}; | ||
visitorFound: boolean; | ||
firstSeenAt: { | ||
global: string | null; | ||
subscription: string | null; | ||
}; | ||
lastSeenAt: { | ||
global: string | null; | ||
subscription: string | null; | ||
}; | ||
visitorId: string; | ||
} | undefined; | ||
} | undefined; | ||
botd?: { | ||
data?: { | ||
ip: string; | ||
time: string; | ||
bot: { | ||
result: "notDetected" | "good" | "bad"; | ||
}; | ||
} | undefined; | ||
} | undefined; | ||
} | undefined; | ||
}>; | ||
/** | ||
@@ -296,4 +679,5 @@ * Gets history for the given visitor | ||
getVisitorHistory(visitorId: string, filter?: VisitorHistoryFilter): Promise<VisitorsResponse>; | ||
private getHeaders; | ||
} | ||
export { AuthenticationMode, FingerprintJsServerApiClient, Options, Region, VisitWebhook, VisitorHistoryFilter, VisitorsResponse, getVisitorsUrl }; | ||
export { AuthenticationMode, EventResponse, FingerprintJsServerApiClient, Options, Region, VisitWebhook, VisitorHistoryFilter, VisitorsResponse, getEventUrl, getVisitorsUrl }; |
/** | ||
* FingerprintJS Server API Node.js SDK v1.2.0 - Copyright (c) FingerprintJS, Inc, 2022 (https://fingerprint.com) | ||
* FingerprintJS Server API Node.js SDK v1.2.1 - Copyright (c) FingerprintJS, Inc, 2022 (https://fingerprint.com) | ||
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. | ||
@@ -28,3 +28,3 @@ */ | ||
var version = "1.2.0"; | ||
var version = "1.2.1"; | ||
@@ -34,4 +34,16 @@ const euRegionUrl = 'https://eu.api.fpjs.io/'; | ||
const globalRegionUrl = 'https://api.fpjs.io/'; | ||
function getIntegrationInfo() { | ||
return `fingerprint-pro-server-node-sdk/${version}`; | ||
} | ||
function getEventUrl(requestId, region, apiKey) { | ||
const params = { | ||
ii: getIntegrationInfo(), | ||
}; | ||
if (apiKey) { | ||
params.api_key = apiKey; | ||
} | ||
return `${getServerApiUrl(region)}events/${requestId}?${serializeQueryStringParams(params)}`; | ||
} | ||
function getVisitorsUrl(region, visitorId, filter, apiKey) { | ||
const queryStringParameters = Object.assign(Object.assign({}, filter), { ii: `fingerprint-pro-server-node-sdk/${version}` }); | ||
const queryStringParameters = Object.assign(Object.assign({}, filter), { ii: getIntegrationInfo() }); | ||
if (apiKey) { | ||
@@ -113,2 +125,21 @@ queryStringParameters.api_key = apiKey; | ||
} | ||
getEvent(requestId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!requestId) { | ||
throw new TypeError('requestId is not set'); | ||
} | ||
const url = this.authenticationMode === exports.AuthenticationMode.QueryParameter | ||
? getEventUrl(requestId, this.region, this.apiKey) | ||
: getEventUrl(requestId, this.region); | ||
const headers = this.getHeaders(); | ||
return this.fetch(url, { | ||
method: 'GET', | ||
headers, | ||
}) | ||
.then((response) => response.json()) | ||
.catch((err) => { | ||
throw new Error(err.toString()); | ||
}); | ||
}); | ||
} | ||
/** | ||
@@ -122,3 +153,3 @@ * Gets history for the given visitor | ||
if (!visitorId) { | ||
throw Error('VisitorId is not set'); | ||
throw TypeError('VisitorId is not set'); | ||
} | ||
@@ -128,5 +159,3 @@ const url = this.authenticationMode === exports.AuthenticationMode.QueryParameter | ||
: getVisitorsUrl(this.region, visitorId, filter); | ||
const headers = this.authenticationMode === exports.AuthenticationMode.AuthHeader | ||
? { 'Auth-API-Key': this.apiKey } | ||
: undefined; | ||
const headers = this.getHeaders(); | ||
return this.fetch(url, { | ||
@@ -142,5 +171,11 @@ method: 'GET', | ||
} | ||
getHeaders() { | ||
return this.authenticationMode === exports.AuthenticationMode.AuthHeader | ||
? { 'Auth-API-Key': this.apiKey } | ||
: undefined; | ||
} | ||
} | ||
exports.FingerprintJsServerApiClient = FingerprintJsServerApiClient; | ||
exports.getEventUrl = getEventUrl; | ||
exports.getVisitorsUrl = getVisitorsUrl; |
{ | ||
"name": "@fingerprintjs/fingerprintjs-pro-server-api", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Node.js wrapper for FingerprintJS Sever API", | ||
@@ -21,3 +21,3 @@ "main": "dist/index.js", | ||
"test": "jest", | ||
"generateTypes": "yarn openapi-typescript https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi/schemes/fingerprint-server-api.yaml --output ./src/generatedApiTypes.ts -c .prettierrc.json", | ||
"generateTypes": "yarn openapi-typescript resources/fingerprint-server-api.yaml --output ./src/generatedApiTypes.ts -c .prettierrc.json", | ||
"release": "semantic-release" | ||
@@ -24,0 +24,0 @@ }, |
@@ -7,34 +7,9 @@ /** | ||
export interface paths { | ||
'/events/{request_id}': { | ||
/** This endpoint allows you to get events with all the information from each activated product - BOTD and Fingerprinting. Use the requestId as a URL path :request_id parameter. This API method is scoped to a request, i.e. all returned information is by requestId. */ | ||
get: operations['getEvent']; | ||
}; | ||
'/visitors/{visitor_id}': { | ||
/** This endpoint allows you to get a history of visits with all available information. Use the visitorID as a URL path parameter. This API method is scoped to a visitor, i.e. all returned information is by visitorId. */ | ||
get: { | ||
parameters: { | ||
path: { | ||
visitor_id: string; | ||
}; | ||
query: { | ||
/** Filter events by requestId */ | ||
request_id?: string; | ||
/** Filter events by custom identifier */ | ||
linked_id?: string; | ||
/** Limit scanned results */ | ||
limit?: number; | ||
/** Used to paginate results */ | ||
before?: number; | ||
}; | ||
}; | ||
responses: { | ||
/** Auto generated using Swagger Inspector */ | ||
200: { | ||
content: { | ||
'application/json': components['schemas']['Response']; | ||
}; | ||
}; | ||
429: { | ||
content: { | ||
'application/json': components['schemas']['ManyRequestsResponse']; | ||
}; | ||
}; | ||
}; | ||
}; | ||
/** This endpoint allows you to get a history of visits with all available information. Use the visitorId as a URL path parameter. This API method is scoped to a visitor, i.e. all returned information is by visitorId. */ | ||
get: operations['getVisits']; | ||
}; | ||
@@ -49,8 +24,2 @@ '/webhook': { | ||
schemas: { | ||
Response: components['schemas']['BaseResponse'] | components['schemas']['PaginatedResponse']; | ||
/** BaseResponse */ | ||
BaseResponse: { | ||
visitorId: string; | ||
visits: components['schemas']['Visit'][]; | ||
}; | ||
/** | ||
@@ -60,15 +29,89 @@ * PaginatedResponse | ||
*/ | ||
PaginatedResponse: { | ||
Response: { | ||
visitorId: string; | ||
visits: components['schemas']['Visit'][]; | ||
visits: { | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
/** | ||
* Format: ipv4 | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
ipLocation: components['schemas']['IPLocation']; | ||
/** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
*/ | ||
timestamp: number; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag: { [key: string]: unknown }; | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
/** | ||
* @example { | ||
* "global": "2022-05-05T18:28:54.535Z", | ||
* "subscription": "2022-06-09T22:58:05.576Z" | ||
* } | ||
*/ | ||
firstSeenAt: components['schemas']['StSeenAt']; | ||
/** | ||
* @example { | ||
* "global": "2022-06-09T22:58:35.795Z", | ||
* "subscription": null | ||
* } | ||
*/ | ||
lastSeenAt: components['schemas']['StSeenAt']; | ||
}[]; | ||
/** | ||
* Format: int64 | ||
* @description When more results are available (e.g., you scanned 200 results using `limit` parameter, but a total of 600 results are available), a special `lastTimestamp` top-level attribute is added to the response. If you want to paginate the results further in the past, you should use the value of this attribute. | ||
* @example 1654815517198 | ||
*/ | ||
lastTimestamp: number; | ||
/** @example 1654815517198.azN4IZ */ | ||
paginationKey: string; | ||
lastTimestamp?: number; | ||
/** | ||
* @description Visit's `requestId` of the last visit in the current page. | ||
* @example 1654815517198.azN4IZ | ||
*/ | ||
paginationKey?: string; | ||
}; | ||
ErrorResponse: { | ||
/** ErrorResponseError */ | ||
error?: { | ||
/** @example TokenRequired */ | ||
code?: string; | ||
/** @example secret key is required */ | ||
message?: string; | ||
}; | ||
}; | ||
ManyRequestsResponse: { | ||
/** @example request throttled */ | ||
/** | ||
* @description Error text. | ||
* @example request throttled | ||
*/ | ||
error: string; | ||
@@ -79,8 +122,69 @@ }; | ||
clientReferrer?: string; | ||
} & components['schemas']['Visit']; | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
/** | ||
* Format: ipv4 | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
ipLocation: components['schemas']['IPLocation']; | ||
/** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
*/ | ||
timestamp: number; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag?: { [key: string]: unknown }; | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
/** | ||
* @example { | ||
* "global": "2022-05-05T18:28:54.535Z", | ||
* "subscription": "2022-06-09T22:58:05.576Z" | ||
* } | ||
*/ | ||
firstSeenAt: components['schemas']['StSeenAt']; | ||
/** | ||
* @example { | ||
* "global": "2022-06-09T22:58:35.795Z", | ||
* "subscription": null | ||
* } | ||
*/ | ||
lastSeenAt: components['schemas']['StSeenAt']; | ||
}; | ||
/** Visit */ | ||
Visit: { | ||
/** @example 1654815516083.OX6kx8 */ | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
@@ -95,2 +199,3 @@ /** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
@@ -100,3 +205,5 @@ */ | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
@@ -107,9 +214,15 @@ */ | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
tag: { [key: string]: unknown }; | ||
/** @example someID */ | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag?: { [key: string]: unknown }; | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
@@ -151,3 +264,6 @@ /** | ||
Confidence: { | ||
/** Format: float */ | ||
/** | ||
* Format: float | ||
* @description The confidence score is a floating-point number between 0 and 1 that represents the probability of accurate identification. | ||
*/ | ||
score: number; | ||
@@ -158,3 +274,3 @@ }; | ||
/** Format: date-time */ | ||
global: string; | ||
global: string | null; | ||
/** Format: date-time */ | ||
@@ -184,2 +300,3 @@ subscription: string | null; | ||
timezone: string; | ||
/** IPLocationCity */ | ||
city?: { | ||
@@ -205,3 +322,3 @@ /** @example Prague */ | ||
}; | ||
/** Continent */ | ||
/** Location */ | ||
Location: { | ||
@@ -219,7 +336,192 @@ /** @example US */ | ||
}; | ||
/** @description Contains all the information from each activated product - BOTD and Identification */ | ||
ProductsResponse: { | ||
/** ProductsResponseIdentification */ | ||
identification?: { | ||
/** ProductsResponseIdentificationData */ | ||
data?: { | ||
/** | ||
* @description Unique identifier of the user's identification request. | ||
* @example 1654815516083.OX6kx8 | ||
*/ | ||
requestId: string; | ||
browserDetails: components['schemas']['BrowserDetails']; | ||
/** @description Flag if user used incognito session. */ | ||
incognito: boolean; | ||
/** | ||
* Format: ipv4 | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
ipLocation: components['schemas']['IPLocation']; | ||
/** | ||
* Format: int64 | ||
* @description Timestamp of the event with millisecond precision in Unix time. | ||
* @example 1654815516086 | ||
*/ | ||
timestamp: number; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time expressed according to ISO 8601 in UTC format. | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* Format: uri | ||
* @description Page URL from which identification request was sent. | ||
* @example https://some.website/path?query=params | ||
*/ | ||
url: string; | ||
/** @description A customer-provided value or an object that was sent with identification request. */ | ||
tag?: { [key: string]: unknown }; | ||
/** | ||
* @description A customer-provided id that was sent with identification request. | ||
* @example someID | ||
*/ | ||
linkedId?: string; | ||
confidence: components['schemas']['Confidence']; | ||
/** @description Attribute represents if a visitor had been identified before. */ | ||
visitorFound: boolean; | ||
/** | ||
* @example { | ||
* "global": "2022-05-05T18:28:54.535Z", | ||
* "subscription": "2022-06-09T22:58:05.576Z" | ||
* } | ||
*/ | ||
firstSeenAt: components['schemas']['StSeenAt']; | ||
/** | ||
* @example { | ||
* "global": "2022-06-09T22:58:35.795Z", | ||
* "subscription": null | ||
* } | ||
*/ | ||
lastSeenAt: components['schemas']['StSeenAt']; | ||
visitorId: string; | ||
}; | ||
}; | ||
/** ProductsResponseBotd */ | ||
botd?: { | ||
data?: components['schemas']['BotdResult']; | ||
}; | ||
}; | ||
/** @description Contains event from activated products - BOTD and Identification */ | ||
EventResponse: { | ||
products?: components['schemas']['ProductsResponse']; | ||
}; | ||
/** @description Contains all the information from BOTD product */ | ||
BotdResult: { | ||
/** | ||
* Format: ipv4 | ||
* @description IP address of the requesting browser or bot. | ||
* @example 8.8.8.8 | ||
*/ | ||
ip: string; | ||
/** | ||
* Time | ||
* Format: date-time | ||
* @description Time in UTC when the request from the JS agent was made. We recommend to treat requests that are older than 2 minutes as malicious. Otherwise, request replay attacks are possible | ||
* @example 2022-06-09T22:58:36Z | ||
*/ | ||
time: string; | ||
/** | ||
* @example { | ||
* "result": "notDetected" | ||
* } | ||
*/ | ||
bot: components['schemas']['BotdDetectionResult']; | ||
}; | ||
/** @description Stores bot detection result */ | ||
BotdDetectionResult: { | ||
/** | ||
* @description Bot detection result: | ||
* * `notDetected` - the visitor is not a bot | ||
* * `good` - good bot detected, such as Google bot, Baidu Spider, AlexaBot and so on | ||
* * `bad` - bad bot detected, such as Selenium, Puppeteer, Playwright, headless browsers, and so on | ||
* | ||
* @enum {string} | ||
*/ | ||
result: 'notDetected' | 'good' | 'bad'; | ||
}; | ||
}; | ||
} | ||
export interface operations {} | ||
export interface operations { | ||
/** This endpoint allows you to get events with all the information from each activated product - BOTD and Fingerprinting. Use the requestId as a URL path :request_id parameter. This API method is scoped to a request, i.e. all returned information is by requestId. */ | ||
getEvent: { | ||
parameters: { | ||
path: { | ||
/** Request ID */ | ||
request_id: string; | ||
}; | ||
}; | ||
responses: { | ||
/** OK */ | ||
200: { | ||
content: { | ||
'application/json': components['schemas']['EventResponse']; | ||
}; | ||
}; | ||
/** Bad Request */ | ||
400: { | ||
content: { | ||
'application/json': components['schemas']['ErrorResponse']; | ||
}; | ||
}; | ||
/** Forbidden */ | ||
403: { | ||
content: { | ||
'application/json': components['schemas']['ErrorResponse']; | ||
}; | ||
}; | ||
/** Too Many Requests */ | ||
429: { | ||
headers: { | ||
/** Indicates how long the user should wait before making a follow-up request. */ | ||
'Retry-After'?: number; | ||
}; | ||
content: { | ||
'application/json': components['schemas']['ManyRequestsResponse']; | ||
}; | ||
}; | ||
}; | ||
}; | ||
/** This endpoint allows you to get a history of visits with all available information. Use the visitorId as a URL path parameter. This API method is scoped to a visitor, i.e. all returned information is by visitorId. */ | ||
getVisits: { | ||
parameters: { | ||
path: { | ||
visitor_id: string; | ||
}; | ||
query: { | ||
/** Filter events by requestId */ | ||
request_id?: string; | ||
/** Filter events by custom identifier */ | ||
linked_id?: string; | ||
/** Limit scanned results */ | ||
limit?: number; | ||
/** Used to paginate results */ | ||
before?: number; | ||
}; | ||
}; | ||
responses: { | ||
/** OK */ | ||
200: { | ||
content: { | ||
'application/json': components['schemas']['Response']; | ||
}; | ||
}; | ||
/** Too Many Requests */ | ||
429: { | ||
headers: { | ||
/** Indicates how long the user should wait before making a follow-up request. */ | ||
'Retry-After'?: number; | ||
}; | ||
content: { | ||
'application/json': components['schemas']['ManyRequestsResponse']; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} | ||
export interface external {} |
import fetchFn from 'node-fetch'; | ||
import { getVisitorsUrl } from './urlUtils'; | ||
import { getEventUrl, getVisitorsUrl } from './urlUtils'; | ||
import { | ||
@@ -9,2 +9,3 @@ VisitorHistoryFilter, | ||
AuthenticationMode, | ||
EventResponse, | ||
} from './types'; | ||
@@ -41,2 +42,24 @@ | ||
public async getEvent(requestId: string) { | ||
if (!requestId) { | ||
throw new TypeError('requestId is not set'); | ||
} | ||
const url = | ||
this.authenticationMode === AuthenticationMode.QueryParameter | ||
? getEventUrl(requestId, this.region, this.apiKey) | ||
: getEventUrl(requestId, this.region); | ||
const headers = this.getHeaders(); | ||
return this.fetch(url, { | ||
method: 'GET', | ||
headers, | ||
}) | ||
.then((response) => response.json() as Promise<EventResponse>) | ||
.catch((err) => { | ||
throw new Error(err.toString()); | ||
}); | ||
} | ||
/** | ||
@@ -52,3 +75,3 @@ * Gets history for the given visitor | ||
if (!visitorId) { | ||
throw Error('VisitorId is not set'); | ||
throw TypeError('VisitorId is not set'); | ||
} | ||
@@ -60,6 +83,3 @@ | ||
: getVisitorsUrl(this.region, visitorId, filter); | ||
const headers = | ||
this.authenticationMode === AuthenticationMode.AuthHeader | ||
? { 'Auth-API-Key': this.apiKey } | ||
: undefined; | ||
const headers = this.getHeaders(); | ||
@@ -75,2 +95,8 @@ return this.fetch(url, { | ||
} | ||
private getHeaders() { | ||
return this.authenticationMode === AuthenticationMode.AuthHeader | ||
? { 'Auth-API-Key': this.apiKey } | ||
: undefined; | ||
} | ||
} |
@@ -50,2 +50,5 @@ import type fetchFn from 'node-fetch'; | ||
export type EventResponse = | ||
paths['/events/{request_id}']['get']['responses']['200']['content']['application/json']; | ||
/** | ||
@@ -52,0 +55,0 @@ * More info: https://dev.fingerprintjs.com/docs/webhooks#identification-webhook-object-format |
@@ -13,2 +13,18 @@ import { Region, VisitorHistoryFilter } from './types'; | ||
function getIntegrationInfo() { | ||
return `fingerprint-pro-server-node-sdk/${version}`; | ||
} | ||
export function getEventUrl(requestId: string, region: Region, apiKey?: string) { | ||
const params: QueryStringParameters = { | ||
ii: getIntegrationInfo(), | ||
}; | ||
if (apiKey) { | ||
params.api_key = apiKey; | ||
} | ||
return `${getServerApiUrl(region)}events/${requestId}?${serializeQueryStringParams(params)}`; | ||
} | ||
export function getVisitorsUrl( | ||
@@ -22,4 +38,5 @@ region: Region, | ||
...filter, | ||
ii: `fingerprint-pro-server-node-sdk/${version}`, | ||
ii: getIntegrationInfo(), | ||
}; | ||
if (apiKey) { | ||
@@ -35,2 +52,3 @@ queryStringParameters.api_key = apiKey; | ||
} | ||
return `${serverApiPath}?${queryString}`; | ||
@@ -37,0 +55,0 @@ } |
Sorry, the diff of this file is not supported yet
71190
1685