mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Remove nostr shim and retarget imports
This commit is contained in:
1 parent
5d22d78717
commit
3996986e63
36 files changed
+89
-206
No files matched your search
@@ -207,9 +207,9 @@ the entry point that matches their feature set:
|
||||
2. **View counters ([NIP-71](https://github.com/nostr-protocol/nips/blob/master/71.md)):** `import { recordVideoView, subscribeVideoViewEvents } from './nostrViewEventsFacade.js';`
|
||||
3. **Watch-history lists ([NIP-51](https://github.com/nostr-protocol/nips/blob/master/51.md) + [NIP-04](https://github.com/nostr-protocol/nips/blob/master/04.md) encryption):** `import { updateWatchHistoryListWithDefaultClient } from './nostrWatchHistoryFacade.js';`
|
||||
|
||||
`js/nostr.js` remains as a compatibility shim while existing plugins migrate, but
|
||||
it will be removed in a future release. Move any legacy `import { ... } from './nostr.js';`
|
||||
calls over to the facades above so upgrades stay painless.
|
||||
The legacy `js/nostr.js` shim has been removed. Update any remaining
|
||||
`import { ... } from './nostr.js';` calls to use the facades above so upgrades
|
||||
stay painless.
|
||||
|
||||
The build command compiles Tailwind with `tailwind.config.cjs`, runs it through
|
||||
the PostCSS pipeline defined in `postcss.config.cjs` (for autoprefixing), and
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
Currently, logic related to the **video note specification** and how data is structured (version, `isPrivate`, encryption placeholders, and so on) is scattered across three files:
|
||||
|
||||
1. **app.js**: Contains UI handling, form submissions, and some note structure (like `version`, `title`, `magnet`).
|
||||
2. **nostr.js**: Builds and edits Nostr events (`publishVideo`, `editVideo`, `deleteVideo`). It also holds methods for “fake encryption” and “fake decryption,” among other utilities.
|
||||
2. **nostr client modules** (for example, `js/nostr/client.js`): Build and edit Nostr events (`publishVideo`, `editVideo`, `deleteVideo`). They also hold methods for “fake encryption” and “fake decryption,” among other utilities.
|
||||
3. **webtorrent.js**: Mostly focuses on torrent streaming but does not handle note logic directly. It rarely touches the note data, so it may not need major restructuring.
|
||||
|
||||
To isolate note-spec-related operations, you can create a new file (for example, `bitvidNoteSpec.js`). This file will have all the code that deals with creating or parsing your event content fields (version, magnet link encryption, etc.). Then `app.js` and `nostr.js` can import those functions.
|
||||
The legacy `nostr.js` shim no longer exists; references to it map to the nostr client layer under `js/nostr/`.
|
||||
|
||||
To isolate note-spec-related operations, you can create a new file (for example, `bitvidNoteSpec.js`). This file will have all the code that deals with creating or parsing your event content fields (version, magnet link encryption, etc.). Then `app.js` and the nostr client modules can import those functions.
|
||||
|
||||
---
|
||||
|
||||
@@ -18,7 +20,7 @@ To isolate note-spec-related operations, you can create a new file (for example,
|
||||
|
||||
- **Centralize the note specification**: Keep details like `version`, `deleted`, `isPrivate`, encryption, and decryption in one place.
|
||||
- **Simplify `app.js`**: Move form building/parsing to new spec-related functions. That way, `app.js` only handles UI and user actions.
|
||||
- **Streamline `nostr.js`**: Shift event creation logic into a function from the new note spec file. Nostr code then just calls that function, signs it, and publishes it.
|
||||
- **Streamline the nostr client layer**: Shift event creation logic into a function from the new note spec file. Nostr code then just calls that function, signs it, and publishes it.
|
||||
|
||||
---
|
||||
|
||||
@@ -118,17 +120,17 @@ Now `handleSubmit` is only handling the UI, while actual note-building moves to
|
||||
|
||||
---
|
||||
|
||||
### 2. Extracting Logic from `nostr.js`
|
||||
### 2. Extracting Logic from the nostr client layer
|
||||
|
||||
In `nostr.js`, you have methods like `publishVideo`, `editVideo`, and `deleteVideo`. They build the note content, sign it, and publish it. You can simplify them:
|
||||
In the nostr client modules, you have methods like `publishVideo`, `editVideo`, and `deleteVideo`. They build the note content, sign it, and publish it. You can simplify them:
|
||||
|
||||
- **Rename** them to something more generic (e.g., `publishNote`, `updateNote`, `deleteNote`) if that aligns better with Nostr usage.
|
||||
- **Import** helper functions from `bitvidNoteSpec.js` to build or edit the actual content. That way, `nostr.js` doesn’t need to know about `version`, `deleted`, or encryption details.
|
||||
- **Import** helper functions from `bitvidNoteSpec.js` to build or edit the actual content. That way, the nostr client layer doesn’t need to know about `version`, `deleted`, or encryption details.
|
||||
|
||||
For example, you might do this:
|
||||
|
||||
```js
|
||||
// nostr.js
|
||||
// nostr client module
|
||||
import { buildEditNote, buildDeleteNote } from "./bitvidNoteSpec.js";
|
||||
|
||||
class NostrClient {
|
||||
@@ -150,7 +152,7 @@ class NostrClient {
|
||||
}
|
||||
```
|
||||
|
||||
By delegating the actual note-building to `buildEditNote` and `buildDeleteNote`, you keep `nostr.js` focused on signing and relaying events.
|
||||
By delegating the actual note-building to `buildEditNote` and `buildDeleteNote`, you keep the nostr client layer focused on signing and relaying events.
|
||||
|
||||
---
|
||||
|
||||
@@ -170,16 +172,16 @@ By delegating the actual note-building to `buildEditNote` and `buildDeleteNote`,
|
||||
- Remove direct references to building the final note object in `handleSubmit`.
|
||||
- Instead, gather user inputs, call a helper function from `bitvidNoteSpec.js` to produce the final note object, then pass that object to `nostrClient.publishNote` (or a similar method).
|
||||
|
||||
3. **Update `nostr.js`:**
|
||||
- Rename or refactor `publishVideo`, `editVideo`, and `deleteVideo` to call your new helper methods from `bitvidNoteSpec.js`.
|
||||
- Keep the Nostr signing and publishing logic inside `nostr.js`.
|
||||
3. **Update the nostr client modules:**
|
||||
- Rename or refactor `publishVideo`, `editVideo`, and `deleteVideo` to call your new helper methods from `bitvidNoteSpec.js`.
|
||||
- Keep the Nostr signing and publishing logic inside the client layer.
|
||||
|
||||
4. **Verify Data Flow:**
|
||||
- Confirm that after form submission, the final event object is built in `bitvidNoteSpec.js`, returned to `app.js`, and forwarded to `nostrClient`.
|
||||
- Ensure you can still subscribe to events and parse them without issues.
|
||||
|
||||
5. **Remove Redundant Code:**
|
||||
- Delete any leftover duplication in `app.js` or `nostr.js` relating to magnet encryption or note structuring.
|
||||
5. **Remove Redundant Code:**
|
||||
- Delete any leftover duplication in `app.js` or the nostr client modules relating to magnet encryption or note structuring.
|
||||
|
||||
6. **Test Thoroughly:**
|
||||
- Create, edit, and delete events to ensure everything behaves the same.
|
||||
@@ -257,7 +259,7 @@ export function isValidNoteContent(content) {
|
||||
}
|
||||
```
|
||||
|
||||
By keeping these details in a single file, you won’t have to search through `app.js` or `nostr.js` whenever you need to tweak the note structure.
|
||||
By keeping these details in a single file, you won’t have to search through `app.js` or the nostr client modules whenever you need to tweak the note structure.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ When wiring moderation or playback toggles into view analytics, import helpers f
|
||||
import { recordVideoView, subscribeVideoViewEvents } from "../nostrViewEventsFacade.js";
|
||||
```
|
||||
|
||||
The facade wraps [`js/nostr/viewEventBindings.js`](../js/nostr/viewEventBindings.js) so feature flags, relay discovery, and COUNT/LIST fallbacks all run through the same guard clauses that enforce the NIP-71/NIP-78 schemas. `js/nostr.js` still exports shimmed versions for legacy bundles, but new code should migrate to the facades to keep the eventual removal painless. Modules that need to no-op when relays disable optional methods can rely on the binding’s "unavailable" errors to short-circuit cleanly.
|
||||
The facade wraps [`js/nostr/viewEventBindings.js`](../js/nostr/viewEventBindings.js) so feature flags, relay discovery, and COUNT/LIST fallbacks all run through the same guard clauses that enforce the NIP-71/NIP-78 schemas. Modules that need to no-op when relays disable optional methods can rely on the binding’s "unavailable" errors to short-circuit cleanly.
|
||||
|
||||
### Hydration, COUNT, and UI sync
|
||||
|
||||
|
||||
@@ -110,9 +110,8 @@ through the dedicated facade when you need to run a NIP-07 handshake:
|
||||
import { nostrClient, requestDefaultExtensionPermissions } from "./nostrClientFacade.js";
|
||||
```
|
||||
|
||||
`js/nostr.js` remains as a compatibility shim while downstream packages migrate;
|
||||
it forwards to the new facades but is slated for removal once legacy imports
|
||||
are retired.【F:js/nostr/defaultClient.js†L1-L25】【F:js/nostr.js†L1-L92】
|
||||
The compatibility shim has been removed; import from the facades above to avoid
|
||||
broken references.【F:js/nostr/defaultClient.js†L1-L25】
|
||||
|
||||
For analytics, route through the
|
||||
[NIP-71](https://github.com/nostr-protocol/nips/blob/master/71.md) helpers in
|
||||
|
||||
@@ -362,7 +362,6 @@
|
||||
<script type="module" src="js/lists.js?v=2024.11.09"></script>
|
||||
<script type="module" src="js/accessControl.js?v=2024.11.09"></script>
|
||||
<script type="module" src="js/webtorrent.js?v=2024.11.09"></script>
|
||||
<script type="module" src="js/nostr.js?v=2024.11.09"></script>
|
||||
<script type="module" src="js/viewManager.js?v=2024.11.09"></script>
|
||||
<script type="module" src="js/bootstrap.js?v=2024.11.09"></script>
|
||||
<script type="module" src="js/disclaimer.js?v=2024.11.09"></script>
|
||||
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
// js/nostr.js
|
||||
//
|
||||
// Compatibility shim that forwards legacy imports to the new domain-specific
|
||||
// facades. Prefer importing from the facades directly in new modules so the
|
||||
// wiring between the default client and helper layers stays explicit.
|
||||
|
||||
import {
|
||||
nostrClient as defaultNostrClient,
|
||||
requestDefaultExtensionPermissions,
|
||||
} from "./nostrClientFacade.js";
|
||||
|
||||
export { requestDefaultExtensionPermissions };
|
||||
export { defaultNostrClient as nostrClient };
|
||||
|
||||
export const publishVideoReaction = (...args) => {
|
||||
if (
|
||||
!defaultNostrClient ||
|
||||
typeof defaultNostrClient.publishVideoReaction !== "function"
|
||||
) {
|
||||
throw new Error("Video reaction publishing is unavailable in this build.");
|
||||
}
|
||||
return defaultNostrClient.publishVideoReaction(...args);
|
||||
};
|
||||
|
||||
export const publishVideoComment = (...args) => {
|
||||
if (
|
||||
!defaultNostrClient ||
|
||||
typeof defaultNostrClient.publishVideoComment !== "function"
|
||||
) {
|
||||
throw new Error("Video comment publishing is unavailable in this build.");
|
||||
}
|
||||
return defaultNostrClient.publishVideoComment(...args);
|
||||
};
|
||||
|
||||
export const fetchVideoComments = (...args) => {
|
||||
if (
|
||||
!defaultNostrClient ||
|
||||
typeof defaultNostrClient.fetchVideoComments !== "function"
|
||||
) {
|
||||
throw new Error("Video comment fetching is unavailable in this build.");
|
||||
}
|
||||
return defaultNostrClient.fetchVideoComments(...args);
|
||||
};
|
||||
|
||||
export const subscribeVideoComments = (...args) => {
|
||||
if (
|
||||
!defaultNostrClient ||
|
||||
typeof defaultNostrClient.subscribeVideoComments !== "function"
|
||||
) {
|
||||
throw new Error("Video comment subscriptions are unavailable in this build.");
|
||||
}
|
||||
return defaultNostrClient.subscribeVideoComments(...args);
|
||||
};
|
||||
|
||||
export {
|
||||
__testExports,
|
||||
NostrClient,
|
||||
getActiveSigner,
|
||||
setActiveSigner,
|
||||
clearActiveSigner,
|
||||
resolveActiveSigner,
|
||||
shouldRequestExtensionPermissions,
|
||||
} from "./nostr/client.js";
|
||||
|
||||
export {
|
||||
DEFAULT_NIP07_ENCRYPTION_METHODS,
|
||||
DEFAULT_NIP07_PERMISSION_METHODS,
|
||||
} from "./nostr/nip07Permissions.js";
|
||||
|
||||
export {
|
||||
buildNip71MetadataTags,
|
||||
buildNip71VideoEvent,
|
||||
collectNip71PointerRequests,
|
||||
convertEventToVideo,
|
||||
extractNip71MetadataFromTags,
|
||||
getDTagValueFromTags,
|
||||
mergeNip71MetadataIntoVideo,
|
||||
populateNip71MetadataForVideos,
|
||||
processNip71Events,
|
||||
buildVideoPointerValue,
|
||||
stringFromInput,
|
||||
} from "./nostr/nip71.js";
|
||||
|
||||
export {
|
||||
normalizePointerInput,
|
||||
pointerKey,
|
||||
buildWatchHistoryPayload,
|
||||
normalizeActorKey,
|
||||
parseWatchHistoryContentWithFallback,
|
||||
isNip04EncryptedWatchHistoryEvent,
|
||||
watchHistoryHelpers,
|
||||
} from "./nostr/watchHistory.js";
|
||||
|
||||
export {
|
||||
recordVideoViewWithDefaultClient,
|
||||
listVideoViewEventsWithDefaultClient,
|
||||
subscribeVideoViewEventsWithDefaultClient,
|
||||
countVideoViewEventsWithDefaultClient,
|
||||
} from "./nostrViewEventsFacade.js";
|
||||
|
||||
export {
|
||||
VIEW_EVENT_KIND,
|
||||
createVideoViewEventFilters,
|
||||
deriveViewEventBucketIndex,
|
||||
deriveViewEventPointerScope,
|
||||
getViewEventGuardWindowMs,
|
||||
hasRecentViewPublish,
|
||||
rememberViewPublish,
|
||||
publishViewEvent,
|
||||
recordVideoView as recordVideoViewWithClient,
|
||||
listVideoViewEvents as listVideoViewEventsWithClient,
|
||||
subscribeVideoViewEvents as subscribeVideoViewEventsWithClient,
|
||||
countVideoViewEvents as countVideoViewEventsWithClient,
|
||||
} from "./nostrViewEventsFacade.js";
|
||||
|
||||
export {
|
||||
updateWatchHistoryListWithDefaultClient,
|
||||
removeWatchHistoryItemWithDefaultClient,
|
||||
} from "./nostrWatchHistoryFacade.js";
|
||||
|
||||
export {
|
||||
updateWatchHistoryListWithDefaultClient as updateWatchHistoryList,
|
||||
removeWatchHistoryItemWithDefaultClient as removeWatchHistoryItem,
|
||||
} from "./nostrWatchHistoryFacade.js";
|
||||
|
||||
export {
|
||||
recordVideoViewWithDefaultClient as recordVideoView,
|
||||
listVideoViewEventsWithDefaultClient as listVideoViewEvents,
|
||||
subscribeVideoViewEventsWithDefaultClient as subscribeVideoViewEvents,
|
||||
countVideoViewEventsWithDefaultClient as countVideoViewEvents,
|
||||
} from "./nostrViewEventsFacade.js";
|
||||
|
||||
// Legacy modules should import from the specific facades above instead of this
|
||||
// shim. The wildcard export that previously forwarded the entire
|
||||
// "./nostr/index.js" barrel has intentionally been removed so bundlers can tree
|
||||
// shake unused helpers.
|
||||
@@ -1,7 +1,7 @@
|
||||
// js/payments/platformAddress.js
|
||||
|
||||
import { PLATFORM_LUD16_OVERRIDE, ADMIN_SUPER_NPUB } from "../config.js";
|
||||
import { nostrClient } from "../nostr.js";
|
||||
import { nostrClient } from "../nostrClientFacade.js";
|
||||
import { setProfileCacheEntry } from "../state/cache.js";
|
||||
import { nostrToolsReady } from "../nostrToolsBootstrap.js";
|
||||
import { userLogger } from "../utils/logger.js";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { publishVideoReaction } from "./nostr.js";
|
||||
import { nostrClient } from "./nostrClientFacade.js";
|
||||
import { normalizePointerInput, pointerKey } from "./nostr/watchHistory.js";
|
||||
import { devLogger, userLogger } from "./utils/logger.js";
|
||||
@@ -749,7 +748,10 @@ export const reactionCounter = {
|
||||
}
|
||||
}
|
||||
|
||||
const result = await publishVideoReaction(enrichedPointer, publishOptions);
|
||||
const result = await nostrClient.publishVideoReaction(
|
||||
enrichedPointer,
|
||||
publishOptions,
|
||||
);
|
||||
if (!result || !result.ok) {
|
||||
userLogger.warn(
|
||||
"[reactionCounter] Reaction publish rejected by relays:",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { nostrClient } from "../nostr.js";
|
||||
import { nostrClient } from "../nostrClientFacade.js";
|
||||
import { publishEventToRelays, assertAnyRelayAccepted } from "../nostrPublish.js";
|
||||
import { accessControl } from "../accessControl.js";
|
||||
import { userBlocks, USER_BLOCK_EVENTS } from "../userBlocks.js";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { nostrClient } from "../nostr.js";
|
||||
import { nostrClient } from "../nostrClientFacade.js";
|
||||
import { convertEventToVideo } from "../nostr/index.js";
|
||||
import { accessControl } from "../accessControl.js";
|
||||
import { ALLOW_NSFW_CONTENT } from "../config.js";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// js/utils/profileBatchFetcher.js
|
||||
|
||||
import { nostrClient } from "../nostr.js";
|
||||
import { nostrClient } from "../nostrClientFacade.js";
|
||||
import { devLogger } from "./logger.js";
|
||||
|
||||
const DEFAULT_PROFILE_IMAGE = "assets/svg/default-profile.svg";
|
||||
|
||||
+3
-2
@@ -566,8 +566,9 @@ function ensureLiveSubscription(key, listeners) {
|
||||
|
||||
export function initViewCounter({ nostrClient } = {}) {
|
||||
if (nostrClient && typeof nostrClient === "object") {
|
||||
// The singleton Nostr client is already registered inside js/nostr.js.
|
||||
// This hook remains for backwards compatibility.
|
||||
// The singleton Nostr client is already registered inside
|
||||
// js/nostr/defaultClient.js. This hook remains for backwards
|
||||
// compatibility.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,10 @@ const {
|
||||
} = await import(
|
||||
"../js/adminListStore.js"
|
||||
);
|
||||
const { nostrClient, setActiveSigner } = await import("../js/nostr.js");
|
||||
const [{ nostrClient }, { setActiveSigner }] = await Promise.all([
|
||||
import("../js/nostrClientFacade.js"),
|
||||
import("../js/nostr/client.js"),
|
||||
]);
|
||||
const {
|
||||
ADMIN_SUPER_NPUB,
|
||||
ADMIN_LIST_NAMESPACE,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { nostrClient } from "../js/nostr.js";
|
||||
import { nostrClient } from "../js/nostrClientFacade.js";
|
||||
import { batchFetchProfilesFromRelays } from "../js/utils/profileBatchFetcher.js";
|
||||
|
||||
const FAST_RELAY = "wss://fast.example";
|
||||
|
||||
@@ -5,11 +5,11 @@ const hashtagPreferencesModule = await import(
|
||||
"../js/services/hashtagPreferencesService.js"
|
||||
);
|
||||
const hashtagPreferences = hashtagPreferencesModule.default;
|
||||
const {
|
||||
nostrClient,
|
||||
setActiveSigner,
|
||||
clearActiveSigner,
|
||||
} = await import("../js/nostr.js");
|
||||
const [{ nostrClient }, { setActiveSigner, clearActiveSigner }] =
|
||||
await Promise.all([
|
||||
import("../js/nostrClientFacade.js"),
|
||||
import("../js/nostr/client.js"),
|
||||
]);
|
||||
|
||||
if (typeof globalThis.window === "undefined") {
|
||||
globalThis.window = {};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "./test-helpers/setup-localstorage.mjs";
|
||||
import assert from "node:assert/strict";
|
||||
import { parseVideoEventPayload } from "../js/videoEventUtils.js";
|
||||
import { convertEventToVideo } from "../js/nostr.js";
|
||||
import { convertEventToVideo } from "../js/nostr/nip71.js";
|
||||
import { deriveTorrentPlaybackConfig } from "../js/playbackUtils.js";
|
||||
|
||||
const LEGACY_INFO_HASH = "0123456789abcdef0123456789abcdef01234567";
|
||||
|
||||
@@ -11,7 +11,9 @@ import { withMockedNostrTools, createModerationServiceHarness } from "../helpers
|
||||
|
||||
const { userBlocks } = await import("../../js/userBlocks.js");
|
||||
const { nostrClient } = await import("../../js/nostrClientFacade.js");
|
||||
const { setActiveSigner, clearActiveSigner } = await import("../../js/nostr.js");
|
||||
const { setActiveSigner, clearActiveSigner } = await import(
|
||||
"../../js/nostr/client.js"
|
||||
);
|
||||
|
||||
test("trusted mute lists from seeds hide authors for anonymous viewers", async (t) => {
|
||||
withMockedNostrTools(t);
|
||||
|
||||
@@ -2,7 +2,8 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { buildVideoPostEvent } from "../js/nostrEventSchemas.js";
|
||||
import { buildNip71MetadataTags, NostrClient } from "../js/nostr.js";
|
||||
import { buildNip71MetadataTags } from "../js/nostr/nip71.js";
|
||||
import { NostrClient } from "../js/nostr/client.js";
|
||||
|
||||
test("30078 events carry nip71 metadata tags and hydrate fallback metadata", () => {
|
||||
const metadataInput = {
|
||||
|
||||
@@ -4,7 +4,7 @@ import test from "node:test";
|
||||
import {
|
||||
buildNip71VideoEvent,
|
||||
extractNip71MetadataFromTags,
|
||||
} from "../js/nostr.js";
|
||||
} from "../js/nostr/nip71.js";
|
||||
|
||||
const participantNpub = "npub1bitvidparticipantfixture";
|
||||
const participantHexFromNpub = "c".repeat(64);
|
||||
|
||||
@@ -12,9 +12,7 @@ if (!globalThis.window.NostrTools) {
|
||||
}
|
||||
|
||||
const { VIEW_COUNT_BACKFILL_MAX_DAYS } = await import("../js/config.js");
|
||||
const { nostrClient } = await import("../js/nostr.js");
|
||||
|
||||
const NostrClient = nostrClient.constructor;
|
||||
const { NostrClient } = await import("../js/nostr/client.js");
|
||||
|
||||
async function withFrozenTime(timestampSeconds, callback) {
|
||||
const originalNow = Date.now;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import "./test-helpers/setup-localstorage.mjs";
|
||||
import assert from "node:assert/strict";
|
||||
import { NostrClient } from "../js/nostr.js";
|
||||
import { NostrClient } from "../js/nostr/client.js";
|
||||
import { NostrService } from "../js/services/nostrService.js";
|
||||
|
||||
await (async function testDeleteFlowPublishesDeletionFlag() {
|
||||
|
||||
@@ -2,7 +2,8 @@ import "./test-helpers/setup-localstorage.mjs";
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { NostrClient, nostrClient, __testExports } from "../js/nostr.js";
|
||||
import { nostrClient } from "../js/nostrClientFacade.js";
|
||||
import { NostrClient, __testExports } from "../js/nostr/client.js";
|
||||
import { accessControl } from "../js/accessControl.js";
|
||||
|
||||
const {
|
||||
|
||||
@@ -17,9 +17,11 @@ test("registerPrivateKeySigner exposes nip04 helpers", async () => {
|
||||
value: canonicalTools,
|
||||
});
|
||||
|
||||
const { nostrClient, getActiveSigner, clearActiveSigner } = await import(
|
||||
"../js/nostr.js"
|
||||
);
|
||||
const [{ nostrClient }, { getActiveSigner, clearActiveSigner }] =
|
||||
await Promise.all([
|
||||
import("../js/nostrClientFacade.js"),
|
||||
import("../js/nostr/client.js"),
|
||||
]);
|
||||
|
||||
const privateKeyBytes = nostrTools.generateSecretKey();
|
||||
const privateKeyHex = nostrTools.utils.bytesToHex(privateKeyBytes);
|
||||
|
||||
@@ -48,7 +48,11 @@ let activeSignerCleanup = null;
|
||||
|
||||
try {
|
||||
const { RelayPublishError } = await import("../js/nostrPublish.js");
|
||||
const { nostrClient, setActiveSigner, clearActiveSigner } = await import("../js/nostr.js");
|
||||
const [{ nostrClient }, { setActiveSigner, clearActiveSigner }] =
|
||||
await Promise.all([
|
||||
import("../js/nostrClientFacade.js"),
|
||||
import("../js/nostr/client.js"),
|
||||
]);
|
||||
const { subscriptions } = await import("../js/subscriptions.js");
|
||||
const { userBlocks } = await import("../js/userBlocks.js");
|
||||
const { Application } = await import("../js/app.js");
|
||||
|
||||
@@ -25,9 +25,11 @@ test("sendDirectMessage succeeds with private key signer and no extension", asyn
|
||||
value: canonicalTools,
|
||||
});
|
||||
|
||||
const { nostrClient, getActiveSigner, clearActiveSigner } = await import(
|
||||
"../js/nostr.js"
|
||||
);
|
||||
const [{ nostrClient }, { getActiveSigner, clearActiveSigner }] =
|
||||
await Promise.all([
|
||||
import("../js/nostrClientFacade.js"),
|
||||
import("../js/nostr/client.js"),
|
||||
]);
|
||||
|
||||
const previousPool = nostrClient.pool;
|
||||
const previousRelays = Array.isArray(nostrClient.relays)
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
NostrClient,
|
||||
setActiveSigner,
|
||||
clearActiveSigner,
|
||||
} from "../../js/nostr.js";
|
||||
} from "../../js/nostr/client.js";
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
|
||||
const {
|
||||
nostrClient,
|
||||
clearActiveSigner,
|
||||
} = await import("../../js/nostr.js");
|
||||
} = await import("../../js/nostrClientFacade.js");
|
||||
const { clearActiveSigner } = await import("../../js/nostr/client.js");
|
||||
const { accessControl } = await import("../../js/accessControl.js");
|
||||
const { WATCH_HISTORY_KIND } = await import("../../js/config.js");
|
||||
const { normalizeActorKey } = await import("../../js/nostr/watchHistory.js");
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
NostrClient,
|
||||
setActiveSigner,
|
||||
clearActiveSigner,
|
||||
} from "../../js/nostr.js";
|
||||
} from "../../js/nostr/client.js";
|
||||
|
||||
function createStubPool() {
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,7 @@ const {
|
||||
setActiveSigner,
|
||||
resolveActiveSigner,
|
||||
clearActiveSigner,
|
||||
} = await import("../../js/nostr.js");
|
||||
} = await import("../../js/nostr/client.js");
|
||||
|
||||
test("setActiveSigner hydrates extension capabilities from window.nostr", async () => {
|
||||
clearActiveSigner();
|
||||
|
||||
@@ -3,7 +3,8 @@ import assert from "node:assert/strict";
|
||||
|
||||
import { JSDOM } from "jsdom";
|
||||
|
||||
import { nostrClient, getActiveSigner, setActiveSigner } from "../js/nostr.js";
|
||||
import { nostrClient } from "../js/nostrClientFacade.js";
|
||||
import { getActiveSigner, setActiveSigner } from "../js/nostr/client.js";
|
||||
import { subscriptions } from "../js/subscriptions.js";
|
||||
import { setApplication } from "../js/applicationContext.js";
|
||||
import nostrService from "../js/services/nostrService.js";
|
||||
|
||||
@@ -4,10 +4,10 @@ import assert from "node:assert/strict";
|
||||
const { userBlocks, USER_BLOCK_EVENTS } = await import("../js/userBlocks.js");
|
||||
const {
|
||||
nostrClient,
|
||||
setActiveSigner,
|
||||
clearActiveSigner,
|
||||
getActiveSigner,
|
||||
} = await import("../js/nostr.js");
|
||||
} = await import("../js/nostrClientFacade.js");
|
||||
const { setActiveSigner, clearActiveSigner, getActiveSigner } = await import(
|
||||
"../js/nostr/client.js"
|
||||
);
|
||||
|
||||
if (typeof globalThis.window === "undefined") {
|
||||
globalThis.window = {};
|
||||
|
||||
@@ -431,7 +431,7 @@ await (async () => {
|
||||
splitAndZap: async () => ({ receipts: [] }),
|
||||
});
|
||||
|
||||
const { nostrClient } = await import("../js/nostr.js");
|
||||
const { nostrClient } = await import("../js/nostrClientFacade.js");
|
||||
const originalSessionActor = nostrClient.sessionActor;
|
||||
const sessionPubkey = "a".repeat(64);
|
||||
nostrClient.sessionActor = { pubkey: sessionPubkey, privateKey: "priv" };
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
NOTE_TYPES,
|
||||
getNostrEventSchema,
|
||||
} from "../js/nostrEventSchemas.js";
|
||||
import { convertEventToVideo } from "../js/nostr.js";
|
||||
import { convertEventToVideo } from "../js/nostr/nip71.js";
|
||||
|
||||
test("video post schema documents nsfw and kids flags", () => {
|
||||
const schema = getNostrEventSchema(NOTE_TYPES.VIDEO_POST);
|
||||
|
||||
@@ -142,7 +142,7 @@ assert.ok(
|
||||
"invalid additional tag values should not be coerced to object strings"
|
||||
);
|
||||
|
||||
const { nostrClient } = await import("../js/nostr.js");
|
||||
const { nostrClient } = await import("../js/nostrClientFacade.js");
|
||||
|
||||
function createMockNostrHarness() {
|
||||
const storedEvents = new Map();
|
||||
|
||||
@@ -17,9 +17,11 @@ const {
|
||||
getWatchHistoryV2Enabled,
|
||||
setWatchHistoryV2Enabled,
|
||||
} = await import("../js/constants.js");
|
||||
const { nostrClient, setActiveSigner, getActiveSigner, clearActiveSigner } = await import(
|
||||
"../js/nostr.js",
|
||||
);
|
||||
const [{ nostrClient }, { setActiveSigner, getActiveSigner, clearActiveSigner }] =
|
||||
await Promise.all([
|
||||
import("../js/nostrClientFacade.js"),
|
||||
import("../js/nostr/client.js"),
|
||||
]);
|
||||
const { rememberNostrTools } = await import("../js/nostr/toolkit.js");
|
||||
const { normalizeActorKey } = await import("../js/nostr/watchHistory.js");
|
||||
const { watchHistoryService } = await import("../js/watchHistoryService.js");
|
||||
|
||||
@@ -90,7 +90,7 @@ const {
|
||||
requestInvoice,
|
||||
} = lnurlModule;
|
||||
const { decodeLnurlBech32 } = lnurlModule.__TESTING__;
|
||||
const { nostrClient } = await import("../js/nostr.js");
|
||||
const { nostrClient } = await import("../js/nostrClientFacade.js");
|
||||
|
||||
const DEFAULT_WALLET_RELAYS = [
|
||||
"wss://wallet.primary.example",
|
||||
|
||||
Reference in new issue
Block a user