@konemono/nostr-login 1.9.14 → 1.10.1

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.
@@ -1,11 +1,12 @@
1
1
  import { Info, RecentType } from 'nostr-login-components/dist/types/types';
2
+ import NDK, { NDKSigner } from '@nostr-dev-kit/ndk';
2
3
  import { NostrLoginOptions } from '../types';
3
4
  export declare const localStorageSetItem: (key: string, value: string) => void;
4
5
  export declare const localStorageGetItem: (key: string) => any;
5
6
  export declare const localStorageRemoveItem: (key: string) => void;
6
- export declare const fetchProfile: (info: Info, profileNdkOrRelays?: any) => Promise<any>;
7
+ export declare const fetchProfile: (info: Info, profileNdk: NDK) => Promise<import("@nostr-dev-kit/ndk").NDKUserProfile | null>;
7
8
  export declare const prepareSignupRelays: (signupRelays?: string) => string[];
8
- export declare const createProfile: (info: Info, signer: any, signupRelays?: string, outboxRelays?: string[]) => Promise<void>;
9
+ export declare const createProfile: (info: Info, profileNdk: NDK, signer: NDKSigner, signupRelays?: string, outboxRelays?: string[]) => Promise<void>;
9
10
  export declare const bunkerUrlToInfo: (bunkerUrl: string, sk?: string) => Info;
10
11
  export declare const isBunkerUrl: (value: string) => boolean;
11
12
  export declare const getBunkerUrl: (value: string, optionsModal: NostrLoginOptions) => Promise<string>;
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@konemono/nostr-login",
3
- "version": "1.9.14",
3
+ "version": "1.10.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "build": "rollup -c",
10
- "format": "npx prettier --write src",
11
- "test": "vitest run",
12
- "test:watch": "vitest"
10
+ "format": "npx prettier --write src"
13
11
  },
14
12
  "author": "a-fralou",
15
13
  "dependencies": {
14
+ "@nostr-dev-kit/ndk": "^2.3.1",
16
15
  "nostr-tools": "^1.17.0",
17
16
  "tseep": "^1.2.1"
18
17
  },
@@ -23,9 +22,7 @@
23
22
  "nostr-login-components": "^1.0.3",
24
23
  "prettier": "^3.2.2",
25
24
  "rollup": "^4.9.6",
26
- "rollup-plugin-typescript2": "^0.36.0",
27
- "vitest": "^1.0.0",
28
- "@types/node": "^18.0.0"
25
+ "rollup-plugin-typescript2": "^0.36.0"
29
26
  },
30
27
  "license": "MIT"
31
28
  }
@@ -1 +1,8 @@
1
1
  export const CALL_TIMEOUT = 5000;
2
+
3
+ // デフォルトのNip46リレー
4
+ export const DEFAULT_NIP46_RELAYS = ['wss://relay.nsec.app/', 'wss://ephemeral.snowflare.cc/'];
5
+
6
+ // Nip46タイムアウト設定
7
+ export const NIP46_REQUEST_TIMEOUT = 30000; // 30秒
8
+ export const NIP46_CONNECT_TIMEOUT = 60000; // 60秒
package/src/index.ts CHANGED
@@ -148,11 +148,7 @@ export class NostrLoginInitializer {
148
148
  }
149
149
 
150
150
  private openPopup(url: string) {
151
- if (url.startsWith('nostrsigner:')) {
152
- window.open(url, '_blank', 'width=400,height=600');
153
- } else {
154
- this.popupManager.openPopup(url);
155
- }
151
+ this.popupManager.openPopup(url);
156
152
  }
157
153
 
158
154
  private async switchAccount(info: Info, signup = false) {
@@ -173,8 +169,6 @@ export class NostrLoginInitializer {
173
169
  await this.extensionService.trySetExtensionForPubkey(info.pubkey);
174
170
  } else if (info.authMethod === 'connect' && info.sk && info.relays && info.relays[0]) {
175
171
  this.authNostrService.setConnect(info);
176
- } else if (info.authMethod === ('amber' as any)) {
177
- this.authNostrService.setAmber(info);
178
172
  } else {
179
173
  throw new Error('Bad auth info');
180
174
  }
@@ -309,7 +303,7 @@ export class NostrLoginInitializer {
309
303
  public setAuth = async (o: NostrLoginAuthOptions) => {
310
304
  if (!o.type) throw new Error('Invalid auth event');
311
305
  if (o.type !== 'login' && o.type !== 'logout' && o.type !== 'signup') throw new Error('Invalid auth event');
312
- if (o.method && o.method !== 'connect' && o.method !== 'extension' && o.method !== 'local' && o.method !== 'otp' && o.method !== 'readOnly' && o.method !== ('amber' as any))
306
+ if (o.method && o.method !== 'connect' && o.method !== 'extension' && o.method !== 'local' && o.method !== 'otp' && o.method !== 'readOnly')
313
307
  throw new Error('Invalid auth event');
314
308
 
315
309
  if (o.type === 'logout') return this.logout();