Skip to content

Commit

Permalink
refactor and add test (#414)
Browse files Browse the repository at this point in the history
* refactor and add test
* remove auth hint on login
  • Loading branch information
Roy Razon authored Feb 1, 2024
1 parent bcc2401 commit b685ef9
Show file tree
Hide file tree
Showing 14 changed files with 750 additions and 237 deletions.
10 changes: 5 additions & 5 deletions tunnel-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { promisify } from 'util'
import pino from 'pino'
import fs from 'fs'
import { KeyObject, createPublicKey } from 'crypto'
import { buildLoginUrl, app as createApp } from './src/app.js'
import { createApp } from './src/app/index.js'
import { activeTunnelStoreKey, inMemoryActiveTunnelStore } from './src/tunnel-store/index.js'
import { getSSHKeys } from './src/ssh-keys.js'
import { proxy } from './src/proxy/index.js'
Expand All @@ -13,6 +13,7 @@ import { editUrl } from './src/url.js'
import { cookieSessionStore } from './src/session.js'
import { IdentityProvider, claimsSchema, cliIdentityProvider, jwtAuthenticator, saasIdentityProvider } from './src/auth.js'
import { createSshServer } from './src/ssh/index.js'
import { calcLoginUrl } from './src/app/urls.js'

const log = pino.default(appLoggerFromEnv())

Expand Down Expand Up @@ -73,8 +74,7 @@ const authFactory = (

const activeTunnelStore = inMemoryActiveTunnelStore({ log })
const sessionStore = cookieSessionStore({ domain: BASE_URL.hostname, schema: claimsSchema, keys: process.env.COOKIE_SECRETS?.split(' ') })

const app = createApp({
const app = await createApp({
sessionStore,
activeTunnelStore,
baseUrl: BASE_URL,
Expand All @@ -84,11 +84,11 @@ const app = createApp({
sessionStore,
baseHostname: BASE_URL.hostname,
authFactory,
loginUrl: ({ env, returnPath }) => buildLoginUrl({ baseUrl: BASE_URL, env, returnPath }),
loginUrl: ({ env, returnPath }) => calcLoginUrl({ baseUrl: BASE_URL, env, returnPath }),
}),
log,
authFactory,
saasBaseUrl: saasIdp ? requiredEnv('SAAS_BASE_URL') : undefined,
saasBaseUrl: saasIdp ? new URL(requiredEnv('SAAS_BASE_URL')) : undefined,
})

const tunnelUrl = (
Expand Down
11 changes: 8 additions & 3 deletions tunnel-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@
"name": "@preevy/tunnel-server",
"version": "1.0.6",
"main": "dist/index.mjs",
"files": ["dist"],
"files": [
"dist"
],
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@fastify/cors": "^8.3.0",
"@fastify/request-context": "^5.0.0",
"@sindresorhus/fnv1a": "^3.0.0",
"content-type": "^1.0.5",
"cookies": "^0.8.0",
"fastify": "^4.22.2",
"fastify-type-provider-zod": "^1.1.9",
"htmlparser2": "^9.0.0",
"http-proxy": "^1.18.1",
"iconv-lite": "^0.6.3",
"jose": "^4.14.4",
"lodash-es": "^4.17.21",
"node-fetch": "2.6.9",
"p-timeout": "^6.1.2",
"pino": "^8.11.0",
"pino-pretty": "^10.2.3",
"prom-client": "^14.2.0",
"ssh2": "^1.12.0",
"tough-cookie": "^4.1.3",
"ts-pattern": "^5.0.5",
"tseep": "^1.1.1",
"zod": "^3.22.4"
Expand All @@ -36,8 +40,8 @@
"@types/http-proxy": "^1.17.9",
"@types/lodash-es": "^4.17.12",
"@types/node": "18",
"@types/node-fetch": "^2.6.4",
"@types/ssh2": "^1.11.8",
"@types/tough-cookie": "^4.0.3",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@typescript-eslint/parser": "6.14.0",
"esbuild": "^0.19.9",
Expand All @@ -47,6 +51,7 @@
"nodemon": "^2.0.20",
"ts-jest": "29.1.1",
"typescript": "^5.3.3",
"undici": "^6.4.0",
"wait-for-expect": "^3.0.2"
},
"scripts": {
Expand Down
142 changes: 0 additions & 142 deletions tunnel-server/src/app.ts

This file was deleted.

Loading

0 comments on commit b685ef9

Please sign in to comment.