@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.
- package/dist/const/index.d.ts +3 -0
- package/dist/index.esm.js +12 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/AuthNostrService.d.ts +13 -12
- package/dist/modules/ModalManager.d.ts +1 -0
- package/dist/modules/Nip46.d.ts +44 -47
- package/dist/modules/NostrExtensionService.d.ts +0 -5
- package/dist/modules/Signer.d.ts +4 -11
- package/dist/types.d.ts +0 -5
- package/dist/unpkg.js +12 -10
- package/dist/utils/index.d.ts +3 -2
- package/package.json +4 -7
- package/src/const/index.ts +7 -0
- package/src/index.ts +2 -8
- package/src/modules/AuthNostrService.ts +169 -311
- package/src/modules/ModalManager.ts +14 -10
- package/src/modules/Nip46.ts +400 -208
- package/src/modules/NostrExtensionService.ts +0 -6
- package/src/modules/Signer.ts +8 -39
- package/src/types.ts +0 -7
- package/src/utils/index.ts +31 -79
- package/tsconfig.json +1 -1
- package/src/modules/AmberDirectSigner.ts +0 -228
- package/src/modules/Nip46.iframe.test.ts +0 -124
- package/src/modules/Nip46.test.ts +0 -31
- package/src/modules/nip46/Nip46Adapter.ts +0 -123
- package/src/modules/nip46/Nip46Client.ts +0 -248
- package/src/modules/nip46/types.ts +0 -26
- package/vitest.config.ts +0 -9
package/dist/utils/index.d.ts
CHANGED
|
@@ -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,
|
|
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:
|
|
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.
|
|
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
|
}
|
package/src/const/index.ts
CHANGED
|
@@ -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
|
-
|
|
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'
|
|
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();
|