diff --git a/packages/core/src/routes/experience/classes/experience-interaction.ts b/packages/core/src/routes/experience/classes/experience-interaction.ts index e69ad74e5..88fdf9f79 100644 --- a/packages/core/src/routes/experience/classes/experience-interaction.ts +++ b/packages/core/src/routes/experience/classes/experience-interaction.ts @@ -14,11 +14,11 @@ import { getNewUserProfileFromVerificationRecord, identifyUserByVerificationRecord, } from './helpers.js'; +import { MfaValidator } from './libraries/mfa-validator.js'; +import { ProfileValidator } from './libraries/profile-validator.js'; +import { ProvisionLibrary } from './libraries/provision-library.js'; +import { SignInExperienceValidator } from './libraries/sign-in-experience-validator.js'; import { toUserSocialIdentityData } from './utils.js'; -import { MfaValidator } from './validators/mfa-validator.js'; -import { ProfileValidator } from './validators/profile-validator.js'; -import { ProvisionLibrary } from './validators/provision-library.js'; -import { SignInExperienceValidator } from './validators/sign-in-experience-validator.js'; import { buildVerificationRecord, verificationRecordDataGuard, @@ -283,7 +283,7 @@ export default class ExperienceInteraction { // TODO: missing profile fields validation if (enterpriseSsoIdentity) { - await this.provisionLibrary.provisionNewSsoIdentity(user.id, enterpriseSsoIdentity); + await this.provisionLibrary.addSsoIdentityToUser(user.id, enterpriseSsoIdentity); } const { provider } = this.tenant; @@ -361,7 +361,7 @@ export default class ExperienceInteraction { const newProfile = await getNewUserProfileFromVerificationRecord(verificationRecord); await this.profileValidator.guardProfileUniquenessAcrossUsers(newProfile); - const user = await this.provisionLibrary.provisionNewUser(newProfile); + const user = await this.provisionLibrary.createUser(newProfile); this.userId = user.id; } diff --git a/packages/core/src/routes/experience/classes/validators/mfa-validator.ts b/packages/core/src/routes/experience/classes/libraries/mfa-validator.ts similarity index 100% rename from packages/core/src/routes/experience/classes/validators/mfa-validator.ts rename to packages/core/src/routes/experience/classes/libraries/mfa-validator.ts diff --git a/packages/core/src/routes/experience/classes/validators/password-validator.ts b/packages/core/src/routes/experience/classes/libraries/password-validator.ts similarity index 100% rename from packages/core/src/routes/experience/classes/validators/password-validator.ts rename to packages/core/src/routes/experience/classes/libraries/password-validator.ts diff --git a/packages/core/src/routes/experience/classes/validators/profile-validator.ts b/packages/core/src/routes/experience/classes/libraries/profile-validator.ts similarity index 100% rename from packages/core/src/routes/experience/classes/validators/profile-validator.ts rename to packages/core/src/routes/experience/classes/libraries/profile-validator.ts diff --git a/packages/core/src/routes/experience/classes/validators/provision-library.ts b/packages/core/src/routes/experience/classes/libraries/provision-library.ts similarity index 96% rename from packages/core/src/routes/experience/classes/validators/provision-library.ts rename to packages/core/src/routes/experience/classes/libraries/provision-library.ts index a8610b7b6..3167b366a 100644 --- a/packages/core/src/routes/experience/classes/validators/provision-library.ts +++ b/packages/core/src/routes/experience/classes/libraries/provision-library.ts @@ -43,10 +43,10 @@ export class ProvisionLibrary { /** * Insert a new user into the Logto database using the provided profile. * - * - Provision the organization for the new user based on the profile - * - OSS only, new user provisioning + * - Provision all JIT organizations for the user if necessary. + * - Assign the first user to the admin role and the default tenant organization membership. [OSS only] */ - async provisionNewUser(profile: InteractionProfile) { + async createUser(profile: InteractionProfile) { const { libraries: { users: { generateUserId, insertUser }, @@ -89,7 +89,7 @@ export class ProvisionLibrary { return user; } - async provisionNewSsoIdentity( + async addSsoIdentityToUser( userId: string, enterpriseSsoIdentity: Required['enterpriseSsoIdentity'] ) { diff --git a/packages/core/src/routes/experience/classes/validators/sign-in-experience-validator.test.ts b/packages/core/src/routes/experience/classes/libraries/sign-in-experience-validator.test.ts similarity index 100% rename from packages/core/src/routes/experience/classes/validators/sign-in-experience-validator.test.ts rename to packages/core/src/routes/experience/classes/libraries/sign-in-experience-validator.test.ts diff --git a/packages/core/src/routes/experience/classes/validators/sign-in-experience-validator.ts b/packages/core/src/routes/experience/classes/libraries/sign-in-experience-validator.ts similarity index 100% rename from packages/core/src/routes/experience/classes/validators/sign-in-experience-validator.ts rename to packages/core/src/routes/experience/classes/libraries/sign-in-experience-validator.ts diff --git a/packages/core/src/routes/experience/classes/verifications/new-password-identity-verification.ts b/packages/core/src/routes/experience/classes/verifications/new-password-identity-verification.ts index 8b51787f8..dceaddb0b 100644 --- a/packages/core/src/routes/experience/classes/verifications/new-password-identity-verification.ts +++ b/packages/core/src/routes/experience/classes/verifications/new-password-identity-verification.ts @@ -13,10 +13,10 @@ import type Libraries from '#src/tenants/Libraries.js'; import type Queries from '#src/tenants/Queries.js'; import assertThat from '#src/utils/assert-that.js'; +import { PasswordValidator } from '../libraries/password-validator.js'; +import { ProfileValidator } from '../libraries/profile-validator.js'; +import { SignInExperienceValidator } from '../libraries/sign-in-experience-validator.js'; import { interactionIdentifierToUserProfile } from '../utils.js'; -import { PasswordValidator } from '../validators/password-validator.js'; -import { ProfileValidator } from '../validators/profile-validator.js'; -import { SignInExperienceValidator } from '../validators/sign-in-experience-validator.js'; import { type VerificationRecord } from './verification-record.js'; diff --git a/packages/core/src/routes/experience/classes/verifications/verification-records-map.ts b/packages/core/src/routes/experience/classes/verifications/verification-records-map.ts index dc60760f3..3645d13d4 100644 --- a/packages/core/src/routes/experience/classes/verifications/verification-records-map.ts +++ b/packages/core/src/routes/experience/classes/verifications/verification-records-map.ts @@ -1,13 +1,15 @@ /** * @fileoverview * - * Since `Map` in TS does not support key value type mapping, - * we have to manually define a `setValue` method to ensure correct key will be set * This class is used to store and manage all the verification records. * - * Extends the Map class and adds a `setValue` method to ensure the key value type mapping. + * Since `Map` in TS does not support key - value type mapping, + * we have to manually define a `setValue` method to ensure correct key will be set. + * + * - Extends the Map class and add a `setValue` method to ensure the key value type mapping. + * - Override the `get` method to return the correct value type. + * - Override the `set` method to throw an error to prevent using it directly. */ - import { type VerificationType } from '@logto/schemas'; import { type VerificationRecord, type VerificationRecordMap } from './index.js';