Skip to content

Commit

Permalink
fix: include relay url and wallet pubkey in app created messages inst…
Browse files Browse the repository at this point in the history
…ead of full NWC url
  • Loading branch information
rolznz committed Jan 31, 2025
1 parent fe726f9 commit 2165ca3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (api *api) CreateApp(createAppRequest *CreateAppRequest) (*CreateAppRespons
responseBody.Name = createAppRequest.Name
responseBody.Pubkey = app.AppPubkey
responseBody.PairingSecret = pairingSecretKey
responseBody.WalletPubkey = *app.WalletPubkey
responseBody.RelayUrl = relayUrl

lightningAddress, err := api.albyOAuthSvc.GetLightningAddress()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions api/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ type CreateAppResponse struct {
PairingUri string `json:"pairingUri"`
PairingSecret string `json:"pairingSecretKey"`
Pubkey string `json:"pairingPublicKey"`
RelayUrl string `json:"relayUrl"`
WalletPubkey string `json:"walletPubkey"`
Id uint `json:"id"`
Name string `json:"name"`
ReturnTo string `json:"returnTo"`
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/screens/apps/AppCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ function AppCreatedInternal() {
}, [app?.lastEventAt, navigate, toast]);

useEffect(() => {
// TODO: find a better way to only execute for deeplink flow
if (appstoreApp) {
return;
}
// dispatch a success event which can be listened to by the opener or by the app that embedded the webview
// this gives those apps the chance to know the user has enabled the connection
const nwcEvent = new CustomEvent("nwc:success", {
detail: {
nostrWalletConnectUrl: pairingUri,
relayUrl: createAppResponse.relayUrl,
walletPubkey: createAppResponse.walletPubkey,
},
});
window.dispatchEvent(nwcEvent);
Expand All @@ -73,12 +75,13 @@ function AppCreatedInternal() {
window.opener.postMessage(
{
type: "nwc:success",
nostrWalletConnectUrl: pairingUri,
relayUrl: createAppResponse.relayUrl,
walletPubkey: createAppResponse.walletPubkey,
},
"*"
);
}
}, [appstoreApp, pairingUri]);
}, [appstoreApp, createAppResponse.relayUrl, createAppResponse.walletPubkey]);

if (!createAppResponse) {
return <Navigate to="/apps/new" />;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ export interface CreateAppResponse {
pairingUri: string;
pairingPublicKey: string;
pairingSecretKey: string;
relayUrl: string;
walletPubkey: string;
returnTo: string;
}

Expand Down

0 comments on commit 2165ca3

Please sign in to comment.