-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@W-15248536@ - [v2] Google Search Console fix createCodeVerifier (#1765)
* Add entropy to nanoid createCodeVerifier * cleanup * bump main.js file size * Debug GA Windows builds * Set shell: true with spawnSync * Set shell: true with spawnSync on generator * lint * Update CHANGELOG.md * Add docs * Update CHANGELOG.md * Update CHANGELOG.md
- Loading branch information
Showing
7 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/template-retail-react-app/app/commerce-api/pkce.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2024, Salesforce, Inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import {createCodeVerifier, generateCodeChallenge} from './pkce' | ||
import seedrandom from 'seedrandom' | ||
|
||
describe('PKCE Utility Functions', () => { | ||
describe('createCodeVerifier', () => { | ||
test('should generate unique code verifiers', () => { | ||
const verifiers = new Set() | ||
const numVerifiers = 100 | ||
|
||
for (let i = 0; i < numVerifiers; i++) { | ||
const verifier = createCodeVerifier() | ||
verifiers.add(verifier) | ||
} | ||
expect(verifiers.size).toBe(numVerifiers) | ||
}) | ||
|
||
test('should provide sufficient entropy', () => { | ||
const seed1 = 123456789 | ||
const seed2 = 987654321 | ||
seedrandom(seed1, {global: true}) | ||
const verifier1 = createCodeVerifier() | ||
seedrandom(seed2, {global: true}) | ||
const verifier2 = createCodeVerifier() | ||
// the generated verifiers should be different because we're using different seeds | ||
expect(verifier1).not.toBe(verifier2) | ||
}) | ||
}) | ||
|
||
describe('generateCodeChallenge', () => { | ||
test('should generate a code challenge based on the provided code verifier', async () => { | ||
const codeVerifier = createCodeVerifier() | ||
const codeChallenge = await generateCodeChallenge(codeVerifier) | ||
|
||
expect(codeChallenge).toBeDefined() | ||
}) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters