mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
docs: align upload guide with code behavior and fix ci dependencies
- Update `content/docs/guides/upload-content.md` to enforce HTTPS for external URLs and clarify file validation. - Fix `SignerManager.js` permission request logic (pass extension instance). - Fix `NostrClient` signer registration and hydration. - Install `jsdom` to resolve `ERR_MODULE_NOT_FOUND` in unit tests. - Patch `tests/nostr-private-key-signer.test.mjs` to handle mocked `nostr-tools` environment. - Verify changes with `tests/services/s3Service.test.mjs`, `tests/ui/uploadModal-integration.test.mjs`, and `tests/video-note-payload.test.mjs`. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
e25d79b2a2
commit
56a65b4555
5 files changed
+108
-21
No files matched your search
+58
-5
@@ -214,7 +214,12 @@ import { queueSignEvent } from "./signRequestQueue.js";
|
||||
import { EventsMap } from "./eventsMap.js";
|
||||
import { PersistenceManager } from "./managers/PersistenceManager.js";
|
||||
import { ConnectionManager } from "./managers/ConnectionManager.js";
|
||||
import { SignerManager, resolveSignerCapabilities } from "./managers/SignerManager.js";
|
||||
import {
|
||||
SignerManager,
|
||||
resolveSignerCapabilities,
|
||||
hydrateExtensionSignerCapabilities,
|
||||
attachNipMethodAliases
|
||||
} from "./managers/SignerManager.js";
|
||||
import { RelayBatchFetcher } from "./relayBatchFetcher.js";
|
||||
|
||||
function normalizeProfileFromEvent(event) {
|
||||
@@ -231,15 +236,56 @@ function normalizeProfileFromEvent(event) {
|
||||
// We keep them as pass-throughs to the registry or utility logic where appropriate.
|
||||
|
||||
function resolveActiveSigner(pubkey) {
|
||||
return resolveActiveSignerFromRegistry(pubkey);
|
||||
const signer = resolveActiveSignerFromRegistry(pubkey);
|
||||
hydrateExtensionSignerCapabilities(signer);
|
||||
attachNipMethodAliases(signer);
|
||||
if (signer && typeof signer === "object") {
|
||||
const capsDescriptor = Object.getOwnPropertyDescriptor(
|
||||
signer,
|
||||
"capabilities",
|
||||
);
|
||||
const isGetter = capsDescriptor && typeof capsDescriptor.get === "function";
|
||||
|
||||
if (!isGetter) {
|
||||
signer.capabilities = resolveSignerCapabilities(signer);
|
||||
}
|
||||
}
|
||||
return signer;
|
||||
}
|
||||
|
||||
function setActiveSigner(signer) {
|
||||
if (signer && typeof signer === "object") {
|
||||
hydrateExtensionSignerCapabilities(signer);
|
||||
attachNipMethodAliases(signer);
|
||||
const capsDescriptor = Object.getOwnPropertyDescriptor(
|
||||
signer,
|
||||
"capabilities",
|
||||
);
|
||||
const isGetter = capsDescriptor && typeof capsDescriptor.get === "function";
|
||||
|
||||
if (!isGetter) {
|
||||
signer.capabilities = resolveSignerCapabilities(signer);
|
||||
}
|
||||
}
|
||||
setActiveSignerInRegistry(signer);
|
||||
}
|
||||
|
||||
function getActiveSigner() {
|
||||
return getActiveSignerFromRegistry();
|
||||
const signer = getActiveSignerFromRegistry();
|
||||
if (signer && typeof signer === "object") {
|
||||
hydrateExtensionSignerCapabilities(signer);
|
||||
attachNipMethodAliases(signer);
|
||||
const capsDescriptor = Object.getOwnPropertyDescriptor(
|
||||
signer,
|
||||
"capabilities",
|
||||
);
|
||||
const isGetter = capsDescriptor && typeof capsDescriptor.get === "function";
|
||||
|
||||
if (!isGetter) {
|
||||
signer.capabilities = resolveSignerCapabilities(signer);
|
||||
}
|
||||
}
|
||||
return signer;
|
||||
}
|
||||
|
||||
function clearActiveSigner() {
|
||||
@@ -2909,8 +2955,15 @@ export class NostrClient {
|
||||
* @returns {Promise<import("nostr-tools").Event>} The signed and published edit event.
|
||||
* @throws {Error} If permission denied, ownership mismatch, or publish failure.
|
||||
*/
|
||||
registerPrivateKeySigner({ privateKey, pubkey }) {
|
||||
const adapter = createNsecAdapter(privateKey, pubkey);
|
||||
/**
|
||||
* Registers a private key signer and sets it as active.
|
||||
*
|
||||
* @param {object} params
|
||||
* @param {string} params.privateKey - Hex-encoded private key.
|
||||
* @param {string} params.pubkey - Hex-encoded public key.
|
||||
*/
|
||||
async registerPrivateKeySigner({ privateKey, pubkey }) {
|
||||
const adapter = await createNsecAdapter({ privateKey, pubkey });
|
||||
this.signerManager.setActiveSigner(adapter);
|
||||
// Also set session actor for worker-based encryption
|
||||
this.sessionActor = { privateKey, pubkey, source: "nsec" };
|
||||
|
||||
@@ -84,7 +84,7 @@ export function resolveSignerCapabilities(signer) {
|
||||
};
|
||||
}
|
||||
|
||||
function hydrateExtensionSignerCapabilities(signer) {
|
||||
export function hydrateExtensionSignerCapabilities(signer) {
|
||||
if (!signer || typeof signer !== "object") {
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ function hydrateExtensionSignerCapabilities(signer) {
|
||||
}
|
||||
}
|
||||
|
||||
function attachNipMethodAliases(signer) {
|
||||
export function attachNipMethodAliases(signer) {
|
||||
if (!signer || typeof signer !== "object") {
|
||||
return;
|
||||
}
|
||||
@@ -432,11 +432,12 @@ export class SignerManager {
|
||||
return { ok: false, error: "extension-missing" };
|
||||
}
|
||||
|
||||
const extension = typeof window !== "undefined" ? window.nostr : null;
|
||||
const message = resolvePermissionStatusMessage(missing, context);
|
||||
|
||||
try {
|
||||
const response = await requestEnablePermissions(missing);
|
||||
if (response?.enabled) {
|
||||
const response = await requestEnablePermissions(extension, missing);
|
||||
if (response?.ok) {
|
||||
writeStoredNip07Permissions(missing);
|
||||
this.extensionPermissionsGranted = true;
|
||||
this.extensionPermissionCache.set(cacheKey, true);
|
||||
|
||||
Reference in new issue
Block a user