pusher / pusher/pusher-websocket-react-native

Got Error: 'Invalid signature: Expected HMAC SHA256 hex digest' on authenticating user for private channel

Open
#149 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
76
Forks
64
PR merge metrics
No merged PRs in 30d

Description

The error i got on pusher debug console
Screenshot 2024-03-05 at 5 57 12 PM

here's my code

async function iniPusher() {
    const pusher = Pusher.getInstance();

    await pusher.init({
      apiKey: '',
      cluster: 'ap2',
      authEndpoint: `https://domain.com/api/v1/pusher/user-auth/${auth.user.id}`,
    });

    await pusher.connect();
    await pusher.subscribe({
      channelName: 'private-chat.' + auth.user.id,
      onEvent: event => {
        console.log(`Event received: ${event}`);
        const formattedData = formatEventData(event);
        setMessages(previousMessages =>
          GiftedChat.append(previousMessages, formattedData),
        );
      },
      onConnectionStateChange(currentState) {
        console.log(`Connection: ${currentState}`);
      },
      onError(message, code, e) {
        console.log(`onError: ${message} code: ${code} exception: ${e}`);
      },
      onSubscriptionSucceeded(channelName, data) {
        console.log(`onSubscriptionSucceeded: ${channelName} data: ${data}`);
      },
      onSubscriptionError(channelName, message, e) {
        console.log(
          `onSubscriptionError: ${message} channelName: ${channelName} Exception: ${e}`,
        );
      },
      onAuthorizer(channelName, socketId) {
        console.log(
          `calling onAuthorizer. channelName=${channelName}, socketId=${socketId},`,
        );

    });
  }

response I got from server

{
    "auth": "d980932ee394770d0950:50b4795375582e8dceb2a6597b8eab6f2f72c23e25b1ee9aa5fc9de9f2160e3f",
    "user_data": "{\"id\":61}"
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the Pusher initialization and private-channel subscription shown in the issue, then compare the auth endpoint response with the SDK's private-channel authentication requirements. Reproduce the subscription using the reported channel and response; done means authentication succeeds without the invalid HMAC signature error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
authentication, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.