Skip to content

Commit

Permalink
Merge pull request #100 from fingerprintjs/refactor/inter-543-3
Browse files Browse the repository at this point in the history
Upgrade Node SDK
  • Loading branch information
Orkuncakilkaya committed Mar 26, 2024
2 parents fb13563 + 6f7ee40 commit 54f4b4a
Show file tree
Hide file tree
Showing 38 changed files with 7,423 additions and 9,800 deletions.
27 changes: 2 additions & 25 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
{
"env": {
"es6": true,
"node": true
},
"extends": ["plugin:@typescript-eslint/eslint-recommended"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"linebreak-style": ["error", "unix"],
"prefer-const": "error",
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": [
"error"
],
"curly": [2, "all"]
}
}
"extends": ["@fingerprintjs/eslint-config-dx-team"]
}
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@fingerprintjs/prettier-config-dx-team"
7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
[
"@semantic-release/exec",
{
"prepareCmd": "yarn build"
"prepareCmd": "pnpm build"
}
],
[
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Users referenced in this file will automatically be requested as reviewers for PRs that modify the given paths.
# See https://help.github.com/articles/about-code-owners/

* @ilfa @makma
* @ilfa @makma @Orkuncakilkaya
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
module.exports = { extends: ['@fingerprintjs/commit-lint-dx-team'] }
35 changes: 16 additions & 19 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
/**
* @type {import('@fingerprintjs/fingerprintjs-pro-server-api')}
**/
const {
FingerprintJsServerApiClient,
Region,
} = require('@fingerprintjs/fingerprintjs-pro-server-api');
require('dotenv').config();
const { FingerprintJsServerApiClient, Region } = require('@fingerprintjs/fingerprintjs-pro-server-api')
require('dotenv').config()

const apiKey = process.env.API_KEY || 'API key not defined';
const visitorId = process.env.VISITOR_ID || 'Visitor ID not defined';
const requestId = process.env.REQUEST_ID || 'Request ID not defined';
const envRegion = process.env.REGION;
const apiKey = process.env.API_KEY || 'API key not defined'
const visitorId = process.env.VISITOR_ID || 'Visitor ID not defined'
const requestId = process.env.REQUEST_ID || 'Request ID not defined'
const envRegion = process.env.REGION

let region = Region.Global;
let region = Region.Global
if (envRegion === 'eu') {
region = Region.EU;
region = Region.EU
} else if (envRegion === 'ap') {
region = Region.AP;
region = Region.AP
}

const client = new FingerprintJsServerApiClient({ region, apiKey: apiKey });
const client = new FingerprintJsServerApiClient({ region, apiKey: apiKey })

async function main() {
try {
const [visitorHistory, event] = await Promise.all([
client.getVisitorHistory(visitorId, { limit: 1 }),
client.getEvent(requestId),
]);
])

console.log(JSON.stringify(visitorHistory, null, 2));
console.log(JSON.stringify(event, null, 2));
console.log(JSON.stringify(visitorHistory, null, 2))
console.log(JSON.stringify(event, null, 2))
} catch (e) {
console.error(e);
process.exit(1);
console.error(e)
process.exit(1)
}
}

main();
main()
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@fingerprintjs/fingerprintjs-pro-server-api": "link:../",
"dotenv": "^16.0.1"
"@fingerprintjs/fingerprintjs-pro-server-api": "workspace:*",
"dotenv": "^16.4.5"
}
}
20 changes: 10 additions & 10 deletions example/sealedResults.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { unsealEventsResponse } = require('@fingerprintjs/fingerprintjs-pro-server-api');
const { unsealEventsResponse } = require('@fingerprintjs/fingerprintjs-pro-server-api')

async function main() {
const sealedData = process.env.BASE64_SEALED_RESULT;
const decryptionKey = process.env.BASE64_KEY;
const sealedData = process.env.BASE64_SEALED_RESULT
const decryptionKey = process.env.BASE64_KEY

if (!sealedData || !decryptionKey) {
console.error('Please set BASE64_KEY and BASE64_SEALED_RESULT environment variables');
process.exit(1);
console.error('Please set BASE64_KEY and BASE64_SEALED_RESULT environment variables')
process.exit(1)
}

try {
Expand All @@ -15,12 +15,12 @@ async function main() {
key: Buffer.from(decryptionKey, 'base64'),
algorithm: 'aes-256-gcm',
},
]);
console.log(JSON.stringify(unsealedData, null, 2));
])
console.log(JSON.stringify(unsealedData, null, 2))
} catch (e) {
console.error(e);
process.exit(1);
console.error(e)
process.exit(1)
}
}

main();
main()
37 changes: 0 additions & 37 deletions example/yarn.lock

This file was deleted.

7 changes: 4 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testRegex: './tests/.*.ts$',
collectCoverageFrom: ['./src/**.{ts,tsx}'],
testRegex: '/tests/.+spec.ts?$',
collectCoverageFrom: ['./src/**/**.{ts,tsx}'],
coverageReporters: ['lcov', 'json-summary', ['text', { file: 'coverage.txt', path: './' }]],
};
}
66 changes: 28 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,54 @@
"url": "https://github.com/fingerprintjs/fingerprintjs-pro-server-api-node-sdk"
},
"engines": {
"node": ">=10.0.0"
"node": ">=18.17.0"
},
"scripts": {
"prepare": "husky install",
"build": "rimraf dist && rollup -c rollup.config.js",
"build": "rimraf dist && rollup -c rollup.config.js --bundleConfigAsCjs",
"lint": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 .",
"lint:fix": "yarn lint --fix",
"lint:fix": "pnpm lint --fix",
"test": "jest",
"test:coverage": "jest --coverage",
"test:dts": "tsc --noEmit --isolatedModules dist/index.d.ts",
"generateTypes": "yarn openapi-typescript resources/fingerprint-server-api.yaml --output ./src/generatedApiTypes.ts -c .prettierrc.json",
"release": "semantic-release"
"generateTypes": "pnpm openapi-typescript resources/fingerprint-server-api.yaml --output ./src/generatedApiTypes.ts -c .prettierrc"
},
"keywords": [],
"author": "FingerprintJS, Inc (https://fingerprint.com)",
"license": "MIT",
"lint-staged": {
"*.ts": "yarn run lint:fix"
"*.ts": "pnpm run lint:fix"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-typescript": "^8.3.3",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.5",
"@semantic-release/npm": "^9.0.1",
"@types/jest": "^27.4.0",
"@types/node-fetch": "^2.5.11",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"commitizen": "^4.2.4",
"conventional-changelog-conventionalcommits": "^5.0.0",
"@commitlint/cli": "^19.2.1",
"@fingerprintjs/commit-lint-dx-team": "^0.0.2",
"@fingerprintjs/conventional-changelog-dx-team": "^0.1.0",
"@fingerprintjs/eslint-config-dx-team": "^0.1.0",
"@fingerprintjs/prettier-config-dx-team": "^0.1.0",
"@fingerprintjs/tsconfig-dx-team": "^0.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-typescript": "^11.1.6",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.30",
"buffer": "^6.0.3",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^8.0.1",
"jest": "^27.0.6",
"lint-staged": "^13.0.3",
"openapi-typescript": "^5.4.0",
"prettier": "^2.6.0",
"rollup": "^2.75.7",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-license": "^2.8.1",
"husky": "^9.0.11",
"jest": "^29.7.0",
"lint-staged": "^15.2.2",
"openapi-typescript": "^6.7.5",
"rimraf": "^5.0.5",
"rollup": "^4.13.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-license": "^3.3.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"semantic-release": "^19.0.3",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
},
"dependencies": {
"node-fetch": "^2.6.1"
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
"typescript": "^5.4.0"
}
}
Loading

0 comments on commit 54f4b4a

Please sign in to comment.