@konemono/nostr-login 1.10.15 → 1.11.0
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 +20 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/AuthNostrService.d.ts +14 -4
- package/dist/modules/Nip46.d.ts +52 -11
- package/dist/modules/Signer.d.ts +12 -6
- package/dist/unpkg.js +20 -15
- package/dist/utils/index.d.ts +6 -3
- package/dist/utils/nip44.d.ts +3 -3
- package/package.json +8 -8
- package/src/modules/AuthNostrService.ts +223 -123
- package/src/modules/ModalManager.ts +3 -3
- package/src/modules/Nip46.ts +273 -91
- package/src/modules/NostrExtensionService.ts +2 -0
- package/src/modules/Signer.ts +35 -12
- package/src/utils/index.ts +73 -23
- package/src/utils/nip44.ts +12 -7
- package/test-relay-management.html +407 -0
|
@@ -3,8 +3,7 @@ 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
|
|
7
|
-
private profileNdk;
|
|
6
|
+
private rxNostr;
|
|
8
7
|
private signer;
|
|
9
8
|
private localSigner;
|
|
10
9
|
private params;
|
|
@@ -43,6 +42,18 @@ declare class AuthNostrService extends EventEmitter implements Signer {
|
|
|
43
42
|
localSignup(name: string, sk?: string): Promise<void>;
|
|
44
43
|
setLocal(info: Info, signup?: boolean): Promise<void>;
|
|
45
44
|
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>;
|
|
46
57
|
importAndConnect(cs: ConnectionString): Promise<void>;
|
|
47
58
|
setReadOnly(pubkey: string): void;
|
|
48
59
|
setExtension(pubkey: string): void;
|
|
@@ -55,7 +66,7 @@ declare class AuthNostrService extends EventEmitter implements Signer {
|
|
|
55
66
|
private releaseSigner;
|
|
56
67
|
logout(keepSigner?: boolean): Promise<void>;
|
|
57
68
|
private setUserInfo;
|
|
58
|
-
exportKeys():
|
|
69
|
+
exportKeys(): string;
|
|
59
70
|
private onAuth;
|
|
60
71
|
private createIframe;
|
|
61
72
|
sendNeedAuth(): Promise<void>;
|
|
@@ -81,7 +92,6 @@ declare class AuthNostrService extends EventEmitter implements Signer {
|
|
|
81
92
|
}): Promise<void>;
|
|
82
93
|
signEvent(event: any): Promise<any>;
|
|
83
94
|
private ensureSigner;
|
|
84
|
-
private codec_call;
|
|
85
95
|
encrypt04(pubkey: string, plaintext: string): Promise<string>;
|
|
86
96
|
decrypt04(pubkey: string, ciphertext: string): Promise<string>;
|
|
87
97
|
encrypt44(pubkey: string, plaintext: string): Promise<string>;
|
package/dist/modules/Nip46.d.ts
CHANGED
|
@@ -1,7 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RxNostr } from 'rx-nostr';
|
|
2
|
+
import { EventEmitter } from 'tseep';
|
|
2
3
|
import { PrivateKeySigner } from './Signer';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
type NostrFilter = {
|
|
5
|
+
ids?: string[];
|
|
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;
|
|
5
37
|
protected _signer: PrivateKeySigner;
|
|
6
38
|
protected requests: Set<string>;
|
|
7
39
|
private sub?;
|
|
@@ -9,12 +41,12 @@ declare class NostrRpc extends NDKNostrRpc {
|
|
|
9
41
|
private reconnectAttempts;
|
|
10
42
|
private maxReconnectAttempts;
|
|
11
43
|
private reconnectDelay;
|
|
12
|
-
constructor(
|
|
13
|
-
subscribe(filter:
|
|
44
|
+
constructor(rxNostr: RxNostr, signer: PrivateKeySigner);
|
|
45
|
+
subscribe(filter: NostrFilter): Promise<NostrSubscription>;
|
|
14
46
|
stop(): void;
|
|
15
47
|
setUseNip44(useNip44: boolean): void;
|
|
16
48
|
private isNip04;
|
|
17
|
-
parseEvent(event:
|
|
49
|
+
parseEvent(event: NostrEvent): Promise<any>;
|
|
18
50
|
parseNostrConnectReply(reply: any, secret: string): Promise<string>;
|
|
19
51
|
listen(nostrConnectSecret: string): Promise<string>;
|
|
20
52
|
connect(pubkey: string, token?: string, perms?: string): Promise<void>;
|
|
@@ -26,7 +58,7 @@ declare class NostrRpc extends NDKNostrRpc {
|
|
|
26
58
|
protected getId(): string;
|
|
27
59
|
sendRequest(remotePubkey: string, method: string, params?: string[], kind?: number, cb?: (res: NDKRpcResponse) => void): Promise<NDKRpcResponse>;
|
|
28
60
|
protected setResponseHandler(id: string, cb?: (res: NDKRpcResponse) => void): Promise<NDKRpcResponse>;
|
|
29
|
-
protected createRequestEvent(id: string, remotePubkey: string, method: string, params?: string[], kind?: number): Promise<
|
|
61
|
+
protected createRequestEvent(id: string, remotePubkey: string, method: string, params?: string[], kind?: number): Promise<NostrEvent>;
|
|
30
62
|
}
|
|
31
63
|
export declare class IframeNostrRpc extends NostrRpc {
|
|
32
64
|
private peerOrigin?;
|
|
@@ -35,8 +67,8 @@ export declare class IframeNostrRpc extends NostrRpc {
|
|
|
35
67
|
private heartbeatInterval?;
|
|
36
68
|
private lastResponseTime;
|
|
37
69
|
private heartbeatTimeoutMs;
|
|
38
|
-
constructor(
|
|
39
|
-
subscribe(filter:
|
|
70
|
+
constructor(rxNostr: RxNostr, localSigner: PrivateKeySigner, iframePeerOrigin?: string);
|
|
71
|
+
subscribe(filter: NostrFilter): Promise<NostrSubscription>;
|
|
40
72
|
private startHeartbeat;
|
|
41
73
|
private stopHeartbeat;
|
|
42
74
|
setWorkerIframePort(port: MessagePort): void;
|
|
@@ -49,10 +81,12 @@ export declare class ReadyListener {
|
|
|
49
81
|
constructor(messages: string[], origin: string);
|
|
50
82
|
wait(): Promise<any>;
|
|
51
83
|
}
|
|
52
|
-
export declare class Nip46Signer extends
|
|
84
|
+
export declare class Nip46Signer extends EventEmitter {
|
|
85
|
+
remotePubkey: string;
|
|
86
|
+
rpc: NostrRpc;
|
|
53
87
|
private _userPubkey;
|
|
54
88
|
private _rpc;
|
|
55
|
-
constructor(
|
|
89
|
+
constructor(rxNostr: RxNostr, localSigner: PrivateKeySigner, signerPubkey: string, iframeOrigin?: string);
|
|
56
90
|
get userPubkey(): string;
|
|
57
91
|
private setSignerPubkey;
|
|
58
92
|
initUserPubkey(hintPubkey?: string): Promise<void>;
|
|
@@ -65,5 +99,12 @@ export declare class Nip46Signer extends NDKNip46Signer {
|
|
|
65
99
|
domain: string;
|
|
66
100
|
perms?: string;
|
|
67
101
|
}): Promise<string>;
|
|
102
|
+
encrypt(recipient: any, value: string): Promise<string>;
|
|
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;
|
|
68
109
|
}
|
|
69
110
|
export {};
|
package/dist/modules/Signer.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare class PrivateKeySigner {
|
|
2
|
+
privateKey: Uint8Array;
|
|
3
3
|
private nip44;
|
|
4
|
-
private
|
|
5
|
-
constructor(privateKey:
|
|
4
|
+
private __pubkey;
|
|
5
|
+
constructor(privateKey: Uint8Array);
|
|
6
6
|
get pubkey(): string;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
user(): Promise<{
|
|
8
|
+
pubkey: string;
|
|
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>;
|
|
9
15
|
}
|