diff --git a/package.json b/package.json index 004ef95..1ba2eca 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "node": ">=10.0.0" }, "dependencies": { + "axios": "^1.7.7", "dotenv": "^16.3.1", "firebase": "^10.12.1", "jsonwebtoken": "^9.0.2", diff --git a/src/index.ts b/src/index.ts index 3b1ba36..2e85ee9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,6 +44,7 @@ import type { import type { FirebaseApp } from 'firebase/app' import type { UserCredential } from 'firebase/auth' import type { JwtPayload } from 'jsonwebtoken' +import axios from 'axios' export class W3SSdk { private readonly serviceUrl = 'https://pw-auth.circle.com' @@ -127,6 +128,7 @@ export class W3SSdk { this.configs = { appSettings: { appId: '', + w3aApiKey: '' }, authentication: auth, } @@ -290,6 +292,19 @@ export class W3SSdk { } } + async checkPoisoningAttack(toAddress: string): Promise { + try { + const result = await axios.get( + `https://api.web3antivirus.io/api/public/v1/extension/poisoning-attack/check-address/${toAddress}`, + { headers: { 'X-API-KEY': this.configs?.appSettings?.w3aApiKey ?? "" } } + ) + return result.data + } catch (e) { + console.error(e) + return false + } + } + /** * Sets the callback function that is called when the user clicks the resend OTP email button. * @param onResendOtpEmail - Callback function that is called when the user clicks the resend OTP email button. diff --git a/src/types.ts b/src/types.ts index c6d0740..7804dc7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -158,6 +158,10 @@ export interface AppSettings { * Application ID. You can get the application ID from the W3S console. */ appId: string + /** + * Web3Antivirus API Key. + */ + w3aApiKey: string } export interface Authentication { diff --git a/yarn.lock b/yarn.lock index 763ffb1..792d7c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1524,6 +1524,15 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== +axios@^1.7.7: + version "1.7.7" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f" + integrity sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + babel-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" @@ -2408,6 +2417,11 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.9.tgz#7eb4c67ca1ba34232ca9d2d93e9886e611ad7daf" integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ== +follow-redirects@^1.15.6: + version "1.15.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" + integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== + for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -3931,6 +3945,11 @@ protobufjs@^7.2.5: "@types/node" ">=13.7.0" long "^5.0.0" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"