-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core,schemas): relocate the profile type defs
relocate the profile type defs
- Loading branch information
Showing
7 changed files
with
61 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/core/src/routes/experience/classes/validators/profile-validator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
import { type SocialUserInfo, socialUserInfoGuard, type ToZodObject } from '@logto/connector-kit'; | ||
import { type CreateUser, Users, UserSsoIdentities, type UserSsoIdentity } from '@logto/schemas'; | ||
import type Provider from 'oidc-provider'; | ||
import { z } from 'zod'; | ||
|
||
export type Interaction = Awaited<ReturnType<Provider['interactionDetails']>>; | ||
|
||
export type InteractionProfile = { | ||
socialIdentity?: { | ||
target: string; | ||
userInfo: SocialUserInfo; | ||
}; | ||
enterpriseSsoIdentity?: Pick< | ||
UserSsoIdentity, | ||
'identityId' | 'ssoConnectorId' | 'issuer' | 'detail' | ||
>; | ||
} & Pick< | ||
CreateUser, | ||
| 'avatar' | ||
| 'name' | ||
| 'username' | ||
| 'primaryEmail' | ||
| 'primaryPhone' | ||
| 'passwordEncrypted' | ||
| 'passwordEncryptionMethod' | ||
>; | ||
|
||
export const interactionProfileGuard = Users.createGuard | ||
.pick({ | ||
avatar: true, | ||
name: true, | ||
username: true, | ||
primaryEmail: true, | ||
primaryPhone: true, | ||
passwordEncrypted: true, | ||
passwordEncryptionMethod: true, | ||
}) | ||
.extend({ | ||
socialIdentity: z | ||
.object({ | ||
target: z.string(), | ||
userInfo: socialUserInfoGuard, | ||
}) | ||
.optional(), | ||
enterpriseSsoIdentity: UserSsoIdentities.guard | ||
.pick({ | ||
identityId: true, | ||
ssoConnectorId: true, | ||
issuer: true, | ||
detail: true, | ||
}) | ||
.optional(), | ||
}) satisfies ToZodObject<InteractionProfile>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters