Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/503-consistent-utf8-challenge-strings #507

Merged
merged 3 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .github/workflows/ciChecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: node -v
- name: Confirm installed Node version
run: node -v

# Install Deno
- name: Setup Deno ${{ matrix.deno-version }}
uses: maximousblk/setup-deno@v2
with:
deno-version: ${{ matrix.deno-version }}
- run: deno -V
- name: Confirm installed Deno version
run: deno -V

# Install pnpm w/cache for quicker installs
# https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time
Expand All @@ -61,9 +63,10 @@ jobs:
- name: Install dependencies
run: pnpm install

# Build and test dnt packages
- run: npm run build:types # browser tests will need this to be built
- run: npm run build:server # dnt will test everything in Node too

# Test packages
- run: npm run test:browser
# Build and test packages
- name: Build & test @simplewebauthn/typescript-types
run: npm run build:types # browser tests will need this to be built
- name: Build & test @simplewebauthn/server
run: npm run build:server # dnt will test everything in Node too
- name: Test @simplewebauthn/browser
run: npm run test:browser
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ Deno.test('should generate a challenge if one is not provided', async () => {
assert(isoBase64URL.isBase64url(options.challenge));
});

Deno.test('should treat string challenges as UTF-8 strings', async () => {
const options = await generateAuthenticationOptions({
challenge: 'こんにちは',
});

assertEquals(
options.challenge,
'44GT44KT44Gr44Gh44Gv',
);
});

Deno.test('should set rpId if specified', async () => {
const rpID = 'simplewebauthn.dev';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ Deno.test('should generate a challenge if one is not provided', async () => {
mockGenerateChallenge.restore();
});

Deno.test('should treat string challenges as UTF-8 strings', async () => {
const options = await generateRegistrationOptions({
rpID: 'not.real',
rpName: 'SimpleWebAuthn',
userID: '1234',
userName: 'usernameHere',
challenge: 'こんにちは',
});

assertEquals(
options.challenge,
'44GT44KT44Gr44Gh44Gv',
);
});

Deno.test('should use custom supported algorithm IDs as-is when provided', async () => {
const options = await generateRegistrationOptions({
rpID: 'not.real',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export async function generateRegistrationOptions(
*/
let _challenge = challenge;
if (typeof _challenge === 'string') {
_challenge = isoUint8Array.fromASCIIString(_challenge);
_challenge = isoUint8Array.fromUTF8String(_challenge);
}

return {
Expand Down
Loading