@qntx/nostr 0.2.2 → 0.3.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/README.md +0 -16
- package/dist/{builder-8VQ_Xr6X.mjs → builder-9tjI6WQ3.mjs} +2 -3
- package/dist/{builder-8VQ_Xr6X.mjs.map → builder-9tjI6WQ3.mjs.map} +1 -1
- package/dist/{builder-C9VuhbfY.d.mts → builder-sSflu6nB.d.mts} +2 -2
- package/dist/{client-BZMG37De.mjs → client-C6EultPx.mjs} +2 -2
- package/dist/{client-BZMG37De.mjs.map → client-C6EultPx.mjs.map} +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +2 -2
- package/dist/{gossip-ZnGOJ1fo.d.mts → gossip-DpIvkBuj.d.mts} +2 -2
- package/dist/gossip.d.mts +1 -1
- package/dist/{index-CLGInxR5.d.mts → index-BP4UmZKF.d.mts} +5 -5
- package/dist/{index-23sRP0wl.d.mts → index-MxC28S4P.d.mts} +2 -2
- package/dist/{index-Dj2TED7O.d.mts → index-skvsYz00.d.mts} +4 -4
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +4 -4
- package/dist/{key-BZBap2p-.mjs → key-Bps-LqX7.mjs} +37 -34
- package/dist/key-Bps-LqX7.mjs.map +1 -0
- package/dist/{key-C6w9Fskk.d.mts → key-Cv4_pN3x.d.mts} +19 -4
- package/dist/loaders.d.mts +1 -1
- package/dist/{nip17-jlcdeIQ8.d.mts → nip17-CKIufV98.d.mts} +2 -2
- package/dist/{nip65-BlSAp_8P.d.mts → nip65-CjgmdpPB.d.mts} +2 -2
- package/dist/nips/blossom.d.mts +1 -1
- package/dist/nips/blossom.mjs +1 -1
- package/dist/nips/nip10.d.mts +1 -1
- package/dist/nips/nip10.mjs +1 -1
- package/dist/nips/nip17.d.mts +1 -1
- package/dist/nips/nip17.mjs +1 -1
- package/dist/nips/nip49.d.mts +22 -2
- package/dist/nips/nip49.mjs +26 -16
- package/dist/nips/nip49.mjs.map +1 -1
- package/dist/nips/nip51.d.mts +1 -1
- package/dist/nips/nip51.mjs +1 -1
- package/dist/nips/nip59.mjs +1 -1
- package/dist/nips/nip65.d.mts +1 -1
- package/dist/nips/nip65.mjs +1 -1
- package/dist/{signer-BGSpLC7e.mjs → signer-CYQutDzD.mjs} +2 -2
- package/dist/{signer-BGSpLC7e.mjs.map → signer-CYQutDzD.mjs.map} +1 -1
- package/dist/signer.d.mts +1 -1
- package/dist/signer.mjs +1 -1
- package/dist/testing.mjs +2 -2
- package/dist/wasm.d.mts +2 -3
- package/dist/wasm.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/key-BZBap2p-.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-fU3Y01PR.mjs";
|
|
2
|
-
import { r as SecretKey, t as Keys } from "./key-
|
|
2
|
+
import { r as SecretKey, t as Keys } from "./key-Cv4_pN3x.mjs";
|
|
3
3
|
import { t as Filter } from "./filter-C0IMByE3.mjs";
|
|
4
4
|
import { a as NostrError } from "./error-CR8Urc84.mjs";
|
|
5
5
|
import { t as NostrSigner } from "./types-CRQEk0Oi.mjs";
|
|
@@ -176,4 +176,4 @@ declare class Nip46Signer implements NostrSigner {
|
|
|
176
176
|
}
|
|
177
177
|
//#endregion
|
|
178
178
|
export { Nip07Signer as a, isNip07Available as c, Nip46Transport as i, KeysSigner as l, Nip46SignerOptions as n, WindowNostr as o, Nip46SubscribeOptions as r, getWindowNostr as s, Nip46Signer as t, NoSignerError as u };
|
|
179
|
-
//# sourceMappingURL=index-
|
|
179
|
+
//# sourceMappingURL=index-MxC28S4P.d.mts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Event } from "./event-fU3Y01PR.mjs";
|
|
2
|
-
import { n as ProfileMetadata } from "./builder-
|
|
3
|
-
import { t as RelayListItem } from "./nip65-
|
|
4
|
-
import { t as Gossip } from "./gossip-
|
|
2
|
+
import { n as ProfileMetadata } from "./builder-sSflu6nB.mjs";
|
|
3
|
+
import { t as RelayListItem } from "./nip65-CjgmdpPB.mjs";
|
|
4
|
+
import { t as Gossip } from "./gossip-DpIvkBuj.mjs";
|
|
5
5
|
import { a as NostrError } from "./error-CR8Urc84.mjs";
|
|
6
6
|
import { n as Pool } from "./pool-B7p_reAm.mjs";
|
|
7
7
|
import { r as OutboxBound, t as EventStore } from "./types-2pCUprRU.mjs";
|
|
@@ -204,4 +204,4 @@ type CreateLoadersOptions = {
|
|
|
204
204
|
declare function createLoaders(opts: CreateLoadersOptions): Loaders;
|
|
205
205
|
//#endregion
|
|
206
206
|
export { ReplaceableLoader as _, OutboxFeed as a, groupAuthorsByOutboxRelay as c, bareNostrUser as d, ListLoaders as f, ReplaceableLoadResult as g, LoadStyle as h, OutboxError as i, NostrUser as l, MutedEntity as m, Loaders as n, OutboxFeedOptions as o, ListResult as p, createLoaders as r, createOutboxFeed as s, CreateLoadersOptions as t, ProfileLoader as u, EventLoader as v, EventRef as y };
|
|
207
|
-
//# sourceMappingURL=index-
|
|
207
|
+
//# sourceMappingURL=index-skvsYz00.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { C as parseEventAddress, S as isTag, T as tagValue, _ as Tag, b as formatEventAddress, d as signedMatchesUnsigned, f as sortEvents, g as EventAddress, h as validateSignedEvent, i as getEventHash, m as validateEvent, n as EventTemplate, o as isReplaceableWinner, p as sortedEvents, r as UnsignedEvent, s as itemCompare, t as Event, u as serializeEvent, v as TagInput, w as tagName, x as getDTag, y as eventAddress } from "./event-fU3Y01PR.mjs";
|
|
2
|
-
import { a as
|
|
3
|
-
import { n as ProfileMetadata, t as EventBuilder } from "./builder-
|
|
2
|
+
import { a as finalizeEvent, c as signEvent, i as SigningBackend, n as PublicKey, o as getPublicKey, r as SecretKey, s as publicKeyFromHex, t as Keys } from "./key-Cv4_pN3x.mjs";
|
|
3
|
+
import { n as ProfileMetadata, t as EventBuilder } from "./builder-sSflu6nB.mjs";
|
|
4
4
|
import { a as getFilterLimit, c as mergeFilters, i as filterFingerprint, n as canonicalizeFilter, o as matchFilter, r as canonicalizeFilters, s as matchFilters, t as Filter } from "./filter-C0IMByE3.mjs";
|
|
5
|
-
import { a as readRelays, c as writeRelays, i as parseRelayList, n as RelayMarker, o as relayListEventBuilder, r as markerOf, s as relayListToTags, t as RelayListItem } from "./nip65-
|
|
6
|
-
import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-
|
|
5
|
+
import { a as readRelays, c as writeRelays, i as parseRelayList, n as RelayMarker, o as relayListEventBuilder, r as markerOf, s as relayListToTags, t as RelayListItem } from "./nip65-CjgmdpPB.mjs";
|
|
6
|
+
import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-DpIvkBuj.mjs";
|
|
7
7
|
import { a as assertSubscriptionId, c as encodeRelayMessage, d as parseRelayMessage, i as SubscriptionId, l as mergeCountHll, n as CountResult, o as createSubscriptionId, r as RelayMessage, s as encodeClientMessage, t as ClientMessage, u as parseClientMessage } from "./message-iGPIqnn0.mjs";
|
|
8
8
|
import { a as NostrError, i as MessageError, n as EventValidationError, o as UrlError, r as HexError, s as WasmVerifyPoisonedError, t as CryptoError } from "./error-CR8Urc84.mjs";
|
|
9
9
|
import { a as PoolPublishResult, c as Relay, d as RelayStatusName, f as SubscribeOptions, i as PoolOptions, l as RelayOptions, n as Pool, o as PoolSubscribeOptions, r as PoolCountResult, s as PublishResult, t as InvalidEventPolicy, u as RelayStatus } from "./pool-B7p_reAm.mjs";
|
|
@@ -11,14 +11,14 @@ import { i as useWebSocketImplementation } from "./websocket-CmeqvAkp.mjs";
|
|
|
11
11
|
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-2pCUprRU.mjs";
|
|
12
12
|
import { n as ReactiveEventStoreOptions, r as Watch, t as ReactiveEventStore } from "./reactive-DFpqtIf_.mjs";
|
|
13
13
|
import { _ as neventEncode, a as NAddr, b as npubEncode, c as NPub, d as Note, f as ProfilePointer, g as naddrEncode, i as EventPointer, l as NSec, m as decodeNostrURI, n as Bech32MaxSize, o as NEvent, p as decode, r as DecodedResult, s as NProfile, t as AddressPointer, u as Nip19Error, v as noteEncode, x as nsecEncode, y as nprofileEncode } from "./nip19-BevCJZsp.mjs";
|
|
14
|
-
import { _ as ReplaceableLoader, a as OutboxFeed, c as groupAuthorsByOutboxRelay, d as bareNostrUser, g as ReplaceableLoadResult, h as LoadStyle, i as OutboxError, l as NostrUser, m as MutedEntity, n as Loaders, o as OutboxFeedOptions, p as ListResult, r as createLoaders, s as createOutboxFeed } from "./index-
|
|
14
|
+
import { _ as ReplaceableLoader, a as OutboxFeed, c as groupAuthorsByOutboxRelay, d as bareNostrUser, g as ReplaceableLoadResult, h as LoadStyle, i as OutboxError, l as NostrUser, m as MutedEntity, n as Loaders, o as OutboxFeedOptions, p as ListResult, r as createLoaders, s as createOutboxFeed } from "./index-skvsYz00.mjs";
|
|
15
15
|
import { t as NostrSigner } from "./types-CRQEk0Oi.mjs";
|
|
16
16
|
import { t as StorageError } from "./error-BW7re1UN.mjs";
|
|
17
|
-
import { f as SubscribePrivateMessagesOptions, g as SyncSummary, h as SyncOptions, i as ClientOptions, l as ReceivedPrivateMessage, m as SyncDirectionName, n as ClientBuilder, o as FetchPrivateMessagesOptions, p as SyncDirection, r as ClientError, s as PrivateMessageSendResult, t as Client, u as SendPrivateMessageOptions } from "./index-
|
|
17
|
+
import { f as SubscribePrivateMessagesOptions, g as SyncSummary, h as SyncOptions, i as ClientOptions, l as ReceivedPrivateMessage, m as SyncDirectionName, n as ClientBuilder, o as FetchPrivateMessagesOptions, p as SyncDirection, r as ClientError, s as PrivateMessageSendResult, t as Client, u as SendPrivateMessageOptions } from "./index-BP4UmZKF.mjs";
|
|
18
18
|
import { C as SIGNATURE_BYTES, S as SECRET_KEY_BYTES, _ as isHex32, a as KindClassification, b as EVENT_ID_BYTES, c as classifyKind, d as isRegularKind, f as isReplaceableKind, g as hexToBytes, h as bytesToHex, i as Kind, l as isAddressableKind, n as createEventVerifier, o as KindName, r as verifyEvent, s as KnownKind, t as SerializedEventVerifier, u as isEphemeralKind, v as isHex64, w as SUBSCRIPTION_ID_MAX_CHARS, x as PUBLIC_KEY_BYTES, y as normalizeURL } from "./index-CvkvqB16.mjs";
|
|
19
|
-
import { a as Nip07Signer, c as isNip07Available, i as Nip46Transport, l as KeysSigner, n as Nip46SignerOptions, o as WindowNostr, r as Nip46SubscribeOptions, s as getWindowNostr, t as Nip46Signer, u as NoSignerError } from "./index-
|
|
19
|
+
import { a as Nip07Signer, c as isNip07Available, i as Nip46Transport, l as KeysSigner, n as Nip46SignerOptions, o as WindowNostr, r as Nip46SubscribeOptions, s as getWindowNostr, t as Nip46Signer, u as NoSignerError } from "./index-MxC28S4P.mjs";
|
|
20
20
|
import { ReplyTagsOptions, ThreadReferences, buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
|
|
21
21
|
import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
|
|
22
22
|
import { a as isInsecureRelayUrl, c as RelayError, d as RelayTimeoutError, l as RelayPublishError, o as RelayClosedError, s as RelayConnectionError, u as RelaySuspendedError } from "./index-D-TK_KJG.mjs";
|
|
23
23
|
import { a as IndexedDbEventStoreOptions, i as IndexedDbEventStore, n as SqlValue, o as MemoryEventStore, r as SqliteEventStore, t as SqlDriver } from "./index-D1bqFHKB.mjs";
|
|
24
|
-
export { type AddressPointer, Bech32MaxSize, Client, ClientBuilder, ClientError, type ClientMessage, type ClientOptions, type CountResult, CryptoError, type DecodedResult, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventPointer, type EventStore, type EventTemplate, EventValidationError, type FetchPrivateMessagesOptions, type Filter, Gossip, HexError, IndexedDbEventStore, type IndexedDbEventStoreOptions, type InvalidEventPolicy, Keys, KeysSigner, Kind, type KindClassification, type KindName, type KnownKind, type ListResult, type LoadStyle, type Loaders, MemoryEventStore, MessageError, type MutedEntity, type NAddr, type NEvent, type NProfile, type NPub, type NSec, type NegentropyItem, Nip07Signer, Nip19Error, Nip46Signer, type Nip46SignerOptions, type Nip46SubscribeOptions, type Nip46Transport, NoSignerError, NostrError, type NostrSigner, type NostrUser, type Note, type OutboxBound, OutboxError, OutboxFeed, type OutboxFeedOptions, PUBLIC_KEY_BYTES, Pool, type PoolCountResult, type PoolOptions, type PoolPublishResult, type PoolSubscribeOptions, type PrivateMessageSendResult, type ProfileMetadata, type ProfilePointer, type PubkeyRoutes, type PublicKey, type PublishResult, type PutResult, ReactiveEventStore, type ReactiveEventStoreOptions, type ReceivedPrivateMessage, Relay, RelayClosedError, RelayConnectionError, RelayError, type RelayListItem, type RelayMarker, type RelayMessage, type RelayOptions, RelayPublishError, RelayStatus, type RelayStatusName, RelaySuspendedError, RelayTimeoutError, type ReplaceableLoadResult, type ReplaceableLoader, type ReplyTagsOptions, type RoutedFilter, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, type SendPrivateMessageOptions, type SerializedEventVerifier, type SqlDriver, type SqlValue, SqliteEventStore, StorageError, type SubscribeOptions, type SubscribePrivateMessagesOptions, type SubscriptionId, SyncDirection, type SyncDirectionName, type SyncOptions, type SyncSummary, Tag, type TagInput, type ThreadReferences, type UnsignedEvent, UrlError, WasmVerifyPoisonedError, type Watch, type WindowNostr, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createOutboxFeed, createSubscriptionId, decodeNostrURI, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, markerOf, matchFilter, matchFilters, mergeCountHll, mergeFilters, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
|
|
24
|
+
export { type AddressPointer, Bech32MaxSize, Client, ClientBuilder, ClientError, type ClientMessage, type ClientOptions, type CountResult, CryptoError, type DecodedResult, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventPointer, type EventStore, type EventTemplate, EventValidationError, type FetchPrivateMessagesOptions, type Filter, Gossip, HexError, IndexedDbEventStore, type IndexedDbEventStoreOptions, type InvalidEventPolicy, Keys, KeysSigner, Kind, type KindClassification, type KindName, type KnownKind, type ListResult, type LoadStyle, type Loaders, MemoryEventStore, MessageError, type MutedEntity, type NAddr, type NEvent, type NProfile, type NPub, type NSec, type NegentropyItem, Nip07Signer, Nip19Error, Nip46Signer, type Nip46SignerOptions, type Nip46SubscribeOptions, type Nip46Transport, NoSignerError, NostrError, type NostrSigner, type NostrUser, type Note, type OutboxBound, OutboxError, OutboxFeed, type OutboxFeedOptions, PUBLIC_KEY_BYTES, Pool, type PoolCountResult, type PoolOptions, type PoolPublishResult, type PoolSubscribeOptions, type PrivateMessageSendResult, type ProfileMetadata, type ProfilePointer, type PubkeyRoutes, type PublicKey, type PublishResult, type PutResult, ReactiveEventStore, type ReactiveEventStoreOptions, type ReceivedPrivateMessage, Relay, RelayClosedError, RelayConnectionError, RelayError, type RelayListItem, type RelayMarker, type RelayMessage, type RelayOptions, RelayPublishError, RelayStatus, type RelayStatusName, RelaySuspendedError, RelayTimeoutError, type ReplaceableLoadResult, type ReplaceableLoader, type ReplyTagsOptions, type RoutedFilter, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, type SendPrivateMessageOptions, type SerializedEventVerifier, type SigningBackend, type SqlDriver, type SqlValue, SqliteEventStore, StorageError, type SubscribeOptions, type SubscribePrivateMessagesOptions, type SubscriptionId, SyncDirection, type SyncDirectionName, type SyncOptions, type SyncSummary, Tag, type TagInput, type ThreadReferences, type UnsignedEvent, UrlError, WasmVerifyPoisonedError, type Watch, type WindowNostr, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createOutboxFeed, createSubscriptionId, decodeNostrURI, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, markerOf, matchFilter, matchFilters, mergeCountHll, mergeFilters, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { C as SUBSCRIPTION_ID_MAX_CHARS, S as SIGNATURE_BYTES, _ as UrlError, a as hexToBytes, b as PUBLIC_KEY_BYTES, f as CryptoError, g as NostrError, h as MessageError, i as bytesToHex, l as normalizeURL, m as HexError, o as isHex32, p as EventValidationError, s as isHex64, v as WasmVerifyPoisonedError, x as SECRET_KEY_BYTES, y as EVENT_ID_BYTES } from "./util-LfQirgDk.mjs";
|
|
2
2
|
import { a as isRegularKind, i as isEphemeralKind, n as classifyKind, o as isReplaceableKind, r as isAddressableKind, t as Kind } from "./kind-Cxwhhkx8.mjs";
|
|
3
3
|
import { S as tagValue, _ as formatEventAddress, a as isReplaceableWinner, b as parseEventAddress, d as sortEvents, f as sortedEvents, g as eventAddress, h as Tag, l as serializeEvent, m as validateSignedEvent, n as getEventHash, o as itemCompare, p as validateEvent, u as signedMatchesUnsigned, v as getDTag, x as tagName, y as isTag } from "./event-D8Nfoh4K.mjs";
|
|
4
|
-
import { a as publicKeyFromHex, i as getPublicKey, n as SecretKey, o as signEvent, r as finalizeEvent, t as Keys } from "./key-
|
|
4
|
+
import { a as publicKeyFromHex, i as getPublicKey, n as SecretKey, o as signEvent, r as finalizeEvent, t as Keys } from "./key-Bps-LqX7.mjs";
|
|
5
5
|
import { n as verifyEvent, t as createEventVerifier } from "./verifier-t5WoWbtY.mjs";
|
|
6
|
-
import { t as EventBuilder } from "./builder-
|
|
6
|
+
import { t as EventBuilder } from "./builder-9tjI6WQ3.mjs";
|
|
7
7
|
import { a as matchFilter, i as getFilterLimit, n as canonicalizeFilters, o as matchFilters, r as filterFingerprint, s as mergeFilters, t as canonicalizeFilter } from "./filter-BQl3GlHt.mjs";
|
|
8
8
|
import { a as mergeCountHll, i as encodeRelayMessage, n as createSubscriptionId, o as parseClientMessage, r as encodeClientMessage, s as parseRelayMessage, t as assertSubscriptionId } from "./message-DcY6Fi9o.mjs";
|
|
9
9
|
import { t as NoSignerError } from "./error-B__OMBRY.mjs";
|
|
10
|
-
import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, r as getWindowNostr, t as Nip46Signer } from "./signer-
|
|
10
|
+
import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, r as getWindowNostr, t as Nip46Signer } from "./signer-CYQutDzD.mjs";
|
|
11
11
|
import { Bech32MaxSize, Nip19Error, decode, decodeNostrURI, naddrEncode, neventEncode, noteEncode, nprofileEncode, npubEncode, nsecEncode } from "./nips/nip19.mjs";
|
|
12
12
|
import { buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
|
|
13
13
|
import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
|
|
@@ -19,7 +19,7 @@ import { a as groupAuthorsByOutboxRelay, i as createOutboxFeed, n as OutboxError
|
|
|
19
19
|
import { t as StorageError } from "./error-DrEIM7FO.mjs";
|
|
20
20
|
import { t as MemoryEventStore } from "./memory-C2EVx0_O.mjs";
|
|
21
21
|
import { t as ReactiveEventStore } from "./reactive-DDlThDSZ.mjs";
|
|
22
|
-
import { i as ClientBuilder, n as ClientError, r as SyncDirection, t as Client } from "./client-
|
|
22
|
+
import { i as ClientBuilder, n as ClientError, r as SyncDirection, t as Client } from "./client-C6EultPx.mjs";
|
|
23
23
|
import { n as IndexedDbEventStore, t as SqliteEventStore } from "./storage-xXxLGCVb.mjs";
|
|
24
24
|
import "./store.mjs";
|
|
25
25
|
export { Bech32MaxSize, Client, ClientBuilder, ClientError, CryptoError, EVENT_ID_BYTES, EventBuilder, EventValidationError, Gossip, HexError, IndexedDbEventStore, Keys, KeysSigner, Kind, MemoryEventStore, MessageError, Nip07Signer, Nip19Error, Nip46Signer, NoSignerError, NostrError, OutboxError, OutboxFeed, PUBLIC_KEY_BYTES, Pool, ReactiveEventStore, Relay, RelayClosedError, RelayConnectionError, RelayError, RelayPublishError, RelayStatus, RelaySuspendedError, RelayTimeoutError, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, SqliteEventStore, StorageError, SyncDirection, Tag, UrlError, WasmVerifyPoisonedError, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createOutboxFeed, createSubscriptionId, decodeNostrURI, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, markerOf, matchFilter, matchFilters, mergeCountHll, mergeFilters, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as hexToBytes, f as CryptoError, i as bytesToHex, n as assertHex32, r as assertSecretKeyBytes } from "./util-LfQirgDk.mjs";
|
|
1
|
+
import { a as hexToBytes$1, f as CryptoError, i as bytesToHex$1, n as assertHex32, r as assertSecretKeyBytes } from "./util-LfQirgDk.mjs";
|
|
2
2
|
import { c as markVerified, n as getEventHash, p as validateEvent } from "./event-D8Nfoh4K.mjs";
|
|
3
|
+
import { randomBytes } from "@noble/hashes/utils.js";
|
|
3
4
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
4
5
|
//#region src/core/key.ts
|
|
5
6
|
/** 32-byte secret key held as bytes; prefer zeroize when done. */
|
|
@@ -16,14 +17,14 @@ var SecretKey = class SecretKey {
|
|
|
16
17
|
return new SecretKey(bytes);
|
|
17
18
|
}
|
|
18
19
|
static fromHex(hex) {
|
|
19
|
-
return new SecretKey(hexToBytes(assertHex32(hex, "secret key")));
|
|
20
|
+
return new SecretKey(hexToBytes$1(assertHex32(hex, "secret key")));
|
|
20
21
|
}
|
|
21
22
|
get bytes() {
|
|
22
23
|
if (!this.#bytes) throw new CryptoError("secret key has been zeroized");
|
|
23
24
|
return new Uint8Array(this.#bytes);
|
|
24
25
|
}
|
|
25
26
|
toHex() {
|
|
26
|
-
return bytesToHex(this.bytes);
|
|
27
|
+
return bytesToHex$1(this.bytes);
|
|
27
28
|
}
|
|
28
29
|
/** Best-effort wipe of the internal buffer. */
|
|
29
30
|
zeroize() {
|
|
@@ -37,74 +38,76 @@ var SecretKey = class SecretKey {
|
|
|
37
38
|
function publicKeyFromHex(hex) {
|
|
38
39
|
return assertHex32(hex, "public key");
|
|
39
40
|
}
|
|
41
|
+
const nobleSigning = {
|
|
42
|
+
publicKey: (secretKey) => schnorr.getPublicKey(secretKey),
|
|
43
|
+
sign: (id, secretKey, auxRand) => schnorr.sign(id, secretKey, auxRand)
|
|
44
|
+
};
|
|
40
45
|
/** Derive the public key for a secret key given as SecretKey, bytes, or hex. */
|
|
41
46
|
function getPublicKey(secretKey) {
|
|
42
|
-
const bytes = secretKey instanceof SecretKey ? secretKey.bytes : typeof secretKey === "string" ? hexToBytes(assertHex32(secretKey, "secret key")) : (assertSecretKeyBytes(secretKey), secretKey);
|
|
43
|
-
return bytesToHex(schnorr.getPublicKey(bytes));
|
|
47
|
+
const bytes = secretKey instanceof SecretKey ? secretKey.bytes : typeof secretKey === "string" ? hexToBytes$1(assertHex32(secretKey, "secret key")) : (assertSecretKeyBytes(secretKey), secretKey);
|
|
48
|
+
return bytesToHex$1(schnorr.getPublicKey(bytes));
|
|
44
49
|
}
|
|
45
50
|
/** Keypair convenience wrapper. */
|
|
46
51
|
var Keys = class Keys {
|
|
47
52
|
secretKey;
|
|
48
53
|
publicKey;
|
|
49
|
-
|
|
54
|
+
/**
|
|
55
|
+
* BIP-340 backend that derived {@link publicKey} and signs in {@link finalizeEvent}/
|
|
56
|
+
* {@link signEvent}. Defaults to noble; pass a loaded `NostrWasm` module or a native backend to
|
|
57
|
+
* delegate signing.
|
|
58
|
+
*/
|
|
59
|
+
backend;
|
|
60
|
+
constructor(secretKey, backend) {
|
|
50
61
|
this.secretKey = secretKey;
|
|
51
|
-
this.
|
|
62
|
+
this.backend = backend;
|
|
63
|
+
const pubkey = backend.publicKey(secretKey.bytes);
|
|
64
|
+
if (pubkey.length !== 32) throw new CryptoError("signing backend returned an invalid public key");
|
|
65
|
+
this.publicKey = bytesToHex$1(pubkey);
|
|
52
66
|
}
|
|
53
|
-
static generate() {
|
|
54
|
-
return new Keys(SecretKey.generate());
|
|
67
|
+
static generate(backend = nobleSigning) {
|
|
68
|
+
return new Keys(SecretKey.generate(), backend);
|
|
55
69
|
}
|
|
56
|
-
static fromSecretKey(secretKey) {
|
|
70
|
+
static fromSecretKey(secretKey, backend = nobleSigning) {
|
|
57
71
|
const sk = secretKey instanceof SecretKey ? secretKey : typeof secretKey === "string" ? SecretKey.fromHex(secretKey) : SecretKey.fromBytes(secretKey);
|
|
58
|
-
return new Keys(sk);
|
|
72
|
+
return new Keys(sk, backend);
|
|
59
73
|
}
|
|
60
74
|
};
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
if (typeof secretKey === "string") return hexToBytes(assertHex32(secretKey, "secret key"));
|
|
64
|
-
assertSecretKeyBytes(secretKey);
|
|
65
|
-
return secretKey;
|
|
66
|
-
}
|
|
67
|
-
function resolveSigningKey(secretKey) {
|
|
68
|
-
if (secretKey instanceof Keys) return {
|
|
69
|
-
bytes: secretKey.secretKey.bytes,
|
|
70
|
-
publicKey: secretKey.publicKey
|
|
71
|
-
};
|
|
72
|
-
return { bytes: resolveSecretKeyBytes(secretKey) };
|
|
75
|
+
function resolveKeys(secretKey) {
|
|
76
|
+
return secretKey instanceof Keys ? secretKey : Keys.fromSecretKey(secretKey);
|
|
73
77
|
}
|
|
74
78
|
/** Fill pubkey/id/sig on a template and return a signed event. */
|
|
75
79
|
function finalizeEvent(template, secretKey) {
|
|
76
|
-
const
|
|
77
|
-
const pubkey = publicKey ?? bytesToHex(schnorr.getPublicKey(sk));
|
|
80
|
+
const keys = resolveKeys(secretKey);
|
|
78
81
|
return signEvent({
|
|
79
82
|
kind: template.kind,
|
|
80
83
|
tags: template.tags,
|
|
81
84
|
content: template.content,
|
|
82
85
|
created_at: template.created_at,
|
|
83
|
-
pubkey
|
|
84
|
-
},
|
|
86
|
+
pubkey: keys.publicKey
|
|
87
|
+
}, keys);
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
87
90
|
* Sign an already-assembled unsigned event. Rejects when `unsigned.pubkey` does not match the
|
|
88
91
|
* secret key.
|
|
89
92
|
*/
|
|
90
93
|
function signEvent(unsigned, secretKey) {
|
|
91
|
-
const
|
|
94
|
+
const keys = resolveKeys(secretKey);
|
|
92
95
|
if (!validateEvent(unsigned)) throw new CryptoError("cannot sign invalid unsigned event");
|
|
93
|
-
|
|
94
|
-
if (unsigned.pubkey !== expected) throw new CryptoError("unsigned event pubkey does not match secret key");
|
|
96
|
+
if (unsigned.pubkey !== keys.publicKey) throw new CryptoError("unsigned event pubkey does not match secret key");
|
|
95
97
|
const normalized = {
|
|
96
98
|
kind: unsigned.kind,
|
|
97
99
|
tags: unsigned.tags,
|
|
98
100
|
content: unsigned.content,
|
|
99
101
|
created_at: unsigned.created_at,
|
|
100
|
-
pubkey:
|
|
102
|
+
pubkey: keys.publicKey
|
|
101
103
|
};
|
|
102
104
|
const id = getEventHash(normalized);
|
|
103
|
-
const sig =
|
|
105
|
+
const sig = keys.backend.sign(hexToBytes$1(id), keys.secretKey.bytes, randomBytes(32));
|
|
106
|
+
if (sig.length !== 64) throw new CryptoError("signing backend returned an invalid signature");
|
|
104
107
|
const event = {
|
|
105
108
|
...normalized,
|
|
106
109
|
id,
|
|
107
|
-
sig
|
|
110
|
+
sig: bytesToHex$1(sig)
|
|
108
111
|
};
|
|
109
112
|
markVerified(event);
|
|
110
113
|
return event;
|
|
@@ -112,4 +115,4 @@ function signEvent(unsigned, secretKey) {
|
|
|
112
115
|
//#endregion
|
|
113
116
|
export { publicKeyFromHex as a, getPublicKey as i, SecretKey as n, signEvent as o, finalizeEvent as r, Keys as t };
|
|
114
117
|
|
|
115
|
-
//# sourceMappingURL=key-
|
|
118
|
+
//# sourceMappingURL=key-Bps-LqX7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-Bps-LqX7.mjs","names":["hexToBytes","bytesToHex"],"sources":["../src/core/key.ts"],"sourcesContent":["import { schnorr } from \"@noble/curves/secp256k1.js\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\n\nimport { CryptoError } from \"./error.ts\";\nimport { getEventHash, markVerified, validateEvent } from \"./event.ts\";\nimport type { Event, EventTemplate, UnsignedEvent } from \"./event.ts\";\nimport { assertHex32, assertSecretKeyBytes, bytesToHex, hexToBytes } from \"./util.ts\";\n\n/** 32-byte secret key held as bytes; prefer zeroize when done. */\nexport class SecretKey {\n #bytes: Uint8Array | undefined;\n\n private constructor(bytes: Uint8Array) {\n assertSecretKeyBytes(bytes);\n this.#bytes = new Uint8Array(bytes);\n }\n\n static generate(): SecretKey {\n return new SecretKey(schnorr.utils.randomSecretKey());\n }\n\n static fromBytes(bytes: Uint8Array): SecretKey {\n return new SecretKey(bytes);\n }\n\n static fromHex(hex: string): SecretKey {\n return new SecretKey(hexToBytes(assertHex32(hex, \"secret key\")));\n }\n\n get bytes(): Uint8Array {\n if (!this.#bytes) {\n throw new CryptoError(\"secret key has been zeroized\");\n }\n return new Uint8Array(this.#bytes);\n }\n\n toHex(): string {\n return bytesToHex(this.bytes);\n }\n\n /** Best-effort wipe of the internal buffer. */\n zeroize(): void {\n if (this.#bytes) {\n this.#bytes.fill(0);\n this.#bytes = undefined;\n }\n }\n}\n\n/** Lowercase hex-encoded secp256k1 public key (x-only, 64 chars). */\nexport type PublicKey = string;\n\n/** Validate and normalize a hex public key; throws {@link HexError} on bad input. */\nexport function publicKeyFromHex(hex: string): PublicKey {\n return assertHex32(hex, \"public key\");\n}\n\n/**\n * BIP-340 signing backend. `publicKey` returns the 32-byte x-only public key of a 32-byte secret\n * key; `sign` returns the 64-byte BIP-340 signature of a 32-byte `id` using 32 bytes of auxiliary\n * randomness. Both throw on invalid input (for example an out-of-range secret key).\n */\nexport type SigningBackend = {\n publicKey: (secretKey: Uint8Array) => Uint8Array;\n sign: (id: Uint8Array, secretKey: Uint8Array, auxRand: Uint8Array) => Uint8Array;\n};\n\nconst nobleSigning: SigningBackend = {\n publicKey: (secretKey) => schnorr.getPublicKey(secretKey),\n sign: (id, secretKey, auxRand) => schnorr.sign(id, secretKey, auxRand),\n};\n\n/** Derive the public key for a secret key given as SecretKey, bytes, or hex. */\nexport function getPublicKey(secretKey: SecretKey | Uint8Array | string): PublicKey {\n const bytes =\n secretKey instanceof SecretKey\n ? secretKey.bytes\n : typeof secretKey === \"string\"\n ? hexToBytes(assertHex32(secretKey, \"secret key\"))\n : (assertSecretKeyBytes(secretKey), secretKey);\n return bytesToHex(schnorr.getPublicKey(bytes));\n}\n\n/** Keypair convenience wrapper. */\nexport class Keys {\n readonly secretKey: SecretKey;\n readonly publicKey: PublicKey;\n /**\n * BIP-340 backend that derived {@link publicKey} and signs in {@link finalizeEvent}/\n * {@link signEvent}. Defaults to noble; pass a loaded `NostrWasm` module or a native backend to\n * delegate signing.\n */\n readonly backend: SigningBackend;\n\n private constructor(secretKey: SecretKey, backend: SigningBackend) {\n this.secretKey = secretKey;\n this.backend = backend;\n const pubkey = backend.publicKey(secretKey.bytes);\n if (pubkey.length !== 32) {\n throw new CryptoError(\"signing backend returned an invalid public key\");\n }\n this.publicKey = bytesToHex(pubkey);\n }\n\n static generate(backend: SigningBackend = nobleSigning): Keys {\n return new Keys(SecretKey.generate(), backend);\n }\n\n static fromSecretKey(\n secretKey: SecretKey | Uint8Array | string,\n backend: SigningBackend = nobleSigning,\n ): Keys {\n const sk =\n secretKey instanceof SecretKey\n ? secretKey\n : typeof secretKey === \"string\"\n ? SecretKey.fromHex(secretKey)\n : SecretKey.fromBytes(secretKey);\n return new Keys(sk, backend);\n }\n}\n\nfunction resolveKeys(secretKey: SecretKey | Uint8Array | string | Keys): Keys {\n return secretKey instanceof Keys ? secretKey : Keys.fromSecretKey(secretKey);\n}\n\n/** Fill pubkey/id/sig on a template and return a signed event. */\nexport function finalizeEvent(\n template: EventTemplate,\n secretKey: SecretKey | Uint8Array | string | Keys,\n): Event {\n const keys = resolveKeys(secretKey);\n const unsigned: UnsignedEvent = {\n kind: template.kind,\n tags: template.tags,\n content: template.content,\n created_at: template.created_at,\n pubkey: keys.publicKey,\n };\n return signEvent(unsigned, keys);\n}\n\n/**\n * Sign an already-assembled unsigned event. Rejects when `unsigned.pubkey` does not match the\n * secret key.\n */\nexport function signEvent(\n unsigned: UnsignedEvent,\n secretKey: SecretKey | Uint8Array | string | Keys,\n): Event {\n const keys = resolveKeys(secretKey);\n if (!validateEvent(unsigned)) {\n throw new CryptoError(\"cannot sign invalid unsigned event\");\n }\n\n if (unsigned.pubkey !== keys.publicKey) {\n throw new CryptoError(\"unsigned event pubkey does not match secret key\");\n }\n\n const normalized: UnsignedEvent = {\n kind: unsigned.kind,\n tags: unsigned.tags,\n content: unsigned.content,\n created_at: unsigned.created_at,\n pubkey: keys.publicKey,\n };\n\n const id = getEventHash(normalized);\n const sig = keys.backend.sign(hexToBytes(id), keys.secretKey.bytes, randomBytes(32));\n if (sig.length !== 64) {\n throw new CryptoError(\"signing backend returned an invalid signature\");\n }\n const event: Event = { ...normalized, id, sig: bytesToHex(sig) };\n markVerified(event);\n return event;\n}\n"],"mappings":";;;;;;AASA,IAAa,YAAb,MAAa,UAAU;CACrB;CAEA,YAAoB,OAAmB;EACrC,qBAAqB,KAAK;EAC1B,KAAK,SAAS,IAAI,WAAW,KAAK;CACpC;CAEA,OAAO,WAAsB;EAC3B,OAAO,IAAI,UAAU,QAAQ,MAAM,gBAAgB,CAAC;CACtD;CAEA,OAAO,UAAU,OAA8B;EAC7C,OAAO,IAAI,UAAU,KAAK;CAC5B;CAEA,OAAO,QAAQ,KAAwB;EACrC,OAAO,IAAI,UAAUA,aAAW,YAAY,KAAK,YAAY,CAAC,CAAC;CACjE;CAEA,IAAI,QAAoB;EACtB,IAAI,CAAC,KAAK,QACR,MAAM,IAAI,YAAY,8BAA8B;EAEtD,OAAO,IAAI,WAAW,KAAK,MAAM;CACnC;CAEA,QAAgB;EACd,OAAOC,aAAW,KAAK,KAAK;CAC9B;;CAGA,UAAgB;EACd,IAAI,KAAK,QAAQ;GACf,KAAK,OAAO,KAAK,CAAC;GAClB,KAAK,SAAS,KAAA;EAChB;CACF;AACF;;AAMA,SAAgB,iBAAiB,KAAwB;CACvD,OAAO,YAAY,KAAK,YAAY;AACtC;AAYA,MAAM,eAA+B;CACnC,YAAY,cAAc,QAAQ,aAAa,SAAS;CACxD,OAAO,IAAI,WAAW,YAAY,QAAQ,KAAK,IAAI,WAAW,OAAO;AACvE;;AAGA,SAAgB,aAAa,WAAuD;CAClF,MAAM,QACJ,qBAAqB,YACjB,UAAU,QACV,OAAO,cAAc,WACnBD,aAAW,YAAY,WAAW,YAAY,CAAC,KAC9C,qBAAqB,SAAS,GAAG;CAC1C,OAAOC,aAAW,QAAQ,aAAa,KAAK,CAAC;AAC/C;;AAGA,IAAa,OAAb,MAAa,KAAK;CAChB;CACA;;;;;;CAMA;CAEA,YAAoB,WAAsB,SAAyB;EACjE,KAAK,YAAY;EACjB,KAAK,UAAU;EACf,MAAM,SAAS,QAAQ,UAAU,UAAU,KAAK;EAChD,IAAI,OAAO,WAAW,IACpB,MAAM,IAAI,YAAY,gDAAgD;EAExE,KAAK,YAAYA,aAAW,MAAM;CACpC;CAEA,OAAO,SAAS,UAA0B,cAAoB;EAC5D,OAAO,IAAI,KAAK,UAAU,SAAS,GAAG,OAAO;CAC/C;CAEA,OAAO,cACL,WACA,UAA0B,cACpB;EACN,MAAM,KACJ,qBAAqB,YACjB,YACA,OAAO,cAAc,WACnB,UAAU,QAAQ,SAAS,IAC3B,UAAU,UAAU,SAAS;EACrC,OAAO,IAAI,KAAK,IAAI,OAAO;CAC7B;AACF;AAEA,SAAS,YAAY,WAAyD;CAC5E,OAAO,qBAAqB,OAAO,YAAY,KAAK,cAAc,SAAS;AAC7E;;AAGA,SAAgB,cACd,UACA,WACO;CACP,MAAM,OAAO,YAAY,SAAS;CAQlC,OAAO,UAAU;EANf,MAAM,SAAS;EACf,MAAM,SAAS;EACf,SAAS,SAAS;EAClB,YAAY,SAAS;EACrB,QAAQ,KAAK;CAES,GAAG,IAAI;AACjC;;;;;AAMA,SAAgB,UACd,UACA,WACO;CACP,MAAM,OAAO,YAAY,SAAS;CAClC,IAAI,CAAC,cAAc,QAAQ,GACzB,MAAM,IAAI,YAAY,oCAAoC;CAG5D,IAAI,SAAS,WAAW,KAAK,WAC3B,MAAM,IAAI,YAAY,iDAAiD;CAGzE,MAAM,aAA4B;EAChC,MAAM,SAAS;EACf,MAAM,SAAS;EACf,SAAS,SAAS;EAClB,YAAY,SAAS;EACrB,QAAQ,KAAK;CACf;CAEA,MAAM,KAAK,aAAa,UAAU;CAClC,MAAM,MAAM,KAAK,QAAQ,KAAKD,aAAW,EAAE,GAAG,KAAK,UAAU,OAAO,YAAY,EAAE,CAAC;CACnF,IAAI,IAAI,WAAW,IACjB,MAAM,IAAI,YAAY,+CAA+C;CAEvE,MAAM,QAAe;EAAE,GAAG;EAAY;EAAI,KAAKC,aAAW,GAAG;CAAE;CAC/D,aAAa,KAAK;CAClB,OAAO;AACT"}
|
|
@@ -16,15 +16,30 @@ declare class SecretKey {
|
|
|
16
16
|
type PublicKey = string;
|
|
17
17
|
/** Validate and normalize a hex public key; throws {@link HexError} on bad input. */
|
|
18
18
|
declare function publicKeyFromHex(hex: string): PublicKey;
|
|
19
|
+
/**
|
|
20
|
+
* BIP-340 signing backend. `publicKey` returns the 32-byte x-only public key of a 32-byte secret
|
|
21
|
+
* key; `sign` returns the 64-byte BIP-340 signature of a 32-byte `id` using 32 bytes of auxiliary
|
|
22
|
+
* randomness. Both throw on invalid input (for example an out-of-range secret key).
|
|
23
|
+
*/
|
|
24
|
+
type SigningBackend = {
|
|
25
|
+
publicKey: (secretKey: Uint8Array) => Uint8Array;
|
|
26
|
+
sign: (id: Uint8Array, secretKey: Uint8Array, auxRand: Uint8Array) => Uint8Array;
|
|
27
|
+
};
|
|
19
28
|
/** Derive the public key for a secret key given as SecretKey, bytes, or hex. */
|
|
20
29
|
declare function getPublicKey(secretKey: SecretKey | Uint8Array | string): PublicKey;
|
|
21
30
|
/** Keypair convenience wrapper. */
|
|
22
31
|
declare class Keys {
|
|
23
32
|
readonly secretKey: SecretKey;
|
|
24
33
|
readonly publicKey: PublicKey;
|
|
34
|
+
/**
|
|
35
|
+
* BIP-340 backend that derived {@link publicKey} and signs in {@link finalizeEvent}/
|
|
36
|
+
* {@link signEvent}. Defaults to noble; pass a loaded `NostrWasm` module or a native backend to
|
|
37
|
+
* delegate signing.
|
|
38
|
+
*/
|
|
39
|
+
readonly backend: SigningBackend;
|
|
25
40
|
private constructor();
|
|
26
|
-
static generate(): Keys;
|
|
27
|
-
static fromSecretKey(secretKey: SecretKey | Uint8Array | string): Keys;
|
|
41
|
+
static generate(backend?: SigningBackend): Keys;
|
|
42
|
+
static fromSecretKey(secretKey: SecretKey | Uint8Array | string, backend?: SigningBackend): Keys;
|
|
28
43
|
}
|
|
29
44
|
/** Fill pubkey/id/sig on a template and return a signed event. */
|
|
30
45
|
declare function finalizeEvent(template: EventTemplate, secretKey: SecretKey | Uint8Array | string | Keys): Event;
|
|
@@ -34,5 +49,5 @@ declare function finalizeEvent(template: EventTemplate, secretKey: SecretKey | U
|
|
|
34
49
|
*/
|
|
35
50
|
declare function signEvent(unsigned: UnsignedEvent, secretKey: SecretKey | Uint8Array | string | Keys): Event;
|
|
36
51
|
//#endregion
|
|
37
|
-
export {
|
|
38
|
-
//# sourceMappingURL=key-
|
|
52
|
+
export { finalizeEvent as a, signEvent as c, SigningBackend as i, PublicKey as n, getPublicKey as o, SecretKey as r, publicKeyFromHex as s, Keys as t };
|
|
53
|
+
//# sourceMappingURL=key-Cv4_pN3x.d.mts.map
|
package/dist/loaders.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { r as OutboxBound } from "./types-2pCUprRU.mjs";
|
|
2
|
-
import { _ as ReplaceableLoader, a as OutboxFeed, c as groupAuthorsByOutboxRelay, d as bareNostrUser, f as ListLoaders, g as ReplaceableLoadResult, h as LoadStyle, i as OutboxError, l as NostrUser, m as MutedEntity, n as Loaders, o as OutboxFeedOptions, p as ListResult, r as createLoaders, s as createOutboxFeed, t as CreateLoadersOptions, u as ProfileLoader, v as EventLoader, y as EventRef } from "./index-
|
|
2
|
+
import { _ as ReplaceableLoader, a as OutboxFeed, c as groupAuthorsByOutboxRelay, d as bareNostrUser, f as ListLoaders, g as ReplaceableLoadResult, h as LoadStyle, i as OutboxError, l as NostrUser, m as MutedEntity, n as Loaders, o as OutboxFeedOptions, p as ListResult, r as createLoaders, s as createOutboxFeed, t as CreateLoadersOptions, u as ProfileLoader, v as EventLoader, y as EventRef } from "./index-skvsYz00.mjs";
|
|
3
3
|
export { CreateLoadersOptions, type EventLoader, type EventRef, type ListLoaders, type ListResult, type LoadStyle, Loaders, type MutedEntity, type NostrUser, type OutboxBound, OutboxError, OutboxFeed, type OutboxFeedOptions, type ProfileLoader, type ReplaceableLoadResult, type ReplaceableLoader, bareNostrUser, createLoaders, createOutboxFeed, groupAuthorsByOutboxRelay };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as Tag, t as Event } from "./event-fU3Y01PR.mjs";
|
|
2
|
-
import { t as EventBuilder } from "./builder-
|
|
2
|
+
import { t as EventBuilder } from "./builder-sSflu6nB.mjs";
|
|
3
3
|
import { a as NostrError } from "./error-CR8Urc84.mjs";
|
|
4
4
|
import { a as Rumor, l as WrapOptions, r as Nip59Crypto } from "./nip59-zQgdLcEr.mjs";
|
|
5
5
|
//#region src/nips/nip17.d.ts
|
|
@@ -36,4 +36,4 @@ declare function wrapDirectMessage(crypto: Nip59Crypto, recipients: ReadonlyArra
|
|
|
36
36
|
declare function requireDmRelays(pubkey: string, relays: ReadonlyArray<string>): string[];
|
|
37
37
|
//#endregion
|
|
38
38
|
export { buildChatMessageRumor as a, normalizeRecipients as c, wrapDirectMessage as d, ReplyTo as i, parseDmRelayList as l, Nip17Error as n, dmRelayListEventBuilder as o, Recipient as r, dmRelayListToTags as s, ChatMessageOptions as t, requireDmRelays as u };
|
|
39
|
-
//# sourceMappingURL=nip17-
|
|
39
|
+
//# sourceMappingURL=nip17-CKIufV98.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as Tag, t as Event } from "./event-fU3Y01PR.mjs";
|
|
2
|
-
import { t as EventBuilder } from "./builder-
|
|
2
|
+
import { t as EventBuilder } from "./builder-sSflu6nB.mjs";
|
|
3
3
|
//#region src/nips/nip65.d.ts
|
|
4
4
|
/** NIP-65 `r` tag marker: read-only, write-only, or unmarked (both). */
|
|
5
5
|
type RelayMarker = "read" | "write" | "readwrite";
|
|
@@ -23,4 +23,4 @@ declare function readRelays(items: RelayListItem[]): string[];
|
|
|
23
23
|
declare function writeRelays(items: RelayListItem[]): string[];
|
|
24
24
|
//#endregion
|
|
25
25
|
export { readRelays as a, writeRelays as c, parseRelayList as i, RelayMarker as n, relayListEventBuilder as o, markerOf as r, relayListToTags as s, RelayListItem as t };
|
|
26
|
-
//# sourceMappingURL=nip65-
|
|
26
|
+
//# sourceMappingURL=nip65-CjgmdpPB.d.mts.map
|
package/dist/nips/blossom.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as EventTemplate, t as Event } from "../event-fU3Y01PR.mjs";
|
|
2
|
-
import { t as EventBuilder } from "../builder-
|
|
2
|
+
import { t as EventBuilder } from "../builder-sSflu6nB.mjs";
|
|
3
3
|
import { a as NostrError } from "../error-CR8Urc84.mjs";
|
|
4
4
|
import { t as ManualFetch } from "../http-C4HwIu4B.mjs";
|
|
5
5
|
//#region src/nips/blossom.d.ts
|
package/dist/nips/blossom.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as isRecord, d as utf8Encoder, g as NostrError, i as bytesToHex, n as assertHex32, p as EventValidationError } from "../util-LfQirgDk.mjs";
|
|
2
2
|
import { t as Kind } from "../kind-Cxwhhkx8.mjs";
|
|
3
|
-
import { t as EventBuilder } from "../builder-
|
|
3
|
+
import { t as EventBuilder } from "../builder-9tjI6WQ3.mjs";
|
|
4
4
|
import { n as requireGlobalFetch, r as sendManual, t as fetchManual } from "../http-CuazNRIP.mjs";
|
|
5
5
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
6
6
|
import { base64urlnopad } from "@scure/base";
|
package/dist/nips/nip10.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as Tag, t as Event } from "../event-fU3Y01PR.mjs";
|
|
2
|
-
import { t as EventBuilder } from "../builder-
|
|
2
|
+
import { t as EventBuilder } from "../builder-sSflu6nB.mjs";
|
|
3
3
|
import { f as ProfilePointer, i as EventPointer, t as AddressPointer } from "../nip19-BevCJZsp.mjs";
|
|
4
4
|
//#region src/nips/nip10.d.ts
|
|
5
5
|
/** Parsed NIP-10 thread references from an event's `e`/`q`/`p` tags. */
|
package/dist/nips/nip10.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as isHex32, p as EventValidationError } from "../util-LfQirgDk.mjs";
|
|
2
2
|
import { t as Kind } from "../kind-Cxwhhkx8.mjs";
|
|
3
3
|
import { _ as formatEventAddress, b as parseEventAddress, h as Tag } from "../event-D8Nfoh4K.mjs";
|
|
4
|
-
import { t as EventBuilder } from "../builder-
|
|
4
|
+
import { t as EventBuilder } from "../builder-9tjI6WQ3.mjs";
|
|
5
5
|
//#region src/nips/nip10.ts
|
|
6
6
|
/**
|
|
7
7
|
* NIP-10: Text Notes and Threads
|
package/dist/nips/nip17.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as buildChatMessageRumor, c as normalizeRecipients, d as wrapDirectMessage, i as ReplyTo, l as parseDmRelayList, n as Nip17Error, o as dmRelayListEventBuilder, r as Recipient, s as dmRelayListToTags, t as ChatMessageOptions, u as requireDmRelays } from "../nip17-
|
|
1
|
+
import { a as buildChatMessageRumor, c as normalizeRecipients, d as wrapDirectMessage, i as ReplyTo, l as parseDmRelayList, n as Nip17Error, o as dmRelayListEventBuilder, r as Recipient, s as dmRelayListToTags, t as ChatMessageOptions, u as requireDmRelays } from "../nip17-CKIufV98.mjs";
|
|
2
2
|
export { ChatMessageOptions, Nip17Error, Recipient, ReplyTo, buildChatMessageRumor, dmRelayListEventBuilder, dmRelayListToTags, normalizeRecipients, parseDmRelayList, requireDmRelays, wrapDirectMessage };
|
package/dist/nips/nip17.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { g as NostrError, l as normalizeURL, n as assertHex32, p as EventValidationError } from "../util-LfQirgDk.mjs";
|
|
2
2
|
import { t as Kind } from "../kind-Cxwhhkx8.mjs";
|
|
3
3
|
import { h as Tag } from "../event-D8Nfoh4K.mjs";
|
|
4
|
-
import { t as EventBuilder } from "../builder-
|
|
4
|
+
import { t as EventBuilder } from "../builder-9tjI6WQ3.mjs";
|
|
5
5
|
import { createGiftWrap, createRumor, createSeal } from "./nip59.mjs";
|
|
6
6
|
//#region src/nips/nip17.ts
|
|
7
7
|
var Nip17Error = class extends NostrError {
|
package/dist/nips/nip49.d.mts
CHANGED
|
@@ -2,12 +2,32 @@ import { a as NostrError } from "../error-CR8Urc84.mjs";
|
|
|
2
2
|
//#region src/nips/nip49.d.ts
|
|
3
3
|
export type Ncryptsec = `ncryptsec1${string}`;
|
|
4
4
|
export type KeySecurityByte = 0x00 | 0x01 | 0x02;
|
|
5
|
+
export type ScryptParams = {
|
|
6
|
+
N: number;
|
|
7
|
+
r: number;
|
|
8
|
+
p: number;
|
|
9
|
+
dkLen: number;
|
|
10
|
+
};
|
|
11
|
+
/** Derive `params.dkLen` bytes from the NFKC-normalized UTF-8 password and salt (RFC 7914). */
|
|
12
|
+
export type Scrypt = (password: Uint8Array, salt: Uint8Array, params: ScryptParams) => Promise<Uint8Array>;
|
|
13
|
+
export type Nip49EncryptOptions = {
|
|
14
|
+
/** Scrypt log2(N) work factor, 1..22. Defaults to 16. */
|
|
15
|
+
logn?: number;
|
|
16
|
+
/** Key security byte recorded in the payload. Defaults to 0x02. */
|
|
17
|
+
ksb?: KeySecurityByte;
|
|
18
|
+
/** Scrypt implementation. Defaults to noble `scryptAsync`. */
|
|
19
|
+
scrypt?: Scrypt;
|
|
20
|
+
};
|
|
21
|
+
export type Nip49DecryptOptions = {
|
|
22
|
+
/** Scrypt implementation. Defaults to noble `scryptAsync`. */
|
|
23
|
+
scrypt?: Scrypt;
|
|
24
|
+
};
|
|
5
25
|
export declare class Nip49Error extends NostrError {
|
|
6
26
|
name: string;
|
|
7
27
|
}
|
|
8
28
|
/** Encrypt a 32-byte secret key to an `ncryptsec` bech32 string. */
|
|
9
|
-
export declare function encrypt(secretKey: Uint8Array, password: string,
|
|
29
|
+
export declare function encrypt(secretKey: Uint8Array, password: string, opts?: Nip49EncryptOptions): Promise<Ncryptsec>;
|
|
10
30
|
/** Decrypt an `ncryptsec` bech32 string to a 32-byte secret key. */
|
|
11
|
-
export declare function decrypt(ncryptsec: string, password: string): Uint8Array
|
|
31
|
+
export declare function decrypt(ncryptsec: string, password: string, opts?: Nip49DecryptOptions): Promise<Uint8Array>;
|
|
12
32
|
//#endregion
|
|
13
33
|
//# sourceMappingURL=nip49.d.mts.map
|
package/dist/nips/nip49.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as NostrError, r as assertSecretKeyBytes } from "../util-LfQirgDk.mjs";
|
|
1
|
+
import { d as utf8Encoder, g as NostrError, r as assertSecretKeyBytes } from "../util-LfQirgDk.mjs";
|
|
2
2
|
import { Bech32MaxSize, encodeBytes } from "./nip19.mjs";
|
|
3
3
|
import { concatBytes, randomBytes } from "@noble/hashes/utils.js";
|
|
4
4
|
import { bech32 } from "@scure/base";
|
|
5
5
|
import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
6
|
-
import {
|
|
6
|
+
import { scryptAsync } from "@noble/hashes/scrypt.js";
|
|
7
7
|
//#region src/nips/nip49.ts
|
|
8
8
|
/**
|
|
9
9
|
* NIP-49: Private Key Encryption (`ncryptsec`).
|
|
@@ -24,30 +24,40 @@ var Nip49Error = class extends NostrError {
|
|
|
24
24
|
function assertLogn(logn) {
|
|
25
25
|
if (!Number.isInteger(logn) || logn < LOGN_MIN || logn > LOGN_MAX) throw new Nip49Error(`invalid logn ${logn}, expected integer ${LOGN_MIN}..${LOGN_MAX}`);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
const nobleScrypt = async (password, salt, params) => scryptAsync(password, salt, {
|
|
28
|
+
...params,
|
|
29
|
+
maxmem: 128 * params.r * (params.N + params.p + 1)
|
|
30
|
+
});
|
|
31
|
+
async function deriveKey(password, salt, logn, kdf) {
|
|
28
32
|
assertLogn(logn);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
let key;
|
|
34
|
+
try {
|
|
35
|
+
key = await kdf(utf8Encoder.encode(password.normalize("NFKC")), salt, {
|
|
36
|
+
N: 2 ** logn,
|
|
37
|
+
r: SCRYPT_R,
|
|
38
|
+
p: SCRYPT_P,
|
|
39
|
+
dkLen: 32
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Nip49Error("scrypt failed", { cause: error instanceof Error ? error : void 0 });
|
|
43
|
+
}
|
|
44
|
+
if (key.length !== 32) throw new Nip49Error(`scrypt returned ${key.length} bytes, expected 32`);
|
|
45
|
+
return key;
|
|
37
46
|
}
|
|
38
47
|
/** Encrypt a 32-byte secret key to an `ncryptsec` bech32 string. */
|
|
39
|
-
function encrypt(secretKey, password,
|
|
48
|
+
async function encrypt(secretKey, password, opts) {
|
|
40
49
|
assertSecretKeyBytes(secretKey);
|
|
50
|
+
const logn = opts?.logn ?? 16;
|
|
41
51
|
const salt = randomBytes(SALT_LEN);
|
|
42
|
-
const key = deriveKey(password, salt, logn);
|
|
52
|
+
const key = await deriveKey(password, salt, logn, opts?.scrypt ?? nobleScrypt);
|
|
43
53
|
const nonce = randomBytes(NONCE_LEN);
|
|
44
|
-
const aad = Uint8Array.from([ksb]);
|
|
54
|
+
const aad = Uint8Array.from([opts?.ksb ?? 2]);
|
|
45
55
|
const ciphertext = xchacha20poly1305(key, nonce, aad).encrypt(secretKey);
|
|
46
56
|
const bytes = concatBytes(Uint8Array.from([VERSION]), Uint8Array.from([logn]), salt, nonce, aad, ciphertext);
|
|
47
57
|
return encodeBytes("ncryptsec", bytes);
|
|
48
58
|
}
|
|
49
59
|
/** Decrypt an `ncryptsec` bech32 string to a 32-byte secret key. */
|
|
50
|
-
function decrypt(ncryptsec, password) {
|
|
60
|
+
async function decrypt(ncryptsec, password, opts) {
|
|
51
61
|
let prefix;
|
|
52
62
|
let b;
|
|
53
63
|
try {
|
|
@@ -71,7 +81,7 @@ function decrypt(ncryptsec, password) {
|
|
|
71
81
|
const aad = Uint8Array.from([ksb]);
|
|
72
82
|
const ciphertext = b.subarray(43);
|
|
73
83
|
try {
|
|
74
|
-
const key = deriveKey(password, salt, logn);
|
|
84
|
+
const key = await deriveKey(password, salt, logn, opts?.scrypt ?? nobleScrypt);
|
|
75
85
|
return xchacha20poly1305(key, nonce, aad).decrypt(ciphertext);
|
|
76
86
|
} catch (error) {
|
|
77
87
|
if (error instanceof Nip49Error) throw error;
|
package/dist/nips/nip49.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nip49.mjs","names":[],"sources":["../../src/nips/nip49.ts"],"sourcesContent":["/**\n * NIP-49: Private Key Encryption (`ncryptsec`).\n *\n * @see https://github.com/nostr-protocol/nips/blob/master/49.md\n */\nimport { xchacha20poly1305 } from \"@noble/ciphers/chacha.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"nip49.mjs","names":[],"sources":["../../src/nips/nip49.ts"],"sourcesContent":["/**\n * NIP-49: Private Key Encryption (`ncryptsec`).\n *\n * @see https://github.com/nostr-protocol/nips/blob/master/49.md\n */\nimport { xchacha20poly1305 } from \"@noble/ciphers/chacha.js\";\nimport { scryptAsync } from \"@noble/hashes/scrypt.js\";\nimport { concatBytes, randomBytes } from \"@noble/hashes/utils.js\";\nimport { bech32 } from \"@scure/base\";\n\nimport { NostrError } from \"../core/error.ts\";\nimport { assertSecretKeyBytes, utf8Encoder } from \"../core/util.ts\";\nimport { Bech32MaxSize, encodeBytes } from \"./nip19.ts\";\n\nexport type Ncryptsec = `ncryptsec1${string}`;\nexport type KeySecurityByte = 0x00 | 0x01 | 0x02;\n\nexport type ScryptParams = { N: number; r: number; p: number; dkLen: number };\n\n/** Derive `params.dkLen` bytes from the NFKC-normalized UTF-8 password and salt (RFC 7914). */\nexport type Scrypt = (\n password: Uint8Array,\n salt: Uint8Array,\n params: ScryptParams,\n) => Promise<Uint8Array>;\n\nexport type Nip49EncryptOptions = {\n /** Scrypt log2(N) work factor, 1..22. Defaults to 16. */\n logn?: number;\n /** Key security byte recorded in the payload. Defaults to 0x02. */\n ksb?: KeySecurityByte;\n /** Scrypt implementation. Defaults to noble `scryptAsync`. */\n scrypt?: Scrypt;\n};\n\nexport type Nip49DecryptOptions = {\n /** Scrypt implementation. Defaults to noble `scryptAsync`. */\n scrypt?: Scrypt;\n};\n\nconst VERSION = 0x02;\nconst SALT_LEN = 16;\nconst NONCE_LEN = 24;\nconst PAYLOAD_LEN = 91;\nconst LOGN_MIN = 1;\nconst LOGN_MAX = 22;\nconst SCRYPT_R = 8;\nconst SCRYPT_P = 1;\n\nexport class Nip49Error extends NostrError {\n override name = \"Nip49Error\";\n}\n\nfunction assertLogn(logn: number): void {\n if (!Number.isInteger(logn) || logn < LOGN_MIN || logn > LOGN_MAX) {\n throw new Nip49Error(`invalid logn ${logn}, expected integer ${LOGN_MIN}..${LOGN_MAX}`);\n }\n}\n\n// noble 2.3: V (N blocks) + p B blocks + one tmp scratch block.\nconst nobleScrypt: Scrypt = async (password, salt, params) =>\n scryptAsync(password, salt, {\n ...params,\n maxmem: 128 * params.r * (params.N + params.p + 1),\n });\n\nasync function deriveKey(\n password: string,\n salt: Uint8Array,\n logn: number,\n kdf: Scrypt,\n): Promise<Uint8Array> {\n assertLogn(logn);\n let key: Uint8Array;\n try {\n key = await kdf(utf8Encoder.encode(password.normalize(\"NFKC\")), salt, {\n N: 2 ** logn,\n r: SCRYPT_R,\n p: SCRYPT_P,\n dkLen: 32,\n });\n } catch (error) {\n throw new Nip49Error(\"scrypt failed\", {\n cause: error instanceof Error ? error : undefined,\n });\n }\n if (key.length !== 32) {\n throw new Nip49Error(`scrypt returned ${key.length} bytes, expected 32`);\n }\n return key;\n}\n\n/** Encrypt a 32-byte secret key to an `ncryptsec` bech32 string. */\nexport async function encrypt(\n secretKey: Uint8Array,\n password: string,\n opts?: Nip49EncryptOptions,\n): Promise<Ncryptsec> {\n assertSecretKeyBytes(secretKey);\n const logn = opts?.logn ?? 16;\n const salt = randomBytes(SALT_LEN);\n const key = await deriveKey(password, salt, logn, opts?.scrypt ?? nobleScrypt);\n const nonce = randomBytes(NONCE_LEN);\n const aad = Uint8Array.from([opts?.ksb ?? 0x02]);\n const ciphertext = xchacha20poly1305(key, nonce, aad).encrypt(secretKey);\n const bytes = concatBytes(\n Uint8Array.from([VERSION]),\n Uint8Array.from([logn]),\n salt,\n nonce,\n aad,\n ciphertext,\n );\n return encodeBytes(\"ncryptsec\", bytes);\n}\n\n/** Decrypt an `ncryptsec` bech32 string to a 32-byte secret key. */\nexport async function decrypt(\n ncryptsec: string,\n password: string,\n opts?: Nip49DecryptOptions,\n): Promise<Uint8Array> {\n let prefix: string;\n let b: Uint8Array;\n try {\n const decoded = bech32.decode(ncryptsec, Bech32MaxSize);\n ({ prefix } = decoded);\n b = new Uint8Array(bech32.fromWords(decoded.words));\n } catch (error) {\n throw new Nip49Error(\"invalid ncryptsec\", {\n cause: error instanceof Error ? error : undefined,\n });\n }\n if (prefix !== \"ncryptsec\") {\n throw new Nip49Error(`invalid prefix ${prefix}, expected 'ncryptsec'`);\n }\n if (b.length !== PAYLOAD_LEN) {\n throw new Nip49Error(\"invalid ncryptsec length\");\n }\n const version = b.at(0);\n if (version === undefined) {\n throw new Nip49Error(\"invalid ncryptsec length\");\n }\n if (version !== VERSION) {\n throw new Nip49Error(`invalid version ${version}, expected 0x02`);\n }\n const logn = b.at(1);\n if (logn === undefined) {\n throw new Nip49Error(\"invalid ncryptsec length\");\n }\n const salt = b.subarray(2, 2 + SALT_LEN);\n const nonce = b.subarray(2 + SALT_LEN, 2 + SALT_LEN + NONCE_LEN);\n const ksb = b.at(2 + SALT_LEN + NONCE_LEN);\n if (ksb === undefined) {\n throw new Nip49Error(\"invalid ncryptsec length\");\n }\n const aad = Uint8Array.from([ksb]);\n const ciphertext = b.subarray(2 + SALT_LEN + NONCE_LEN + 1);\n try {\n const key = await deriveKey(password, salt, logn, opts?.scrypt ?? nobleScrypt);\n return xchacha20poly1305(key, nonce, aad).decrypt(ciphertext);\n } catch (error) {\n if (error instanceof Nip49Error) {\n throw error;\n }\n throw new Nip49Error(\"failed to decrypt\", {\n cause: error instanceof Error ? error : undefined,\n });\n }\n}\n"],"mappings":"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"}
|
package/dist/nips/nip51.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as Event } from "../event-fU3Y01PR.mjs";
|
|
2
|
-
import { t as EventBuilder } from "../builder-
|
|
2
|
+
import { t as EventBuilder } from "../builder-sSflu6nB.mjs";
|
|
3
3
|
//#region src/nips/nip51.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Structural crypto used by NIP-51 private tags. Satisfied by NostrSigner when
|
package/dist/nips/nip51.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { l as normalizeURL, n as assertHex32, o as isHex32, p as EventValidationError } from "../util-LfQirgDk.mjs";
|
|
2
2
|
import { t as Kind } from "../kind-Cxwhhkx8.mjs";
|
|
3
3
|
import { h as Tag, v as getDTag, y as isTag } from "../event-D8Nfoh4K.mjs";
|
|
4
|
-
import { t as EventBuilder } from "../builder-
|
|
4
|
+
import { t as EventBuilder } from "../builder-9tjI6WQ3.mjs";
|
|
5
5
|
//#region src/nips/nip51.ts
|
|
6
6
|
/**
|
|
7
7
|
* NIP-51: Lists Public tags plus NIP-44 private `.content` (author encrypts to self). Crypto is
|
package/dist/nips/nip59.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as isRecord, g as NostrError, n as assertHex32 } from "../util-LfQirgDk.mjs";
|
|
2
2
|
import { t as Kind } from "../kind-Cxwhhkx8.mjs";
|
|
3
3
|
import { h as Tag, m as validateSignedEvent, n as getEventHash, p as validateEvent } from "../event-D8Nfoh4K.mjs";
|
|
4
|
-
import { r as finalizeEvent, t as Keys } from "../key-
|
|
4
|
+
import { r as finalizeEvent, t as Keys } from "../key-Bps-LqX7.mjs";
|
|
5
5
|
import { n as verifyEvent } from "../verifier-t5WoWbtY.mjs";
|
|
6
6
|
import { encryptToPubkey } from "./nip44.mjs";
|
|
7
7
|
import { randomBytes } from "@noble/hashes/utils.js";
|
package/dist/nips/nip65.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as readRelays, c as writeRelays, i as parseRelayList, n as RelayMarker, o as relayListEventBuilder, r as markerOf, s as relayListToTags, t as RelayListItem } from "../nip65-
|
|
1
|
+
import { a as readRelays, c as writeRelays, i as parseRelayList, n as RelayMarker, o as relayListEventBuilder, r as markerOf, s as relayListToTags, t as RelayListItem } from "../nip65-CjgmdpPB.mjs";
|
|
2
2
|
export { RelayListItem, RelayMarker, markerOf, parseRelayList, readRelays, relayListEventBuilder, relayListToTags, writeRelays };
|
package/dist/nips/nip65.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as normalizeURL, p as EventValidationError } from "../util-LfQirgDk.mjs";
|
|
2
2
|
import { t as Kind } from "../kind-Cxwhhkx8.mjs";
|
|
3
|
-
import { t as EventBuilder } from "../builder-
|
|
3
|
+
import { t as EventBuilder } from "../builder-9tjI6WQ3.mjs";
|
|
4
4
|
//#region src/nips/nip65.ts
|
|
5
5
|
/** The NIP-65 marker an item's read/write flags map to. */
|
|
6
6
|
function markerOf(item) {
|