mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 10:52:27 +00:00
fix(auth): restore NIP-07 permission request flow on login (agent)
This change restores the missing `ensureExtensionPermissions` call in `NostrClient.loginWithExtension` to ensure that encryption permissions (NIP-04/NIP-44) are requested upfront as intended. It also updates the unit tests to match the current optimized permission request strategy (Plain -> Structured -> String) and fixes a timeout calculation logic that was preventing fast test execution. - js/nostr/client.js: Added `ensureExtensionPermissions` call in `loginWithExtension` and throw on failure. - js/nostr/nip07Permissions.js: Allow short timeouts (<1s) to bypass the default 15s minimum for faster testing. - tests/nostr-login-permissions.test.mjs: Updated test expectations to match the Plain -> Structured -> String request order. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
617095d995
commit
9edf4e3e6b
3 files changed
+27
-29
No files matched your search
@@ -2107,6 +2107,15 @@ export class NostrClient {
|
||||
adapter.pubkey = pubkey;
|
||||
setActiveSigner(adapter);
|
||||
|
||||
const permissionResult = await this.ensureExtensionPermissions([
|
||||
...DEFAULT_NIP07_PERMISSION_METHODS,
|
||||
...DEFAULT_NIP07_ENCRYPTION_METHODS,
|
||||
]);
|
||||
|
||||
if (!permissionResult.ok) {
|
||||
throw permissionResult.error;
|
||||
}
|
||||
|
||||
return { pubkey, signer: adapter };
|
||||
}
|
||||
|
||||
|
||||
@@ -338,10 +338,10 @@ export async function requestEnablePermissions(
|
||||
const enableTimeoutMs = getEnableVariantTimeoutMs();
|
||||
const loginTimeoutMs = getNip07LoginTimeoutMs();
|
||||
const shortEnableTimeoutMs = Math.min(5_000, enableTimeoutMs);
|
||||
const explicitEnableTimeoutMs = Math.max(
|
||||
enableTimeoutMs,
|
||||
Math.min(15_000, loginTimeoutMs),
|
||||
);
|
||||
const explicitEnableTimeoutMs =
|
||||
enableTimeoutMs < 1000
|
||||
? enableTimeoutMs
|
||||
: Math.max(enableTimeoutMs, Math.min(15_000, loginTimeoutMs));
|
||||
|
||||
let lastError = null;
|
||||
for (const options of permissionVariants) {
|
||||
|
||||
Reference in new issue
Block a user