Skip to content

Commit d92e183

Browse files
committed
differentiate first unlock vs re-lock messaging on locked sheet
First unlock (cold start, no keys decrypted yet): "NostrKey Needs to Decrypt Your Keys" "Enter your master password to decrypt your key vault for this session." Re-lock (auto-locked after timeout): "NostrKey is Locked" "This site needs your key to sign or encrypt."
1 parent 55acadd commit d92e183

6 files changed

Lines changed: 24 additions & 17 deletions

File tree

distros/safari/background.build.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distros/safari/background.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,10 +1276,11 @@ async function ask(uuid, { kind, host, payload }) {
12761276
if (isLocked) {
12771277
if (!(nostrAccessWhileLocked && sessionKeys.has(pi))) {
12781278
// No keys available — show locked notification and reject
1279+
const isFirstUnlock = sessionKeys.size === 0;
12791280
try {
12801281
const [activeTab] = await api.tabs.query({ active: true, currentWindow: true });
12811282
if (activeTab?.id) {
1282-
api.tabs.sendMessage(activeTab.id, { kind: 'showLockedSheet' }).catch(() => {});
1283+
api.tabs.sendMessage(activeTab.id, { kind: 'showLockedSheet', firstUnlock: isFirstUnlock }).catch(() => {});
12831284
}
12841285
} catch (_) {}
12851286
const sendResponse = validations[uuid];

distros/safari/content.build.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distros/safari/content.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function showPermissionSheet(host, kind, queuePosition, queueTotal) {
223223
let lockedSheetEl = null;
224224
let lockedSheetTimer = null;
225225

226-
function showLockedSheet() {
226+
function showLockedSheet(firstUnlock) {
227227
// If already visible, reset the auto-dismiss timer
228228
if (lockedSheetEl && lockedSheetEl.classList.contains('active')) {
229229
if (lockedSheetTimer) clearTimeout(lockedSheetTimer);
@@ -322,8 +322,10 @@ function showLockedSheet() {
322322
<div class="nk-sheet">
323323
<div class="nk-handle"></div>
324324
<div class="nk-icon">&#x1F512;</div>
325-
<div class="nk-title">NostrKey is Locked</div>
326-
<div class="nk-text">This site needs your key to sign or encrypt.</div>
325+
<div class="nk-title">${firstUnlock ? 'NostrKey Needs to Decrypt Your Keys' : 'NostrKey is Locked'}</div>
326+
<div class="nk-text">${firstUnlock
327+
? 'This site is requesting your Nostr identity. Enter your master password to decrypt your key vault for this session.'
328+
: 'This site needs your key to sign or encrypt.'}</div>
327329
<div class="nk-muted">Click the NostrKey icon in your toolbar and enter your master password.</div>
328330
<button class="nk-btn">Got it</button>
329331
</div>
@@ -357,7 +359,7 @@ api.runtime.onMessage.addListener((message, sender, sendResponse) => {
357359
return true; // Keep channel open for async response
358360
}
359361
if (message.kind === 'showLockedSheet') {
360-
showLockedSheet();
362+
showLockedSheet(message.firstUnlock || false);
361363
sendResponse(true);
362364
return true;
363365
}

src/background.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,10 +1276,11 @@ async function ask(uuid, { kind, host, payload }) {
12761276
if (isLocked) {
12771277
if (!(nostrAccessWhileLocked && sessionKeys.has(pi))) {
12781278
// No keys available — show locked notification and reject
1279+
const isFirstUnlock = sessionKeys.size === 0;
12791280
try {
12801281
const [activeTab] = await api.tabs.query({ active: true, currentWindow: true });
12811282
if (activeTab?.id) {
1282-
api.tabs.sendMessage(activeTab.id, { kind: 'showLockedSheet' }).catch(() => {});
1283+
api.tabs.sendMessage(activeTab.id, { kind: 'showLockedSheet', firstUnlock: isFirstUnlock }).catch(() => {});
12831284
}
12841285
} catch (_) {}
12851286
const sendResponse = validations[uuid];

src/content.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function showPermissionSheet(host, kind, queuePosition, queueTotal) {
223223
let lockedSheetEl = null;
224224
let lockedSheetTimer = null;
225225

226-
function showLockedSheet() {
226+
function showLockedSheet(firstUnlock) {
227227
// If already visible, reset the auto-dismiss timer
228228
if (lockedSheetEl && lockedSheetEl.classList.contains('active')) {
229229
if (lockedSheetTimer) clearTimeout(lockedSheetTimer);
@@ -322,8 +322,10 @@ function showLockedSheet() {
322322
<div class="nk-sheet">
323323
<div class="nk-handle"></div>
324324
<div class="nk-icon">&#x1F512;</div>
325-
<div class="nk-title">NostrKey is Locked</div>
326-
<div class="nk-text">This site needs your key to sign or encrypt.</div>
325+
<div class="nk-title">${firstUnlock ? 'NostrKey Needs to Decrypt Your Keys' : 'NostrKey is Locked'}</div>
326+
<div class="nk-text">${firstUnlock
327+
? 'This site is requesting your Nostr identity. Enter your master password to decrypt your key vault for this session.'
328+
: 'This site needs your key to sign or encrypt.'}</div>
327329
<div class="nk-muted">Click the NostrKey icon in your toolbar and enter your master password.</div>
328330
<button class="nk-btn">Got it</button>
329331
</div>
@@ -357,7 +359,7 @@ api.runtime.onMessage.addListener((message, sender, sendResponse) => {
357359
return true; // Keep channel open for async response
358360
}
359361
if (message.kind === 'showLockedSheet') {
360-
showLockedSheet();
362+
showLockedSheet(message.firstUnlock || false);
361363
sendResponse(true);
362364
return true;
363365
}

0 commit comments

Comments
 (0)