Skip to content

Commit

Permalink
Default user.displayName to empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterKale committed Mar 6, 2024
1 parent c016aa8 commit 9710bf6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { returnsNext, stub } from 'https://deno.land/std@0.198.0/testing/mock.ts

import { generateRegistrationOptions } from './generateRegistrationOptions.ts';
import { _generateChallengeInternals } from '../helpers/generateChallenge.ts';
import { isoUint8Array } from '../helpers/iso/index.ts';

Deno.test('should generate credential request options suitable for sending via JSON', async () => {
const rpName = 'SimpleWebAuthn';
Expand All @@ -13,13 +12,15 @@ Deno.test('should generate credential request options suitable for sending via J
const userName = 'usernameHere';
const timeout = 1;
const attestationType = 'indirect';
const userDisplayName = 'userDisplayName';

const options = await generateRegistrationOptions({
rpName,
rpID,
challenge,
userID,
userName,
userDisplayName,
timeout,
attestationType,
});
Expand All @@ -36,7 +37,7 @@ Deno.test('should generate credential request options suitable for sending via J
user: {
id: userID,
name: userName,
displayName: userName,
displayName: userDisplayName,
},
pubKeyCredParams: [
{ alg: -8, type: 'public-key' },
Expand Down Expand Up @@ -109,6 +110,18 @@ Deno.test('defaults to none attestation if no attestation type is specified', as
assertEquals(options.attestation, 'none');
});

Deno.test('defaults to empty string for displayName if no userDisplayName is specified', async () => {
const options = await generateRegistrationOptions({
rpName: 'SimpleWebAuthn',
rpID: 'not.real',
challenge: 'totallyrandomvalue',
userID: '1234',
userName: 'usernameHere',
});

assertEquals(options.user.displayName, '');
});

Deno.test('should set authenticatorSelection if specified', async () => {
const options = await generateRegistrationOptions({
rpName: 'SimpleWebAuthn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function generateRegistrationOptions(
userID,
userName,
challenge = await generateChallenge(),
userDisplayName = userName,
userDisplayName = '',
timeout = 60000,
attestationType = 'none',
excludeCredentials = [],
Expand Down

0 comments on commit 9710bf6

Please sign in to comment.