Skip to main content
Home

API wrapper around the "VeePN" extension from the Firefox store (they use HTTP proxies)

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
76%
Published
a month ago (0.0.1)
Package root>accountAPI.ts
import type { ProxyType } from "./utils/common_types.ts"; import randomDeviceInfo from "./utils/deviceInfoGenerator.ts"; import DomainFetcher, { type Ret } from "./domainFetcher.ts"; import type { Result } from "./utils/result.ts"; export type LaunchRoot = Result<Data, unknown>; export interface Data { /** the access token of the account */ accessToken: string; /** user data */ user: User; } export interface User { /** a uuid for this user */ udid: string; /*** some status */ status: number; /** time this account was registered at, unix millis */ registeredAt: number; /** time this account was last logged in at, unix millis */ lastLoggedAt: number; /** default proxy selection */ default: DefaultProxy; } export interface DefaultProxy { /** should be https */ protocol: string; /** location data */ location: DefaultLocation; } export interface DefaultLocation { /** region name of this location */ region: string; /** name of the city (e.g. Amsterdam) */ name: string; /** {Country}, {City or something} (e.g. Netherlands, Amsterdam) */ description: string; /** iso2 country code (e.g. NL) */ countryCode: string; /** seems to always be 0? */ latitude: string; /** seems to always be 0? */ longitude: string; /** ALSO seems to always be 0? */ networkLoad: string; /** priority number */ priority: number; /** 0 for free? */ type: 0 | 1; /** 0 for free, 1 for paid? */ proxy_type: ProxyType; } const domains: Ret = await DomainFetcher.fetchDomains("free"); export class AccountAPI { /** creates a new account */ static async launch(domain = domains.main): Promise<{ success: true; data: Data; }> { const url = new URL("/api/launch/", domain); const dmn = url.host; const di = randomDeviceInfo(); //console.info("Device Info:", di); const response: LaunchRoot = await fetch(url, { headers: { "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0", Accept: "application/json", "Accept-Language": "en-US,en;q=0.5", "Content-Type": "application/json", "Sec-GPC": "1", "Alt-Used": dmn, "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", Priority: "u=4", Origin: "moz-extension://9cd0ad97-40d1-4a82-aa17-893312bba011", Host: dmn, "Accept-Encoding": "gzip, deflate, br, zstd", Authorization: "Bearer", Connection: "keep-alive", TE: "trailers", }, body: JSON.stringify(di), method: "POST", }).then((r) => r.json()); if (!response.success) { throw new Error(`Launch failed: ${response.errors.join(", ")}`, { cause: response.errors, }); } return response; } } export default AccountAPI;