@things-factory/oauth2-client 5.0.7 → 6.0.0-alpha.0
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.js → bootstrap.ts} +0 -0
- package/{server/controllers → client}/index.ts +0 -0
- package/client/pages/oauth2-client/oauth2-client-importer.ts +97 -0
- package/client/pages/oauth2-client/oauth2-client-list-page.ts +337 -0
- package/client/pages/{oauth2-client-register.js → oauth2-client-register.ts} +79 -86
- package/client/pages/{oauth2-client.js → oauth2-client.ts} +157 -161
- package/client/pages/oauth2-clients.ts +192 -0
- package/client/{route.js → route.ts} +1 -1
- package/client/tsconfig.json +11 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +0 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/oauth2-client/oauth2-client-importer.d.ts +22 -0
- package/dist-client/pages/oauth2-client/oauth2-client-importer.js +100 -0
- package/dist-client/pages/oauth2-client/oauth2-client-importer.js.map +1 -0
- package/dist-client/pages/oauth2-client/oauth2-client-list-page.d.ts +55 -0
- package/dist-client/pages/oauth2-client/oauth2-client-list-page.js +315 -0
- package/dist-client/pages/oauth2-client/oauth2-client-list-page.js.map +1 -0
- package/dist-client/pages/oauth2-client-register.d.ts +21 -0
- package/dist-client/pages/oauth2-client-register.js +190 -0
- package/dist-client/pages/oauth2-client-register.js.map +1 -0
- package/dist-client/pages/oauth2-client.d.ts +35 -0
- package/dist-client/pages/oauth2-client.js +586 -0
- package/dist-client/pages/oauth2-client.js.map +1 -0
- package/dist-client/pages/oauth2-clients.d.ts +1 -0
- package/dist-client/pages/oauth2-clients.js +194 -0
- package/dist-client/pages/oauth2-clients.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +14 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/index.d.ts +2 -0
- package/dist-server/index.js +2 -16
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/routes.js +10 -18
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/index.d.ts +5 -0
- package/dist-server/service/index.js +19 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/oauth2-client/index.d.ts +5 -0
- package/dist-server/service/oauth2-client/index.js +9 -0
- package/dist-server/service/oauth2-client/index.js.map +1 -0
- package/dist-server/service/oauth2-client/oauth2-client-mutation.d.ts +11 -0
- package/dist-server/service/oauth2-client/oauth2-client-mutation.js +165 -0
- package/dist-server/service/oauth2-client/oauth2-client-mutation.js.map +1 -0
- package/dist-server/service/oauth2-client/oauth2-client-query.d.ts +11 -0
- package/dist-server/service/oauth2-client/oauth2-client-query.js +79 -0
- package/dist-server/service/oauth2-client/oauth2-client-query.js.map +1 -0
- package/dist-server/service/oauth2-client/oauth2-client-type.d.ts +45 -0
- package/dist-server/service/oauth2-client/oauth2-client-type.js +177 -0
- package/dist-server/service/oauth2-client/oauth2-client-type.js.map +1 -0
- package/dist-server/service/oauth2-client/oauth2-client.d.ts +39 -0
- package/dist-server/service/oauth2-client/oauth2-client.js +220 -0
- package/dist-server/service/oauth2-client/oauth2-client.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +12 -10
- package/server/index.ts +2 -3
- package/server/routes.ts +9 -20
- 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 +188 -0
- package/server/service/oauth2-client/oauth2-client-query.ts +50 -0
- package/server/service/oauth2-client/oauth2-client-type.ts +126 -0
- package/server/service/oauth2-client/oauth2-client.ts +193 -0
- package/server/tsconfig.json +11 -0
- package/things-factory.config.js +5 -14
- package/client/index.js +0 -1
- package/client/pages/oauth2-clients.js +0 -197
- package/dist-server/controllers/index.js +0 -1
- package/dist-server/controllers/index.js.map +0 -1
- package/dist-server/entities/index.js +0 -9
- package/dist-server/entities/index.js.map +0 -1
- package/dist-server/entities/oauth2-client.js +0 -190
- package/dist-server/entities/oauth2-client.js.map +0 -1
- package/dist-server/graphql/index.js +0 -34
- package/dist-server/graphql/index.js.map +0 -1
- package/dist-server/graphql/resolvers/index.js +0 -18
- package/dist-server/graphql/resolvers/index.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/create-oauth2-client.js +0 -19
- package/dist-server/graphql/resolvers/oauth2-client/create-oauth2-client.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/delete-oauth2-client.js +0 -12
- package/dist-server/graphql/resolvers/oauth2-client/delete-oauth2-client.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/delete-oauth2-clients.js +0 -15
- package/dist-server/graphql/resolvers/oauth2-client/delete-oauth2-clients.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/get-oauth2-access-token.js +0 -49
- package/dist-server/graphql/resolvers/oauth2-client/get-oauth2-access-token.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/index.js +0 -15
- package/dist-server/graphql/resolvers/oauth2-client/index.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/oauth2-client-query.js +0 -46
- package/dist-server/graphql/resolvers/oauth2-client/oauth2-client-query.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/refresh-oauth2-access-token.js +0 -38
- package/dist-server/graphql/resolvers/oauth2-client/refresh-oauth2-access-token.js.map +0 -1
- package/dist-server/graphql/resolvers/oauth2-client/update-oauth2-client.js +0 -15
- package/dist-server/graphql/resolvers/oauth2-client/update-oauth2-client.js.map +0 -1
- package/dist-server/graphql/types/index.js +0 -18
- package/dist-server/graphql/types/index.js.map +0 -1
- package/dist-server/graphql/types/oauth2-client/index.js +0 -42
- package/dist-server/graphql/types/oauth2-client/index.js.map +0 -1
- package/dist-server/graphql/types/oauth2-client/new-oauth2-client.js +0 -30
- package/dist-server/graphql/types/oauth2-client/new-oauth2-client.js.map +0 -1
- package/dist-server/graphql/types/oauth2-client/oauth2-client-list.js +0 -14
- package/dist-server/graphql/types/oauth2-client/oauth2-client-list.js.map +0 -1
- package/dist-server/graphql/types/oauth2-client/oauth2-client-patch.js +0 -30
- package/dist-server/graphql/types/oauth2-client/oauth2-client-patch.js.map +0 -1
- package/dist-server/graphql/types/oauth2-client/oauth2-client.js +0 -38
- package/dist-server/graphql/types/oauth2-client/oauth2-client.js.map +0 -1
- package/server/entities/index.ts +0 -9
- package/server/entities/oauth2-client.ts +0 -156
- package/server/graphql/index.ts +0 -9
- package/server/graphql/resolvers/index.ts +0 -1
- package/server/graphql/resolvers/oauth2-client/create-oauth2-client.ts +0 -24
- package/server/graphql/resolvers/oauth2-client/delete-oauth2-client.ts +0 -10
- package/server/graphql/resolvers/oauth2-client/delete-oauth2-clients.ts +0 -13
- package/server/graphql/resolvers/oauth2-client/get-oauth2-access-token.ts +0 -64
- package/server/graphql/resolvers/oauth2-client/index.ts +0 -21
- package/server/graphql/resolvers/oauth2-client/oauth2-client-query.ts +0 -62
- package/server/graphql/resolvers/oauth2-client/refresh-oauth2-access-token.ts +0 -54
- package/server/graphql/resolvers/oauth2-client/update-oauth2-client.ts +0 -17
- package/server/graphql/types/index.ts +0 -1
- package/server/graphql/types/oauth2-client/index.ts +0 -23
- package/server/graphql/types/oauth2-client/new-oauth2-client.ts +0 -24
- package/server/graphql/types/oauth2-client/oauth2-client-list.ts +0 -8
- package/server/graphql/types/oauth2-client/oauth2-client-patch.ts +0 -24
- package/server/graphql/types/oauth2-client/oauth2-client.ts +0 -32
- package/tsconfig.json +0 -9
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import ClientOAuth2 from 'client-oauth2'
|
|
2
|
-
|
|
3
|
-
import { getRepository } from 'typeorm'
|
|
4
|
-
import { Oauth2Client } from '../../../entities'
|
|
5
|
-
|
|
6
|
-
const debug = require('debug')('things-factory:oauth2-client:refresh-oauth2-access-token')
|
|
7
|
-
|
|
8
|
-
export const refreshOauth2AccessToken = {
|
|
9
|
-
async refreshOauth2AccessToken(_: any, { id }, context: any) {
|
|
10
|
-
const repository = getRepository(Oauth2Client)
|
|
11
|
-
const oauth2Client = await repository.findOne(id)
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
clientId,
|
|
15
|
-
clientSecret,
|
|
16
|
-
accessTokenUrl: accessTokenUri,
|
|
17
|
-
authUrl: authorizationUri,
|
|
18
|
-
scopes,
|
|
19
|
-
tokenType,
|
|
20
|
-
accessToken,
|
|
21
|
-
refreshToken
|
|
22
|
-
} = oauth2Client
|
|
23
|
-
|
|
24
|
-
if (!refreshToken) {
|
|
25
|
-
throw new Error('refreshToken not found')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var auth = new ClientOAuth2({
|
|
29
|
-
clientId,
|
|
30
|
-
clientSecret,
|
|
31
|
-
accessTokenUri,
|
|
32
|
-
authorizationUri,
|
|
33
|
-
scopes: scopes?.split(' ')
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
var token = await auth.createToken(accessToken, refreshToken, tokenType, {}).refresh()
|
|
38
|
-
} catch (err) {
|
|
39
|
-
debug('getting refresh-token error', err)
|
|
40
|
-
throw err
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const { accessToken: newAccessToken, refreshToken: newRefreshToken, tokenType: newTokenType, data } = token
|
|
44
|
-
const expires = data?.expires_in ? token.expiresIn(data?.expires_in as any) : null
|
|
45
|
-
|
|
46
|
-
return await repository.save({
|
|
47
|
-
...oauth2Client,
|
|
48
|
-
accessToken: newAccessToken,
|
|
49
|
-
refreshToken: newRefreshToken,
|
|
50
|
-
tokenType: newTokenType,
|
|
51
|
-
expires
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { getRepository } from 'typeorm'
|
|
2
|
-
import { Oauth2Client } from '../../../entities'
|
|
3
|
-
|
|
4
|
-
export const updateOauth2Client = {
|
|
5
|
-
async updateOauth2Client(_: any, { id, patch }, context: any) {
|
|
6
|
-
const repository = getRepository(Oauth2Client)
|
|
7
|
-
const oauth2Client = await repository.findOne({
|
|
8
|
-
where: { domain: context.state.domain, id }
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
return await repository.save({
|
|
12
|
-
...oauth2Client,
|
|
13
|
-
...patch,
|
|
14
|
-
updater: context.state.user
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './oauth2-client'
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
export * from './oauth2-client'
|
|
4
|
-
export * from './new-oauth2-client'
|
|
5
|
-
export * from './oauth2-client-patch'
|
|
6
|
-
export * from './oauth2-client-list'
|
|
7
|
-
|
|
8
|
-
export const Oauth2ClientResolver = gql`
|
|
9
|
-
extend type Mutation {
|
|
10
|
-
createOauth2Client(oauth2Client: NewOauth2Client!): Oauth2Client
|
|
11
|
-
updateOauth2Client(id: String!, patch: Oauth2ClientPatch!): Oauth2Client
|
|
12
|
-
deleteOauth2Client(id: String!): Boolean
|
|
13
|
-
deleteOauth2Clients(ids: [String]!): Boolean
|
|
14
|
-
getOauth2AccessToken(id: String!): Oauth2Client
|
|
15
|
-
refreshOauth2AccessToken(id: String!): Oauth2Client
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
extend type Query {
|
|
19
|
-
oauth2Clients(filters: [Filter], pagination: Pagination, sortings: [Sorting]): Oauth2ClientList
|
|
20
|
-
oauth2Client(id: String!): Oauth2Client
|
|
21
|
-
getOauth2AuthUrl(id: String!): String
|
|
22
|
-
}
|
|
23
|
-
`
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
export const NewOauth2Client = gql`
|
|
4
|
-
input NewOauth2Client {
|
|
5
|
-
name: String
|
|
6
|
-
description: String
|
|
7
|
-
icon: String
|
|
8
|
-
grantType: String
|
|
9
|
-
clientId: String
|
|
10
|
-
clientSecret: String
|
|
11
|
-
callbackUrl: String
|
|
12
|
-
authUrl: String
|
|
13
|
-
accessTokenUrl: String
|
|
14
|
-
webhook: String
|
|
15
|
-
username: String
|
|
16
|
-
password: String
|
|
17
|
-
codeChallengeMethod: String
|
|
18
|
-
codeVerifier: String
|
|
19
|
-
scopes: String
|
|
20
|
-
accessToken: String
|
|
21
|
-
refreshToken: String
|
|
22
|
-
jwtToken: String
|
|
23
|
-
}
|
|
24
|
-
`
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
export const Oauth2ClientPatch = gql`
|
|
4
|
-
input Oauth2ClientPatch {
|
|
5
|
-
name: String
|
|
6
|
-
description: String
|
|
7
|
-
icon: String
|
|
8
|
-
grantType: String
|
|
9
|
-
clientId: String
|
|
10
|
-
clientSecret: String
|
|
11
|
-
callbackUrl: String
|
|
12
|
-
authUrl: String
|
|
13
|
-
accessTokenUrl: String
|
|
14
|
-
webhook: String
|
|
15
|
-
username: String
|
|
16
|
-
password: String
|
|
17
|
-
codeChallengeMethod: String
|
|
18
|
-
codeVerifier: String
|
|
19
|
-
scopes: String
|
|
20
|
-
accessToken: String
|
|
21
|
-
refreshToken: String
|
|
22
|
-
jwtToken: String
|
|
23
|
-
}
|
|
24
|
-
`
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
export const Oauth2Client = gql`
|
|
4
|
-
type Oauth2Client {
|
|
5
|
-
id: String
|
|
6
|
-
domain: Domain
|
|
7
|
-
name: String
|
|
8
|
-
description: String
|
|
9
|
-
icon: String
|
|
10
|
-
grantType: String
|
|
11
|
-
clientId: String
|
|
12
|
-
clientSecret: String
|
|
13
|
-
callbackUrl: String
|
|
14
|
-
authUrl: String
|
|
15
|
-
accessTokenUrl: String
|
|
16
|
-
webhook: String
|
|
17
|
-
username: String
|
|
18
|
-
password: String
|
|
19
|
-
codeChallengeMethod: String
|
|
20
|
-
codeVerifier: String
|
|
21
|
-
scopes: String
|
|
22
|
-
accessToken: String
|
|
23
|
-
refreshToken: String
|
|
24
|
-
expires: String
|
|
25
|
-
jwtToken: String
|
|
26
|
-
tokenType: String
|
|
27
|
-
updater: User
|
|
28
|
-
creator: User
|
|
29
|
-
updatedAt: String
|
|
30
|
-
createdAt: String
|
|
31
|
-
}
|
|
32
|
-
`
|