-
Notifications
You must be signed in to change notification settings - Fork 3
feat: support paykit receiver paths #620
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -346,7 +346,7 @@ class PubkyProfileManager: ObservableObject { | |||||
| } | ||||||
|
|
||||||
| func deleteProfile() async throws { | ||||||
| await Self.removePrivatePaykitEndpointsBestEffort(context: "PubkyProfileManager.deleteProfile") | ||||||
| try await Self.removePrivatePaykitEndpoints(context: "PubkyProfileManager.deleteProfile") | ||||||
| do { | ||||||
| try await Task.detached { | ||||||
| try await PubkyService.deletePaykitProfile() | ||||||
|
|
@@ -684,13 +684,26 @@ class PubkyProfileManager: ObservableObject { | |||||
| } | ||||||
|
|
||||||
| static func removePublicPaykitEndpoints(context: String) async throws { | ||||||
| var firstError: Error? | ||||||
| do { | ||||||
| try await PublicPaykitService.removePublishedEndpoints() | ||||||
| } catch PubkyServiceError.sessionNotActive { | ||||||
| Logger.debug("Skipping public Paykit endpoint cleanup because no session is active", context: context) | ||||||
| } catch { | ||||||
| Logger.warn("Failed to remove public Paykit endpoints before clearing session: \(error)", context: context) | ||||||
| throw error | ||||||
| firstError = error | ||||||
| } | ||||||
|
|
||||||
| do { | ||||||
| try await PublicPaykitService.syncLocalReceiverMarker(publicSharingEnabled: false, privateSharingEnabled: false) | ||||||
| } catch PubkyServiceError.sessionNotActive { | ||||||
| Logger.debug("Skipping Paykit receiver marker cleanup because no session is active", context: context) | ||||||
| } catch { | ||||||
| firstError = firstError ?? error | ||||||
| } | ||||||
|
|
||||||
| if let firstError { | ||||||
| Logger.warn("Failed to remove public Paykit state before clearing session: \(firstError)", context: context) | ||||||
| throw firstError | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -730,7 +743,7 @@ class PubkyProfileManager: ObservableObject { | |||||
| private func signOut(cleanPrivatePaykitEndpoints: Bool) async throws { | ||||||
| try await Task.detached { | ||||||
| if cleanPrivatePaykitEndpoints { | ||||||
| await Self.removePrivatePaykitEndpointsBestEffort(context: "PubkyProfileManager.signOut") | ||||||
| try await Self.removePrivatePaykitEndpoints(context: "PubkyProfileManager.signOut") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When private endpoint cleanup fails here, the detached sign-out task throws before public Paykit cleanup, server sign-out, local key removal, and
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is intentional for the same reason as deletion. Normal sign-out must keep the session and private SDK state available until the receiver-scoped clears are delivered. Otherwise local sign-out would erase the retry state and could strand shared private details. Forced wallet wipe remains the best-effort escape path. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood — the throw acts as a gate to keep session and retry state intact until all receiver-scoped clears succeed, which is consistent with the deletion path. That makes sense. I'll drop this comment. |
||||||
| } | ||||||
| await Self.removePublicPaykitEndpointsBestEffort(context: "PubkyProfileManager.signOut") | ||||||
| do { | ||||||
|
|
||||||
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.
When private Paykit endpoint removal fails during profile deletion, this new throwing call exits before
deletePaykitProfile()andsignOut(cleanPrivatePaykitEndpoints: false)run. A transient cleanup error can leave the user signed in with the profile, public endpoints, and receiver marker still active instead of deleting the profile and recording cleanup for retry.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.
Keeping this blocking is intentional. If deletion continues after private cleanup fails,
clearLocalState()removes the SDK state and credentials needed to retry clearing private details that may already be shared. Normal deletion keeps the profile in place so the user can retry; the forced wallet wipe path remains best effort.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.
That's a solid rationale — preserving credentials for retry is more important than a clean deletion path here. Withdrawing the concern.
Shall I remember this as a rule: "prefer throwing cleanup over best-effort when failure would wipe the credentials needed to retry that same cleanup"?
Tip: You can customize Greptile's behavior for this repo with
.greptile/rules.mdand.greptile/config.json.