Skip to content

Conversation

@germ-mark
Copy link
Contributor

This hides the implementation of ATProtoAuthenticator wrapping an Authenticator object

Comment on lines 99 to 106
loginStorage: .init(
retrieveLogin: { @MainActor in
login
},
storeLogin: { @MainActor newLogin in
login = newLogin
}
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is all temporary until the authenticate() method returns the session, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. And it’s my assertion/belief that once authenticate returns we should have no further need for the authenticator and the (local) login storage. The resulting token gets passed to another object which spawns its own authenticator object(s)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, we could define a login storage that handles both initial and ongoing storage, that gets handed off from in-memory storage to persistent storage. That seems more complex, but could handle refresh calls that happen after authenticate() returns

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, refresh could be required immediately after authenticate() in some certain scenarios.

ChimeHQ/OAuthenticator#46 — here's the change to return the current session from the authenticate method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems more complex, but could handle refresh calls that happen after authenticate() returns

It is slightly more complex, but guarantees safe handling everywhere, and prevents leaking the Login, so maybe with that we wouldn't need #46 above.

Copy link
Collaborator

@ThisIsMissEm ThisIsMissEm left a comment

Choose a reason for hiding this comment

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

This will work, but it looks a little weird

The sendAuthenticatedRequest in ATProtoLiteClient will trigger calls to loginStorage to store changes to the tokens, or even clear the current login. So it'd probably make sense to have a single shared LoginStorage implementation that stores the data correctly and securely, then share that across all authenticators.

In this case, until we have authenticate() returning the Login we'd need to use a custom loginStorage here, but it should probably still interact with the global implementation, I think.

@germ-mark germ-mark force-pushed the mark/GER-1260 branch 2 times, most recently from 75a6d3b to bdcbba1 Compare December 23, 2025 18:42
@germ-mark
Copy link
Contributor Author

To properly hide the implementation in tests, ended up defining an ATProtoInterface, behind which are a struct that encapsulates the online calls, and an actor that mocks out ATProtocol for multiple test apps to interact with

@germ-mark
Copy link
Contributor Author

rebased atop PR #1 and added a similar interface for load Protected Metadata so we can run offline tests

@germ-mark germ-mark merged commit 31a71d6 into main Dec 29, 2025
2 checks passed
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