@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.
@@ -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
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "strict": false,
5
+ "declaration": true,
6
+ "module": "commonjs",
7
+ "outDir": "../dist-server",
8
+ "baseUrl": "./"
9
+ },
10
+ "include": ["./**/*"]
11
+ }