Skip to content

Commit

Permalink
api comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
blidd-google committed Oct 9, 2024
1 parent fe45165 commit 030cb59
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
20 changes: 12 additions & 8 deletions src/common/providers/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,20 @@ export interface Credential {
signInMethod: string;
}

/** Possible types of emails as described by the GCIP backend. */
/**
* Possible types of emails as described by the GCIP backend, which can be:
* - An sign-in email
* - A password reset email
*/
export type EmailType = "EMAIL_SIGN_IN" | "PASSWORD_RESET";

/**
* The type of SMS message
* The type of SMS message, which can be:
* - A sign-in or sign up SMS message
* - A multi-factor sign-in SMS message
* - A multi-factor enrollment SMS message
*/
export type SmsType =
| "SIGN_IN_OR_SIGN_UP" // A sign-in or sign up SMS message
| "MULTI_FACTOR_SIGN_IN" // A multi-factor sign-in SMS message
| "MULTI_FACTOR_ENROLLMENT"; // A multi-factor enrollment SMS message
export type SmsType = "SIGN_IN_OR_SIGN_UP" | "MULTI_FACTOR_SIGN_IN" | "MULTI_FACTOR_ENROLLMENT";

/** Defines the auth event context for blocking events */
export interface AuthEventContext extends EventContext {
Expand Down Expand Up @@ -374,7 +378,7 @@ export interface BeforeSmsResponse {
recaptchaActionOverride?: RecaptchaActionOptions;
}

/** The handler response type for beforeCreate blocking events */
/** The handler response type for `beforeCreate` blocking events */
export interface BeforeCreateResponse {
displayName?: string;
disabled?: boolean;
Expand Down Expand Up @@ -472,7 +476,7 @@ export interface DecodedPayload {
* Internal definition to include all the fields that can be sent as
* a response from the blocking function to the backend.
* This is added mainly to have a type definition for 'generateResponsePayload'
* @internal */
@internal */
export interface ResponsePayload {
userRecord?: UserRecordResponsePayload;
recaptchaActionOverride?: RecaptchaActionOptions;
Expand Down
27 changes: 13 additions & 14 deletions src/v2/providers/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,26 @@ export interface BlockingOptions {

/**
* Handles an event that is triggered before a user is created.
* @param handler - Event handler which is run every time before a user is created
* @param handler - Event handler which is run every time before a user is created.
*/
export function beforeUserCreated(
handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeCreateResponse | void>
): BlockingFunction;

/**
* Handles an event that is triggered before a user is created.
* @param opts - Object containing function options
* @param handler - Event handler which is run every time before a user is created
* @param opts - Object containing function options.
* @param handler - Event handler which is run every time before a user is created.
*/
export function beforeUserCreated(
opts: BlockingOptions,
handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeCreateResponse | void>
): BlockingFunction;

/**
* Handles an event that is triggered before a user is created
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user creation)
* @param handler? - If defined, an event handler which is run every time before a user is created
* Handles an event that is triggered before a user is created.
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user creation).
* @param handler? - If defined, an event handler which is run every time before a user is created.
*/
export function beforeUserCreated(
optsOrHandler:
Expand All @@ -199,16 +199,16 @@ export function beforeUserCreated(

/**
* Handles an event that is triggered before a user is signed in.
* @param handler - Event handler which is run every time before a user is signed in
* @param handler - Event handler which is run every time before a user is signed in.
*/
export function beforeUserSignedIn(
handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeSignInResponse | void>
): BlockingFunction;

/**
* Handles an event that is triggered before a user is signed in.
* @param opts - Object containing function options
* @param handler - Event handler which is run every time before a user is signed in
* @param opts - Object containing function options.
* @param handler - Event handler which is run every time before a user is signed in.
*/
export function beforeUserSignedIn(
opts: BlockingOptions,
Expand All @@ -217,8 +217,8 @@ export function beforeUserSignedIn(

/**
* Handles an event that is triggered before a user is signed in.
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user signin)
* @param handler - Event handler which is run every time before a user is signed in
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user signin).
* @param handler - Event handler which is run every time before a user is signed in.
*/
export function beforeUserSignedIn(
optsOrHandler:
Expand All @@ -239,7 +239,7 @@ export function beforeEmailSent(

/**
* Handles an event that is triggered before an email is sent to a user.
* @param opts - Object containing function options
* @param opts - Object containing function options.
* @param handler - Event handler that is run before an email is sent to a user.
*/
export function beforeEmailSent(
Expand Down Expand Up @@ -270,7 +270,7 @@ export function beforeSmsSent(

/**
* Handles an event that is triggered before an SMS is sent to a user.
* @param opts - Object containing function options
* @param opts - Object containing function options.
* @param handler - Event handler that is run before an SMS is sent to a user.
*/
export function beforeSmsSent(
Expand Down Expand Up @@ -317,7 +317,6 @@ export function beforeOperation(

// Create our own function that just calls the provided function so we know for sure that
// handler takes one argument. This is something common/providers/identity depends on.
// const wrappedHandler = (event: AuthBlockingEvent) => handler(event);
const annotatedHandler = Object.assign(handler, { platform: "gcfv2" as const });
const func: any = wrapTraceContext(withInit(wrapHandler(eventType, annotatedHandler)));

Expand Down

0 comments on commit 030cb59

Please sign in to comment.