Skip to content

Commit a4b5643

Browse files
committed
feedback, prettier, rebuild
1 parent ba7a51d commit a4b5643

8 files changed

+25
-18
lines changed

.prettierignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@
22
noble-hashes.js
33
noble-ed25519.js
44
hpke-core.js
5+
6+
# Built
7+
dist/
8+
build/
9+
out/
10+
*.min.js
11+
*.min.css
12+
*.bundle.js
13+
coverage/
14+
.next/
15+
.cache/
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
<<<<<<< HEAD:export-and-sign/dist/bundle.3eaea85f4001b9cc63c3.js
2-
(self.webpackChunkexport_and_sign=self.webpackChunkexport_and_sign||[]).push([[291],{291:()=>{}}]);
3-
=======
4-
(self.webpackChunkexport_and_sign =
5-
self.webpackChunkexport_and_sign || []).push([[487], { 487: () => {} }]);
6-
>>>>>>> e4b882d (remove clearing of in-memory private keys to allow for multiple signatures. also, prettier):export-and-sign/dist/bundle.0ced51019a21da6755fa.js
1+
(self.webpackChunkexport_and_sign=self.webpackChunkexport_and_sign||[]).push([[291],{291:()=>{}}]);

export-and-sign/dist/bundle.c5cd417284634384a0c1.js renamed to export-and-sign/dist/bundle.9c6601d83fa62623ff06.js

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

export-and-sign/dist/bundle.9c6601d83fa62623ff06.js.map

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

export-and-sign/dist/bundle.c5cd417284634384a0c1.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

export-and-sign/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html class="no-js"><head><link rel="icon" type="image/svg+xml" href="./favicon.svg"/><meta charset="utf-8"/><title>Turnkey Export</title><meta name="viewport" content="width=device-width,initial-scale=1"/><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; base-uri 'self'; object-src 'none'; form-action 'none'"><link href="/styles.e084a69a94c0575bc6ba.css" rel="stylesheet"></head><body><h2>Export Key Material</h2><p><em>This public key will be sent along with a private key ID or wallet ID inside of a new <code>EXPORT_PRIVATE_KEY</code> or <code>EXPORT_WALLET</code> activity</em></p><form><label>Embedded key</label> <input name="embedded-key" id="embedded-key" disabled="disabled"/> <button id="reset">Reset Key</button></form><br/><br/><br/><h2>Inject Key Export Bundle</h2><p><em>The export bundle comes from the parent page and is composed of a public key and an encrypted payload. The payload is encrypted to this document's embedded key (stored in local storage and displayed above). The scheme relies on <a target="_blank" href="https://datatracker.ietf.org/doc/rfc9180/">HPKE (RFC 9180)</a></em>.</p><form><label>Bundle</label> <input name="key-export-bundle" id="key-export-bundle"/> <button id="inject-key">Inject Bundle</button><br/><label>Key Format</label> <select id="key-export-format" name="key-export-format"><option value="HEXADECIMAL">Hexadecimal (Default)</option><option value="SOLANA">Solana</option></select><br/><label>Organization Id</label> <input name="key-organization-id" id="key-organization-id"/></form><br/><br/><h2>Inject Wallet Export Bundle</h2><p><em>The export bundle comes from the parent page and is composed of a public key and an encrypted payload. The payload is encrypted to this document's embedded key (stored in local storage and displayed above). The scheme relies on <a target="_blank" href="https://datatracker.ietf.org/doc/rfc9180/">HPKE (RFC 9180)</a></em>.</p><form><label>Bundle</label> <input name="wallet-export-bundle" id="wallet-export-bundle"/> <button id="inject-wallet">Inject Bundle</button><br/><label>Organization Id</label> <input name="wallet-organization-id" id="wallet-organization-id"/></form><br/><br/><h2>Sign Transaction</h2><p><em>Input a serialized transaction to sign.</em></p><form><label>Transaction</label> <input name="transaction-to-sign" id="transaction-to-sign"/> <button id="sign-transaction">Sign</button></form><br/><br/><h2>Sign Message</h2><p><em>Input a serialized message to sign.</em></p><form><label>Message</label> <input name="message-to-sign" id="message-to-sign"/> <button id="sign-message">Sign</button></form><br/><br/><h2>Message log</h2><p><em>Below we display a log of the messages sent / received. The forms above send messages, and the code communicates results by sending events via the <code>postMessage</code> API.</em></p><div id="message-log"></div><div id="key-div"></div><script defer="defer" src="/bundle.8aa7e9549cc7095da2a1.js"></script><script defer="defer" src="/bundle.c5cd417284634384a0c1.js"></script></body></html>
1+
<!doctype html><html class="no-js"><head><link rel="icon" type="image/svg+xml" href="./favicon.svg"/><meta charset="utf-8"/><title>Turnkey Export</title><meta name="viewport" content="width=device-width,initial-scale=1"/><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; base-uri 'self'; object-src 'none'; form-action 'none'"><link href="/styles.e084a69a94c0575bc6ba.css" rel="stylesheet"></head><body><h2>Export Key Material</h2><p><em>This public key will be sent along with a private key ID or wallet ID inside of a new <code>EXPORT_PRIVATE_KEY</code> or <code>EXPORT_WALLET</code> activity</em></p><form><label>Embedded key</label> <input name="embedded-key" id="embedded-key" disabled="disabled"/> <button id="reset">Reset Key</button></form><br/><br/><br/><h2>Inject Key Export Bundle</h2><p><em>The export bundle comes from the parent page and is composed of a public key and an encrypted payload. The payload is encrypted to this document's embedded key (stored in local storage and displayed above). The scheme relies on <a target="_blank" href="https://datatracker.ietf.org/doc/rfc9180/">HPKE (RFC 9180)</a></em>.</p><form><label>Bundle</label> <input name="key-export-bundle" id="key-export-bundle"/> <button id="inject-key">Inject Bundle</button><br/><label>Key Format</label> <select id="key-export-format" name="key-export-format"><option value="HEXADECIMAL">Hexadecimal (Default)</option><option value="SOLANA">Solana</option></select><br/><label>Organization Id</label> <input name="key-organization-id" id="key-organization-id"/></form><br/><br/><h2>Inject Wallet Export Bundle</h2><p><em>The export bundle comes from the parent page and is composed of a public key and an encrypted payload. The payload is encrypted to this document's embedded key (stored in local storage and displayed above). The scheme relies on <a target="_blank" href="https://datatracker.ietf.org/doc/rfc9180/">HPKE (RFC 9180)</a></em>.</p><form><label>Bundle</label> <input name="wallet-export-bundle" id="wallet-export-bundle"/> <button id="inject-wallet">Inject Bundle</button><br/><label>Organization Id</label> <input name="wallet-organization-id" id="wallet-organization-id"/></form><br/><br/><h2>Sign Transaction</h2><p><em>Input a serialized transaction to sign.</em></p><form><label>Transaction</label> <input name="transaction-to-sign" id="transaction-to-sign"/> <button id="sign-transaction">Sign</button></form><br/><br/><h2>Sign Message</h2><p><em>Input a serialized message to sign.</em></p><form><label>Message</label> <input name="message-to-sign" id="message-to-sign"/> <button id="sign-message">Sign</button></form><br/><br/><h2>Message log</h2><p><em>Below we display a log of the messages sent / received. The forms above send messages, and the code communicates results by sending events via the <code>postMessage</code> API.</em></p><div id="message-log"></div><div id="key-div"></div><script defer="defer" src="/bundle.8aa7e9549cc7095da2a1.js"></script><script defer="defer" src="/bundle.9c6601d83fa62623ff06.js"></script></body></html>

export-and-sign/src/event-handlers.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { Keypair, VersionedTransaction } from "@solana/web3.js";
33
import nacl from "tweetnacl";
44
import { HpkeDecrypt } from "./crypto-utils.js";
55

6-
// persist the encrypted keys in memory
7-
// or maybe local storage?
8-
// key, value store: address --> encrypted bundle
6+
// Persist the encrypted keys in memory via mapping of { address --> encrypted bundle }
97
let encryptedKeys = {};
108

119
const DEFAULT_TTL_SECONDS = 24 * 60 * 60; // 24 hours
@@ -145,7 +143,7 @@ async function onGetPublicEmbeddedKey(requestId) {
145143
* @param {string} bundle
146144
* @param {string} keyFormat
147145
* @param {string} address
148-
* @param {Function} HpkeDecrypt // TODO: don't pass this in by reference
146+
* @param {Function} HpkeDecrypt // TODO: import this directly (instead of passing around)
149147
*/
150148
async function onInjectKeyBundle(
151149
requestId,
@@ -158,6 +156,10 @@ async function onInjectKeyBundle(
158156
// Decrypt the export bundle
159157
const keyBytes = await decryptBundle(bundle, organizationId, HpkeDecrypt);
160158

159+
// Reset embedded key after using for decryption.
160+
// For subsequent decryptions, use `TKHQ.initEmbeddKey()`
161+
TKHQ.onResetEmbeddedKey();
162+
161163
// Parse the decrypted key bytes
162164
let key;
163165
const privateKeyBytes = new Uint8Array(keyBytes);
@@ -172,8 +174,7 @@ async function onInjectKeyBundle(
172174
key = await TKHQ.encodeKey(privateKeyBytes, keyFormat);
173175
}
174176

175-
// Display only the key --> this functionality should be deprecated at some point
176-
// TODO: In debug mode, we also now need to be display multiple keys?
177+
// TODO: In debug mode and only debug mode (aka standalone), support displaying multiple keys
177178
displayKey(key);
178179

179180
// Set in memory
@@ -195,7 +196,7 @@ async function onInjectKeyBundle(
195196

196197
/**
197198
* Function triggered when INJECT_WALLET_EXPORT_BUNDLE event is received.
198-
* Unclear if this needs to be maintained.
199+
* TODO: remove
199200
* @param {string} bundle
200201
* @param {string} organizationId
201202
* @param {string} requestId

0 commit comments

Comments
 (0)