@konemono/nostr-login 1.11.0 → 1.11.3
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 +15 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/AuthNostrService.d.ts +4 -14
- package/dist/modules/Nip46.d.ts +26 -64
- package/dist/modules/Signer.d.ts +6 -12
- package/dist/unpkg.js +15 -20
- package/dist/utils/index.d.ts +3 -6
- package/dist/utils/nip44.d.ts +3 -3
- package/package.json +8 -8
- package/src/modules/AuthNostrService.ts +109 -210
- package/src/modules/ModalManager.ts +3 -3
- package/src/modules/Nip46.ts +185 -390
- package/src/modules/NostrExtensionService.ts +0 -2
- package/src/modules/Signer.ts +12 -35
- package/src/utils/index.ts +23 -73
- package/src/utils/nip44.ts +7 -12
- package/test-relay-management.html +0 -407
|
@@ -3,7 +3,8 @@ import { NostrParams } from './';
|
|
|
3
3
|
import { EventEmitter } from 'tseep';
|
|
4
4
|
import { Signer } from './Nostr';
|
|
5
5
|
declare class AuthNostrService extends EventEmitter implements Signer {
|
|
6
|
-
private
|
|
6
|
+
private ndk;
|
|
7
|
+
private profileNdk;
|
|
7
8
|
private signer;
|
|
8
9
|
private localSigner;
|
|
9
10
|
private params;
|
|
@@ -42,18 +43,6 @@ declare class AuthNostrService extends EventEmitter implements Signer {
|
|
|
42
43
|
localSignup(name: string, sk?: string): Promise<void>;
|
|
43
44
|
setLocal(info: Info, signup?: boolean): Promise<void>;
|
|
44
45
|
prepareImportUrl(url: string): string;
|
|
45
|
-
getRelayStatus(): Record<string, string>;
|
|
46
|
-
getRelayStats(): {
|
|
47
|
-
total: number;
|
|
48
|
-
connected: number;
|
|
49
|
-
connecting: number;
|
|
50
|
-
disconnected: number;
|
|
51
|
-
error: number;
|
|
52
|
-
};
|
|
53
|
-
connectToRelay(relayUrl: string): Promise<void>;
|
|
54
|
-
disconnectFromRelay(relayUrl: string): Promise<void>;
|
|
55
|
-
reconnectAllRelays(): Promise<void>;
|
|
56
|
-
checkRelayHealth(): Promise<boolean>;
|
|
57
46
|
importAndConnect(cs: ConnectionString): Promise<void>;
|
|
58
47
|
setReadOnly(pubkey: string): void;
|
|
59
48
|
setExtension(pubkey: string): void;
|
|
@@ -66,7 +55,7 @@ declare class AuthNostrService extends EventEmitter implements Signer {
|
|
|
66
55
|
private releaseSigner;
|
|
67
56
|
logout(keepSigner?: boolean): Promise<void>;
|
|
68
57
|
private setUserInfo;
|
|
69
|
-
exportKeys(): string
|
|
58
|
+
exportKeys(): "" | `nsec1${string}`;
|
|
70
59
|
private onAuth;
|
|
71
60
|
private createIframe;
|
|
72
61
|
sendNeedAuth(): Promise<void>;
|
|
@@ -92,6 +81,7 @@ declare class AuthNostrService extends EventEmitter implements Signer {
|
|
|
92
81
|
}): Promise<void>;
|
|
93
82
|
signEvent(event: any): Promise<any>;
|
|
94
83
|
private ensureSigner;
|
|
84
|
+
private codec_call;
|
|
95
85
|
encrypt04(pubkey: string, plaintext: string): Promise<string>;
|
|
96
86
|
decrypt04(pubkey: string, ciphertext: string): Promise<string>;
|
|
97
87
|
encrypt44(pubkey: string, plaintext: string): Promise<string>;
|
package/dist/modules/Nip46.d.ts
CHANGED
|
@@ -1,76 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventEmitter } from 'tseep';
|
|
1
|
+
import NDK, { NDKEvent, NDKFilter, NDKNip46Signer, NDKNostrRpc, NDKRpcRequest, NDKRpcResponse, NDKSubscription, NDKUser, NostrEvent } from '@nostr-dev-kit/ndk';
|
|
3
2
|
import { PrivateKeySigner } from './Signer';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
kinds?: number[];
|
|
7
|
-
authors?: string[];
|
|
8
|
-
since?: number;
|
|
9
|
-
until?: number;
|
|
10
|
-
limit?: number;
|
|
11
|
-
search?: string;
|
|
12
|
-
[key: `#${string}`]: string[] | undefined;
|
|
13
|
-
};
|
|
14
|
-
type NostrEvent = {
|
|
15
|
-
id?: string;
|
|
16
|
-
kind: number;
|
|
17
|
-
pubkey: string;
|
|
18
|
-
content: string;
|
|
19
|
-
tags: string[][];
|
|
20
|
-
created_at: number;
|
|
21
|
-
sig?: string;
|
|
22
|
-
};
|
|
23
|
-
type NostrSubscription = {
|
|
24
|
-
on: (event: string, cb: any) => void;
|
|
25
|
-
stop: () => void;
|
|
26
|
-
};
|
|
27
|
-
type NDKRpcResponse = {
|
|
28
|
-
id: string;
|
|
29
|
-
pubkey: string;
|
|
30
|
-
content: string;
|
|
31
|
-
result?: string;
|
|
32
|
-
error?: string;
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
};
|
|
35
|
-
declare class NostrRpc extends EventEmitter {
|
|
36
|
-
rxNostr: RxNostr;
|
|
3
|
+
declare class NostrRpc extends NDKNostrRpc {
|
|
4
|
+
protected _ndk: NDK;
|
|
37
5
|
protected _signer: PrivateKeySigner;
|
|
38
6
|
protected requests: Set<string>;
|
|
39
7
|
private sub?;
|
|
40
8
|
protected _useNip44: boolean;
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
constructor(rxNostr: RxNostr, signer: PrivateKeySigner);
|
|
45
|
-
subscribe(filter: NostrFilter): Promise<NostrSubscription>;
|
|
9
|
+
private eventEmitter;
|
|
10
|
+
constructor(ndk: NDK, signer: PrivateKeySigner);
|
|
11
|
+
subscribe(filter: NDKFilter): Promise<NDKSubscription>;
|
|
46
12
|
stop(): void;
|
|
47
13
|
setUseNip44(useNip44: boolean): void;
|
|
48
14
|
private isNip04;
|
|
49
|
-
parseEvent(event:
|
|
15
|
+
parseEvent(event: NDKEvent): Promise<NDKRpcRequest | NDKRpcResponse>;
|
|
50
16
|
parseNostrConnectReply(reply: any, secret: string): Promise<string>;
|
|
51
17
|
listen(nostrConnectSecret: string): Promise<string>;
|
|
52
18
|
connect(pubkey: string, token?: string, perms?: string): Promise<void>;
|
|
53
19
|
connectWithTimeout(pubkey: string, token?: string, perms?: string, timeoutMs?: number): Promise<void>;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
private ensureConnected;
|
|
57
|
-
protected reconnect(): Promise<void>;
|
|
20
|
+
ping(remotePubkey: string): Promise<void>;
|
|
21
|
+
pingWithTimeout(remotePubkey: string, timeoutMs?: number): Promise<void>;
|
|
58
22
|
protected getId(): string;
|
|
59
23
|
sendRequest(remotePubkey: string, method: string, params?: string[], kind?: number, cb?: (res: NDKRpcResponse) => void): Promise<NDKRpcResponse>;
|
|
60
24
|
protected setResponseHandler(id: string, cb?: (res: NDKRpcResponse) => void): Promise<NDKRpcResponse>;
|
|
61
|
-
protected createRequestEvent(id: string, remotePubkey: string, method: string, params?: string[], kind?: number): Promise<
|
|
25
|
+
protected createRequestEvent(id: string, remotePubkey: string, method: string, params?: string[], kind?: number): Promise<NDKEvent>;
|
|
26
|
+
on: <EventKey extends string | symbol = string>(event: EventKey, listener: (...args: any[]) => void) => this;
|
|
27
|
+
emit: <EventKey extends string | symbol = string>(event: EventKey, ...args: any[]) => boolean;
|
|
62
28
|
}
|
|
63
29
|
export declare class IframeNostrRpc extends NostrRpc {
|
|
64
30
|
private peerOrigin?;
|
|
65
31
|
private iframePort?;
|
|
66
32
|
private iframeRequests;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
private heartbeatTimeoutMs;
|
|
70
|
-
constructor(rxNostr: RxNostr, localSigner: PrivateKeySigner, iframePeerOrigin?: string);
|
|
71
|
-
subscribe(filter: NostrFilter): Promise<NostrSubscription>;
|
|
72
|
-
private startHeartbeat;
|
|
73
|
-
private stopHeartbeat;
|
|
33
|
+
constructor(ndk: NDK, localSigner: PrivateKeySigner, iframePeerOrigin?: string);
|
|
34
|
+
subscribe(filter: NDKFilter): Promise<NDKSubscription>;
|
|
74
35
|
setWorkerIframePort(port: MessagePort): void;
|
|
75
36
|
sendRequest(remotePubkey: string, method: string, params?: string[], kind?: number, cb?: (res: NDKRpcResponse) => void): Promise<NDKRpcResponse>;
|
|
76
37
|
}
|
|
@@ -81,30 +42,31 @@ export declare class ReadyListener {
|
|
|
81
42
|
constructor(messages: string[], origin: string);
|
|
82
43
|
wait(): Promise<any>;
|
|
83
44
|
}
|
|
84
|
-
export declare class Nip46Signer extends
|
|
85
|
-
remotePubkey: string;
|
|
86
|
-
rpc: NostrRpc;
|
|
45
|
+
export declare class Nip46Signer extends NDKNip46Signer {
|
|
87
46
|
private _userPubkey;
|
|
88
47
|
private _rpc;
|
|
89
|
-
|
|
48
|
+
private lastPingTime;
|
|
49
|
+
private pingCacheDuration;
|
|
50
|
+
private _remotePubkey?;
|
|
51
|
+
constructor(ndk: NDK, localSigner: PrivateKeySigner, signerPubkey: string, iframeOrigin?: string);
|
|
90
52
|
get userPubkey(): string;
|
|
53
|
+
get remotePubkeyAccessor(): string | undefined;
|
|
54
|
+
set remotePubkeyAccessor(value: string | undefined);
|
|
55
|
+
private ensureConnection;
|
|
91
56
|
private setSignerPubkey;
|
|
92
57
|
initUserPubkey(hintPubkey?: string): Promise<void>;
|
|
93
58
|
listen(nostrConnectSecret: string): Promise<void>;
|
|
94
59
|
connect(token?: string, perms?: string): Promise<void>;
|
|
95
60
|
setListenReply(reply: any, nostrConnectSecret: string): Promise<void>;
|
|
61
|
+
sign(event: NostrEvent): Promise<string>;
|
|
62
|
+
encrypt(recipient: NDKUser, value: string): Promise<string>;
|
|
63
|
+
decrypt(sender: NDKUser, value: string): Promise<string>;
|
|
96
64
|
createAccount2({ bunkerPubkey, name, domain, perms }: {
|
|
97
65
|
bunkerPubkey: string;
|
|
98
66
|
name: string;
|
|
99
67
|
domain: string;
|
|
100
68
|
perms?: string;
|
|
101
69
|
}): Promise<string>;
|
|
102
|
-
|
|
103
|
-
decrypt(sender: any, value: string): Promise<string>;
|
|
104
|
-
encryptNip44(recipient: any, value: string): Promise<string>;
|
|
105
|
-
decryptNip44(sender: any, value: string): Promise<string>;
|
|
106
|
-
sign(event: any): Promise<string>;
|
|
107
|
-
user(): Promise<any>;
|
|
108
|
-
private rpcSend;
|
|
70
|
+
emit: <EventKey extends string | symbol = string>(event: EventKey, ...args: any[]) => boolean;
|
|
109
71
|
}
|
|
110
72
|
export {};
|
package/dist/modules/Signer.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { NDKPrivateKeySigner, NDKUser } from '@nostr-dev-kit/ndk';
|
|
2
|
+
export declare class PrivateKeySigner extends NDKPrivateKeySigner {
|
|
3
3
|
private nip44;
|
|
4
|
-
private
|
|
5
|
-
constructor(privateKey:
|
|
4
|
+
private _pubkey;
|
|
5
|
+
constructor(privateKey: string);
|
|
6
6
|
get pubkey(): string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}>;
|
|
10
|
-
sign(event: any): Promise<string>;
|
|
11
|
-
encrypt(recipientPubkey: string, value: string): Promise<string>;
|
|
12
|
-
decrypt(senderPubkey: string, value: string): Promise<string>;
|
|
13
|
-
encryptNip44(recipientPubkey: string, value: string): Promise<string>;
|
|
14
|
-
decryptNip44(senderPubkey: string, value: string): Promise<string>;
|
|
7
|
+
encryptNip44(recipient: NDKUser, value: string): Promise<string>;
|
|
8
|
+
decryptNip44(sender: NDKUser, value: string): Promise<string>;
|
|
15
9
|
}
|