-
Couldn't load subscription status.
- Fork 255
feat: added support for visionOS platform #859
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
Conversation
…handle breaking changes
…g network requests
… opening up a new tab in safari
…versions which support visionOS
Auth0/MobileWebAuth.swift
Outdated
| func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { | ||
| if let windowScene = UIApplication.shared()?.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene { | ||
| return windowScene.windows.last(where: \.isKeyWindow) ?? ASPresentationAnchor() | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the else is not necessary here because of the early return on L24.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, modified it accordingly
| static var authentication = Auth0.authentication(clientId: clientId, domain: domain) | ||
| static var validatorContext = IDTokenValidatorContext(issuer: URL.httpsURL(from: domain).absoluteString, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these be static constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, updated them
| beforeEach { | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary, removed it now
| stub(condition: isToken(Domain) && hasAtLeast(["refresh_token": RefreshToken, key: value]) && hasHeader(key, value: "bar")) { _ in | ||
| return authResponse(accessToken: NewAccessToken, idToken: NewIdToken, refreshToken: NewRefreshToken, expiresIn: ExpiresIn) | ||
| } | ||
| NetworkStub.addStub(condition: { $0.isToken(Domain) && $0.hasAtLeast(["refresh_token": RefreshToken, key: value])}, response: authResponse(accessToken: NewAccessToken, idToken: NewIdToken, refreshToken: NewRefreshToken, expiresIn: ExpiresIn)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be missing a hasHeader check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you for pointing it out, added it back now
Auth0Tests/NetworkStub.swift
Outdated
| typealias RequestResponse = (URLRequest) -> (Data?, URLResponse?, Error?) | ||
|
|
||
| struct NetworkStub { | ||
| static var stubs: [(condition: RequestCondition, response: RequestResponse)] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be private(set)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, made its setter private now
Auth0Tests/Responses.swift
Outdated
| func apiSuccessResponse(json: [AnyHashable: Any] = [:]) -> RequestResponse { | ||
| return { request in | ||
| let data = try! JSONSerialization.data(withJSONObject: json, options: []) | ||
| let response = HTTPURLResponse(url: request.url!, statusCode: APISuccessStatusCode, httpVersion: nil, headerFields: APIResponseHeaders) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we force-unwrap the response here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, missed it, added it now
📋 Changes
feat: added support for visionOS platform
ASProvider.swift,Auth0WebAuth.swift&MobileWebAuth.swift.Quick&Nimbleto latest versions in order to supportvisionOS.sharedExamplesfromQuicktoBehaviorpattern as its the recommended, and at the same time we are facing issues with it ontvOSplatform.cwlPreConditionTestingpackage viaSPMas latest versions ofQuick&Nimbleneeded it.OHHTTPStubsdoes not supportvisionOSplatform yet.Xcode 14andSwiftversions[5.7, 5.8]as they came along with Xcode 14 and the minimum version of swift required now is5.9✅ Checks
📎 References
Auth0.swift#823
🎯 Testing
ASWebAuthenticationSession, and not onSFSafariViewControlleras we are not supporting it as user agent on visionOS platform as its opening as a new tab in the safari app instead of a pop-up in the app.