File tree Expand file tree Collapse file tree 3 files changed +285
-203
lines changed Expand file tree Collapse file tree 3 files changed +285
-203
lines changed Original file line number Diff line number Diff line change 1+ import { ref } from 'vue' ;
2+
3+ interface ClipboardOptions {
4+ timeout ?: number ;
5+ }
6+
7+ export function useClipboard ( options : ClipboardOptions = { } ) {
8+ const { timeout = 1500 } = options ;
9+
10+ const copied = ref ( false ) ;
11+
12+ const copyToClipboard = async ( text : string ) : Promise < void > => {
13+ if ( typeof window === 'undefined' || ! navigator . clipboard ) {
14+ return ;
15+ }
16+
17+ try {
18+ await navigator . clipboard . writeText ( text ) ;
19+ copied . value = true ;
20+ setTimeout ( ( ) => ( copied . value = false ) , timeout ) ;
21+ } catch ( error ) {
22+ console . error ( 'Failed to copy to clipboard:' , error ) ;
23+ }
24+ } ;
25+
26+ return {
27+ copied,
28+ copyToClipboard,
29+ } ;
30+ }
Original file line number Diff line number Diff line change 1+ export const useTwoFactorAuth = ( ) => {
2+ const fetchQRCode = async ( ) : Promise < { svg : string } > => {
3+ const response = await fetch ( route ( 'two-factor.qr-code' ) ) ;
4+ return await response . json ( ) ;
5+ } ;
6+
7+ const fetchManualSetupKey = async ( ) : Promise < { secretKey : string } > => {
8+ const response = await fetch ( route ( 'two-factor.secret-key' ) ) ;
9+ return await response . json ( ) ;
10+ } ;
11+
12+ const fetchRecoveryCodes = async ( ) : Promise < string [ ] > => {
13+ const response = await fetch ( route ( 'two-factor.recovery-codes' ) ) ;
14+ return await response . json ( ) ;
15+ } ;
16+
17+ return {
18+ fetchQRCode,
19+ fetchManualSetupKey,
20+ fetchRecoveryCodes,
21+ } ;
22+ } ;
You can’t perform that action at this time.
0 commit comments