Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Cheung <[email protected]>
  • Loading branch information
pragatimodi and kevinthecheung authored Oct 19, 2023
1 parent 1ab9273 commit c294ff4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/auth/passkey-config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from './passkey-config';

/**
* Manages Passkey Configuration for a Firebase app.
* Manages Passkey configuration for a Firebase app.
*/
export class PasskeyConfigManager {
private readonly authRequestHandler: AuthRequestHandler;
Expand All @@ -43,7 +43,7 @@ export class PasskeyConfigManager {
}

/**
* Retrieves the Passkey Configuration.
* Retrieves the Passkey configuration.
*
* @param tenantId - (optional) The tenant ID if querying passkeys on a specific tenant.
* @returns A promise fulfilled with the passkey configuration.
Expand Down
18 changes: 9 additions & 9 deletions src/auth/passkey-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';
import { deepCopy } from '../utils/deep-copy';

/**
* Interface representing the properties to update in the provided passkey config.
* Interface representing the properties to update in a passkey config.
*/
export interface PasskeyConfigRequest {
/**
* An array of website or app origins associated with the customer's sites or apps.
* Only challenges signed from these origins will be allowed for signing in with passkeys.
* An array of website or app origins. Only challenges signed
* from these origins will be allowed for signing in with passkeys.
*/
expectedOrigins?: string[];
}
Expand Down Expand Up @@ -59,7 +59,7 @@ export class PasskeyConfig {
*/
public readonly rpId?: string;
/**
* The website or app origins associated with the customer's sites or apps.
* The allowed website or app origins.
* Only challenges signed from these origins will be allowed for signing in with passkeys.
*/
public readonly expectedOrigins?: string[];
Expand All @@ -78,7 +78,7 @@ export class PasskeyConfig {
if (isCreateRequest && !validator.isNonEmptyString(rpId)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
"'rpId' must be a valid non-empty string.",
"'rpId' must be a non-empty string.",
);
}
// Validation for updating an existing PasskeyConfig.
Expand All @@ -91,7 +91,7 @@ export class PasskeyConfig {
if (!validator.isNonNullObject(passkeyConfigRequest)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
"'passkeyConfigRequest' must be a valid non-empty object.",
"'passkeyConfigRequest' must not be null.",
);
}
const validKeys = {
Expand All @@ -109,21 +109,21 @@ export class PasskeyConfig {
if (!validator.isNonEmptyArray(passkeyConfigRequest.expectedOrigins)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
"'passkeyConfigRequest.expectedOrigins' must be a valid non-empty array of strings.",
"'passkeyConfigRequest.expectedOrigins' must contain at least one item.",
);
}
for (const origin of passkeyConfigRequest.expectedOrigins) {
if (!validator.isNonEmptyString(origin)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_ARGUMENT,
"'passkeyConfigRequest.expectedOrigins' must be a valid non-empty array of strings.",
"'passkeyConfigRequest.expectedOrigins' cannot contain empty strings.",
);
}
}
}

/**
* Build the corresponding server request for a Passkey Config object.
* Build a server request for a Passkey Config object.
* @param isCreateRequest - A boolean stating if it's a create request.
* @param passkeyConfigRequest - Passkey config to be updated.
* @param rpId - (optional) Relying party ID for the request if it's a create request.
Expand Down

0 comments on commit c294ff4

Please sign in to comment.