vapor / jwt-kit

🔑 JSON Web Token (JWT) signing and verification (HMAC, ECDSA, EdDSA, RSA, PSS) with support for JWS and JWK
https://api.vapor.codes/jwtkit/documentation/jwtkit/
MIT License
202 stars 53 forks source link

Sendable conformances? #167

Closed adam-rocska closed 5 months ago

adam-rocska commented 5 months ago

Is your feature request related to a problem? Please describe. When writing more complex yet dynamic software using for example Vapor, it would come in handy to have units of this library conform to the Sendable protocol so that we can toss them around between threads and whatnot.

For now, the clients of this library get the following warnings during build, which, if I am not mistaken will yield an error with Swift 6:

/Users/rocskaadam/src/21gram-id/src/oauth-kit/Sources/OAuthKit/RFC7591/ClientInformationResponse/ClientInformationResponse.swift:23:14: warning: stored property 'jwks' of 'Sendable'-conforming generic struct 'ClientInformationResponse' has non-sendable type 'JWKS?'
  public var jwks: JWKS?

Client provided Sendable protocol conformances are sadly also not possible, so the only practical way is to throw Sendable on the relevant and likely relevant types. I am not aware of any drawbacks, but I'm no expert in the subject going this deep yet.

Describe the solution you'd like If the proposal makes sense, my naive vision is to just rampage through the sources and throw Sendable left & right wherever it seems to serve the described purpose. But again, I guess it's naive ¯\(ツ)

Describe alternatives you've considered

  1. Conformance from the dependent: doesn't work
  2. Fork: ew, this library rocks and deserves to be the single source of truth
  3. Pre-build patch hackery in the .build artifacts: DON'T DO THIS AT HOME! It works, and solves my local problem, but Good Lord I'm shaking what'll happen in the future....

Additional context If there's any better idea around or I might be doing something totally wrong, feel free to correct me.

gwynne commented 5 months ago

The 5.0 beta of this package (currently at 5.0.0-beta.3) includes full Sendable conformance.

adam-rocska commented 5 months ago

Is there an estimated release date for it perhaps? (I’m not too comfortable using beta in production code 😢 )

If it’s a long way ahead, or unclear yet, I’m more than happy to do the gruntwork on 4.x - assuming my assumptions were correct

0xTim commented 5 months ago

@adam-rocska Pretty soon, we're just letting people give the APIs a run through to make sure we haven't missed anything. You can see more info on the blog https://blog.vapor.codes/posts/jwtkit-v5

I wouldn't be surprised if we tagged the main release this month

adam-rocska commented 5 months ago

AWESOME! Thank you🙏 I guess I'm up for a rewrite on my end 🤓