UNPKG

navs-aml

Version:

Anti-Money Laundering (AML) services powered by NAVS - Node-Assisted Verification Service

118 lines 5.54 kB
"use strict"; /** * NAVS AML (Anti-Money Laundering) Services * * This package provides AML compliance functions powered by NAVS (Node-Assisted Verification Service). * Functions are executed by a decentralized network of operators with economic stake backing the results. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AMLServices = exports.navsClient = void 0; const navskit_1 = require("navskit"); const viem_1 = require("viem"); const dotenv = __importStar(require("dotenv")); const Pkg = __importStar(require("../package.json")); dotenv.config(); exports.navsClient = (0, navskit_1.navs)({ serviceName: Pkg.name, serviceVersion: Pkg.version, }); const { navs } = exports.navsClient; // Cache for OFAC sanctions list to avoid repeated downloads let __sanctionList = undefined; let __sanctionPromise = undefined; /** * AML Compliance Services * * This class provides Anti-Money Laundering (AML) compliance functions * that are executed by a decentralized network with cryptoeconomic security. */ class AMLServices { /** * Check if an Ethereum address appears on the OFAC Sanctions List * * This function downloads and searches the official OFAC SDN (Specially Designated Nationals) * Enhanced XML file to determine if a given Ethereum address is sanctioned. * * Results are backed by cryptoeconomic security through the NAVS network - operators * stake tokens to participate and are slashed for providing incorrect results. * * @param address The Ethereum address to check (must be valid hex string) * @returns Promise<boolean> true if the address is sanctioned, false otherwise * * @example * ```typescript * const isSanctioned = await AMLServices.isAddressSanctioned('0x1234567890123456789012345678901234567890'); * console.log(`Address is sanctioned: ${isSanctioned}`); * ``` */ static async isAddressSanctioned(address) { // Download OFAC sanctions list if not already cached if (__sanctionList === undefined) { if (__sanctionPromise === undefined) { console.log('Downloading OFAC sanctions list...'); __sanctionPromise = fetch('https://sanctionslistservice.ofac.treas.gov/api/PublicationPreview/exports/SDN_ENHANCED.XML') .then(res => { if (!res.ok) { throw new Error(`Failed to fetch OFAC list: ${res.status} ${res.statusText}`); } return res.text(); }); } __sanctionList = await __sanctionPromise; console.log(`OFAC sanctions list loaded (${__sanctionList.length} characters)`); } // Normalize address to checksum format for consistent searching const searchAddress = (0, viem_1.getAddress)(address); // Search for the address in the sanctions list const isListed = __sanctionList.includes(searchAddress); console.log(`AML Check: ${searchAddress} -> ${isListed ? 'SANCTIONED' : 'CLEAR'}`); return isListed; } } exports.AMLServices = AMLServices; __decorate([ navs(), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], AMLServices, "isAddressSanctioned", null); // Export for external use exports.default = AMLServices; // Re-export contract configurations for use in frontends __exportStar(require("./abi"), exports); //# sourceMappingURL=index.js.map