@things-factory/shell 6.2.42 → 6.2.48
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/dist-server/routers/global-router.js +12 -0
- package/dist-server/routers/global-router.js.map +1 -1
- package/dist-server/server-dev.js +11 -0
- package/dist-server/server-dev.js.map +1 -1
- package/dist-server/server.js +11 -0
- package/dist-server/server.js.map +1 -1
- package/dist-server/service/domain/domain.d.ts +1 -0
- package/dist-server/service/domain/domain.js +9 -1
- package/dist-server/service/domain/domain.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/get-domain.js +12 -1
- package/dist-server/utils/get-domain.js.map +1 -1
- package/package.json +3 -3
- package/server/routers/global-router.ts +14 -0
- package/server/server-dev.ts +14 -0
- package/server/server.ts +14 -0
- package/server/service/domain/domain.ts +19 -2
- package/server/utils/get-domain.ts +16 -1
@@ -21,7 +21,18 @@ function getUrlFromContext(context, path = '') {
|
|
21
21
|
}
|
22
22
|
}
|
23
23
|
let url = new url_1.URL(path, base);
|
24
|
-
|
24
|
+
const originalProtocol = context.headers['x-forwarded-proto'];
|
25
|
+
const originalHost = context.headers['x-forwarded-host'];
|
26
|
+
const originalPort = context.headers['x-forwarded-port'];
|
27
|
+
if (protocol || originalProtocol) {
|
28
|
+
url.protocol = protocol || originalProtocol;
|
29
|
+
}
|
30
|
+
if (originalHost) {
|
31
|
+
url.host = originalHost;
|
32
|
+
if (originalPort) {
|
33
|
+
url.port = originalPort;
|
34
|
+
}
|
35
|
+
}
|
25
36
|
return url;
|
26
37
|
}
|
27
38
|
exports.getUrlFromContext = getUrlFromContext;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-domain.js","sourceRoot":"","sources":["../../server/utils/get-domain.ts"],"names":[],"mappings":";;;AAAA,6BAAyB;AAEzB,6CAA4C;AAC5C,iDAAmD;AAEnD,uDAAwD;AACxD,qDAAiD;AAEjD,MAAM,yBAAyB,GAAG,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config } from '@things-factory/env'\nimport { getPathInfo } from '@things-factory/utils'\n\nimport { getRepository } from '../initializers/database'\nimport { Domain } from '../service/domain/domain'\n\nconst useVirtualHostBasedDomain = !!config.get('useVirtualHostBasedDomain')\nconst protocol: string = config.get('protocol')\nconst fixed = config.get('subdomain')\nconst subdomainOffset = config.getNumber('subdomainOffset', 2)\n\nexport function getUrlFromContext(context, path = '') {\n const { method, href, host, header } = context\n const { referer } = header || {}\n\n var base = href\n\n if (method !== 'GET' && referer) {\n var { host: refererHost } = new URL(referer)\n if (refererHost === host) {\n base = referer\n }\n }\n\n let url: URL = new URL(path, base)\n\n const originalProtocol = context.headers['x-forwarded-proto']\n const originalHost = context.headers['x-forwarded-host']\n const originalPort = context.headers['x-forwarded-port']\n\n if (protocol || originalProtocol) {\n url.protocol = protocol || originalProtocol\n }\n\n if (originalHost) {\n url.host = originalHost\n if (originalPort) {\n url.port = originalPort\n }\n }\n\n return url\n}\n\nfunction getSubdomainsFromHost(context: any) {\n const { request } = context\n var subdomains = request.headers.host.split('.').reverse()\n return subdomains.slice(subdomainOffset)\n}\n\nfunction getSubdomainFromPath(context: any) {\n var { path } = context\n\n var domain = getPathInfo(path || '')?.domain\n if (domain) {\n return domain\n }\n\n var {\n header: { referer }\n } = context\n\n if (referer) {\n var { pathname } = new URL(referer)\n return getPathInfo(pathname || '')?.domain\n }\n}\n\nfunction getSubdomainFromVhost(context: any) {\n const subdomain = (context.subdomains || getSubdomainsFromHost(context)).slice(-1)[0]\n\n return subdomain\n}\n\nfunction getSubdomainFromURL(context) {\n return fixed || (useVirtualHostBasedDomain ? getSubdomainFromVhost(context) : getSubdomainFromPath(context))\n}\n\nexport async function getDomainFromURL(context: any): Promise<Domain> {\n const { header } = context\n\n const subdomain = header['x-things-factory-domain'] || getSubdomainFromURL(context)\n\n if (subdomain) {\n return await getRepository(Domain).findOne({ where: { subdomain }, cache: true })\n }\n}\n\nexport function getCookieDomainFromHostname(hostname) {\n if (useVirtualHostBasedDomain) {\n return hostname.split('.').slice(-subdomainOffset).join('.')\n }\n}\n\nexport function getContextPath(subdomain) {\n return fixed || useVirtualHostBasedDomain ? '' : '/domain/' + subdomain\n}\n\nexport function getRedirectSubdomainPath(context, subdomain, redirectTo = '/') {\n if (fixed) {\n return redirectTo || '/'\n }\n\n var parsed = getUrlFromContext(context, redirectTo)\n var { hostname, pathname } = parsed\n\n if (useVirtualHostBasedDomain) {\n const splitHost = hostname.split('.').reverse()\n splitHost[subdomainOffset] = subdomain\n parsed.hostname = splitHost\n .reverse()\n .filter(a => a)\n .join('.')\n } else {\n const contextPath = `/domain/${subdomain}`\n const match = pathname.match(/^\\/domain\\/([^\\/]+)/)\n\n if (match) {\n parsed.pathname = pathname.replace(match[0], contextPath)\n } else {\n parsed.pathname = `${contextPath}${pathname}`\n }\n }\n\n return parsed.toString()\n}\n\nexport function findSubdomainFromPath(context, path) {\n if (fixed) {\n return fixed\n }\n\n var parsed = getUrlFromContext(context, path)\n var { hostname, pathname } = parsed\n\n if (useVirtualHostBasedDomain) {\n return hostname.split('.').reverse()[subdomainOffset]\n }\n\n const match = pathname.match(/^\\/domain\\/([^\\/]+)/)\n return match && match[1]\n}\n\nexport function getSiteRootPath(context) {\n if (useVirtualHostBasedDomain) {\n var { protocol, host } = context\n protocol = protocol.replace(':', '')\n\n let domainname = host.split('.').slice(-subdomainOffset).join('.')\n return protocol + '://' + domainname + '/'\n } else {\n return '/'\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/shell",
|
3
|
-
"version": "6.2.
|
3
|
+
"version": "6.2.48",
|
4
4
|
"description": "Core module for framework",
|
5
5
|
"bin": {
|
6
6
|
"things-factory": "bin/things-factory",
|
@@ -63,7 +63,7 @@
|
|
63
63
|
"@things-factory/env": "^6.2.33",
|
64
64
|
"@things-factory/operato-license-checker": "^4.0.4",
|
65
65
|
"@things-factory/styles": "^6.2.33",
|
66
|
-
"@things-factory/utils": "^6.2.
|
66
|
+
"@things-factory/utils": "^6.2.48",
|
67
67
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
68
68
|
"args": "^5.0.0",
|
69
69
|
"broadcastchannel-polyfill": "^1.0.1",
|
@@ -133,5 +133,5 @@
|
|
133
133
|
"pg": "^8.7.3",
|
134
134
|
"sqlite3": "^5.0.8"
|
135
135
|
},
|
136
|
-
"gitHead": "
|
136
|
+
"gitHead": "70ed4f01ef662cde4d99911dc9374abd564cbe0e"
|
137
137
|
}
|
@@ -53,6 +53,20 @@ globalPublicRouter.get('/opensource-licenses', (context, next) => {
|
|
53
53
|
})
|
54
54
|
})
|
55
55
|
|
56
|
+
globalPublicRouter.get('/request-info', context => {
|
57
|
+
const clientIP = context.headers['x-forwarded-for'] || context.ip
|
58
|
+
const protocol = context.headers['x-forwarded-proto'] || context.protocol
|
59
|
+
const host = context.headers['x-forwarded-host'] || context.host
|
60
|
+
const port = context.headers['x-forwarded-port'] || context.host.split(':')[1]
|
61
|
+
|
62
|
+
context.body = `
|
63
|
+
Client IP: ${clientIP}
|
64
|
+
Protocol: ${protocol}
|
65
|
+
Host: ${host}
|
66
|
+
Port: ${port}
|
67
|
+
`
|
68
|
+
})
|
69
|
+
|
56
70
|
/* Paths starting with /public are assumed to use the koa-view renderer. */
|
57
71
|
globalPublicRouter.get('/public/(.[^.]*)', async (context, next) => {
|
58
72
|
const { path } = context
|
package/server/server-dev.ts
CHANGED
@@ -22,6 +22,7 @@ import { historyApiFallback } from 'koa2-connect-history-api-fallback'
|
|
22
22
|
import { WebSocketServer } from 'ws'
|
23
23
|
import co from 'co'
|
24
24
|
import http from 'http'
|
25
|
+
import requestIp from 'request-ip'
|
25
26
|
|
26
27
|
import koaWebpack from '@hatiolab/koa-webpack'
|
27
28
|
import cors from '@koa/cors'
|
@@ -117,6 +118,7 @@ const bootstrap = async () => {
|
|
117
118
|
|
118
119
|
const whitelist = config.get('whitelist')
|
119
120
|
const blacklist = config.get('blacklist')
|
121
|
+
const protectedlist = config.get('protectedlist')
|
120
122
|
|
121
123
|
if (whitelist || blacklist) {
|
122
124
|
app.use(
|
@@ -130,6 +132,18 @@ const bootstrap = async () => {
|
|
130
132
|
)
|
131
133
|
}
|
132
134
|
|
135
|
+
if (protectedlist) {
|
136
|
+
app.use((context, next) => {
|
137
|
+
const ip = context.ip || requestIp.getClientIp(context.req)
|
138
|
+
|
139
|
+
context.state.protected = protectedlist.some(item => {
|
140
|
+
return new RegExp(item).test(ip)
|
141
|
+
})
|
142
|
+
|
143
|
+
return next()
|
144
|
+
})
|
145
|
+
}
|
146
|
+
|
133
147
|
var subscriptionMiddleware = []
|
134
148
|
process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)
|
135
149
|
|
package/server/server.ts
CHANGED
@@ -22,6 +22,7 @@ import { historyApiFallback } from 'koa2-connect-history-api-fallback'
|
|
22
22
|
import { WebSocketServer } from 'ws'
|
23
23
|
import co from 'co'
|
24
24
|
import http from 'http'
|
25
|
+
import requestIp from 'request-ip'
|
25
26
|
|
26
27
|
import cors from '@koa/cors'
|
27
28
|
import { config, loader, logger, orderedModuleNames } from '@things-factory/env'
|
@@ -92,6 +93,7 @@ const bootstrap = async () => {
|
|
92
93
|
|
93
94
|
const whitelist = config.get('whitelist')
|
94
95
|
const blacklist = config.get('blacklist')
|
96
|
+
const protectedlist = config.get('protectedlist')
|
95
97
|
|
96
98
|
if (whitelist || blacklist) {
|
97
99
|
app.use(
|
@@ -105,6 +107,18 @@ const bootstrap = async () => {
|
|
105
107
|
)
|
106
108
|
}
|
107
109
|
|
110
|
+
if (protectedlist) {
|
111
|
+
app.use((context, next) => {
|
112
|
+
const ip = context.ip || requestIp.getClientIp(context.req)
|
113
|
+
|
114
|
+
context.state.protected = protectedlist.some(item => {
|
115
|
+
return new RegExp(item).test(ip)
|
116
|
+
})
|
117
|
+
|
118
|
+
return next()
|
119
|
+
})
|
120
|
+
}
|
121
|
+
|
108
122
|
var subscriptionMiddleware = []
|
109
123
|
process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)
|
110
124
|
|
@@ -1,4 +1,14 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
Column,
|
3
|
+
CreateDateColumn,
|
4
|
+
ManyToOne,
|
5
|
+
OneToMany,
|
6
|
+
RelationId,
|
7
|
+
Entity,
|
8
|
+
Index,
|
9
|
+
UpdateDateColumn,
|
10
|
+
DeleteDateColumn
|
11
|
+
} from 'typeorm'
|
2
12
|
import { ObjectType, Directive, Field, ID } from 'type-graphql'
|
3
13
|
import { config } from '@things-factory/env'
|
4
14
|
import { ScalarObject } from '../common-types'
|
@@ -10,7 +20,10 @@ const domainPrimaryType = domainPrimaryOption?.type
|
|
10
20
|
const domainPrimaryStrategy = domainPrimaryOption?.strategy
|
11
21
|
|
12
22
|
@Entity()
|
13
|
-
@Index('ix_domain_0', (domain: Domain) => [domain.subdomain], {
|
23
|
+
@Index('ix_domain_0', (domain: Domain) => [domain.subdomain, domain.deletedAt], {
|
24
|
+
unique: true,
|
25
|
+
where: '"deleted_at" IS NULL'
|
26
|
+
})
|
14
27
|
@ObjectType()
|
15
28
|
export class Domain {
|
16
29
|
@Field(type => ID)
|
@@ -113,4 +126,8 @@ export class Domain {
|
|
113
126
|
@Field({ nullable: true })
|
114
127
|
@UpdateDateColumn()
|
115
128
|
updatedAt: Date
|
129
|
+
|
130
|
+
@DeleteDateColumn()
|
131
|
+
@Field({ nullable: true })
|
132
|
+
deletedAt?: Date
|
116
133
|
}
|
@@ -25,7 +25,22 @@ export function getUrlFromContext(context, path = '') {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
let url: URL = new URL(path, base)
|
28
|
-
|
28
|
+
|
29
|
+
const originalProtocol = context.headers['x-forwarded-proto']
|
30
|
+
const originalHost = context.headers['x-forwarded-host']
|
31
|
+
const originalPort = context.headers['x-forwarded-port']
|
32
|
+
|
33
|
+
if (protocol || originalProtocol) {
|
34
|
+
url.protocol = protocol || originalProtocol
|
35
|
+
}
|
36
|
+
|
37
|
+
if (originalHost) {
|
38
|
+
url.host = originalHost
|
39
|
+
if (originalPort) {
|
40
|
+
url.port = originalPort
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
29
44
|
return url
|
30
45
|
}
|
31
46
|
|