@konemono/nostr-login 1.9.10 → 1.9.12

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.9.10",
3
+ "version": "1.9.12",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,7 +27,7 @@ const NOSTRCONNECT_APPS: ConnectionString[] = [
27
27
  {
28
28
  name: 'Amber',
29
29
  img: 'https://raw.githubusercontent.com/greenart7c3/Amber/refs/heads/master/assets/android-icon.svg',
30
- link: 'amber',
30
+ link: '<nostrconnect>',
31
31
  relays: DEFAULT_NOSTRCONNECT_RELAYS,
32
32
  },
33
33
  {
@@ -73,9 +73,6 @@ class AuthNostrService extends EventEmitter implements Signer {
73
73
  encrypt: this.encrypt44.bind(this),
74
74
  decrypt: this.decrypt44.bind(this),
75
75
  };
76
-
77
- // ページロード時にAmberフローを復元
78
- this.checkAndResumeAmberFlow();
79
76
  }
80
77
 
81
78
  public isIframe() {
@@ -99,58 +96,6 @@ class AuthNostrService extends EventEmitter implements Signer {
99
96
  public cancelNostrConnect() {
100
97
  this.releaseSigner();
101
98
  this.resetAuth();
102
- // Amber pending状態もクリア
103
- localStorage.removeItem('nostr-login-amber-pending');
104
- }
105
-
106
- /**
107
- * Amberから戻ってきた際に保存された状態を確認して復元する
108
- */
109
- private async checkAndResumeAmberFlow() {
110
- try {
111
- const pendingData = localStorage.getItem('nostr-login-amber-pending');
112
- if (!pendingData) return;
113
-
114
- const { nostrConnectKey, nostrConnectSecret, relays, domain, timestamp } = JSON.parse(pendingData);
115
-
116
- // タイムアウトチェック(10分以内なら有効)
117
- if (Date.now() - timestamp > 10 * 60 * 1000) {
118
- console.log('[Amber] Pending flow expired, clearing');
119
- localStorage.removeItem('nostr-login-amber-pending');
120
- return;
121
- }
122
-
123
- console.log('[Amber] Resuming pending flow from localStorage');
124
-
125
- // 状態を復元
126
- this.nostrConnectKey = nostrConnectKey;
127
- this.nostrConnectSecret = nostrConnectSecret;
128
-
129
- const info: Info = {
130
- authMethod: 'connect',
131
- pubkey: '',
132
- signerPubkey: '',
133
- sk: this.nostrConnectKey,
134
- domain: domain,
135
- relays: relays,
136
- };
137
-
138
- // リスナーを再開してAmberからの接続を待つ
139
- await this.startAuth();
140
- await this.initSigner(info, { listen: true });
141
-
142
- // 接続が成功したらlocalStorageをクリア
143
- if (info.pubkey && info.signerPubkey) {
144
- info.bunkerUrl = `bunker://${info.signerPubkey}?${relays.map((r: string, i: number) => `${i !== 0 ? '&' : ''}relay=${r}`).join('')}`;
145
- this.onAuth('login', info);
146
- await this.endAuth();
147
- localStorage.removeItem('nostr-login-amber-pending');
148
- console.log('[Amber] Flow resumed successfully');
149
- }
150
- } catch (error) {
151
- console.error('[Amber] Failed to resume flow:', error);
152
- localStorage.removeItem('nostr-login-amber-pending');
153
- }
154
99
  }
155
100
 
156
101
  public async nostrConnect(
@@ -181,41 +126,9 @@ class AuthNostrService extends EventEmitter implements Signer {
181
126
 
182
127
  console.log('nostrconnect info', info, link);
183
128
 
184
- // non-iframe flow - Amber も NIP-46 経由(nostrsigner:// の代わりに nostrconnect:// を使用)
129
+ // non-iframe flow
185
130
  if (link && !iframeUrl) {
186
- if (link === 'amber') {
187
- // Amber に nostrconnect:// URL を渡す
188
- const nostrconnectUrl = await this.createNostrConnect(relays);
189
- console.log('Amber flow via NIP-46, opening:', nostrconnectUrl);
190
-
191
- // 状態を保存してAmberから戻ってきたときに復元できるようにする
192
- localStorage.setItem(
193
- 'nostr-login-amber-pending',
194
- JSON.stringify({
195
- nostrConnectKey: this.nostrConnectKey,
196
- nostrConnectSecret: this.nostrConnectSecret,
197
- relays: relays,
198
- domain: domain,
199
- timestamp: Date.now(),
200
- }),
201
- );
202
-
203
- // AndroidではIntent URLを使用してAmberを開く(ページコンテキストを保持しようと試みる)
204
- try {
205
- const intentUrl = `intent://${nostrconnectUrl.replace('nostrconnect://', '')}#Intent;scheme=nostrconnect;package=com.greenart7c3.nostrsigner;end;`;
206
- const opened = window.open(intentUrl, '_system');
207
-
208
- // window.openが失敗した場合は従来の方法にフォールバック
209
- if (!opened) {
210
- window.location.href = nostrconnectUrl;
211
- }
212
- } catch (e) {
213
- // エラー時はdirect schemeにフォールバック
214
- window.location.href = nostrconnectUrl;
215
- }
216
- } else {
217
- window.open(link, '_blank', 'width=400,height=700');
218
- }
131
+ window.open(link, '_blank', 'width=400,height=700');
219
132
  }
220
133
 
221
134
  // init nip46 signer