@things-factory/auth-base 6.2.70 → 6.2.79

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.
Files changed (35) hide show
  1. package/dist-client/tsconfig.tsbuildinfo +1 -1
  2. package/dist-server/service/application/application-mutation.d.ts +37 -37
  3. package/dist-server/service/application/application-types.js +3 -2
  4. package/dist-server/service/application/application-types.js.map +1 -1
  5. package/dist-server/service/application/application.d.ts +20 -20
  6. package/dist-server/service/application/application.js +7 -16
  7. package/dist-server/service/application/application.js.map +1 -1
  8. package/dist-server/service/domain-generator/domain-generator-types.js +2 -1
  9. package/dist-server/service/domain-generator/domain-generator-types.js.map +1 -1
  10. package/dist-server/service/invitation/invitation-mutation.js +3 -2
  11. package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
  12. package/dist-server/service/invitation/invitation-query.js +2 -1
  13. package/dist-server/service/invitation/invitation-query.js.map +1 -1
  14. package/dist-server/service/invitation/invitation.js +2 -1
  15. package/dist-server/service/invitation/invitation.js.map +1 -1
  16. package/dist-server/service/user/user-mutation.js +6 -5
  17. package/dist-server/service/user/user-mutation.js.map +1 -1
  18. package/dist-server/service/user/user-query.js +3 -2
  19. package/dist-server/service/user/user-query.js.map +1 -1
  20. package/dist-server/service/user/user-types.js +3 -2
  21. package/dist-server/service/user/user-types.js.map +1 -1
  22. package/dist-server/service/user/user.js +2 -1
  23. package/dist-server/service/user/user.js.map +1 -1
  24. package/dist-server/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +5 -5
  26. package/server/service/application/application-types.ts +3 -2
  27. package/server/service/application/application.ts +27 -36
  28. package/server/service/domain-generator/domain-generator-types.ts +2 -1
  29. package/server/service/invitation/invitation-mutation.ts +7 -2
  30. package/server/service/invitation/invitation-query.ts +6 -1
  31. package/server/service/invitation/invitation.ts +2 -1
  32. package/server/service/user/user-mutation.ts +19 -5
  33. package/server/service/user/user-query.ts +3 -2
  34. package/server/service/user/user-types.ts +3 -2
  35. package/server/service/user/user.ts +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/auth-base",
3
- "version": "6.2.70",
3
+ "version": "6.2.79",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -30,10 +30,10 @@
30
30
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
31
31
  },
32
32
  "dependencies": {
33
- "@things-factory/email-base": "^6.2.70",
33
+ "@things-factory/email-base": "^6.2.79",
34
34
  "@things-factory/env": "^6.2.33",
35
- "@things-factory/i18n-base": "^6.2.70",
36
- "@things-factory/shell": "^6.2.70",
35
+ "@things-factory/i18n-base": "^6.2.79",
36
+ "@things-factory/shell": "^6.2.79",
37
37
  "@things-factory/utils": "^6.2.48",
38
38
  "jsonwebtoken": "^9.0.0",
39
39
  "koa-passport": "^6.0.0",
@@ -43,5 +43,5 @@
43
43
  "passport-local": "^1.0.0",
44
44
  "popsicle-cookie-jar": "^1.0.0"
45
45
  },
46
- "gitHead": "99c274f281e62be08a952c10cb3b8fdecba24a65"
46
+ "gitHead": "79bd268667377c76554071d41c5ab50203110a52"
47
47
  }
@@ -1,4 +1,5 @@
1
1
  import { Field, InputType, Int, ObjectType } from 'type-graphql'
2
+ import { GraphQLEmailAddress } from 'graphql-scalars'
2
3
 
3
4
  import { Application, ApplicationType } from './application'
4
5
 
@@ -28,7 +29,7 @@ export class ApplicationPatch {
28
29
  @Field({ nullable: true })
29
30
  description?: string
30
31
 
31
- @Field({ nullable: true })
32
+ @Field(type => GraphQLEmailAddress, { nullable: true })
32
33
  email?: string
33
34
 
34
35
  @Field({ nullable: true })
@@ -55,7 +56,7 @@ export class NewApplication {
55
56
  @Field({ nullable: true })
56
57
  description?: string
57
58
 
58
- @Field({ nullable: true })
59
+ @Field(type => GraphQLEmailAddress, { nullable: true })
59
60
  email?: string
60
61
 
61
62
  @Field({ nullable: true })
@@ -1,6 +1,7 @@
1
1
  import crypto from 'crypto'
2
2
  import jwt from 'jsonwebtoken'
3
3
  import { Directive, Field, ID, ObjectType, registerEnumType } from 'type-graphql'
4
+ import { GraphQLEmailAddress } from 'graphql-scalars'
4
5
  import {
5
6
  Column,
6
7
  CreateDateColumn,
@@ -50,53 +51,45 @@ registerEnumType(ApplicationType, {
50
51
  export class Application {
51
52
  @PrimaryGeneratedColumn('uuid')
52
53
  @Field(type => ID)
53
- readonly id: string
54
+ readonly id?: string
54
55
 
55
56
  @ManyToOne(type => Domain)
56
- domain: Domain
57
+ domain?: Domain
57
58
 
58
59
  @RelationId((application: Application) => application.domain)
59
- domainId: string
60
+ domainId?: string
60
61
 
61
62
  @Column()
62
63
  @Field()
63
- name: string
64
+ name?: string
64
65
 
65
- @Column({
66
- nullable: true
67
- })
66
+ @Column({ nullable: true })
68
67
  @Field({ nullable: true })
69
- description: string
68
+ description?: string
70
69
 
71
70
  @Column()
72
- @Field()
73
- email: string
71
+ @Field(type => GraphQLEmailAddress)
72
+ email?: string
74
73
 
75
74
  @Column()
76
75
  @Field()
77
- url: string
76
+ url?: string
78
77
 
79
- @Column({
80
- nullable: true
81
- })
78
+ @Column({ nullable: true })
82
79
  @Field({ nullable: true })
83
- icon: string
80
+ icon?: string
84
81
 
85
82
  @Column()
86
83
  @Field()
87
- redirectUrl: string
84
+ redirectUrl?: string
88
85
 
89
- @Column({
90
- nullable: true
91
- })
86
+ @Column({ nullable: true })
92
87
  @Field({ nullable: true })
93
- webhook: string
88
+ webhook?: string
94
89
 
95
- @Column({
96
- nullable: true
97
- })
90
+ @Column({ nullable: true })
98
91
  @Field({ nullable: true })
99
- appKey: string
92
+ appKey?: string
100
93
 
101
94
  @Column({
102
95
  nullable: true,
@@ -109,13 +102,11 @@ export class Application {
109
102
  })
110
103
  @Field({ nullable: true })
111
104
  @Directive('@privilege(category: "security", privilege: "query", domainOwnerGranted: true)')
112
- appSecret: string
105
+ appSecret?: string
113
106
 
114
- @Column({
115
- default: ApplicationStatus.DRAFT
116
- })
107
+ @Column({ default: ApplicationStatus.DRAFT })
117
108
  @Field()
118
- status: ApplicationStatus
109
+ status?: ApplicationStatus
119
110
 
120
111
  @Column({
121
112
  type:
@@ -128,29 +119,29 @@ export class Application {
128
119
  default: ApplicationType.OTHERS
129
120
  })
130
121
  @Field()
131
- type: ApplicationType
122
+ type?: ApplicationType
132
123
 
133
124
  @CreateDateColumn()
134
125
  @Field({ nullable: true })
135
- createdAt: Date
126
+ createdAt?: Date
136
127
 
137
128
  @UpdateDateColumn()
138
129
  @Field({ nullable: true })
139
- updatedAt: Date
130
+ updatedAt?: Date
140
131
 
141
132
  @ManyToOne(type => User, { nullable: true })
142
133
  @Field({ nullable: true })
143
- creator: User
134
+ creator?: User
144
135
 
145
136
  @RelationId((application: Application) => application.creator)
146
- creatorId: string
137
+ creatorId?: string
147
138
 
148
139
  @ManyToOne(type => User, { nullable: true })
149
140
  @Field({ nullable: true })
150
- updater: User
141
+ updater?: User
151
142
 
152
143
  @RelationId((application: Application) => application.updater)
153
- updaterId: string
144
+ updaterId?: string
154
145
 
155
146
  /* generateAppSecret */
156
147
  static generateAppSecret() {
@@ -1,4 +1,5 @@
1
1
  import { Field, InputType } from 'type-graphql'
2
+ import { GraphQLEmailAddress } from 'graphql-scalars'
2
3
  import { DomainInput } from '@things-factory/shell'
3
4
  import { NewRole } from '../role/role-types'
4
5
 
@@ -28,7 +29,7 @@ export class NewUserByDomainWizardInput {
28
29
  @Field()
29
30
  name: string
30
31
 
31
- @Field()
32
+ @Field(type => GraphQLEmailAddress)
32
33
  email: string
33
34
 
34
35
  @Field({ nullable: true })
@@ -1,4 +1,5 @@
1
1
  import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'
2
+ import { GraphQLEmailAddress } from 'graphql-scalars'
2
3
 
3
4
  import { getRepository } from '@things-factory/shell'
4
5
 
@@ -8,7 +9,11 @@ import { Invitation } from './invitation'
8
9
  @Resolver(Invitation)
9
10
  export class InvitationMutation {
10
11
  @Mutation(returns => Boolean)
11
- async cancelInvitation(@Arg('email') email: string, @Arg('reference') reference: string, @Arg('type') type: string) {
12
+ async cancelInvitation(
13
+ @Arg('email', type => GraphQLEmailAddress) email: string,
14
+ @Arg('reference') reference: string,
15
+ @Arg('type') type: string
16
+ ) {
12
17
  const repository = getRepository(Invitation)
13
18
 
14
19
  await repository.delete({
@@ -22,7 +27,7 @@ export class InvitationMutation {
22
27
 
23
28
  @Mutation(returns => Invitation)
24
29
  async sendInvitation(
25
- @Arg('email') email: string,
30
+ @Arg('email', type => GraphQLEmailAddress) email: string,
26
31
  @Arg('reference') reference: string,
27
32
  @Arg('type') type: string,
28
33
  @Ctx() context: ResolverContext
@@ -1,3 +1,4 @@
1
+ import { GraphQLEmailAddress } from 'graphql-scalars'
1
2
  import { Arg, Query, Resolver } from 'type-graphql'
2
3
 
3
4
  import { getRepository } from '@things-factory/shell'
@@ -8,7 +9,11 @@ import { InvitationList } from './invitation-types'
8
9
  @Resolver(Invitation)
9
10
  export class InvitationQuery {
10
11
  @Query(returns => Invitation)
11
- async invitation(@Arg('email') email: string, @Arg('reference') reference: string, @Arg('type') type: string) {
12
+ async invitation(
13
+ @Arg('email', type => GraphQLEmailAddress) email: string,
14
+ @Arg('reference') reference: string,
15
+ @Arg('type') type: string
16
+ ) {
12
17
  return await getRepository(Invitation).findOneBy({
13
18
  email,
14
19
  reference,
@@ -9,6 +9,7 @@ import {
9
9
  PrimaryGeneratedColumn
10
10
  } from 'typeorm'
11
11
  import { ObjectType, Field, ID } from 'type-graphql'
12
+ import { GraphQLEmailAddress } from 'graphql-scalars'
12
13
  import { User } from '../user/user'
13
14
 
14
15
  @Entity()
@@ -23,7 +24,7 @@ export class Invitation {
23
24
  readonly id: string
24
25
 
25
26
  @Column()
26
- @Field()
27
+ @Field(type => GraphQLEmailAddress)
27
28
  email: string
28
29
 
29
30
  @Column()
@@ -1,4 +1,5 @@
1
1
  import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
+ import { GraphQLEmailAddress } from 'graphql-scalars'
2
3
  import { ILike, In, SelectQueryBuilder } from 'typeorm'
3
4
 
4
5
  import { config } from '@things-factory/env'
@@ -54,7 +55,11 @@ export class UserMutation {
54
55
  @Directive('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)')
55
56
  @Directive('@transaction')
56
57
  @Mutation(returns => User, { description: 'To modify user information' })
57
- async updateUser(@Arg('email') email: string, @Arg('patch') patch: UserPatch, @Ctx() context: ResolverContext) {
58
+ async updateUser(
59
+ @Arg('email', type => GraphQLEmailAddress) email: string,
60
+ @Arg('patch') patch: UserPatch,
61
+ @Ctx() context: ResolverContext
62
+ ) {
58
63
  const { domain, user: updater }: { domain: Domain; user: User } = context.state
59
64
  const qb: SelectQueryBuilder<User> = buildDomainUsersQueryBuilder(domain.id, 'USER')
60
65
  const user: User = await qb
@@ -174,7 +179,7 @@ export class UserMutation {
174
179
  @Directive('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)')
175
180
  @Directive('@transaction')
176
181
  @Mutation(returns => Boolean, { description: 'To delete a user' })
177
- async deleteUser(@Arg('email') email: string, @Ctx() context: ResolverContext) {
182
+ async deleteUser(@Arg('email', type => GraphQLEmailAddress) email: string, @Ctx() context: ResolverContext) {
178
183
  const { tx } = context.state
179
184
 
180
185
  await commonDeleteUser({ email }, tx)
@@ -194,7 +199,10 @@ export class UserMutation {
194
199
 
195
200
  @Directive('@transaction')
196
201
  @Mutation(returns => Boolean, { description: 'To invite new user' })
197
- async inviteUser(@Arg('email') email: string, @Ctx() context: ResolverContext): Promise<boolean> {
202
+ async inviteUser(
203
+ @Arg('email', type => GraphQLEmailAddress) email: string,
204
+ @Ctx() context: ResolverContext
205
+ ): Promise<boolean> {
198
206
  const { domain } = context.state
199
207
  const invitee: User = await getRepository(User).findOne({
200
208
  where: { email: ILike(email) },
@@ -218,7 +226,10 @@ export class UserMutation {
218
226
  @Directive('@transaction')
219
227
  @Directive('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)')
220
228
  @Mutation(returns => Boolean, { description: 'To delete domain user' })
221
- async deleteDomainUser(@Arg('email') email: string, @Ctx() context: ResolverContext): Promise<boolean> {
229
+ async deleteDomainUser(
230
+ @Arg('email', type => GraphQLEmailAddress) email: string,
231
+ @Ctx() context: ResolverContext
232
+ ): Promise<boolean> {
222
233
  const { tx, domain } = context.state
223
234
 
224
235
  let user: User = await tx
@@ -247,7 +258,10 @@ export class UserMutation {
247
258
  @Directive('@privilege(domainOwnerGranted: true, superUserGranted: true)')
248
259
  @Directive('@transaction')
249
260
  @Mutation(returns => Boolean, { description: 'To transfer owner of domain' })
250
- async transferOwner(@Arg('email') email: string, @Ctx() context: ResolverContext): Promise<boolean> {
261
+ async transferOwner(
262
+ @Arg('email', type => GraphQLEmailAddress) email: string,
263
+ @Ctx() context: ResolverContext
264
+ ): Promise<boolean> {
251
265
  const { domain } = context.state
252
266
  const user: User = await getRepository(User).findOne({
253
267
  where: { email: ILike(email) }
@@ -1,4 +1,5 @@
1
1
  import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
2
+ import { GraphQLEmailAddress } from 'graphql-scalars'
2
3
  import { ILike, SelectQueryBuilder } from 'typeorm'
3
4
 
4
5
  import { config } from '@things-factory/env'
@@ -15,7 +16,7 @@ import { UserList } from './user-types'
15
16
  export class UserQuery {
16
17
  @Directive('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)')
17
18
  @Query(returns => User, { description: 'To fetch user' })
18
- async user(@Arg('email') email: string, @Ctx() context: ResolverContext): Promise<User> {
19
+ async user(@Arg('email', type => GraphQLEmailAddress) email: string, @Ctx() context: ResolverContext): Promise<User> {
19
20
  const { domain } = context.state
20
21
 
21
22
  const qb: SelectQueryBuilder<User> = buildDomainUsersQueryBuilder(domain.id, 'USER')
@@ -116,7 +117,7 @@ export class UserQuery {
116
117
 
117
118
  @Directive('@privilege(category: "user", privilege: "query")')
118
119
  @Query(returns => Boolean, { description: '...' })
119
- async checkUserExistence(@Arg('email') email: string): Promise<Boolean> {
120
+ async checkUserExistence(@Arg('email', type => GraphQLEmailAddress) email: string): Promise<Boolean> {
120
121
  return Boolean(await getRepository(User).count({ where: { email: ILike(email) } }))
121
122
  }
122
123
 
@@ -1,4 +1,5 @@
1
1
  import { ObjectType, InputType, Field, ID, Int } from 'type-graphql'
2
+ import { GraphQLEmailAddress } from 'graphql-scalars'
2
3
  import { ObjectRef } from '@things-factory/shell'
3
4
  import { User } from './user'
4
5
 
@@ -10,7 +11,7 @@ export class NewUser {
10
11
  @Field({ nullable: true })
11
12
  description?: string
12
13
 
13
- @Field()
14
+ @Field(type => GraphQLEmailAddress)
14
15
  email: string
15
16
 
16
17
  @Field({ nullable: true })
@@ -37,7 +38,7 @@ export class UserPatch {
37
38
  @Field({ nullable: true })
38
39
  description?: string
39
40
 
40
- @Field({ nullable: true })
41
+ @Field(type => GraphQLEmailAddress, { nullable: true })
41
42
  email?: string
42
43
 
43
44
  @Field({ nullable: true })
@@ -1,6 +1,7 @@
1
1
  import crypto from 'crypto'
2
2
  import jwt from 'jsonwebtoken'
3
3
  import { Directive, Field, ID, ObjectType } from 'type-graphql'
4
+ import { GraphQLEmailAddress } from 'graphql-scalars'
4
5
  import {
5
6
  Column,
6
7
  CreateDateColumn,
@@ -64,7 +65,7 @@ export class User {
64
65
  domains?: Domain[]
65
66
 
66
67
  @Column()
67
- @Field()
68
+ @Field(type => GraphQLEmailAddress)
68
69
  email: string
69
70
 
70
71
  @Directive('@privilege(category: "security", privilege: "query", domainOwnerGranted: true)')