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

feat: parse token util function #27

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: parse token util function #27

wants to merge 2 commits into from

Conversation

guru-web3
Copy link
Contributor

No description provided.

Comment on lines +102 to +109
func decodeJWTPart(_ value: String) -> [String: Any]? {
guard let bodyData = base64UrlDecode(value),
let json = try? JSONSerialization.jsonObject(with: bodyData, options: []), let payload = json as? [String: Any] else {
return nil
}

return payload
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should throw if the jwt is not decodable, not return nil.

func decodeJWTPart(_ value: String) throws -> [String: Any] {
...
}

Could you not just use the jwtDecode package instead?

i.e

 return try decode(jwt: idToken)

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

Successfully merging this pull request may close these issues.

3 participants