Skip to content

Commit

Permalink
feat: Ensure password is always masked by default
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg committed Jul 29, 2023
1 parent 3f87051 commit cffefa2
Show file tree
Hide file tree
Showing 9 changed files with 941 additions and 597 deletions.
5 changes: 1 addition & 4 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1524,12 +1524,9 @@ function snapshot(
week: true,
textarea: true,
select: true,
password: true,
}
: maskAllInputs === false
? {
password: true,
}
? {}
: maskAllInputs;
const slimDOMOptions: SlimDOMOptions =
slimDOM === true || slimDOM === 'all'
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb-snapshot/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export type MaskInputOptions = Partial<{
// unify textarea and select element with text input
textarea: boolean;
select: boolean;
password: boolean;
// password is _always_ masked, can't opt out of this
radio: boolean;
checkbox: boolean;
}>;
Expand Down
5 changes: 4 additions & 1 deletion packages/rrweb-snapshot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ export function shouldMaskInput({
const actualType = type && toLowerCase(type);
return Boolean(
maskInputOptions[tagName.toLowerCase() as keyof MaskInputOptions] ||
(actualType && maskInputOptions[actualType as keyof MaskInputOptions]),
(actualType && maskInputOptions[actualType as keyof MaskInputOptions]) ||
actualType === 'password' ||
// Default to "text" option for inputs without a "type" attribute defined
(tagName === 'INPUT' && !type && maskInputOptions['text'])
);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,12 @@ function record<T = eventWithTime>(
week: true,
textarea: true,
select: true,
password: true,
radio: true,
checkbox: true,
}
: _maskInputOptions !== undefined
? _maskInputOptions
: { password: true };
: {};

const slimDOMOptions: SlimDOMOptions =
_slimDOMOptions === true || _slimDOMOptions === 'all'
Expand Down
Loading

0 comments on commit cffefa2

Please sign in to comment.