@stacksjs/tunnel 0.70.55 → 0.70.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -7
- package/src/index.ts +0 -42
- package/src/localtunnels.d.ts +0 -66
- package/src/shims.d.ts +0 -9
- package/src/tunnel.ts +0 -63
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/tunnel.d.ts → tunnel.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/tunnel",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.57",
|
|
5
5
|
"description": "Local development tunnel.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -27,20 +27,23 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"development": "./src/index.ts",
|
|
31
|
+
"bun": "./dist/index.js",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
32
34
|
},
|
|
33
35
|
"./*": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
+
"development": "./src/*",
|
|
37
|
+
"bun": "./dist/*",
|
|
38
|
+
"import": "./dist/*",
|
|
39
|
+
"default": "./dist/*"
|
|
36
40
|
}
|
|
37
41
|
},
|
|
38
42
|
"module": "dist/index.js",
|
|
39
43
|
"types": "dist/index.d.ts",
|
|
40
44
|
"files": [
|
|
41
45
|
"README.md",
|
|
42
|
-
"dist"
|
|
43
|
-
"src"
|
|
46
|
+
"dist"
|
|
44
47
|
],
|
|
45
48
|
"scripts": {
|
|
46
49
|
"build": "bun build.ts",
|
package/src/index.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/// <reference path="./shims.d.ts" />
|
|
2
|
-
import type { LocalTunnel, TunnelOptions } from './tunnel'
|
|
3
|
-
import { localTunnel } from './tunnel'
|
|
4
|
-
|
|
5
|
-
export async function createLocalTunnel(port: number): Promise<string> {
|
|
6
|
-
const tunnel = await localTunnel({ port })
|
|
7
|
-
return tunnel.url
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Deploy a tunnel server to AWS EC2.
|
|
12
|
-
* Only needed for custom domains — localtunnel.dev is the shared default.
|
|
13
|
-
*/
|
|
14
|
-
export async function deployTunnelServer(config: {
|
|
15
|
-
domain: string
|
|
16
|
-
region?: string
|
|
17
|
-
instanceType?: string
|
|
18
|
-
prefix?: string
|
|
19
|
-
enableSsl?: boolean
|
|
20
|
-
porkbunApiKey?: string
|
|
21
|
-
porkbunSecretKey?: string
|
|
22
|
-
verbose?: boolean
|
|
23
|
-
}) {
|
|
24
|
-
const { deployTunnelInfrastructure } = await import('localtunnels/cloud')
|
|
25
|
-
return deployTunnelInfrastructure(config)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Destroy a previously deployed tunnel server from AWS.
|
|
30
|
-
*/
|
|
31
|
-
export async function destroyTunnelServer(config: {
|
|
32
|
-
domain?: string
|
|
33
|
-
region?: string
|
|
34
|
-
prefix?: string
|
|
35
|
-
verbose?: boolean
|
|
36
|
-
}) {
|
|
37
|
-
const { destroyTunnelInfrastructure } = await import('localtunnels/cloud')
|
|
38
|
-
return destroyTunnelInfrastructure(config)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { localTunnel }
|
|
42
|
-
export type { LocalTunnel, TunnelOptions }
|
package/src/localtunnels.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// Type declarations for localtunnels package
|
|
2
|
-
// The published package has broken exports paths (dtsx issue)
|
|
3
|
-
// These declarations bridge the gap until the package is fixed
|
|
4
|
-
|
|
5
|
-
declare module 'localtunnels' {
|
|
6
|
-
import { EventEmitter } from 'node:events'
|
|
7
|
-
|
|
8
|
-
export function startLocalTunnel(_options: {
|
|
9
|
-
port: number
|
|
10
|
-
subdomain?: string
|
|
11
|
-
host?: string
|
|
12
|
-
server?: string
|
|
13
|
-
verbose?: boolean
|
|
14
|
-
timeout?: number
|
|
15
|
-
maxReconnectAttempts?: number
|
|
16
|
-
manageHosts?: boolean
|
|
17
|
-
onConnect?: (info: { url: string, subdomain: string }) => void
|
|
18
|
-
onRequest?: (req: { method: string, url: string }) => void
|
|
19
|
-
onResponse?: (res: { status: number, size: number, duration?: number }) => void
|
|
20
|
-
onError?: (error: Error) => void
|
|
21
|
-
onReconnecting?: (info: { attempt: number, delay: number }) => void
|
|
22
|
-
}): Promise<TunnelClient>
|
|
23
|
-
|
|
24
|
-
export class TunnelClient extends EventEmitter {
|
|
25
|
-
getState(): string
|
|
26
|
-
connect(): Promise<void>
|
|
27
|
-
disconnect(): Promise<void>
|
|
28
|
-
isConnected(): boolean
|
|
29
|
-
getSubdomain(): string
|
|
30
|
-
getTunnelUrl(): string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class TunnelServer extends EventEmitter {
|
|
34
|
-
start(): Promise<void>
|
|
35
|
-
stop(): void
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module 'localtunnels/cloud' {
|
|
40
|
-
export interface TunnelDeployConfig {
|
|
41
|
-
region?: string
|
|
42
|
-
prefix?: string
|
|
43
|
-
domain?: string
|
|
44
|
-
hostedZoneId?: string
|
|
45
|
-
instanceType?: string
|
|
46
|
-
keyName?: string
|
|
47
|
-
verbose?: boolean
|
|
48
|
-
enableSsl?: boolean
|
|
49
|
-
porkbunApiKey?: string
|
|
50
|
-
porkbunSecretKey?: string
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface TunnelDeployResult {
|
|
54
|
-
publicIp: string
|
|
55
|
-
instanceId: string
|
|
56
|
-
securityGroupId: string
|
|
57
|
-
allocationId: string
|
|
58
|
-
serverUrl: string
|
|
59
|
-
wsUrl: string
|
|
60
|
-
domain?: string
|
|
61
|
-
region: string
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function deployTunnelInfrastructure(config?: TunnelDeployConfig): Promise<TunnelDeployResult>
|
|
65
|
-
export function destroyTunnelInfrastructure(config?: TunnelDeployConfig): Promise<void>
|
|
66
|
-
}
|
package/src/shims.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module 'localtunnels/cloud' {
|
|
2
|
-
export function deployTunnelInfrastructure(config: Record<string, unknown>): Promise<unknown>
|
|
3
|
-
export function destroyTunnelInfrastructure(config: Record<string, unknown>): Promise<unknown>
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module 'localtunnels' {
|
|
7
|
-
export type TunnelClient = any
|
|
8
|
-
export function startLocalTunnel(options?: any): Promise<any>
|
|
9
|
-
}
|
package/src/tunnel.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/// <reference path="./shims.d.ts" />
|
|
2
|
-
import type { TunnelClient } from 'localtunnels'
|
|
3
|
-
import { startLocalTunnel } from 'localtunnels'
|
|
4
|
-
|
|
5
|
-
export interface TunnelOptions {
|
|
6
|
-
/** Local port to expose through the tunnel */
|
|
7
|
-
port: number
|
|
8
|
-
/** Tunnel server URL (default: api.localtunnel.dev) */
|
|
9
|
-
server?: string
|
|
10
|
-
/** Request a specific subdomain */
|
|
11
|
-
subdomain?: string
|
|
12
|
-
/** Enable verbose logging */
|
|
13
|
-
verbose?: boolean
|
|
14
|
-
/** Connection timeout in milliseconds */
|
|
15
|
-
timeout?: number
|
|
16
|
-
/** Maximum reconnection attempts */
|
|
17
|
-
maxReconnectAttempts?: number
|
|
18
|
-
/** Called when tunnel connects */
|
|
19
|
-
onConnect?: (info: { url: string, subdomain: string }) => void
|
|
20
|
-
/** Called on each proxied request */
|
|
21
|
-
onRequest?: (req: { method: string, url: string }) => void
|
|
22
|
-
/** Called on each proxied response */
|
|
23
|
-
onResponse?: (res: { status: number, size: number, duration?: number }) => void
|
|
24
|
-
/** Called on error */
|
|
25
|
-
onError?: (error: Error) => void
|
|
26
|
-
/** Called when reconnecting */
|
|
27
|
-
onReconnecting?: (info: { attempt: number, delay: number }) => void
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface LocalTunnel {
|
|
31
|
-
url: string
|
|
32
|
-
subdomain: string
|
|
33
|
-
client: TunnelClient
|
|
34
|
-
close: () => Promise<void>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export async function localTunnel(options?: TunnelOptions | { port: number }): Promise<LocalTunnel> {
|
|
38
|
-
const opts: TunnelOptions = options || { port: 3000 }
|
|
39
|
-
const port = opts.port || 3000
|
|
40
|
-
|
|
41
|
-
const tunnelOpts: Parameters<typeof startLocalTunnel>[0] = {
|
|
42
|
-
port,
|
|
43
|
-
...(opts.server ? { server: opts.server } : {}),
|
|
44
|
-
...(opts.subdomain ? { subdomain: opts.subdomain } : {}),
|
|
45
|
-
...(opts.verbose !== undefined ? { verbose: opts.verbose } : {}),
|
|
46
|
-
...(opts.timeout ? { timeout: opts.timeout } : {}),
|
|
47
|
-
...(opts.maxReconnectAttempts ? { maxReconnectAttempts: opts.maxReconnectAttempts } : {}),
|
|
48
|
-
...(opts.onConnect ? { onConnect: opts.onConnect } : {}),
|
|
49
|
-
...(opts.onRequest ? { onRequest: opts.onRequest } : {}),
|
|
50
|
-
...(opts.onResponse ? { onResponse: opts.onResponse } : {}),
|
|
51
|
-
...(opts.onError ? { onError: opts.onError } : {}),
|
|
52
|
-
...(opts.onReconnecting ? { onReconnecting: opts.onReconnecting } : {}),
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const client = await startLocalTunnel(tunnelOpts)
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
url: client.getTunnelUrl(),
|
|
59
|
-
subdomain: client.getSubdomain(),
|
|
60
|
-
client,
|
|
61
|
-
close: () => client.disconnect() as Promise<void>,
|
|
62
|
-
}
|
|
63
|
-
}
|
|
File without changes
|
|
File without changes
|