Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kbw2204 opened this issue May 21, 2024 · 0 comments

Comments

@kbw2204
Copy link

kbw2204 commented May 21, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant