@konemono/nostr-login 1.7.65 → 1.7.66
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/dist/index.esm.js +1 -1
- package/dist/unpkg.js +1 -1
- package/package.json +1 -1
- package/src/modules/AmberDirectSigner.ts +10 -10
- package/src/modules/AuthNostrService.ts +19 -3
package/package.json
CHANGED
|
@@ -95,9 +95,9 @@ export class AmberDirectSigner implements Signer {
|
|
|
95
95
|
const encodedContent = encodeURIComponent(content || '');
|
|
96
96
|
const encodedCallback = encodeURIComponent(callbackUrl);
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
localStorage.setItem('amber_last_type', type);
|
|
99
|
+
localStorage.setItem('amber_last_id', id);
|
|
100
|
+
localStorage.setItem('amber_last_timestamp', Date.now().toString());
|
|
101
101
|
|
|
102
102
|
// NIP-55準拠: nostrsigner: スキーム
|
|
103
103
|
let url = `nostrsigner:${encodedContent}`;
|
|
@@ -136,18 +136,18 @@ export class AmberDirectSigner implements Signer {
|
|
|
136
136
|
href: window.location.href,
|
|
137
137
|
eventParam: url.searchParams.get('event'),
|
|
138
138
|
pathResult: result,
|
|
139
|
-
sessionId:
|
|
140
|
-
sessionType:
|
|
139
|
+
sessionId: localStorage.getItem('amber_last_id'),
|
|
140
|
+
sessionType: localStorage.getItem('amber_last_type')
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
if (!result) return null;
|
|
144
144
|
|
|
145
|
-
const id =
|
|
146
|
-
const type =
|
|
145
|
+
const id = localStorage.getItem('amber_last_id');
|
|
146
|
+
const type = localStorage.getItem('amber_last_type');
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
localStorage.removeItem('amber_last_id');
|
|
149
|
+
localStorage.removeItem('amber_last_type');
|
|
150
|
+
localStorage.removeItem('amber_last_timestamp');
|
|
151
151
|
|
|
152
152
|
if (id && type) {
|
|
153
153
|
return { id, type, result };
|
|
@@ -130,10 +130,26 @@ class AuthNostrService extends EventEmitter implements Signer {
|
|
|
130
130
|
// NIP-55では直接resultを使用するため、追加のキャッシュは不要
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
// ★ 追加: URL
|
|
133
|
+
// ★ 追加: URLクリーンアップをより徹底的に
|
|
134
134
|
const url = new URL(window.location.href);
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
let changed = false;
|
|
136
|
+
if (url.searchParams.has('event')) {
|
|
137
|
+
url.searchParams.delete('event');
|
|
138
|
+
changed = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// パス末尾が結果と一致する場合はパスもクリア
|
|
142
|
+
const pathParts = url.pathname.split('/');
|
|
143
|
+
if (pathParts.length > 0 && pathParts[pathParts.length - 1] === response.result) {
|
|
144
|
+
pathParts.pop();
|
|
145
|
+
url.pathname = pathParts.join('/') || '/';
|
|
146
|
+
changed = true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (changed) {
|
|
150
|
+
console.log('Cleaning up Amber response URL', url.toString());
|
|
151
|
+
window.history.replaceState({}, '', url.toString());
|
|
152
|
+
}
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
155
|
|