Skip to content

Commit

Permalink
chore(core): update some comments
Browse files Browse the repository at this point in the history
update some comments
  • Loading branch information
simeng-li committed Jun 21, 2024
1 parent 7128c6b commit 8ee8685
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,27 @@ import { findUserByIdentifier } from '../../utils.js';

import { type Verification } from './verification.js';

const eventToTemplateTypeMap: Record<InteractionEvent, TemplateType> = {
SignIn: TemplateType.SignIn,
Register: TemplateType.Register,
ForgotPassword: TemplateType.ForgotPassword,
};

/**
* To make the typescript type checking work. A valid TemplateType is required.
* This is a work around to map the latest interaction event type to old TemplateType.
*
* @remark This is a temporary solution until the connector-kit is updated to use the latest interaction event types.
**/
const eventToTemplateTypeMap: Record<InteractionEvent, TemplateType> = {
SignIn: TemplateType.SignIn,
Register: TemplateType.Register,
ForgotPassword: TemplateType.ForgotPassword,
};
const getTemplateTypeByEvent = (event: InteractionEvent): TemplateType =>
eventToTemplateTypeMap[event];

/** The JSON data type for the CodeVerification record */
export type CodeVerificationRecordData = {
id: string;
type: VerificationType.VerificationCode;
identifier: VerificationCodeIdentifier;
/**
* The interaction event that triggered the verification.
* This will be used to determine the template type for the verification code.
* @remark
* `InteractionEvent.ForgotPassword` triggered verification results can not used as a verification record for other events.
*/
interactionEvent: InteractionEvent;
/** The userId of the user that has been verified. Only available after the verification of existing identifier */
userId?: string;
verified: boolean;
};
Expand Down Expand Up @@ -75,7 +70,7 @@ const getPasscodeIdentifierPayload = (
export class CodeVerification implements Verification {
/**
* Factory method to create a new CodeVerification record using the given identifier.
* The sendVerificationCode method will be automatically triggered on the creation of the record.
* The sendVerificationCode method will be automatically triggered.
*/
static async create(
libraries: Libraries,
Expand All @@ -96,10 +91,18 @@ export class CodeVerification implements Verification {
return record;
}

Check warning on line 92 in packages/core/src/routes/experience/classes/verifications/code-verification.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/experience/classes/verifications/code-verification.ts#L76-L92

Added lines #L76 - L92 were not covered by tests

readonly type = VerificationType.VerificationCode;
public readonly type = VerificationType.VerificationCode;
public readonly identifier: VerificationCodeIdentifier;
public readonly id: string;
/**
* The interaction event that triggered the verification.
* This will be used to determine the template type for the verification code.
*
* @remark
* `InteractionEvent.ForgotPassword` triggered verification results can not used as a verification record for other events.
*/
private readonly interactionEvent: InteractionEvent;
/** The userId will be set after the verification if the identifier matches any existing user's record */
private userId?: string;
private verified: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export type PasswordVerificationRecordData = {
id: string;
type: VerificationType.Password;
identifier: InteractionIdentifier;
/* The userId of the user that has been verified */
userId?: string;
};

Expand Down Expand Up @@ -48,6 +47,7 @@ export class PasswordVerification implements Verification {
readonly type = VerificationType.Password;
public readonly identifier: InteractionIdentifier;
public readonly id: string;
/* The userId of the user that has been identifier by the given identifier and password */
private userId?: string;

constructor(
Expand Down

0 comments on commit 8ee8685

Please sign in to comment.