@konemono/nostr-login 1.7.54 → 1.7.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konemono/nostr-login",
3
- "version": "1.7.54",
3
+ "version": "1.7.56",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -119,16 +119,27 @@ export class AmberDirectSigner implements Signer {
119
119
  }
120
120
 
121
121
  private generateUrl(content: string, type: string, id: string, recipient?: string): string {
122
- const callbackUrl = new URL(window.location.href);
123
- callbackUrl.searchParams.set('amberType', type);
124
- callbackUrl.searchParams.set('amberId', id);
122
+ const url = new URL(window.location.href);
123
+ const searchParams = url.searchParams;
124
+ searchParams.delete('amberType');
125
+ searchParams.delete('amberId');
126
+ searchParams.delete('signature');
127
+ searchParams.delete('result');
128
+ url.hash = ''; // Amber/Android may not handle hash in callbackUrl well
129
+
130
+ url.searchParams.set('amberType', type);
131
+ url.searchParams.set('amberId', id);
125
132
 
126
133
  const params = new URLSearchParams();
127
134
  params.set('type', type);
128
135
  params.set('id', id);
129
- params.set('callbackUrl', callbackUrl.toString());
130
- if (this._pubkey) params.set('pubkey', this._pubkey);
131
- if (recipient) params.set('pubkey', recipient); // Amber uses pubkey param for recipient in encrypt/decrypt
136
+ params.set('callbackUrl', url.toString());
137
+ params.set('name', document.location.host);
138
+ if (recipient) {
139
+ params.set('pubkey', recipient);
140
+ } else if (this._pubkey) {
141
+ params.set('pubkey', this._pubkey);
142
+ }
132
143
 
133
144
  return `nostrsigner:${encodeURIComponent(content)}?${params.toString()}`;
134
145
  }
@@ -87,6 +87,10 @@ class AuthNostrService extends EventEmitter implements Signer {
87
87
  };
88
88
 
89
89
  setTimeout(() => this.checkAmberResponse(), 500);
90
+
91
+ window.addEventListener('focus', () => {
92
+ this.checkAmberResponse();
93
+ });
90
94
  }
91
95
 
92
96
  private checkAmberResponse() {