@konemono/nostr-login 1.7.66 → 1.7.68
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 +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/unpkg.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/modules/AmberDirectSigner.ts +10 -7
- package/src/modules/AuthNostrService.ts +2 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -173,6 +173,8 @@ export class NostrLoginInitializer {
|
|
|
173
173
|
await this.extensionService.trySetExtensionForPubkey(info.pubkey);
|
|
174
174
|
} else if (info.authMethod === 'connect' && info.sk && info.relays && info.relays[0]) {
|
|
175
175
|
this.authNostrService.setConnect(info);
|
|
176
|
+
} else if (info.authMethod === ('amber' as any)) {
|
|
177
|
+
this.authNostrService.setAmber(info);
|
|
176
178
|
} else {
|
|
177
179
|
throw new Error('Bad auth info');
|
|
178
180
|
}
|
|
@@ -307,7 +309,7 @@ export class NostrLoginInitializer {
|
|
|
307
309
|
public setAuth = async (o: NostrLoginAuthOptions) => {
|
|
308
310
|
if (!o.type) throw new Error('Invalid auth event');
|
|
309
311
|
if (o.type !== 'login' && o.type !== 'logout' && o.type !== 'signup') throw new Error('Invalid auth event');
|
|
310
|
-
if (o.method && o.method !== 'connect' && o.method !== 'extension' && o.method !== 'local' && o.method !== 'otp' && o.method !== 'readOnly')
|
|
312
|
+
if (o.method && o.method !== 'connect' && o.method !== 'extension' && o.method !== 'local' && o.method !== 'otp' && o.method !== 'readOnly' && o.method !== ('amber' as any))
|
|
311
313
|
throw new Error('Invalid auth event');
|
|
312
314
|
|
|
313
315
|
if (o.type === 'logout') return this.logout();
|
|
@@ -106,6 +106,7 @@ export class AmberDirectSigner implements Signer {
|
|
|
106
106
|
params.append('returnType', 'signature');
|
|
107
107
|
params.append('type', type);
|
|
108
108
|
params.append('callbackUrl', callbackUrl);
|
|
109
|
+
params.append('name', window.location.hostname);
|
|
109
110
|
if (pubkey) params.append('pubkey', pubkey);
|
|
110
111
|
if (this._pubkey) params.append('current_user', this._pubkey);
|
|
111
112
|
|
|
@@ -132,13 +133,15 @@ export class AmberDirectSigner implements Signer {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
if (result) {
|
|
137
|
+
console.log('Amber response detection:', {
|
|
138
|
+
href: window.location.href,
|
|
139
|
+
eventParam: url.searchParams.get('event'),
|
|
140
|
+
pathResult: result,
|
|
141
|
+
sessionId: localStorage.getItem('amber_last_id'),
|
|
142
|
+
sessionType: localStorage.getItem('amber_last_type')
|
|
143
|
+
});
|
|
144
|
+
}
|
|
142
145
|
|
|
143
146
|
if (!result) return null;
|
|
144
147
|
|
|
@@ -121,6 +121,7 @@ class AuthNostrService extends EventEmitter implements Signer {
|
|
|
121
121
|
if (response.type === 'get_public_key' || response.type.includes('pub')) {
|
|
122
122
|
const info: Info = {
|
|
123
123
|
pubkey: response.result,
|
|
124
|
+
name: nip19.npubEncode(response.result),
|
|
124
125
|
authMethod: 'amber' as any,
|
|
125
126
|
};
|
|
126
127
|
console.log('Amber login success', info);
|
|
@@ -219,6 +220,7 @@ class AuthNostrService extends EventEmitter implements Signer {
|
|
|
219
220
|
|
|
220
221
|
const info: Info = {
|
|
221
222
|
pubkey,
|
|
223
|
+
name: nip19.npubEncode(pubkey),
|
|
222
224
|
authMethod: 'amber' as any,
|
|
223
225
|
};
|
|
224
226
|
|