feat: implement tenant OAuth flow and guest achievements
This commit is contained in:
16
resources/js/admin/auth/pkce.ts
Normal file
16
resources/js/admin/auth/pkce.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { base64UrlEncode } from './utils';
|
||||
|
||||
export function generateState(): string {
|
||||
return base64UrlEncode(window.crypto.getRandomValues(new Uint8Array(32)));
|
||||
}
|
||||
|
||||
export function generateCodeVerifier(): string {
|
||||
// RFC 7636 recommends a length between 43 and 128 characters.
|
||||
return base64UrlEncode(window.crypto.getRandomValues(new Uint8Array(64)));
|
||||
}
|
||||
|
||||
export async function generateCodeChallenge(verifier: string): Promise<string> {
|
||||
const data = new TextEncoder().encode(verifier);
|
||||
const digest = await window.crypto.subtle.digest('SHA-256', data);
|
||||
return base64UrlEncode(new Uint8Array(digest));
|
||||
}
|
||||
Reference in New Issue
Block a user