1
0
Fork 0

feat(shared): Initial implementation of Oauth flow

This commit is contained in:
Joost De Cock 2023-09-01 18:30:24 +02:00
parent 70b8fdd703
commit 01ef6c9896
24 changed files with 1077 additions and 172 deletions

View file

@ -445,3 +445,14 @@ export const horFlexClassesNoSm =
* A method that check that a var is not empty
*/
export const notEmpty = (thing) => `${thing}`.length > 0
/*
* Generates a random string (used in Oauth flow)
*/
const dec2hex = (dec) => dec.toString(16).padStart(2, '0')
export const randomString = (len = 42) => {
if (typeof window === 'undefined') return '' // Not used in SSR
const arr = new Uint8Array(len / 2)
window.crypto.getRandomValues(arr)
return Array.from(arr, dec2hex).join('')
}