@things-factory/oauth2-client 8.0.0-beta.9 → 8.0.2
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/client/bootstrap.ts +1 -0
- package/client/index.ts +0 -0
- package/client/pages/oauth2-client/oauth2-client-importer.ts +87 -0
- package/client/pages/oauth2-client/oauth2-client-list-page.ts +312 -0
- package/client/pages/oauth2-client-register.ts +189 -0
- package/client/pages/oauth2-client.ts +636 -0
- package/client/pages/oauth2-clients.ts +188 -0
- package/client/route.ts +15 -0
- package/client/tsconfig.json +13 -0
- package/dist-client/pages/oauth2-client-register.js +3 -15
- package/dist-client/pages/oauth2-client-register.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/server/index.ts +3 -0
- package/server/routes.ts +156 -0
- package/server/service/index.ts +17 -0
- package/server/service/oauth2-client/index.ts +6 -0
- package/server/service/oauth2-client/oauth2-client-mutation.ts +202 -0
- package/server/service/oauth2-client/oauth2-client-query.ts +53 -0
- package/server/service/oauth2-client/oauth2-client-type.ts +127 -0
- package/server/service/oauth2-client/oauth2-client.ts +152 -0
- package/server/tsconfig.json +11 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Field, ID, ObjectType } from 'type-graphql'
|
|
2
|
+
import { GraphQLJWT } from 'graphql-scalars'
|
|
3
|
+
import {
|
|
4
|
+
Column,
|
|
5
|
+
CreateDateColumn,
|
|
6
|
+
Entity,
|
|
7
|
+
Index,
|
|
8
|
+
ManyToOne,
|
|
9
|
+
PrimaryGeneratedColumn,
|
|
10
|
+
RelationId,
|
|
11
|
+
UpdateDateColumn
|
|
12
|
+
} from 'typeorm'
|
|
13
|
+
|
|
14
|
+
import { User } from '@things-factory/auth-base'
|
|
15
|
+
import { Domain } from '@things-factory/shell'
|
|
16
|
+
|
|
17
|
+
@Entity()
|
|
18
|
+
@Index('ix_oauth2_client_0', (oauth2Client: Oauth2Client) => [oauth2Client.domain, oauth2Client.name], { unique: true })
|
|
19
|
+
@ObjectType({ description: 'Entity for Oauth2Client' })
|
|
20
|
+
export class Oauth2Client {
|
|
21
|
+
@PrimaryGeneratedColumn('uuid')
|
|
22
|
+
@Field(type => ID)
|
|
23
|
+
readonly id: string
|
|
24
|
+
|
|
25
|
+
@ManyToOne(type => Domain)
|
|
26
|
+
@Field(type => Domain)
|
|
27
|
+
domain?: Domain
|
|
28
|
+
|
|
29
|
+
@RelationId((oauth2Client: Oauth2Client) => oauth2Client.domain)
|
|
30
|
+
domainId?: string
|
|
31
|
+
|
|
32
|
+
@Column()
|
|
33
|
+
@Field()
|
|
34
|
+
name: string
|
|
35
|
+
|
|
36
|
+
@Column({ nullable: true })
|
|
37
|
+
@Field({ nullable: true })
|
|
38
|
+
description?: string
|
|
39
|
+
|
|
40
|
+
@Column({ nullable: true })
|
|
41
|
+
@Field({ nullable: true })
|
|
42
|
+
icon?: string
|
|
43
|
+
|
|
44
|
+
@Column({ nullable: true })
|
|
45
|
+
@Field({ nullable: true })
|
|
46
|
+
grantType?: string
|
|
47
|
+
|
|
48
|
+
@Column({ nullable: true })
|
|
49
|
+
@Field({ nullable: true })
|
|
50
|
+
clientId?: string
|
|
51
|
+
|
|
52
|
+
@Column({ nullable: true })
|
|
53
|
+
@Field({ nullable: true })
|
|
54
|
+
clientSecret?: string
|
|
55
|
+
|
|
56
|
+
@Column({ nullable: true })
|
|
57
|
+
@Field({ nullable: true })
|
|
58
|
+
accessTokenUrl?: string
|
|
59
|
+
|
|
60
|
+
@Column({ nullable: true })
|
|
61
|
+
@Field({ nullable: true })
|
|
62
|
+
authUrl?: string
|
|
63
|
+
|
|
64
|
+
@Column({ nullable: true })
|
|
65
|
+
@Field({ nullable: true })
|
|
66
|
+
callbackUrl?: string
|
|
67
|
+
|
|
68
|
+
@Column({ nullable: true })
|
|
69
|
+
@Field({ nullable: true })
|
|
70
|
+
webhook?: string
|
|
71
|
+
|
|
72
|
+
@Column({ nullable: true })
|
|
73
|
+
@Field({ nullable: true })
|
|
74
|
+
username?: string
|
|
75
|
+
|
|
76
|
+
@Column({ nullable: true })
|
|
77
|
+
@Field({ nullable: true })
|
|
78
|
+
password?: string
|
|
79
|
+
|
|
80
|
+
@Column({ nullable: true })
|
|
81
|
+
@Field({ nullable: true })
|
|
82
|
+
codeChallengeMethod?: string
|
|
83
|
+
|
|
84
|
+
@Column({ nullable: true })
|
|
85
|
+
@Field({ nullable: true })
|
|
86
|
+
codeVerifier?: string
|
|
87
|
+
|
|
88
|
+
@Column({ nullable: true })
|
|
89
|
+
@Field({ nullable: true })
|
|
90
|
+
scopes?: string
|
|
91
|
+
|
|
92
|
+
@Column({ nullable: true })
|
|
93
|
+
@Field({ nullable: true })
|
|
94
|
+
accessToken?: string
|
|
95
|
+
|
|
96
|
+
@Column({ nullable: true })
|
|
97
|
+
@Field({ nullable: true })
|
|
98
|
+
refreshToken?: string
|
|
99
|
+
|
|
100
|
+
@Column({ nullable: true })
|
|
101
|
+
@Field({ nullable: true })
|
|
102
|
+
expires?: Date
|
|
103
|
+
|
|
104
|
+
@Column({ nullable: true })
|
|
105
|
+
@Field({ nullable: true })
|
|
106
|
+
state?: string
|
|
107
|
+
|
|
108
|
+
@Column({ nullable: true })
|
|
109
|
+
@Field(type => GraphQLJWT, { nullable: true })
|
|
110
|
+
jwtToken?: string
|
|
111
|
+
|
|
112
|
+
@Column({ nullable: true })
|
|
113
|
+
@Field({ nullable: true })
|
|
114
|
+
tokenType?: string
|
|
115
|
+
|
|
116
|
+
@CreateDateColumn()
|
|
117
|
+
@Field({ nullable: true })
|
|
118
|
+
createdAt?: Date
|
|
119
|
+
|
|
120
|
+
@UpdateDateColumn()
|
|
121
|
+
@Field({ nullable: true })
|
|
122
|
+
updatedAt?: Date
|
|
123
|
+
|
|
124
|
+
@ManyToOne(type => User, { nullable: true })
|
|
125
|
+
@Field(type => User, { nullable: true })
|
|
126
|
+
creator?: User
|
|
127
|
+
|
|
128
|
+
@RelationId((oauth2Client: Oauth2Client) => oauth2Client.creator)
|
|
129
|
+
creatorId?: string
|
|
130
|
+
|
|
131
|
+
@ManyToOne(type => User, { nullable: true })
|
|
132
|
+
@Field(type => User, { nullable: true })
|
|
133
|
+
updater?: User
|
|
134
|
+
|
|
135
|
+
@RelationId((oauth2Client: Oauth2Client) => oauth2Client.updater)
|
|
136
|
+
updaterId?: string
|
|
137
|
+
|
|
138
|
+
getAuthHeaders() {
|
|
139
|
+
if (this.tokenType == 'bearer') {
|
|
140
|
+
return {
|
|
141
|
+
Authorization: `Bearer ${this.accessToken}`
|
|
142
|
+
}
|
|
143
|
+
} else if (this.tokenType == 'basic' || !this.tokenType) {
|
|
144
|
+
const encoded = Buffer.from(`${this.username}:${this.password}`).toString('base64')
|
|
145
|
+
return {
|
|
146
|
+
Authorization: `Basic ${encoded}`
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {}
|
|
151
|
+
}
|
|
152
|
+
}
|