Skip to content

Is there a logic in connect(withPayload: ) that automatically wraps dict into auth:dict? #1493

Open
@kbw2204

Description

@kbw2204

I have a question regarding the connect parameter (withPayload) in swift-socketIO.
Specifically, I want to know if there is any internal logic that automatically wraps the dictionary into an "auth" key when using withPayload.

I'm trying to set the auth option during connect (like this), but couldn't find any related information in the swift-socketIO documentation.

// Socket.IO doc
const socket = io({
  auth: {
    token: "abc"
  }
});

// swift-socketIO
// ??

then I saw an Github issue where auth information was passed using withPayload, and it worked fine.
However, when I wrap the payload with an "auth" key, authentication fails.. Without wrapping it, authentication succeeds.

// authentication ✅
let payload: [String: Any] = [
"token": token
]
manager.connect(withPayload: payload)

// authentication ❌
let payload: [String: Any] = [
    "auth": ["token": token]
]
manager.connect(withPayload: payload)

I checked the internal code of swift-socketIO and couldn't find any logic that automatically wraps the dictionary into an "auth" key. Is there any internal logic in swift-socketIO that does this?

Thank you for your assistance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions