Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fingerprintjs/fingerprintjs-pro-server-api

Package Overview
Dependencies
Maintainers
0
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fingerprintjs/fingerprintjs-pro-server-api - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

src/responseUtils.ts

2

package.json
{
"name": "@fingerprintjs/fingerprintjs-pro-server-api",
"version": "4.1.0",
"version": "4.1.1",
"description": "Node.js wrapper for FingerprintJS Sever API",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs",

@@ -166,2 +166,15 @@ /**

}
ErrorCommon429Response: {
error?: {
/**
* @description Error code: * `TooManyRequests` - The request is throttled.
*
* @example TooManyRequests
* @enum {string}
*/
code: 'TooManyRequests'
/** @example request throttled */
message: string
}
}
ErrorEvent404Response: {

@@ -189,3 +202,3 @@ /** ErrorEvent404ResponseError */

}
ManyRequestsResponse: {
TooManyRequestsResponse: {
/**

@@ -211,2 +224,15 @@ * @description Error text.

}
ErrorVisitsDelete400Response: {
error?: {
/**
* @description Error code: * `RequestCannotBeParsed` - The visitor ID parameter is missing or in the wrong format.
*
* @example RequestCannotBeParsed
* @enum {string}
*/
code: 'RequestCannotBeParsed'
/** @example invalid visitor id */
message: string
}
}
WebhookVisit: {

@@ -1098,7 +1124,7 @@ /** @example 3HNey93AkBW6CRbxV6xP */

headers: {
/** @description Indicates how long you should wait before attempting the next request. */
/** @description Indicates how many seconds you should wait before attempting the next request. */
'Retry-After'?: number
}
content: {
'application/json': components['schemas']['ManyRequestsResponse']
'application/json': components['schemas']['TooManyRequestsResponse']
}

@@ -1130,2 +1156,8 @@ }

}
/** @description Bad request. The visitor ID parameter is missing or in the wrong format. */
400: {
content: {
'application/json': components['schemas']['ErrorVisitsDelete400Response']
}
}
/** @description Forbidden. Access to this API is denied. */

@@ -1143,4 +1175,10 @@ 403: {

}
/** @description Too Many Requests. The request is throttled. */
429: {
content: {
'application/json': components['schemas']['ErrorCommon429Response']
}
}
}
}
}
import { getDeleteVisitorDataUrl, getEventUrl, getVisitorsUrl } from './urlUtils'
import {
AuthenticationMode,
CommonError429,
DeleteVisitorError,

@@ -17,2 +18,3 @@ EventError,

} from './types'
import { copyResponseJson } from './responseUtils'

@@ -28,2 +30,4 @@ export class FingerprintJsServerApiClient {

protected static readonly DEFAULT_RETRY_AFTER = 1
/**

@@ -85,3 +89,4 @@ * FingerprintJS server API client used to fetch data from FingerprintJS

.then(async (response) => {
const jsonResponse = await response.json()
const jsonResponse = await copyResponseJson(response)
if (response.status !== 200) {

@@ -149,4 +154,12 @@ throw { ...jsonResponse, response, status: response.status } as EventError

const jsonResponse = await response.json()
const jsonResponse = await copyResponseJson(response)
if (response.status === 429) {
const retryAfter = this.getRetryAfter(response)
;(jsonResponse as CommonError429).retryAfter = retryAfter
? parseInt(retryAfter)
: FingerprintJsServerApiClient.DEFAULT_RETRY_AFTER
}
throw { ...(jsonResponse as DeleteVisitorError), response, status: response.status } as DeleteVisitorError

@@ -213,3 +226,4 @@ })

.then(async (response) => {
const jsonResponse = await response.json()
const jsonResponse = await copyResponseJson(response)
if (response.status === 200) {

@@ -219,4 +233,6 @@ return jsonResponse as VisitorsResponse

if (response.status === 429) {
const retryAfter = response.headers.get('retry-after') || ''
;(jsonResponse as VisitorsError429).retryAfter = retryAfter === '' ? 1 : parseInt(retryAfter)
const retryAfter = this.getRetryAfter(response)
;(jsonResponse as VisitorsError429).retryAfter = retryAfter
? parseInt(retryAfter)
: FingerprintJsServerApiClient.DEFAULT_RETRY_AFTER
}

@@ -239,2 +255,6 @@ throw { ...(jsonResponse as VisitorsError), response, status: response.status } as VisitorsError

}
private getRetryAfter(response: Response) {
return response.headers.get('retry-after')
}
}

@@ -43,2 +43,10 @@ import { components, paths } from './generatedApiTypes'

export type TooManyRequestsError = {
status: 429
/**
* How many seconds to wait before retrying
*/
retryAfter: number
}
/**

@@ -53,9 +61,3 @@ * More info: https://dev.fingerprintjs.com/docs/server-api#response

export type VisitorsError429 =
paths['/visitors/{visitor_id}']['get']['responses']['429']['content']['application/json'] & {
status: 429
/**
* How many seconds to wait before retrying
*/
retryAfter: number
}
paths['/visitors/{visitor_id}']['get']['responses']['429']['content']['application/json'] & TooManyRequestsError

@@ -72,5 +74,14 @@ export type DeleteVisitError404 =

export type DeleteVisitError400 =
paths['/visitors/{visitor_id}']['delete']['responses']['400']['content']['application/json'] & {
status: 400
}
export type CommonError429 = components['schemas']['ErrorCommon429Response'] & TooManyRequestsError
export type VisitorsError = WithResponse<VisitorsError403 | VisitorsError429>
export type DeleteVisitorError = WithResponse<DeleteVisitError404 | DeleteVisitError403>
export type DeleteVisitorError = WithResponse<
DeleteVisitError404 | DeleteVisitError403 | DeleteVisitError400 | CommonError429
>

@@ -88,10 +99,11 @@ export function isVisitorsError(response: any): response is VisitorsError {

export function isDeleteVisitorError(response: any): response is DeleteVisitorError {
return (
(response?.hasOwnProperty('status') &&
(response.status === 403 || response.status === 404) &&
const statusCodes = [400, 403, 404, 429]
return Boolean(
response?.hasOwnProperty('status') &&
statusCodes.includes(response.status) &&
response.error?.hasOwnProperty('message') &&
typeof response.error.message === 'string' &&
response.error?.hasOwnProperty('code') &&
typeof response.error.code === 'string') ||
false
typeof response.error.code === 'string'
)

@@ -98,0 +110,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc