From ff0ecddbdd8453906533e533cce829f8a707576d Mon Sep 17 00:00:00 2001 From: yougotwill Date: Thu, 6 Feb 2025 09:26:47 +1100 Subject: [PATCH] feat: added method to fetch user public keys --- preload.js | 11 +++++++++++ ts/window.d.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/preload.js b/preload.js index c1d294df8..b22c7c8ec 100644 --- a/preload.js +++ b/preload.js @@ -10,6 +10,8 @@ const url = require('url'); const _ = require('lodash'); const { setupI18n } = require('./ts/util/i18n/i18n'); +const { UserUtils } = require('./ts/session/utils'); +const { BlindingActions } = require('./ts/webworker/workers/browser/libsession_worker_interface'); const { crowdinLocale } = ipc.sendSync('locale-data'); @@ -36,6 +38,15 @@ window.getNodeVersion = () => configAny.node_version; window.getOSRelease = () => `${os.type()} ${os.release()}, Node.js ${config.node_version} ${os.platform()} ${os.arch()}`; window.saveLog = additionalText => ipc.send('save-debug-log', additionalText); +window.getUserKeys = async () => { + const pubkey = UserUtils.getOurPubKeyStrFromCache(); + const userEd25519SecretKey = (await UserUtils.getUserED25519KeyPairBytes())?.privKeyBytes; + const blindedPkHex = await BlindingActions.blindVersionPubkey({ + ed25519SecretKey: userEd25519SecretKey, + }); + + return { id: pubkey, vbid: blindedPkHex }; +}; window.sessionFeatureFlags = { useOnionRequests: true, diff --git a/ts/window.d.ts b/ts/window.d.ts index 7c1278cb8..5ec2eaa96 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -179,5 +179,6 @@ declare global { setAutoUpdateEnabled: (enabled: boolean) => void; setZoomFactor: (newZoom: number) => void; updateZoomFactor: () => void; + getUserKeys: () => Promise<{ id: string; vbid: string }>; } }