@things-factory/shell 6.2.44 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/shell",
3
- "version": "6.2.44",
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.33",
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": "a2a1ebf823f6b1315e751b12a01372e9a867d7af"
136
+ "gitHead": "70ed4f01ef662cde4d99911dc9374abd564cbe0e"
137
137
  }
@@ -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 { Column, CreateDateColumn, ManyToOne, OneToMany, RelationId, Entity, Index, UpdateDateColumn } from 'typeorm'
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], { unique: true })
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
  }