chrome-tools 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execSync as e}from"node:child_process";import{pbkdf2Sync as
|
|
1
|
+
import{execSync as e}from"node:child_process";import{pbkdf2Sync as n}from"node:crypto";const t=Buffer.from("saltysalt"),o="Chrome Safe Storage",r=44,i=36,s=45;let a=null,c=null;function l(e,n){const t="See docs/remote-keychain-access.md for non-interactive / SSH setup.";let a;a=e===r||/could not be found/i.test(n)?`No '${o}' item found in the Keychain.\nRun Google Chrome at least once on this machine so it creates the key.`:e===i||/interaction.*not allowed/i.test(n)?"The Keychain needs a GUI authorization prompt that can't be shown here "+(Boolean(process.env.SSH_CONNECTION||process.env.SSH_TTY)||!process.env.TERM_PROGRAM?"(you appear to be on a remote/SSH session).\n":".\n")+'Authorize once from a GUI Terminal (click "Always Allow"), then unlock the\nkeychain in this session:\n security unlock-keychain ~/Library/Keychains/login.keychain-db\n'+t:e===s?`Keychain authorization failed (wrong password or denied).\nTry: security unlock-keychain ~/Library/Keychains/login.keychain-db\n${t}`:`macOS likely showed a Keychain access prompt that was denied or dismissed.\nRun \`security find-generic-password -w -s "${o}"\` in a GUI\nTerminal and click "Always Allow".\n${t}`;const c=[null!==e?`exit ${e}`:null,n||null].filter(Boolean).join(": ");return new Error(`Could not retrieve ${o} key from macOS Keychain.\n${a}`+(c?`\n(security: ${c})`:""))}export function getChromeKeychainPassword(){if(null!==a)return a;let n;try{n=e(`security find-generic-password -w -s "${o}"`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()}catch(e){const{status:n,stderr:t}=function(e){const n=e;return{status:"number"==typeof n?.status?n.status:null,stderr:(n?.stderr??"").toString().trim()}}(e);throw l(n,t)}if(!n)throw new Error(`Keychain returned an empty ${o} key.\nThe item may exist with no password. Re-run Google Chrome to recreate it.`);return a=n,n}export function deriveEncryptionKey(e){if(null!==c)return c;const o=e||getChromeKeychainPassword();if(!o)throw new Error("Keychain password cannot be empty for key derivation.");return c=n(o,t,1003,16,"sha1"),c}export function clearKeychainCache(){a=null,c=null}
|