Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

What should `onAuthorizer` return when authorization is denied?

Aperta
#175 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Documentazione
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
react-native, typescript

Direzione di ricerca

Inizia dal contratto onAuthorizer nel listener init della classe Pusher e confrontalo con la documentazione collegata sulla risposta di autorizzazione di Pusher. Traccia come {}, undefined e l’autorizzazione negata vengono gestiti dal metodo nativo e da onError. Il lavoro è completato quando il comportamento documentato di restituzione e degli errori, inclusi i casi missing-auth e authorizer-timeout, è chiaro e coerente con il tipo TypeScript.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I can't find a clear answer to this question in the documentation. In the Pusher authorization docs it says:

Unsuccessful responses from an authorization endpoint should serve a 403 Forbidden HTTP status.

Moreover, return type of onAuthorizer is Promise<PusherAuthorizerResult> which is defined as

export interface PusherAuthorizerResult {
  auth?: string;
  shared_secret?: string;
  channel_data?: string;
}

Together this makes me think that onAuthorizer should return {} when the server responds with HTTP 403. But if I do that, then I get the following error: Client error | Invalid key in subscription auth data: '<missing_auth_param>' since the auth field is missing.

If I instead look at the usage of onAuthorizer in the Pusher class, I see this in Pusher#init:

this.addListener(
  PusherEventName.ON_AUTHORIZER,
  async ({ channelName, socketId }) => {
    const data = await args.onAuthorizer?.(channelName, socketId);
    if (data) {
      await PusherWebsocketReactNative.onAuthorizer(
        channelName,
        socketId,
        data
      );
    }
  }
);

Here we check if the result of onAuthorizer is truthy before calling the native method. So from this I think that onAuthorizer should return a falsey value if authorization fails. But that (1) wouldn't typecheck and (2) if I return undefined then I instead get Client Error | Invalid key in subscription auth data: '<authorizer_timeout>'

So I'm at a bit of a loss as to how to implement this correctly. Should I just be handling the client errors with the onError method? Any pointers here, am I overlooking something?

Lingua principale
TypeScript
Stelle
76
Fork
64
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pusher/pusher-websocket-react-native

Tutte le issue di pusher/pusher-websocket-react-native

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.