From 6ca21e9bd3f9457f60dc241784c4d37005ab6985 Mon Sep 17 00:00:00 2001 From: Shigma Date: Fri, 26 Apr 2024 12:18:53 +0800 Subject: [PATCH] refa: merge file into core --- package.json | 20 +++---- packages/core/package.json | 21 ++++---- packages/core/readme.md | 4 +- packages/core/src/adapter/browser.ts | 34 ++++++++++++ packages/core/src/adapter/node.ts | 18 +++++++ packages/core/src/index.ts | 55 +++++++++++++++++-- packages/{file => core}/src/utils.ts | 2 +- packages/file/package.json | 66 ----------------------- packages/file/readme.md | 3 -- packages/file/src/adapter/browser.ts | 33 ------------ packages/file/src/adapter/index.d.ts | 5 -- packages/file/src/adapter/node.ts | 17 ------ packages/file/src/index.ts | 79 ---------------------------- packages/file/tsconfig.json | 10 ---- packages/proxy-agent/package.json | 26 ++++----- packages/proxy-agent/readme.md | 4 +- packages/proxy-agent/src/index.ts | 6 +-- tsconfig.json | 4 +- 18 files changed, 148 insertions(+), 259 deletions(-) rename packages/{file => core}/src/utils.ts (98%) delete mode 100644 packages/file/package.json delete mode 100644 packages/file/readme.md delete mode 100644 packages/file/src/adapter/browser.ts delete mode 100644 packages/file/src/adapter/index.d.ts delete mode 100644 packages/file/src/adapter/node.ts delete mode 100644 packages/file/src/index.ts delete mode 100644 packages/file/tsconfig.json diff --git a/package.json b/package.json index 7159a2e..8bd307e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@root/undios", + "name": "@root/http", "private": true, "type": "module", "version": "1.0.0", @@ -20,21 +20,21 @@ "test:html": "shx rm -rf coverage && c8 -r html yarn test" }, "devDependencies": { - "@cordisjs/eslint-config": "^1.0.4", - "@types/chai": "^4.3.11", + "@cordisjs/eslint-config": "^1.1.1", + "@types/chai": "^4.3.14", "@types/chai-as-promised": "^7.1.8", - "@types/node": "^20.10.2", + "@types/node": "^20.11.30", "c8": "^7.14.0", - "chai": "^4.3.10", + "chai": "^4.4.1", "chai-as-promised": "^7.1.1", "esbuild": "^0.18.20", "esbuild-register": "^3.5.0", - "eslint": "^8.55.0", + "eslint": "^8.57.0", "shx": "^0.3.4", - "tsx": "^4.7.0", - "typescript": "^5.3.2", - "yakumo": "^1.0.0-beta.7", - "yakumo-esbuild": "^1.0.0-beta.3", + "tsx": "^4.7.1", + "typescript": "^5.4.3", + "yakumo": "^1.0.0-beta.13", + "yakumo-esbuild": "^1.0.0-beta.5", "yakumo-publish-sync": "^1.0.0-alpha.1", "yakumo-tsc": "^1.0.0-alpha.2" } diff --git a/packages/core/package.json b/packages/core/package.json index 6686ff9..50f84c1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { - "name": "undios", + "name": "@cordisjs/plugin-http", "description": "Fetch-based axios-style HTTP client", - "version": "0.3.3", + "version": "0.4.0", "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,13 +30,13 @@ "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/cordiverse/undios.git", + "url": "git+https://github.com/cordiverse/http.git", "directory": "packages/core" }, "bugs": { - "url": "https://github.com/cordiverse/undios/issues" + "url": "https://github.com/cordiverse/http/issues" }, - "homepage": "https://github.com/cordiverse/undios", + "homepage": "https://github.com/cordiverse/http", "keywords": [ "http", "fetch", @@ -49,14 +49,17 @@ "plugin" ], "devDependencies": { - "cordis": "^3.13.3", - "undici": "^6.6.2" + "@types/mime-db": "^1.43.5", + "cordis": "^3.13.6", + "undici": "^6.10.1" }, "peerDependencies": { - "cordis": "^3.13.3" + "cordis": "^3.13.6" }, "dependencies": { - "cosmokit": "^1.5.2", + "cosmokit": "^1.6.2", + "file-type": "^16.5.4", + "mime-db": "^1.52.0", "ws": "^8.16.0" } } diff --git a/packages/core/readme.md b/packages/core/readme.md index 322608f..bb4c4ae 100644 --- a/packages/core/readme.md +++ b/packages/core/readme.md @@ -15,7 +15,7 @@ Fetch-based axios-style HTTP client. ## Basic Usage ```ts -import Undios from 'undios' +import Undios from '@cordisjs/plugin-http' const http = new Undios() @@ -163,7 +163,7 @@ The request timeout in milliseconds. > [!NOTE] > -> In order to use a proxy agent, you need to install `undios-proxy-agent`. +> In order to use a proxy agent, you need to install `@cordisjs/plugin-proxy-agent`. ### Response diff --git a/packages/core/src/adapter/browser.ts b/packages/core/src/adapter/browser.ts index f89dd19..c081407 100644 --- a/packages/core/src/adapter/browser.ts +++ b/packages/core/src/adapter/browser.ts @@ -1,2 +1,36 @@ +// Modified from https://github.com/sindresorhus/ip-regex/blob/3e220cae3eb66ecfdf4f7678bea7306ceaa41c76/index.js + +import { LookupAddress } from 'dns' +import { FileResponse } from '../index.js' + +const v4 = /^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/ + +const v6seg = '[a-fA-F\\d]{1,4}' + +/* eslint-disable no-multi-spaces */ +const v6core = [ + `(?:${v6seg}:){7}(?:${v6seg}|:)`, // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8 + `(?:${v6seg}:){6}(?:${v4}|:${v6seg}|:)`, // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4 + `(?:${v6seg}:){5}(?::${v4}|(?::${v6seg}){1,2}|:)`, // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4 + `(?:${v6seg}:){4}(?:(?::${v6seg}){0,1}:${v4}|(?::${v6seg}){1,3}|:)`, // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4 + `(?:${v6seg}:){3}(?:(?::${v6seg}){0,2}:${v4}|(?::${v6seg}){1,4}|:)`, // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4 + `(?:${v6seg}:){2}(?:(?::${v6seg}){0,3}:${v4}|(?::${v6seg}){1,5}|:)`, // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4 + `(?:${v6seg}:){1}(?:(?::${v6seg}){0,4}:${v4}|(?::${v6seg}){1,6}|:)`, // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4 + `(?::(?:(?::${v6seg}){0,5}:${v4}|(?::${v6seg}){1,7}|:))`, // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4 +] +/* eslint-enable no-multi-spaces */ + +const v6 = new RegExp(`^(?:${v6core.join('|')})(?:%[0-9a-zA-Z]{1,})?$`) + +export async function lookup(address: string): Promise { + if (v4.test(address)) return { address, family: 4 } + if (v6.test(address)) return { address, family: 6 } + throw new Error('Invalid IP address') +} + +export async function loadFile(url: string): Promise { + return undefined +} + const { WebSocket } = globalThis export { WebSocket } diff --git a/packages/core/src/adapter/node.ts b/packages/core/src/adapter/node.ts index 50f6f72..20cf6d3 100644 --- a/packages/core/src/adapter/node.ts +++ b/packages/core/src/adapter/node.ts @@ -1 +1,19 @@ +import { fileURLToPath } from 'node:url' +import { basename } from 'node:path' +import { fromBuffer } from 'file-type' +import { FileResponse } from '../index.js' +import { readFile } from 'node:fs/promises' + +export { lookup } from 'node:dns/promises' + +export async function loadFile(url: string): Promise { + if (url.startsWith('file://')) { + const data = await readFile(fileURLToPath(url)) + const result = await fromBuffer(data) + // https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer#answer-31394257 + const buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) + return { mime: result?.mime, filename: basename(url), data: buffer } + } +} + export { WebSocket } from 'ws' diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 26b503f..9d0c8c5 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,10 +1,12 @@ import { Context, Service } from 'cordis' -import { Awaitable, defineProperty, Dict, isNullable, trimSlash } from 'cosmokit' +import { Awaitable, Binary, defineProperty, Dict, isNullable, trimSlash } from 'cosmokit' import { ClientOptions } from 'ws' -import { WebSocket } from 'undios/adapter' +import { loadFile, lookup, WebSocket } from '@cordisjs/plugin-http/adapter' import { ReadableStream } from 'node:stream/web' +import { isLocalAddress } from './utils.ts' +import mimedb from 'mime-db' -export type { WebSocket } from 'undios/adapter' +export type { WebSocket } from '@cordisjs/plugin-http/adapter' declare module 'cordis' { interface Context { @@ -22,7 +24,7 @@ declare module 'cordis' { } } -const kHTTPError = Symbol.for('undios.error') +const kHTTPError = Symbol.for('cordis.http.error') class HTTPError extends Error { [kHTTPError] = true @@ -115,6 +117,16 @@ export namespace HTTP { } } +export interface FileConfig { + timeout?: number | string +} + +export interface FileResponse { + mime?: string + filename: string + data: ArrayBuffer +} + export interface HTTP { (url: string, config: HTTP.RequestConfig & { responseType: K }): Promise> (url: string | URL, config?: HTTP.RequestConfig): Promise> @@ -363,6 +375,41 @@ export class HTTP extends Service { }) return socket } + + async file(this: HTTP, url: string, options: FileConfig = {}): Promise { + const result = await loadFile(url) + if (result) return result + const capture = /^data:([\w/-]+);base64,(.*)$/.exec(url) + if (capture) { + const [, mime, base64] = capture + let name = 'file' + const ext = mime && mimedb[mime]?.extensions?.[0] + if (ext) name += `.${ext}` + return { mime, data: Binary.fromBase64(base64), filename: name } + } + const { headers, data, url: responseUrl } = await this(url, { + method: 'GET', + responseType: 'arraybuffer', + timeout: +options.timeout! || undefined, + }) + const mime = headers.get('content-type') ?? undefined + const [, name] = responseUrl.match(/.+\/([^/?]*)(?=\?)?/)! + return { mime, filename: name, data } + } + + async isLocal(url: string) { + let { hostname, protocol } = new URL(url) + if (protocol !== 'http:' && protocol !== 'https:') return true + if (/^\[.+\]$/.test(hostname)) { + hostname = hostname.slice(1, -1) + } + try { + const address = await lookup(hostname) + return isLocalAddress(address) + } catch { + return false + } + } } export default HTTP diff --git a/packages/file/src/utils.ts b/packages/core/src/utils.ts similarity index 98% rename from packages/file/src/utils.ts rename to packages/core/src/utils.ts index a190767..3e0e7aa 100644 --- a/packages/file/src/utils.ts +++ b/packages/core/src/utils.ts @@ -1,4 +1,4 @@ -import { LookupAddress } from 'dns' +import { LookupAddress } from 'node:dns' /* eslint-disable no-multi-spaces */ const bogonV4 = [ diff --git a/packages/file/package.json b/packages/file/package.json deleted file mode 100644 index 1773d63..0000000 --- a/packages/file/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "undios-file", - "description": "File support for undios", - "version": "0.1.2", - "type": "module", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "exports": { - ".": { - "require": "./lib/index.cjs", - "import": "./lib/index.js", - "types": "./lib/index.d.ts" - }, - "./adapter": { - "node": { - "require": "./lib/adapter/node.cjs", - "import": "./lib/adapter/node.js" - }, - "default": { - "import": "./lib/adapter/browser.js" - }, - "types": "./lib/adapter/index.d.ts" - }, - "./package.json": "./package.json" - }, - "files": [ - "lib", - "src" - ], - "author": "Shigma ", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/cordiverse/undios.git", - "directory": "packages/file" - }, - "bugs": { - "url": "https://github.com/cordiverse/undios/issues" - }, - "homepage": "https://github.com/cordiverse/undios", - "keywords": [ - "http", - "client", - "undici", - "fetch", - "axios", - "file", - "mime", - "request", - "cordis", - "plugin" - ], - "devDependencies": { - "@types/mime-db": "^1.43.5", - "cordis": "^3.10.4" - }, - "peerDependencies": { - "cordis": "^3.10.4", - "undios": "^0.1.9" - }, - "dependencies": { - "cosmokit": "^1.5.2", - "file-type": "^16.5.4", - "mime-db": "^1.52.0" - } -} diff --git a/packages/file/readme.md b/packages/file/readme.md deleted file mode 100644 index 1290dba..0000000 --- a/packages/file/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# undios-file - -Support `http.file()` in undios. diff --git a/packages/file/src/adapter/browser.ts b/packages/file/src/adapter/browser.ts deleted file mode 100644 index 20a7a9b..0000000 --- a/packages/file/src/adapter/browser.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Modified from https://github.com/sindresorhus/ip-regex/blob/3e220cae3eb66ecfdf4f7678bea7306ceaa41c76/index.js - -import { LookupAddress } from 'dns' -import { FileResponse } from '../index.js' - -const v4 = /^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/ - -const v6seg = '[a-fA-F\\d]{1,4}' - -/* eslint-disable no-multi-spaces */ -const v6core = [ - `(?:${v6seg}:){7}(?:${v6seg}|:)`, // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8 - `(?:${v6seg}:){6}(?:${v4}|:${v6seg}|:)`, // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4 - `(?:${v6seg}:){5}(?::${v4}|(?::${v6seg}){1,2}|:)`, // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4 - `(?:${v6seg}:){4}(?:(?::${v6seg}){0,1}:${v4}|(?::${v6seg}){1,3}|:)`, // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4 - `(?:${v6seg}:){3}(?:(?::${v6seg}){0,2}:${v4}|(?::${v6seg}){1,4}|:)`, // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4 - `(?:${v6seg}:){2}(?:(?::${v6seg}){0,3}:${v4}|(?::${v6seg}){1,5}|:)`, // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4 - `(?:${v6seg}:){1}(?:(?::${v6seg}){0,4}:${v4}|(?::${v6seg}){1,6}|:)`, // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4 - `(?::(?:(?::${v6seg}){0,5}:${v4}|(?::${v6seg}){1,7}|:))`, // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4 -] -/* eslint-enable no-multi-spaces */ - -const v6 = new RegExp(`^(?:${v6core.join('|')})(?:%[0-9a-zA-Z]{1,})?$`) - -export async function lookup(address: string): Promise { - if (v4.test(address)) return { address, family: 4 } - if (v6.test(address)) return { address, family: 6 } - throw new Error('Invalid IP address') -} - -export async function loadFile(url: string): Promise { - return undefined -} diff --git a/packages/file/src/adapter/index.d.ts b/packages/file/src/adapter/index.d.ts deleted file mode 100644 index c4fb79a..0000000 --- a/packages/file/src/adapter/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { LookupAddress } from 'dns' -import { HTTP } from '../index.ts' - -export function loadFile(url: string): Promise -export function lookup(address: string): Promise diff --git a/packages/file/src/adapter/node.ts b/packages/file/src/adapter/node.ts deleted file mode 100644 index ad54868..0000000 --- a/packages/file/src/adapter/node.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { fileURLToPath } from 'node:url' -import { basename } from 'node:path' -import { fromBuffer } from 'file-type' -import { FileResponse } from '../index.js' -import { readFile } from 'node:fs/promises' - -export { lookup } from 'node:dns/promises' - -export async function loadFile(url: string): Promise { - if (url.startsWith('file://')) { - const data = await readFile(fileURLToPath(url)) - const result = await fromBuffer(data) - // https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer#answer-31394257 - const buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) - return { mime: result?.mime, filename: basename(url), data: buffer } - } -} diff --git a/packages/file/src/index.ts b/packages/file/src/index.ts deleted file mode 100644 index 4a17240..0000000 --- a/packages/file/src/index.ts +++ /dev/null @@ -1,79 +0,0 @@ -import HTTP, {} from 'undios' -import { loadFile, lookup } from 'undios-file/adapter' -import { Context, z } from 'cordis' -import { base64ToArrayBuffer } from 'cosmokit' -import mimedb from 'mime-db' -import { isLocalAddress } from './utils.ts' - -declare module 'undios' { - interface HTTP { - file(url: string, options?: FileConfig): Promise - isLocal(url: string): Promise - } -} - -export interface FileConfig { - timeout?: number | string -} - -export interface FileResponse { - mime?: string - filename: string - data: ArrayBuffer -} - -export const name = 'undios-file' -export const inject = ['http'] - -export interface Config {} - -export const Config: z = z.object({}) - -export function apply(ctx: Context, config: Config) { - ctx.provide('http.file') - ctx.provide('http.isLocal') - - function createName(mime: string | undefined) { - let name = 'file' - const ext = mime && mimedb[mime]?.extensions?.[0] - if (ext) name += `.${ext}` - return name - } - - ctx['http.file'] = async function file(this: HTTP, url: string, options: FileConfig = {}): Promise { - const result = await loadFile(url) - if (result) return result - const capture = /^data:([\w/-]+);base64,(.*)$/.exec(url) - if (capture) { - const [, mime, base64] = capture - return { mime, data: base64ToArrayBuffer(base64), filename: createName(mime) } - } - const { headers, data, url: responseUrl } = await this(url, { - method: 'GET', - responseType: 'arraybuffer', - timeout: +options.timeout! || undefined, - }) - const mime = headers.get('content-type') ?? undefined - const [, name] = responseUrl.match(/.+\/([^/?]*)(?=\?)?/)! - return { mime, filename: name, data } - } - - ctx['http.isLocal'] = async function isLocal(url: string) { - let { hostname, protocol } = new URL(url) - if (protocol !== 'http:' && protocol !== 'https:') return true - if (/^\[.+\]$/.test(hostname)) { - hostname = hostname.slice(1, -1) - } - try { - const address = await lookup(hostname) - return isLocalAddress(address) - } catch { - return false - } - } - - ctx.on('dispose', () => { - ctx['http.file'] = undefined - ctx['http.isLocal'] = undefined - }) -} diff --git a/packages/file/tsconfig.json b/packages/file/tsconfig.json deleted file mode 100644 index 42cbe59..0000000 --- a/packages/file/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib", - }, - "include": [ - "src", - ], -} diff --git a/packages/proxy-agent/package.json b/packages/proxy-agent/package.json index 4cb76a7..2759e48 100644 --- a/packages/proxy-agent/package.json +++ b/packages/proxy-agent/package.json @@ -1,7 +1,7 @@ { - "name": "undios-proxy-agent", - "description": "Proxy agent support for undios", - "version": "0.1.4", + "name": "@cordisjs/plugin-proxy-agent", + "description": "Proxy agent support for @cordisjs/plugin-http", + "version": "0.3.0", "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -21,13 +21,13 @@ "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/cordiverse/undios.git", + "url": "git+https://github.com/cordiverse/http.git", "directory": "packages/proxy-agent" }, "bugs": { - "url": "https://github.com/cordiverse/undios/issues" + "url": "https://github.com/cordiverse/http/issues" }, - "homepage": "https://github.com/cordiverse/undios", + "homepage": "https://github.com/cordiverse/http", "keywords": [ "http", "client", @@ -44,17 +44,17 @@ "plugin" ], "devDependencies": { - "cordis": "^3.10.4" + "cordis": "^3.13.6" }, "peerDependencies": { - "cordis": "^3.10.4", - "undios": "^0.1.9" + "@cordisjs/plugin-http": "^0.4.0", + "cordis": "^3.13.6" }, "dependencies": { - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.2", - "socks": "^2.7.1", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.4", + "socks": "^2.8.1", "socks-proxy-agent": "^8.0.2", - "undici": "^6.6.2" + "undici": "^6.10.1" } } diff --git a/packages/proxy-agent/readme.md b/packages/proxy-agent/readme.md index f49ab0a..76ebdf4 100644 --- a/packages/proxy-agent/readme.md +++ b/packages/proxy-agent/readme.md @@ -1,3 +1,3 @@ -# undios-proxy-agent +# @cordisjs/plugin-proxy-agent -Supports HTTP, HTTPS, and SOCKS proxy agents for [undios](https://github.com/cordiverse/undios). +Supports HTTP, HTTPS, and SOCKS proxy agents for [@cordisjs/plugin-http](https://github.com/cordiverse/http). diff --git a/packages/proxy-agent/src/index.ts b/packages/proxy-agent/src/index.ts index 2b72417..fcefbc9 100644 --- a/packages/proxy-agent/src/index.ts +++ b/packages/proxy-agent/src/index.ts @@ -1,7 +1,7 @@ // modified from https://github.com/Kaciras/fetch-socks/blob/41cec5a02c36687279ad2628f7c46327f7ff3e2d/index.ts // modified from https://github.com/TooTallNate/proxy-agents/blob/c881a1804197b89580320b87082971c3c6a61746/packages/socks-proxy-agent/src/index.ts -import {} from 'undios' +import {} from '@cordisjs/plugin-http' import * as http from 'node:http' import { lookup } from 'node:dns/promises' import { Context, z } from 'cordis' @@ -18,7 +18,7 @@ declare module 'cordis' { } } -declare module 'undios' { +declare module '@cordisjs/plugin-http' { namespace HTTP { interface Config { proxyAgent?: string @@ -73,7 +73,7 @@ function socksAgent(result: ParseResult, options: SocksDispatcherOptions = {}) { return new Agent({ ...rest, connect: createConnect(result, connect) }) } -export const name = 'undios-proxy-agent' +export const name = 'proxy-agent' export const inject = ['http'] export interface Config {} diff --git a/tsconfig.json b/tsconfig.json index e259559..94866f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,8 @@ "compilerOptions": { "baseUrl": ".", "paths": { - "undios": ["packages/core/src"], - "undios-*": ["packages/*/src"], + "@cordisjs/plugin-http": ["packages/core/src"], + "@cordisjs/*": ["packages/*/src"], }, }, "files": [],