Skip to content

Flowchart — Módulo: auth

Gerado pelo Archaeologist (Reversa) em 2026-05-11


Fluxo Principal: Auth.autenticar()

flowchart TD
    A([autenticar chamado]) --> B[CredentialsService.getGenericPassword]
    B --> C{Credenciais existem?}
    C -- Não --> D[react-native-app-auth authorize PKCE]
    D --> E{OAuth completado?}
    E -- Cancelado/Erro --> F([undefined])
    E -- Sucesso --> G[Api.auth authState.idToken]
    G --> H{API OK?}
    H -- Erro --> I([Toast de erro])
    H -- Sucesso --> J[CredentialsService.setGenericPassword slug + JSON credenciais]
    J --> K[UsuarioLogadoRepository.setUsuarioLogado]
    K --> L([Retorna idToken])
    C -- Sim --> M{Token ativo? expirationDate - 1min > agora}
    M -- Sim --> L
    M -- Não --> N[react-native-app-auth refresh refreshToken]
    N --> O[CredentialsService.setGenericPassword atualizado]
    O --> L

Fluxo: CredentialsService — Dual Strategy

flowchart TD
    A([new CredentialsService]) --> B{Platform.OS}
    B -- web --> C[WebCredentialsStrategy]
    B -- ios/android --> D[NativeCredentialsStrategy]

    C --> C1[getGenericPassword: localStorage.getItem + JSON.parse + validação]
    C --> C2[setGenericPassword: JSON.stringify + localStorage.setItem]
    C --> C3[resetGenericPassword: localStorage.removeItem]

    D --> D1[getGenericPassword: keychain.getGenericPassword]
    D --> D2[setGenericPassword: keychain.setGenericPassword]
    D --> D3[resetGenericPassword: keychain.resetGenericPassword]

Fluxo: Logout

flowchart TD
    A([logout]) --> B[CredentialsService.resetGenericPassword]
    B --> C[UsuarioLogadoRepository.logout MMKV.remove]
    C --> D[Auth.revogarTokenGoogle]
    D --> E[POST Google OAuth revoke?token=refreshToken]
    E --> F([Store Redux: clearUsuario])

Fluxo: Verificação de Autenticação

flowchart TD
    A([isAutenticado]) --> B[CredentialsService.getGenericPassword]
    B --> C{Resultado falso?}
    C -- Sim --> D([false])
    C -- Não --> E{Token ativo? expirationDate - 1min > agora}
    E -- Sim --> F([true])
    E -- Não --> G[Tentar refresh]
    G --> H{Refresh OK?}
    H -- Sim --> F
    H -- Não --> D