-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(prettier): Add prettier, pr template (#3)
* add prettier * add prettier * add max-len * add pr template * no semi * add lint step
- Loading branch information
Showing
8 changed files
with
78 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Story: ... | ||
|
||
1. Why this change is required? | ||
- ... | ||
2. What problem does it solve? | ||
- ... | ||
|
||
## Implementation | ||
1. | ||
2. | ||
3. | ||
|
||
## Checklist | ||
- [x] Fulfilled specs | ||
- [x] Ensured code is readable | ||
- [x] Consistency in architecture | ||
- [x] Added Test |
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 |
---|---|---|
|
@@ -13,4 +13,5 @@ jobs: | |
with: | ||
node-version: '20.x' | ||
- run: npm ci | ||
- run: npm run lint | ||
- run: npm run test |
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,7 @@ | ||
{ | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true, | ||
"arrowParens": "avoid", | ||
"printWidth": 100 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
|
||
import { render } from '@testing-library/react'; | ||
import App from './App'; | ||
import { test, expect } from 'vitest' | ||
import { render } from '@testing-library/react' | ||
import App from './App' | ||
|
||
it('runs vitest', () => { | ||
expect(1).toBe(1); | ||
}); | ||
test('runs vitest', () => { | ||
expect(1).toBe(1) | ||
}) | ||
|
||
it('renders text', () => { | ||
const wrapper = render(<App />); | ||
expect(wrapper).toBeTruthy(); | ||
test('renders text', () => { | ||
const wrapper = render(<App />) | ||
expect(wrapper).toBeTruthy() | ||
|
||
const { getByText } = wrapper; | ||
expect(getByText('Vite + React')).toBeTruthy(); | ||
}); | ||
const { getByText } = wrapper | ||
expect(getByText('Vite + React')).toBeTruthy() | ||
}) |
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
import { Sha256 } from '@aws-crypto/sha256-js'; | ||
import { Sha256 } from '@aws-crypto/sha256-js' | ||
|
||
export const toSha256 = async (data: string): Promise<Uint8Array> => { | ||
if (!data) throw new Error('data is required'); | ||
if (!data) throw new Error('data is required') | ||
|
||
const hash = new Sha256(); | ||
hash.update(data); | ||
const hash = new Sha256() | ||
hash.update(data) | ||
|
||
const hashed = await hash.digest(); | ||
return hashed; | ||
const hashed = await hash.digest() | ||
return hashed | ||
} | ||
|
||
// refer to base64url-encoding in RFC 7636 | ||
// https://datatracker.ietf.org/doc/html/rfc7636#appendix-A | ||
export const toBase64Url = (bytes: Uint8Array) => { | ||
if (bytes.length === 0) throw new Error('bytes must not be empty'); | ||
|
||
const charCodes = Array.from(bytes); | ||
let str = btoa(String.fromCharCode.apply(null, charCodes)); | ||
str = str.split('=')[0]; | ||
str = str.replace(/\+/g, '-'); | ||
str = str.replace(/\//g, '_'); | ||
return str; | ||
if (bytes.length === 0) throw new Error('bytes must not be empty') | ||
|
||
const charCodes = Array.from(bytes) | ||
let str = btoa(String.fromCharCode.apply(null, charCodes)) | ||
str = str.split('=')[0] | ||
str = str.replace(/\+/g, '-') | ||
str = str.replace(/\//g, '_') | ||
return str | ||
} | ||
|
||
// refer to random string generation in RFC 7636 | ||
// https://datatracker.ietf.org/doc/html/rfc7636#section-4.1 | ||
export const createRandomString = (length: number = 34): string => { | ||
if (length === 0) throw new Error('length must be greater than 0'); | ||
if (length === 0) throw new Error('length must be greater than 0') | ||
|
||
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~'; | ||
let randomString = ''; | ||
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~' | ||
let randomString = '' | ||
for (let i = 0; i < length; i++) { | ||
const randomIndex = Math.floor(Math.random() * charset.length); | ||
randomString += charset[randomIndex]; | ||
const randomIndex = Math.floor(Math.random() * charset.length) | ||
randomString += charset[randomIndex] | ||
} | ||
return randomString; | ||
return randomString | ||
} | ||
|
||
export const createPKCECodeChallenge = async (codeVerifier: string): string => { | ||
const hashed: Uint8Array = await toSha256(codeVerifier) | ||
const codeChallenge = toBase64Url(hashed) | ||
return codeChallenge; | ||
return codeChallenge | ||
} |