@dypai-ai/client-sdk - v1.12.0
    Preparing search index...
    Index

    Constructors

    Accessors

    • get hasPasswordRecoveryToken(): boolean

      True while a recovery token captured from an email link is available. The SDK removes sensitive auth params from the URL after storing them.

      Returns boolean

    • get isPasswordRecoveryCallback(): boolean

      Checks if the last callback was a password recovery/invite flow. Does NOT consume the value — use consumeCallbackType() to consume.

      Returns boolean

    • get lastError(): { code: string; message: string } | null

      Returns the last auth error from a callback (expired link, invalid token, etc.) Null if no error. Cleared on next successful auth action.

      Returns { code: string; message: string } | null

    Methods

    • Returns and consumes the pending callback type from the last auth redirect. Use this on callback pages to determine the redirect destination. Returns 'recovery' | 'invite' | 'signup' | 'magiclink' | null.

      Example:

      const type = dypai.auth.consumeCallbackType();
      if (type === 'recovery' || type === 'invite') navigate('/set-password');
      else navigate('/dashboard');

      Returns string | null

    • Clears the local session after an unrecoverable 401. Called internally by the API layer.

      Returns void

    • Invita a un miembro a una organización por email.

      Parameters

      • organizationId: string
      • email: string
      • Optionalrole: string

      Returns Promise<DypaiResponse<any>>

    • Comprueba si hay una sesión activa de forma síncrona. Nota: al inicio de la app, puede retornar false hasta que _recoverSession() termine. Para una comprobación fiable al arranque, usa getSession() (que espera la inicialización).

      Returns boolean

    • Subscribes to authentication state changes. The listener receives an INITIAL_SESSION event immediately after registration, followed by SIGNED_IN, SIGNED_OUT, TOKEN_REFRESHED, PASSWORD_RECOVERY, etc.

      Parameters

      • listener: AuthListener

        Callback invoked with (event, session) on every auth state change.

      Returns { data: { subscription: { unsubscribe: () => void } } }

      An object with data.subscription.unsubscribe() to remove the listener.

      const { data: { subscription } } = dypai.auth.onAuthStateChange((event, session) => {
      if (event === 'SIGNED_IN') console.log('Welcome!', session.user.email);
      if (event === 'SIGNED_OUT') router.push('/login');
      });

      // Later: stop listening
      subscription.unsubscribe();
    • Reenvía el email de confirmación de registro. Útil cuando el usuario no recibió el email original o este expiró. Reenvía el email de verificación.

      Parameters

      • email: string
      • Optionaloptions: { redirectTo?: string }

      Returns Promise<DypaiResponse<{ message: string }>>

    • Establece o actualiza la contraseña del usuario autenticado actual. Útil para flujos de invitación o recuperación donde el usuario llega con token válido.

      Parameters

      • password: string

      Returns Promise<DypaiResponse<{ status: boolean }>>

    • Envía un magic link al email del usuario para login sin contraseña.

      Parameters

      • email: string
      • Optionaloptions: { redirectTo?: string }

      Returns Promise<DypaiResponse<{ message: string }>>

    • Inicia el auto-refresh basado en ticks. Cada 30s verifica si el token está próximo a expirar y lo refresca. Más robusto que setTimeout porque Chrome throttlea setTimeout en background tabs.

      Returns void