fix(auth): request NIP-07 permissions during login and fix retry order (agent)

- Updated `NostrClient.loginWithExtension` to explicitly request `DEFAULT_NIP07_PERMISSION_METHODS` and `DEFAULT_NIP07_ENCRYPTION_METHODS` after retrieving the public key.
- Ensures that encryption capabilities are available immediately upon login, satisfying unit tests.
- Modified `requestEnablePermissions` in `js/nostr/nip07Permissions.js` to attempt structured permission requests *before* the generic `enable()` fallback, aligning implementation with test expectations and ensuring extensions receive the specific scope request.
- `loginWithExtension` now throws if the permission request fails.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-28 20:12:17 +00:00
1 parent 0ecd10a84e
commit 4e549709a9
2 files changed
+11 -1

No files matched your search

+9
View File
@@ -2103,6 +2103,15 @@ export class NostrClient {
}
}
const permissionResult = await this.ensureExtensionPermissions([
...DEFAULT_NIP07_PERMISSION_METHODS,
...DEFAULT_NIP07_ENCRYPTION_METHODS,
]);
if (!permissionResult.ok) {
throw permissionResult.error;
}
const adapter = await createNip07Adapter(extension);
adapter.pubkey = pubkey;
setActiveSigner(adapter);
+2 -1
View File
@@ -327,13 +327,14 @@ export async function requestEnablePermissions(
.filter(Boolean)
: [];
const permissionVariants = [null];
const permissionVariants = [];
if (normalized.length) {
permissionVariants.push({
permissions: normalized.map((method) => ({ method })),
});
permissionVariants.push({ permissions: normalized });
}
permissionVariants.push(null);
const enableTimeoutMs = getEnableVariantTimeoutMs();
const loginTimeoutMs = getNip07LoginTimeoutMs();