Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

What should `onAuthorizer` return when authorization is denied?

オープン
#175 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 9 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
ドキュメント
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
react-native, typescript

調査の方向性

PusherクラスのinitリスナーにあるonAuthorizerの契約から始め、リンクされているPusher認証レスポンスのドキュメントと比較してください。{}, undefined、認証拒否がネイティブメソッドとonErrorによってどのように処理されるかを追跡してください。missing-authおよびauthorizer-timeoutのケースを含む、ドキュメント化された戻り値とエラーの動作が明確で、TypeScriptの型と一貫していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
TypeScript
スター
76
フォーク
65
平均マージ
9日 2時間
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pusher/pusher-websocket-react-native のほかの issue

pusher/pusher-websocket-react-native の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。