@contember/engine-tenant-api 2.0.0-alpha.18 → 2.0.0-alpha.20
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/dist/development/src/model/service/IDPSignInManager.cjs +1 -1
- package/dist/development/src/model/service/IDPSignInManager.cjs.map +1 -1
- package/dist/development/src/model/service/IDPSignInManager.js +1 -1
- package/dist/development/src/model/service/IDPSignInManager.js.map +1 -1
- package/dist/development/src/model/service/idp/providers/AppleProvider.cjs +1 -1
- package/dist/development/src/model/service/idp/providers/AppleProvider.cjs.map +1 -1
- package/dist/development/src/model/service/idp/providers/AppleProvider.js +1 -1
- package/dist/development/src/model/service/idp/providers/AppleProvider.js.map +1 -1
- package/dist/development/src/model/service/idp/providers/FacebookProvider.cjs +1 -1
- package/dist/development/src/model/service/idp/providers/FacebookProvider.cjs.map +1 -1
- package/dist/development/src/model/service/idp/providers/FacebookProvider.js +1 -1
- package/dist/development/src/model/service/idp/providers/FacebookProvider.js.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCHelpers.cjs +7 -5
- package/dist/development/src/model/service/idp/providers/OIDCHelpers.cjs.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCHelpers.js +7 -5
- package/dist/development/src/model/service/idp/providers/OIDCHelpers.js.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs +2 -2
- package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCProvider.js +2 -2
- package/dist/development/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.cjs +4 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.cjs.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.js +4 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.js.map +1 -1
- package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.cjs +4 -1
- package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.js +4 -1
- package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
- package/dist/development/src/schema/tenant.graphql.cjs +1 -0
- package/dist/development/src/schema/tenant.graphql.cjs.map +1 -1
- package/dist/development/src/schema/tenant.graphql.js +1 -0
- package/dist/development/src/schema/tenant.graphql.js.map +1 -1
- package/dist/production/src/model/service/IDPSignInManager.cjs +1 -1
- package/dist/production/src/model/service/IDPSignInManager.cjs.map +1 -1
- package/dist/production/src/model/service/IDPSignInManager.js +1 -1
- package/dist/production/src/model/service/IDPSignInManager.js.map +1 -1
- package/dist/production/src/model/service/idp/providers/AppleProvider.cjs +1 -1
- package/dist/production/src/model/service/idp/providers/AppleProvider.cjs.map +1 -1
- package/dist/production/src/model/service/idp/providers/AppleProvider.js +1 -1
- package/dist/production/src/model/service/idp/providers/AppleProvider.js.map +1 -1
- package/dist/production/src/model/service/idp/providers/FacebookProvider.cjs +1 -1
- package/dist/production/src/model/service/idp/providers/FacebookProvider.cjs.map +1 -1
- package/dist/production/src/model/service/idp/providers/FacebookProvider.js +1 -1
- package/dist/production/src/model/service/idp/providers/FacebookProvider.js.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCHelpers.cjs +7 -5
- package/dist/production/src/model/service/idp/providers/OIDCHelpers.cjs.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCHelpers.js +7 -5
- package/dist/production/src/model/service/idp/providers/OIDCHelpers.js.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs +2 -2
- package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCProvider.js +2 -2
- package/dist/production/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs +4 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.js +4 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.js.map +1 -1
- package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.cjs +4 -1
- package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.js +4 -1
- package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
- package/dist/production/src/schema/tenant.graphql.cjs +1 -0
- package/dist/production/src/schema/tenant.graphql.cjs.map +1 -1
- package/dist/production/src/schema/tenant.graphql.js +1 -0
- package/dist/production/src/schema/tenant.graphql.js.map +1 -1
- package/dist/tests/src/IdPMock.d.ts +2 -2
- package/dist/tests/src/IdPMock.d.ts.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/model/service/IDPSignInManager.d.ts +1 -0
- package/dist/types/model/service/IDPSignInManager.d.ts.map +1 -1
- package/dist/types/model/service/idp/IdentityProviderHandler.d.ts +3 -3
- package/dist/types/model/service/idp/IdentityProviderHandler.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/AppleProvider.d.ts +6 -2
- package/dist/types/model/service/idp/providers/AppleProvider.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/FacebookProvider.d.ts +6 -2
- package/dist/types/model/service/idp/providers/FacebookProvider.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/OIDCHelpers.d.ts +4 -4
- package/dist/types/model/service/idp/providers/OIDCHelpers.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/OIDCProvider.d.ts +4 -2
- package/dist/types/model/service/idp/providers/OIDCProvider.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/OIDCTypes.d.ts +8 -0
- package/dist/types/model/service/idp/providers/OIDCTypes.d.ts.map +1 -1
- package/dist/types/resolvers/mutation/person/IDPMutationResolver.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +2 -0
- package/dist/types/schema/index.d.ts.map +1 -1
- package/dist/types/schema/tenant.graphql.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/model/service/IDPSignInManager.ts +7 -6
- package/src/model/service/idp/IdentityProviderHandler.ts +3 -3
- package/src/model/service/idp/providers/AppleProvider.ts +3 -3
- package/src/model/service/idp/providers/FacebookProvider.ts +3 -3
- package/src/model/service/idp/providers/OIDCHelpers.ts +9 -6
- package/src/model/service/idp/providers/OIDCProvider.ts +4 -4
- package/src/model/service/idp/providers/OIDCTypes.ts +3 -1
- package/src/resolvers/mutation/person/IDPMutationResolver.ts +4 -1
- package/src/schema/index.ts +2 -0
- package/src/schema/tenant.graphql.ts +1 -0
- package/tests/src/IdPMock.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-tenant-api",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.20",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,30 +26,30 @@
|
|
|
26
26
|
"generate": "gql-gen --config graphql.codegen.yml"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/authorization": "2.0.0-alpha.
|
|
30
|
-
"@contember/config-loader": "2.0.0-alpha.
|
|
31
|
-
"@contember/database": "2.0.0-alpha.
|
|
32
|
-
"@contember/database-migrations": "2.0.0-alpha.
|
|
33
|
-
"@contember/dic": "2.0.0-alpha.
|
|
34
|
-
"@contember/graphql-utils": "2.0.0-alpha.
|
|
35
|
-
"@contember/logger": "2.0.0-alpha.
|
|
36
|
-
"@contember/schema": "2.0.0-alpha.
|
|
37
|
-
"@contember/schema-utils": "2.0.0-alpha.
|
|
38
|
-
"@contember/typesafe": "2.0.0-alpha.
|
|
39
|
-
"@graphql-tools/utils": "^10.5.
|
|
29
|
+
"@contember/authorization": "2.0.0-alpha.20",
|
|
30
|
+
"@contember/config-loader": "2.0.0-alpha.20",
|
|
31
|
+
"@contember/database": "2.0.0-alpha.20",
|
|
32
|
+
"@contember/database-migrations": "2.0.0-alpha.20",
|
|
33
|
+
"@contember/dic": "2.0.0-alpha.20",
|
|
34
|
+
"@contember/graphql-utils": "2.0.0-alpha.20",
|
|
35
|
+
"@contember/logger": "2.0.0-alpha.20",
|
|
36
|
+
"@contember/schema": "2.0.0-alpha.20",
|
|
37
|
+
"@contember/schema-utils": "2.0.0-alpha.20",
|
|
38
|
+
"@contember/typesafe": "2.0.0-alpha.20",
|
|
39
|
+
"@graphql-tools/utils": "^10.5.5",
|
|
40
40
|
"graphql-tag": "^2.12.6",
|
|
41
41
|
"jose": "^5.8.0",
|
|
42
42
|
"mustache": "^4.2.0",
|
|
43
43
|
"nodemailer": "^6.9.15",
|
|
44
44
|
"openid-client": "^5.7.0",
|
|
45
|
-
"otpauth": "^9.3.
|
|
45
|
+
"otpauth": "^9.3.4"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@contember/database-tester": "2.0.0-alpha.
|
|
49
|
-
"@graphql-tools/schema": "^10.0.
|
|
48
|
+
"@contember/database-tester": "2.0.0-alpha.20",
|
|
49
|
+
"@graphql-tools/schema": "^10.0.7",
|
|
50
50
|
"@types/mustache": "^4.2.5",
|
|
51
|
-
"@types/node": "^20.16.
|
|
52
|
-
"@types/nodemailer": "^6.4.
|
|
51
|
+
"@types/node": "^20.16.11",
|
|
52
|
+
"@types/nodemailer": "^6.4.16",
|
|
53
53
|
"graphql": "^16.9.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiKeyManager } from './apiKey'
|
|
2
2
|
import { IdentityProviderBySlugQuery, PersonByIdPQuery, PersonQuery, PersonRow } from '../queries'
|
|
3
|
-
import {
|
|
3
|
+
import { IDPResponse, IDPHandlerRegistry, IDPResponseError, IDPValidationError } from './idp'
|
|
4
4
|
import { Response, ResponseError, ResponseOk } from '../utils/Response'
|
|
5
5
|
import { InitSignInIdpErrorCode, InitSignInIdpResult, SignInIdpErrorCode } from '../../schema'
|
|
6
6
|
import { DatabaseContext } from '../utils'
|
|
@@ -28,7 +28,7 @@ class IDPSignInManager {
|
|
|
28
28
|
}
|
|
29
29
|
const providerService = this.idpRegistry.getHandler(provider.type)
|
|
30
30
|
const validatedConfig = providerService.validateConfiguration(provider.configuration)
|
|
31
|
-
let claim:
|
|
31
|
+
let claim: IDPResponse
|
|
32
32
|
try {
|
|
33
33
|
claim = await providerService.processResponse(
|
|
34
34
|
validatedConfig,
|
|
@@ -54,7 +54,7 @@ class IDPSignInManager {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const sessionToken = await this.apiKeyManager.createSessionApiKey(db, personRow.identity_id, expiration)
|
|
57
|
-
return new ResponseOk({ person: personRow, token: sessionToken })
|
|
57
|
+
return new ResponseOk({ person: personRow, token: sessionToken, idpResponse: claim })
|
|
58
58
|
})
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -84,7 +84,7 @@ class IDPSignInManager {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
private async resolvePerson(db: DatabaseContext, claim:
|
|
87
|
+
private async resolvePerson(db: DatabaseContext, claim: IDPResponse, provider: IdentityProviderRow): Promise<PersonRow | null> {
|
|
88
88
|
const personByIdPQuery = new PersonByIdPQuery(provider.id, claim.externalIdentifier)
|
|
89
89
|
const personByIdp = await db.queryHandler.fetch(personByIdPQuery)
|
|
90
90
|
if (personByIdp) {
|
|
@@ -108,7 +108,7 @@ class IDPSignInManager {
|
|
|
108
108
|
return null
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
private async signUp(db: DatabaseContext, { email, name, externalIdentifier }:
|
|
111
|
+
private async signUp(db: DatabaseContext, { email, name, externalIdentifier }: IDPResponse, provider: IdentityProviderRow): Promise<PersonRow> {
|
|
112
112
|
const roles = [TenantRole.PERSON]
|
|
113
113
|
const identityId = await db.commandBus.execute(new CreateIdentityCommand(roles))
|
|
114
114
|
const newPerson = await db.commandBus.execute(new CreatePersonCommand({
|
|
@@ -125,7 +125,7 @@ class IDPSignInManager {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
private async saveIdpIdentifier(db: DatabaseContext, provider: IdentityProviderRow, claim:
|
|
128
|
+
private async saveIdpIdentifier(db: DatabaseContext, provider: IdentityProviderRow, claim: IDPResponse, person: PersonRow) {
|
|
129
129
|
await db.commandBus.execute(new CreatePersonIdentityProviderIdentifierCommand(provider.id, person.id, claim.externalIdentifier))
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -136,6 +136,7 @@ namespace IDPSignInManager {
|
|
|
136
136
|
interface SignInIDPResult {
|
|
137
137
|
readonly person: PersonRow
|
|
138
138
|
readonly token: string
|
|
139
|
+
readonly idpResponse?: Record<string, unknown>
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
export type SignInIDPResponse = Response<SignInIDPResult, SignInIdpErrorCode>
|
|
@@ -3,17 +3,17 @@ export interface InitIDPAuthResult {
|
|
|
3
3
|
sessionData: unknown
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export type IDPResponse = {
|
|
7
7
|
externalIdentifier: string
|
|
8
8
|
email?: string
|
|
9
9
|
name?: string
|
|
10
|
-
}
|
|
10
|
+
} & Record<string, unknown>
|
|
11
11
|
|
|
12
12
|
export interface IdentityProviderHandler<Configuration extends {}> {
|
|
13
13
|
|
|
14
14
|
initAuth: (configuration: Configuration, data: unknown) => Promise<InitIDPAuthResult>
|
|
15
15
|
|
|
16
|
-
processResponse: (configuration: Configuration, responseData: unknown) => Promise<
|
|
16
|
+
processResponse: (configuration: Configuration, responseData: unknown) => Promise<IDPResponse>
|
|
17
17
|
|
|
18
18
|
validateConfiguration: (config: unknown) => Configuration
|
|
19
19
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Typesafe from '@contember/typesafe'
|
|
2
|
-
import { IdentityProviderHandler,
|
|
2
|
+
import { IdentityProviderHandler, IDPResponse, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
3
3
|
import { OIDCConfiguration, OIDCConfigurationOptions, OIDCInitData, OIDCResponseData, OIDCSessionData } from './OIDCTypes'
|
|
4
4
|
import { catchTypesafe } from './helpers'
|
|
5
5
|
import { IDPValidationError } from '../IDPValidationError'
|
|
@@ -31,12 +31,12 @@ export class AppleProvider implements IdentityProviderHandler<AppleConfiguration
|
|
|
31
31
|
const initData = catchTypesafe(OIDCInitData, IDPValidationError)(data)
|
|
32
32
|
const client = await this.createOIDCClient(configuration)
|
|
33
33
|
return await initOIDCAuth(client, {
|
|
34
|
-
|
|
34
|
+
scope: configuration.scope ?? configuration.claims,
|
|
35
35
|
...initData,
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
public async processResponse(configuration: AppleConfiguration, data: unknown): Promise<
|
|
39
|
+
public async processResponse(configuration: AppleConfiguration, data: unknown): Promise<IDPResponse> {
|
|
40
40
|
const responseData = catchTypesafe(OIDCResponseData, IDPValidationError)(data)
|
|
41
41
|
const client = await this.createOIDCClient(configuration)
|
|
42
42
|
return await handleOIDCResponse(client, responseData)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Typesafe from '@contember/typesafe'
|
|
2
2
|
import { Client, Issuer } from 'openid-client'
|
|
3
|
-
import { IdentityProviderHandler,
|
|
3
|
+
import { IdentityProviderHandler, IDPResponse, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
4
4
|
import { IDPValidationError } from '../IDPValidationError'
|
|
5
5
|
import { InvalidIDPConfigurationError } from '../InvalidIDPConfigurationError'
|
|
6
6
|
import { catchTypesafe } from './helpers'
|
|
@@ -80,12 +80,12 @@ export class FacebookProvider implements IdentityProviderHandler<FacebookConfigu
|
|
|
80
80
|
const initData = catchTypesafe(OIDCInitData, IDPValidationError)(data)
|
|
81
81
|
const client = await this.createOIDCClient(configuration)
|
|
82
82
|
return await initOIDCAuth(client, {
|
|
83
|
-
|
|
83
|
+
scope: configuration.scope ?? configuration.claims,
|
|
84
84
|
...initData,
|
|
85
85
|
})
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
public async processResponse(configuration: FacebookConfiguration, data: unknown): Promise<
|
|
88
|
+
public async processResponse(configuration: FacebookConfiguration, data: unknown): Promise<IDPResponse> {
|
|
89
89
|
const responseData = catchTypesafe(FacebookResponseData, IDPValidationError)(data)
|
|
90
90
|
|
|
91
91
|
if (!('authResponse' in responseData)) {
|
|
@@ -2,19 +2,19 @@ import { Client, custom, errors, generators } from 'openid-client'
|
|
|
2
2
|
import { OIDCResponseData } from './OIDCTypes'
|
|
3
3
|
import { IDPValidationError } from '../IDPValidationError'
|
|
4
4
|
import { IDPResponseError } from '../IDPResponseError'
|
|
5
|
-
import {
|
|
5
|
+
import { IDPResponse, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
6
6
|
|
|
7
7
|
custom.setHttpOptionsDefaults({
|
|
8
8
|
timeout: 5000,
|
|
9
9
|
})
|
|
10
10
|
|
|
11
|
-
export const initOIDCAuth = async (client: Client, { redirectUrl,
|
|
11
|
+
export const initOIDCAuth = async (client: Client, { redirectUrl, scope, responseMode }: { redirectUrl: string; scope?: string; responseMode?: string }): Promise<InitIDPAuthResult> => {
|
|
12
12
|
const nonce = generators.nonce()
|
|
13
13
|
const state = generators.state()
|
|
14
14
|
const url = client.authorizationUrl({
|
|
15
15
|
redirect_uri: redirectUrl,
|
|
16
16
|
response_mode: responseMode,
|
|
17
|
-
scope:
|
|
17
|
+
scope: scope ?? 'openid email',
|
|
18
18
|
nonce,
|
|
19
19
|
state,
|
|
20
20
|
})
|
|
@@ -25,7 +25,7 @@ export const initOIDCAuth = async (client: Client, { redirectUrl, claims, respon
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const handleOIDCResponse = async (client: Client, { sessionData, redirectUrl, ...otherData }: OIDCResponseData): Promise<
|
|
28
|
+
export const handleOIDCResponse = async (client: Client, { sessionData, redirectUrl, ...otherData }: OIDCResponseData, fetchUserInfo?: boolean): Promise<IDPResponse> => {
|
|
29
29
|
const params = 'parameters' in otherData ? otherData.parameters : client.callbackParams(otherData.url)
|
|
30
30
|
if (params.state && !sessionData?.state) {
|
|
31
31
|
throw new IDPValidationError(`state is present in parameters, but missing in session data`)
|
|
@@ -33,10 +33,13 @@ export const handleOIDCResponse = async (client: Client, { sessionData, redirect
|
|
|
33
33
|
try {
|
|
34
34
|
const result = await client.callback(redirectUrl, params, sessionData)
|
|
35
35
|
const claims = result.claims()
|
|
36
|
+
const { at_hash, c_hash, nonce, ...claimsWithoutHashes } = claims
|
|
37
|
+
const userInfo = result.access_token && fetchUserInfo ? await client.userinfo(result) : {}
|
|
38
|
+
|
|
36
39
|
return {
|
|
37
40
|
externalIdentifier: claims.sub,
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
...claimsWithoutHashes,
|
|
42
|
+
...userInfo,
|
|
40
43
|
}
|
|
41
44
|
} catch (e: any) {
|
|
42
45
|
if (e instanceof errors.RPError) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client, Issuer } from 'openid-client'
|
|
2
|
-
import { IdentityProviderHandler,
|
|
2
|
+
import { IdentityProviderHandler, IDPResponse, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
3
3
|
import { InvalidIDPConfigurationError } from '../InvalidIDPConfigurationError'
|
|
4
4
|
import { catchTypesafe } from './helpers'
|
|
5
5
|
import { OIDCConfiguration, OIDCInitData, OIDCResponseData } from './OIDCTypes'
|
|
@@ -16,15 +16,15 @@ export class OIDCProvider implements IdentityProviderHandler<OIDCConfiguration>
|
|
|
16
16
|
const initData = catchTypesafe(OIDCInitData, IDPValidationError)(data)
|
|
17
17
|
const client = await this.createOIDCClient(configuration)
|
|
18
18
|
return await initOIDCAuth(client, {
|
|
19
|
-
|
|
19
|
+
scope: configuration.scope ?? configuration.claims,
|
|
20
20
|
...initData,
|
|
21
21
|
})
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
public async processResponse(configuration: OIDCConfiguration, data: unknown): Promise<
|
|
24
|
+
public async processResponse(configuration: OIDCConfiguration, data: unknown): Promise<IDPResponse> {
|
|
25
25
|
const responseData = catchTypesafe(OIDCResponseData, IDPValidationError)(data)
|
|
26
26
|
const client = await this.createOIDCClient(configuration)
|
|
27
|
-
return await handleOIDCResponse(client, responseData)
|
|
27
|
+
return await handleOIDCResponse(client, responseData, configuration.fetchUserInfo)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
@@ -8,9 +8,11 @@ export interface OIDCSessionData {
|
|
|
8
8
|
|
|
9
9
|
export const OIDCConfigurationOptions = Typesafe.partial({
|
|
10
10
|
responseType: Typesafe.enumeration<ResponseType>('code', 'code id_token', 'code id_token token', 'code token', 'id_token', 'id_token token', 'none'),
|
|
11
|
-
claims: Typesafe.string,
|
|
11
|
+
claims: Typesafe.string, // deprecated, use scope instead
|
|
12
|
+
scope: Typesafe.string,
|
|
12
13
|
additionalAuthorizedParties: Typesafe.array(Typesafe.string),
|
|
13
14
|
idTokenSignedResponseAlg: Typesafe.string,
|
|
15
|
+
fetchUserInfo: Typesafe.boolean,
|
|
14
16
|
})
|
|
15
17
|
export const BaseOIDCConfiguration = Typesafe.intersection(
|
|
16
18
|
Typesafe.object({
|
|
@@ -55,7 +55,10 @@ export class IDPMutationResolver implements MutationResolvers {
|
|
|
55
55
|
return {
|
|
56
56
|
ok: true,
|
|
57
57
|
errors: [],
|
|
58
|
-
result:
|
|
58
|
+
result: {
|
|
59
|
+
...await this.signInResponseFactory.createResponse(signIn.result, context),
|
|
60
|
+
idpResponse: signIn.result.idpResponse,
|
|
61
|
+
},
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
}
|
package/src/schema/index.ts
CHANGED
|
@@ -1270,6 +1270,7 @@ export type SignInIdpResponse = {
|
|
|
1270
1270
|
|
|
1271
1271
|
export type SignInIdpResult = CommonSignInResult & {
|
|
1272
1272
|
readonly __typename?: 'SignInIDPResult'
|
|
1273
|
+
readonly idpResponse?: Maybe<Scalars['Json']['output']>
|
|
1273
1274
|
readonly person: Person
|
|
1274
1275
|
readonly token: Scalars['String']['output']
|
|
1275
1276
|
}
|
|
@@ -2518,6 +2519,7 @@ export type SignInIdpResponseResolvers<ContextType = any, ParentType extends Res
|
|
|
2518
2519
|
}
|
|
2519
2520
|
|
|
2520
2521
|
export type SignInIdpResultResolvers<ContextType = any, ParentType extends ResolversParentTypes['SignInIDPResult'] = ResolversParentTypes['SignInIDPResult']> = {
|
|
2522
|
+
idpResponse?: Resolver<Maybe<ResolversTypes['Json']>, ParentType, ContextType>
|
|
2521
2523
|
person?: Resolver<ResolversTypes['Person'], ParentType, ContextType>
|
|
2522
2524
|
token?: Resolver<ResolversTypes['String'], ParentType, ContextType>
|
|
2523
2525
|
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>
|
package/tests/src/IdPMock.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IdentityProviderHandler,
|
|
1
|
+
import { IdentityProviderHandler, IDPResponse, InitIDPAuthResult } from '../../src'
|
|
2
2
|
|
|
3
3
|
export class IdPMock implements IdentityProviderHandler<any> {
|
|
4
4
|
initAuth(configuration: any, data: unknown): Promise<InitIDPAuthResult> {
|
|
@@ -8,7 +8,7 @@ export class IdPMock implements IdentityProviderHandler<any> {
|
|
|
8
8
|
})
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
processResponse(configuration: any, responseData: any): Promise<
|
|
11
|
+
processResponse(configuration: any, responseData: any): Promise<IDPResponse> {
|
|
12
12
|
return Promise.resolve({
|
|
13
13
|
externalIdentifier: configuration.externalIdentifier,
|
|
14
14
|
email: configuration.email,
|