From 8b19ff87af8b878ebd77043b6013389db66680be Mon Sep 17 00:00:00 2001 From: Ethan Konkolowicz Date: Mon, 6 Apr 2026 16:17:39 -0400 Subject: [PATCH] added dev signer enclave pub key --- export-and-sign/dist/bundle.9876c027ef7327c209f1.js.map | 2 +- export/index.template.html | 1 + import/dist/551.bundle.27da59437a4e403e3c24.js | 3 --- import/dist/551.bundle.27da59437a4e403e3c24.js.map | 1 - import/dist/551.bundle.49402ee939a00be74d76.js | 3 +++ ...ENSE.txt => 551.bundle.49402ee939a00be74d76.js.LICENSE.txt} | 0 import/dist/551.bundle.49402ee939a00be74d76.js.map | 1 + import/dist/index.html | 2 +- import/dist/standalone.html | 2 +- shared/turnkey-core.js | 1 + 10 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 import/dist/551.bundle.27da59437a4e403e3c24.js delete mode 100644 import/dist/551.bundle.27da59437a4e403e3c24.js.map create mode 100644 import/dist/551.bundle.49402ee939a00be74d76.js rename import/dist/{551.bundle.27da59437a4e403e3c24.js.LICENSE.txt => 551.bundle.49402ee939a00be74d76.js.LICENSE.txt} (100%) create mode 100644 import/dist/551.bundle.49402ee939a00be74d76.js.map diff --git a/export-and-sign/dist/bundle.9876c027ef7327c209f1.js.map b/export-and-sign/dist/bundle.9876c027ef7327c209f1.js.map index f6f380e..710d9ac 100644 --- a/export-and-sign/dist/bundle.9876c027ef7327c209f1.js.map +++ b/export-and-sign/dist/bundle.9876c027ef7327c209f1.js.map @@ -1 +1 @@ -{"version":3,"file":"bundle.9876c027ef7327c209f1.js","mappings":";UAAIA,ECCAC,EADAC,ECAAC,EACAC,E,svCCAJ,IAAAC,EAAAC,EAAAC,EAAA,mBAAAC,OAAAA,OAAA,GAAAC,EAAAF,EAAAG,UAAA,aAAAC,EAAAJ,EAAAK,aAAA,yBAAAC,EAAAN,EAAAE,EAAAE,EAAAE,GAAA,IAAAC,EAAAL,GAAAA,EAAAM,qBAAAC,EAAAP,EAAAO,EAAAC,EAAAC,OAAAC,OAAA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GIoN,EAAUyB,GAHTnB,EAAUgE,EAAaC,GAAW3R,EAGhB3S,EAAI,EAC3B,GAAGqgB,EAASkE,KAAMtE,GAAgC,IAAxB2D,EAAgB3D,IAAa,CACtD,IAAIF,KAAYsE,EACZvE,EAAoBhgB,EAAEukB,EAAatE,KACrCD,EAAoBhe,EAAEie,GAAYsE,EAAYtE,IAGhD,GAAGuE,EAAS,IAAI7a,EAAS6a,EAAQxE,EAClC,CAEA,IADGsE,GAA4BA,EAA2BzR,GACrD3S,EAAIqgB,EAASrf,OAAQhB,IACzBwhB,EAAUnB,EAASrgB,GAChB8f,EAAoBhgB,EAAE8jB,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAO1B,EAAoBM,EAAE3W,IAG1B+a,EAAqBC,KAAkC,4BAAIA,KAAkC,6BAAK,GACtGD,EAAmBzX,QAAQoX,EAAqBpjB,KAAK,KAAM,IAC3DyjB,EAAmB3a,KAAOsa,EAAqBpjB,KAAK,KAAMyjB,EAAmB3a,KAAK9I,KAAKyjB,G,KClFvF,IAAIE,EAAsB5E,EAAoBM,OAAE/b,EAAW,CAAC,IAAK,IAAOyb,EAAoB,MAC5F4E,EAAsB5E,EAAoBM,EAAEsE,E","sources":["webpack://export-and-sign/webpack/runtime/chunk loaded","webpack://export-and-sign/webpack/runtime/create fake namespace object","webpack://export-and-sign/webpack/runtime/load script","webpack://export-and-sign/../shared/turnkey-core.js","webpack://export-and-sign/./src/turnkey-core.js","webpack://export-and-sign/./src/event-handlers.js","webpack://export-and-sign/../shared/crypto-utils.js","webpack://export-and-sign/./src/index.js","webpack://export-and-sign/external var \"crypto\"","webpack://export-and-sign/webpack/bootstrap","webpack://export-and-sign/webpack/runtime/compat get default export","webpack://export-and-sign/webpack/runtime/define property getters","webpack://export-and-sign/webpack/runtime/ensure chunk","webpack://export-and-sign/webpack/runtime/get javascript chunk filename","webpack://export-and-sign/webpack/runtime/get mini-css chunk filename","webpack://export-and-sign/webpack/runtime/global","webpack://export-and-sign/webpack/runtime/hasOwnProperty shorthand","webpack://export-and-sign/webpack/runtime/make namespace object","webpack://export-and-sign/webpack/runtime/node module decorator","webpack://export-and-sign/webpack/runtime/publicPath","webpack://export-and-sign/webpack/runtime/compat","webpack://export-and-sign/webpack/runtime/jsonp chunk loading","webpack://export-and-sign/webpack/startup"],"sourcesContent":["var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);\nvar leafPrototypes;\n// create a fake namespace object\n// mode & 1: value is a module id, require it\n// mode & 2: merge all properties of value into the ns\n// mode & 4: return value when already ns object\n// mode & 16: return value when it's Promise-like\n// mode & 8|1: behave like require\n__webpack_require__.t = function(value, mode) {\n\tif(mode & 1) value = this(value);\n\tif(mode & 8) return value;\n\tif(typeof value === 'object' && value) {\n\t\tif((mode & 4) && value.__esModule) return value;\n\t\tif((mode & 16) && typeof value.then === 'function') return value;\n\t}\n\tvar ns = Object.create(null);\n\t__webpack_require__.r(ns);\n\tvar def = {};\n\tleafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];\n\tfor(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {\n\t\tObject.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));\n\t}\n\tdef['default'] = () => (value);\n\t__webpack_require__.d(ns, def);\n\treturn ns;\n};","var inProgress = {};\nvar dataWebpackPrefix = \"export-and-sign:\";\n// loadScript function to load a script via script tag\n__webpack_require__.l = (url, done, key, chunkId) => {\n\tif(inProgress[url]) { inProgress[url].push(done); return; }\n\tvar script, needAttach;\n\tif(key !== undefined) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tfor(var i = 0; i < scripts.length; i++) {\n\t\t\tvar s = scripts[i];\n\t\t\tif(s.getAttribute(\"src\") == url || s.getAttribute(\"data-webpack\") == dataWebpackPrefix + key) { script = s; break; }\n\t\t}\n\t}\n\tif(!script) {\n\t\tneedAttach = true;\n\t\tscript = document.createElement('script');\n\n\t\tscript.charset = 'utf-8';\n\t\tif (__webpack_require__.nc) {\n\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n\t\t}\n\t\tscript.setAttribute(\"data-webpack\", dataWebpackPrefix + key);\n\n\t\tscript.src = url;\n\t\tif (script.src.indexOf(window.location.origin + '/') !== 0) {\n\t\t\tscript.crossOrigin = \"anonymous\";\n\t\t}\n\t\tscript.integrity = __webpack_require__.sriHashes[chunkId];\n\t\tscript.crossOrigin = \"anonymous\";\n\t}\n\tinProgress[url] = [done];\n\tvar onScriptComplete = (prev, event) => {\n\t\t// avoid mem leaks in IE.\n\t\tscript.onerror = script.onload = null;\n\t\tclearTimeout(timeout);\n\t\tvar doneFns = inProgress[url];\n\t\tdelete inProgress[url];\n\t\tscript.parentNode && script.parentNode.removeChild(script);\n\t\tdoneFns && doneFns.forEach((fn) => (fn(event)));\n\t\tif(prev) return prev(event);\n\t}\n\tvar timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);\n\tscript.onerror = onScriptComplete.bind(null, script.onerror);\n\tscript.onload = onScriptComplete.bind(null, script.onload);\n\tneedAttach && document.head.appendChild(script);\n};","import { bech32 } from \"bech32\";\n\n/**\n * Turnkey Core Module - Shared\n * Contains all the core cryptographic and utility functions shared across frames\n */\n\n/** constants for LocalStorage */\nconst TURNKEY_EMBEDDED_KEY = \"TURNKEY_EMBEDDED_KEY\";\nconst TURNKEY_TARGET_EMBEDDED_KEY = \"TURNKEY_TARGET_EMBEDDED_KEY\";\nconst TURNKEY_SETTINGS = \"TURNKEY_SETTINGS\";\n/** 48 hours in milliseconds */\nconst TURNKEY_EMBEDDED_KEY_TTL_IN_MILLIS = 1000 * 60 * 60 * 48;\nconst TURNKEY_EMBEDDED_KEY_ORIGIN = \"TURNKEY_EMBEDDED_KEY_ORIGIN\";\n\nlet parentFrameMessageChannelPort = null;\nvar cryptoProviderOverride = null;\n\n/*\n * Returns a reference to the WebCrypto subtle interface regardless of the host environment.\n */\nfunction getSubtleCrypto() {\n if (cryptoProviderOverride && cryptoProviderOverride.subtle) {\n return cryptoProviderOverride.subtle;\n }\n if (\n typeof globalThis !== \"undefined\" &&\n globalThis.crypto &&\n globalThis.crypto.subtle\n ) {\n return globalThis.crypto.subtle;\n }\n if (typeof window !== \"undefined\" && window.crypto && window.crypto.subtle) {\n return window.crypto.subtle;\n }\n if (typeof global !== \"undefined\" && global.crypto && global.crypto.subtle) {\n return global.crypto.subtle;\n }\n if (typeof crypto !== \"undefined\" && crypto.subtle) {\n return crypto.subtle;\n }\n\n return null;\n}\n\n/*\n * Allows tests to explicitly set the crypto provider (e.g. crypto.webcrypto) when the runtime\n * environment does not expose one on the global/window objects.\n */\nfunction setCryptoProvider(cryptoProvider) {\n cryptoProviderOverride = cryptoProvider || null;\n}\n\n/* Security functions */\n\nfunction isDoublyIframed() {\n if (window.location.ancestorOrigins !== undefined) {\n // Does not exist in IE and firefox.\n // See https://developer.mozilla.org/en-US/docs/Web/API/Location/ancestorOrigins for how this works\n return window.location.ancestorOrigins.length > 1;\n } else {\n return window.parent !== window.top;\n }\n}\n\n/*\n * Loads the quorum public key as a CryptoKey.\n */\nasync function loadQuorumKey(quorumPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.importKey(\n \"raw\",\n quorumPublic,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n [\"verify\"]\n );\n}\n\n/*\n * Load a key to encrypt to as a CryptoKey and return it as a JSON Web Key.\n */\nasync function loadTargetKey(targetPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const targetKey = await subtle.importKey(\n \"raw\",\n targetPublic,\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n\n return await subtle.exportKey(\"jwk\", targetKey);\n}\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n */\nasync function initEmbeddedKey() {\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n const retrievedKey = await getEmbeddedKey();\n if (retrievedKey === null) {\n const targetKey = await generateTargetKey();\n setEmbeddedKey(targetKey);\n }\n // Nothing to do, key is correctly initialized!\n}\n\n/*\n * Generate a key to encrypt to and export it as a JSON Web Key.\n */\nasync function generateTargetKey() {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const p256key = await subtle.generateKey(\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n [\"deriveBits\"]\n );\n\n return await subtle.exportKey(\"jwk\", p256key.privateKey);\n}\n\n/**\n * Gets the current embedded private key JWK. Returns `null` if not found.\n */\nfunction getEmbeddedKey() {\n const jwtKey = getItemWithExpiry(TURNKEY_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the embedded private key JWK with the default expiration time.\n * @param {JsonWebKey} targetKey\n */\nfunction setEmbeddedKey(targetKey) {\n setItemWithExpiry(\n TURNKEY_EMBEDDED_KEY,\n JSON.stringify(targetKey),\n TURNKEY_EMBEDDED_KEY_TTL_IN_MILLIS\n );\n}\n\n/**\n * Gets the current target embedded private key JWK. Returns `null` if not found.\n */\nfunction getTargetEmbeddedKey() {\n const jwtKey = window.localStorage.getItem(TURNKEY_TARGET_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the target embedded public key JWK.\n * @param {JsonWebKey} targetKey\n */\nfunction setTargetEmbeddedKey(targetKey) {\n window.localStorage.setItem(\n TURNKEY_TARGET_EMBEDDED_KEY,\n JSON.stringify(targetKey)\n );\n}\n\n/**\n * Resets the current embedded private key JWK.\n */\nfunction onResetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY);\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY_ORIGIN);\n}\n\n/**\n * Resets the current target embedded private key JWK.\n */\nfunction resetTargetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_TARGET_EMBEDDED_KEY);\n}\n\nfunction setParentFrameMessageChannelPort(port) {\n parentFrameMessageChannelPort = port;\n}\n\n/**\n * Gets the current settings.\n */\nfunction getSettings() {\n const settings = window.localStorage.getItem(TURNKEY_SETTINGS);\n return settings ? JSON.parse(settings) : null;\n}\n\n/**\n * Sets the settings object.\n * @param {Object} settings\n */\nfunction setSettings(settings) {\n window.localStorage.setItem(TURNKEY_SETTINGS, JSON.stringify(settings));\n}\n\n/**\n * Set an item in localStorage with an expiration time\n * @param {string} key\n * @param {string} value\n * @param {number} ttl expiration time in milliseconds\n */\nfunction setItemWithExpiry(key, value, ttl) {\n const now = new Date();\n const item = {\n value: value,\n expiry: now.getTime() + ttl,\n };\n window.localStorage.setItem(key, JSON.stringify(item));\n}\n\n/**\n * Get an item from localStorage. Returns `null` and\n * removes the item from localStorage if expired or\n * expiry time is missing.\n * @param {string} key\n */\nfunction getItemWithExpiry(key) {\n const itemStr = window.localStorage.getItem(key);\n if (!itemStr) {\n return null;\n }\n const item = JSON.parse(itemStr);\n if (\n !Object.prototype.hasOwnProperty.call(item, \"expiry\") ||\n !Object.prototype.hasOwnProperty.call(item, \"value\")\n ) {\n window.localStorage.removeItem(key);\n return null;\n }\n const now = new Date();\n if (now.getTime() > item.expiry) {\n window.localStorage.removeItem(key);\n return null;\n }\n return item.value;\n}\n\n/**\n * Takes a hex string (e.g. \"e4567ab\" or \"0xe4567ab\") and returns an array buffer (Uint8Array)\n * @param {string} hexString - Hex string with or without \"0x\" prefix\n * @returns {Uint8Array}\n */\nfunction uint8arrayFromHexString(hexString) {\n if (!hexString || typeof hexString !== \"string\") {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n\n // Remove 0x prefix if present\n const hexWithoutPrefix =\n hexString.startsWith(\"0x\") || hexString.startsWith(\"0X\")\n ? hexString.slice(2)\n : hexString;\n\n var hexRegex = /^[0-9A-Fa-f]+$/;\n if (hexWithoutPrefix.length % 2 != 0 || !hexRegex.test(hexWithoutPrefix)) {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n return new Uint8Array(\n hexWithoutPrefix.match(/../g).map((h) => parseInt(h, 16))\n );\n}\n\n/**\n * Takes a Uint8Array and returns a hex string\n * @param {Uint8Array} buffer\n * @return {string}\n */\nfunction uint8arrayToHexString(buffer) {\n return [...buffer].map((x) => x.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Function to normalize padding of byte array with 0's to a target length\n */\nfunction normalizePadding(byteArray, targetLength) {\n const paddingLength = targetLength - byteArray.length;\n\n // Add leading 0's to array\n if (paddingLength > 0) {\n const padding = new Uint8Array(paddingLength).fill(0);\n return new Uint8Array([...padding, ...byteArray]);\n }\n\n // Remove leading 0's from array\n if (paddingLength < 0) {\n const expectedZeroCount = paddingLength * -1;\n let zeroCount = 0;\n for (let i = 0; i < expectedZeroCount && i < byteArray.length; i++) {\n if (byteArray[i] === 0) {\n zeroCount++;\n }\n }\n // Check if the number of zeros found equals the number of zeroes expected\n if (zeroCount !== expectedZeroCount) {\n throw new Error(\n `invalid number of starting zeroes. Expected number of zeroes: ${expectedZeroCount}. Found: ${zeroCount}.`\n );\n }\n return byteArray.slice(expectedZeroCount, expectedZeroCount + targetLength);\n }\n return byteArray;\n}\n\n/**\n * Additional Associated Data (AAD) in the format dictated by the enclave_encrypt crate.\n */\nfunction additionalAssociatedData(senderPubBuf, receiverPubBuf) {\n const s = Array.from(new Uint8Array(senderPubBuf));\n const r = Array.from(new Uint8Array(receiverPubBuf));\n return new Uint8Array([...s, ...r]);\n}\n\n/**\n * Converts an ASN.1 DER-encoded ECDSA signature to the raw format that WebCrypto uses.\n */\nfunction fromDerSignature(derSignature) {\n const derSignatureBuf = uint8arrayFromHexString(derSignature);\n\n // Check and skip the sequence tag (0x30)\n let index = 2;\n\n // Parse 'r' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for r\"\n );\n }\n index++; // Move past the INTEGER tag\n const rLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const r = derSignatureBuf.slice(index, index + rLength);\n index += rLength; // Move to the start of s\n\n // Parse 's' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for s\"\n );\n }\n index++; // Move past the INTEGER tag\n const sLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const s = derSignatureBuf.slice(index, index + sLength);\n\n // Normalize 'r' and 's' to 32 bytes each\n const rPadded = normalizePadding(r, 32);\n const sPadded = normalizePadding(s, 32);\n\n // Concatenate and return the raw signature\n return new Uint8Array([...rPadded, ...sPadded]);\n}\n\n/**\n * Function to verify enclave signature on import bundle received from the server.\n * @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature\n * @param {string} publicSignature signature bytes encoded as a hexadecimal string\n * @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes\n */\nasync function verifyEnclaveSignature(\n enclaveQuorumPublic,\n publicSignature,\n signedData\n) {\n /** Turnkey Signer enclave's public keys */\n const TURNKEY_SIGNERS_ENCLAVES = {\n prod: \"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\",\n preprod:\n \"04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212\",\n };\n\n // Use window.__TURNKEY_SIGNER_ENVIRONMENT__ if available (for testing), otherwise use the webpack replacement\n const environment =\n (typeof window !== \"undefined\" && window.__TURNKEY_SIGNER_ENVIRONMENT__) ||\n \"__TURNKEY_SIGNER_ENVIRONMENT__\";\n const TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY =\n TURNKEY_SIGNERS_ENCLAVES[environment];\n\n if (TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY === undefined) {\n throw new Error(\n `Configuration error: TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY is undefined`\n );\n }\n\n // todo(olivia): throw error if enclave quorum public is null once server changes are deployed\n if (enclaveQuorumPublic) {\n if (enclaveQuorumPublic !== TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY) {\n throw new Error(\n `enclave quorum public keys from client and bundle do not match. Client: ${TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY}. Bundle: ${enclaveQuorumPublic}.`\n );\n }\n }\n\n const encryptionQuorumPublicBuf = new Uint8Array(\n uint8arrayFromHexString(TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY)\n );\n const quorumKey = await loadQuorumKey(encryptionQuorumPublicBuf);\n if (!quorumKey) {\n throw new Error(\"failed to load quorum key\");\n }\n\n // The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format\n const publicSignatureBuf = fromDerSignature(publicSignature);\n const signedDataBuf = uint8arrayFromHexString(signedData);\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.verify(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n quorumKey,\n publicSignatureBuf,\n signedDataBuf\n );\n}\n\n/**\n * Function to send a message.\n *\n * If this page is embedded as an iframe we'll send a postMessage\n * in one of two ways depending on the version of @turnkey/iframe-stamper:\n * 1. newer versions (>=v2.1.0) pass a MessageChannel MessagePort from the parent frame for postMessages.\n * 2. older versions ( 0) {\n digits.push(carry % 58);\n carry = (carry / 58) | 0;\n }\n }\n // Convert digits to a base58 string\n for (let k = 0; k < digits.length; k++) {\n result = alphabet[digits[k]] + result;\n }\n\n // Add '1' for each leading 0 byte\n for (let i = 0; bytes[i] === 0 && i < bytes.length - 1; i++) {\n result = \"1\" + result;\n }\n return result;\n}\n\n/**\n * Decodes a base58-encoded string into a buffer\n * This function throws an error when the string contains invalid characters.\n * @param {string} s The base58-encoded string.\n * @return {Uint8Array} The decoded buffer.\n */\nfunction base58Decode(s) {\n // See https://en.bitcoin.it/wiki/Base58Check_encoding\n var alphabet = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n var decodedBytes = [];\n var leadingZeros = [];\n for (var i = 0; i < s.length; i++) {\n if (alphabet.indexOf(s[i]) === -1) {\n throw new Error(`cannot base58-decode: ${s[i]} isn't a valid character`);\n }\n var carry = alphabet.indexOf(s[i]);\n\n // If the current base58 digit is 0, append a 0 byte.\n // \"i == leadingZeros.length\" can only be true if we have not seen non-zero bytes so far.\n // If we had seen a non-zero byte, carry wouldn't be 0, and i would be strictly more than `leadingZeros.length`\n if (carry == 0 && i === leadingZeros.length) {\n leadingZeros.push(0);\n }\n\n var j = 0;\n while (j < decodedBytes.length || carry > 0) {\n var currentByte = decodedBytes[j];\n\n // shift the current byte 58 units and add the carry amount\n // (or just add the carry amount if this is a new byte -- undefined case)\n if (currentByte === undefined) {\n currentByte = carry;\n } else {\n currentByte = currentByte * 58 + carry;\n }\n\n // find the new carry amount (1-byte shift of current byte value)\n carry = currentByte >> 8;\n // reset the current byte to the remainder (the carry amount will pass on the overflow)\n decodedBytes[j] = currentByte % 256;\n j++;\n }\n }\n\n var result = leadingZeros.concat(decodedBytes.reverse());\n return new Uint8Array(result);\n}\n\n/**\n * Decodes a base58check-encoded string and verifies the checksum.\n * Base58Check encoding includes a 4-byte checksum at the end to detect errors.\n * The checksum is the first 4 bytes of SHA256(SHA256(payload)).\n * This function throws an error if the checksum is invalid.\n * @param {string} s The base58check-encoded string.\n * @return {Promise} The decoded payload (without checksum).\n */\nasync function base58CheckDecode(s) {\n const decoded = base58Decode(s);\n\n if (decoded.length < 5) {\n throw new Error(\n `invalid base58check length: expected at least 5 bytes, got ${decoded.length}`\n );\n }\n\n const payload = decoded.subarray(0, decoded.length - 4);\n const checksum = decoded.subarray(decoded.length - 4);\n\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n\n // Compute double SHA256 hash\n const hash1Buf = await subtle.digest(\"SHA-256\", payload);\n const hash1 = new Uint8Array(hash1Buf);\n const hash2Buf = await subtle.digest(\"SHA-256\", hash1);\n const hash2 = new Uint8Array(hash2Buf);\n const computedChecksum = hash2.subarray(0, 4);\n\n // Verify checksum\n const mismatch =\n (checksum[0] ^ computedChecksum[0]) |\n (checksum[1] ^ computedChecksum[1]) |\n (checksum[2] ^ computedChecksum[2]) |\n (checksum[3] ^ computedChecksum[3]);\n if (mismatch !== 0) {\n throw new Error(\"invalid base58check checksum\");\n }\n\n return payload;\n}\n\n/**\n * Returns private key bytes from a private key, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {string} privateKey\n * @param {string} keyFormat Can be \"HEXADECIMAL\", \"SUI_BECH32\", \"BITCOIN_MAINNET_WIF\", \"BITCOIN_TESTNET_WIF\" or \"SOLANA\"\n * @return {Promise}\n */\nasync function decodeKey(privateKey, keyFormat) {\n switch (keyFormat) {\n case \"SOLANA\": {\n const decodedKeyBytes = base58Decode(privateKey);\n if (decodedKeyBytes.length !== 64) {\n throw new Error(\n `invalid key length. Expected 64 bytes. Got ${decodedKeyBytes.length}.`\n );\n }\n return decodedKeyBytes.subarray(0, 32);\n }\n case \"HEXADECIMAL\":\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n case \"BITCOIN_MAINNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0x80 = mainnet\n if (version !== 0x80) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0x80 (mainnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"BITCOIN_TESTNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0xEF = testnet\n if (version !== 0xef) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0xEF (testnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"SUI_BECH32\": {\n const { prefix, words } = bech32.decode(privateKey);\n\n if (prefix !== \"suiprivkey\") {\n throw new Error(\n `invalid SUI private key human-readable part (HRP): expected \"suiprivkey\"`\n );\n }\n\n const bytes = bech32.fromWords(words);\n if (bytes.length !== 33) {\n throw new Error(\n `invalid SUI private key length: expected 33 bytes, got ${bytes.length}`\n );\n }\n\n const schemeFlag = bytes[0];\n const privkey = bytes.slice(1);\n\n // schemeFlag = 0 is Ed25519; We currently only support Ed25519 keys for SUI.\n if (schemeFlag !== 0) {\n throw new Error(\n `invalid SUI private key scheme flag: expected 0 (Ed25519). Turnkey only supports Ed25519 keys for SUI.`\n );\n }\n\n return new Uint8Array(privkey);\n }\n default:\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n }\n}\n\n/**\n * Returns a private key from private key bytes, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {Uint8Array} privateKeyBytes\n * @param {string} keyFormat Can be \"HEXADECIMAL\" or \"SOLANA\"\n */\nasync function encodeKey(privateKeyBytes, keyFormat, publicKeyBytes) {\n switch (keyFormat) {\n case \"SOLANA\":\n if (!publicKeyBytes) {\n throw new Error(\"public key must be specified for SOLANA key format\");\n }\n if (privateKeyBytes.length !== 32) {\n throw new Error(\n `invalid private key length. Expected 32 bytes. Got ${privateKeyBytes.length}.`\n );\n }\n if (publicKeyBytes.length !== 32) {\n throw new Error(\n `invalid public key length. Expected 32 bytes. Got ${publicKeyBytes.length}.`\n );\n }\n {\n const concatenatedBytes = new Uint8Array(64);\n concatenatedBytes.set(privateKeyBytes, 0);\n concatenatedBytes.set(publicKeyBytes, 32);\n return base58Encode(concatenatedBytes);\n }\n case \"HEXADECIMAL\":\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n default:\n // keeping console.warn for debugging purposes.\n // eslint-disable-next-line no-console\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n }\n}\n\n// Helper to parse a private key into a Solana base58 private key.\n// To be used if a wallet account is exported without the `SOLANA` address format.\nfunction parsePrivateKey(privateKey) {\n if (Array.isArray(privateKey)) {\n return new Uint8Array(privateKey);\n }\n\n if (typeof privateKey === \"string\") {\n // Remove 0x prefix if present\n if (privateKey.startsWith(\"0x\")) {\n privateKey = privateKey.slice(2);\n }\n\n // Check if it's hex-formatted correctly (i.e. 64 hex chars)\n if (privateKey.length === 64 && /^[0-9a-fA-F]+$/.test(privateKey)) {\n return uint8arrayFromHexString(privateKey);\n }\n\n // Otherwise assume it's base58 format (for Solana)\n try {\n return base58Decode(privateKey);\n } catch (error) {\n throw new Error(\n \"Invalid private key format. Use hex (64 chars) or base58 format.\"\n );\n }\n }\n\n throw new Error(\"Private key must be a string (hex/base58) or number array\");\n}\n\n/**\n * Function to validate and sanitize the styles object using the accepted map of style keys and values (as regular expressions).\n * Any invalid style throws an error. Returns an object of valid styles.\n * @param {Object} styles\n * @param {HTMLElement} element - Optional element parameter (for import frame)\n * @return {Object}\n */\nfunction validateStyles(styles, element) {\n const validStyles = {};\n\n const cssValidationRegex = {\n padding: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n margin: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n borderWidth: \"^(\\\\d+(px|em|rem) ?){1,4}$\",\n borderStyle:\n \"^(none|solid|dashed|dotted|double|groove|ridge|inset|outset)$\",\n borderColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n borderRadius: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n fontSize: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax))$\",\n fontWeight: \"^(normal|bold|bolder|lighter|\\\\d{3})$\",\n fontFamily: '^[^\";<>]*$', // checks for the absence of some characters that could lead to CSS/HTML injection\n color:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n labelColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n backgroundColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n width: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n height: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n maxWidth: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n maxHeight:\n \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n lineHeight:\n \"^(\\\\d+(\\\\.\\\\d+)?(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|normal)$\",\n boxShadow:\n \"^(none|(\\\\d+(px|em|rem) ?){2,4} (#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)) ?(inset)?)$\",\n textAlign: \"^(left|right|center|justify|initial|inherit)$\",\n overflowWrap: \"^(normal|break-word|anywhere)$\",\n wordWrap: \"^(normal|break-word)$\",\n resize: \"^(none|both|horizontal|vertical|block|inline)$\",\n };\n\n Object.entries(styles).forEach(([property, value]) => {\n const styleProperty = property.trim();\n if (styleProperty.length === 0) {\n throw new Error(\"css style property cannot be empty\");\n }\n const styleRegexStr = cssValidationRegex[styleProperty];\n if (!styleRegexStr) {\n throw new Error(\n `invalid or unsupported css style property: \"${styleProperty}\"`\n );\n }\n const styleRegex = new RegExp(styleRegexStr);\n const styleValue = value.trim();\n if (styleValue.length == 0) {\n throw new Error(`css style for \"${styleProperty}\" is empty`);\n }\n const isValidStyle = styleRegex.test(styleValue);\n if (!isValidStyle) {\n throw new Error(\n `invalid css style value for property \"${styleProperty}\"`\n );\n }\n validStyles[styleProperty] = styleValue;\n });\n\n return validStyles;\n}\n\n// Export all shared functions\nexport {\n setCryptoProvider,\n getSubtleCrypto,\n isDoublyIframed,\n loadQuorumKey,\n loadTargetKey,\n initEmbeddedKey,\n generateTargetKey,\n getEmbeddedKey,\n setEmbeddedKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n onResetEmbeddedKey,\n resetTargetEmbeddedKey,\n setParentFrameMessageChannelPort,\n getSettings,\n setSettings,\n setItemWithExpiry,\n getItemWithExpiry,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n normalizePadding,\n additionalAssociatedData,\n fromDerSignature,\n verifyEnclaveSignature,\n sendMessageUp,\n logMessage,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n encodeKey,\n parsePrivateKey,\n validateStyles,\n};\n","import * as nobleEd25519 from \"@noble/ed25519\";\nimport * as nobleHashes from \"@noble/hashes/sha512\";\nimport { fromDerSignature } from \"@turnkey/crypto\";\nimport * as SharedTKHQ from \"@shared/turnkey-core.js\";\n\nconst {\n initEmbeddedKey: sharedInitEmbeddedKey,\n generateTargetKey,\n setItemWithExpiry,\n getItemWithExpiry,\n getEmbeddedKey,\n setEmbeddedKey,\n onResetEmbeddedKey,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n encodeKey,\n sendMessageUp,\n logMessage,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n setParentFrameMessageChannelPort,\n normalizePadding,\n additionalAssociatedData,\n getSettings,\n setSettings,\n parsePrivateKey,\n validateStyles,\n isDoublyIframed,\n loadQuorumKey,\n} = SharedTKHQ;\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n */\nasync function initEmbeddedKey() {\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n return await sharedInitEmbeddedKey();\n}\n\n/**\n * Function to verify enclave signature on import bundle received from the server.\n * @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature\n * @param {string} publicSignature signature bytes encoded as a hexadecimal string\n * @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes\n */\nasync function verifyEnclaveSignature(\n enclaveQuorumPublic,\n publicSignature,\n signedData\n) {\n /** Turnkey Signer enclave's public keys */\n const TURNKEY_SIGNERS_ENCLAVES = {\n prod: \"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\",\n preprod:\n \"04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212\",\n };\n\n // Read environment from meta tag (templated at deploy time), fall back to window variable (for testing)\n let environment = null;\n if (typeof document !== \"undefined\") {\n const meta = document.querySelector(\n 'meta[name=\"turnkey-signer-environment\"]'\n );\n if (\n meta &&\n meta.content &&\n meta.content !== \"__TURNKEY_SIGNER_ENVIRONMENT__\"\n ) {\n environment = meta.content;\n }\n }\n if (!environment && typeof window !== \"undefined\") {\n environment = window.__TURNKEY_SIGNER_ENVIRONMENT__;\n }\n const TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY =\n TURNKEY_SIGNERS_ENCLAVES[environment];\n\n if (TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY === undefined) {\n throw new Error(\n `Configuration error: TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY is undefined`\n );\n }\n\n if (enclaveQuorumPublic !== TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY) {\n throw new Error(\n `enclave quorum public keys from client and bundle do not match. Client: ${TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY}. Bundle: ${enclaveQuorumPublic}.`\n );\n }\n\n const encryptionQuorumPublicBuf = new Uint8Array(\n uint8arrayFromHexString(TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY)\n );\n const quorumKey = await loadQuorumKey(encryptionQuorumPublicBuf);\n if (!quorumKey) {\n throw new Error(\"failed to load quorum key\");\n }\n\n // The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format\n const publicSignatureBuf = fromDerSignature(publicSignature);\n const signedDataBuf = uint8arrayFromHexString(signedData);\n return await crypto.subtle.verify(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n quorumKey,\n publicSignatureBuf,\n signedDataBuf\n );\n}\n\n/**\n * Returns the public key bytes for a hex-encoded Ed25519 private key.\n * @param {string} privateKeyHex\n */\nfunction getEd25519PublicKey(privateKeyHex) {\n nobleEd25519.etc.sha512Sync = (...m) =>\n nobleHashes.sha512(nobleEd25519.etc.concatBytes(...m));\n return nobleEd25519.getPublicKey(privateKeyHex);\n}\n\n/**\n * Function to apply settings on this page. For now, the only settings that can be applied\n * are for \"styles\". Upon successful application, return the valid, sanitized settings JSON string.\n * @param {string} settings\n * @return {string}\n */\nfunction applySettings(settings) {\n const validSettings = {};\n if (!settings) {\n return JSON.stringify(validSettings);\n }\n const settingsObj = JSON.parse(settings);\n if (settingsObj.styles) {\n // Valid styles will be applied the \"key-div\" div HTML element.\n const keyDivTextarea = document.getElementById(\"key-div\");\n if (!keyDivTextarea) {\n throw new Error(\"no key-div HTML element found to apply settings to.\");\n }\n\n // Validate, sanitize, and apply the styles to the \"key-div\" div element.\n const validStyles = validateStyles(settingsObj.styles);\n Object.entries(validStyles).forEach(([key, value]) => {\n keyDivTextarea.style[key] = value;\n });\n\n validSettings[\"styles\"] = validStyles;\n }\n\n return JSON.stringify(validSettings);\n}\n\nexport const TKHQ = {\n initEmbeddedKey,\n generateTargetKey,\n setItemWithExpiry,\n getItemWithExpiry,\n getEmbeddedKey,\n setEmbeddedKey,\n onResetEmbeddedKey,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n encodeKey,\n sendMessageUp,\n logMessage,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n setParentFrameMessageChannelPort,\n normalizePadding,\n fromDerSignature,\n additionalAssociatedData,\n verifyEnclaveSignature,\n getEd25519PublicKey,\n applySettings,\n validateStyles,\n getSettings,\n setSettings,\n parsePrivateKey,\n};\n","import { TKHQ } from \"./turnkey-core.js\";\nimport { Keypair, VersionedTransaction } from \"@solana/web3.js\";\nimport * as nobleEd25519 from \"@noble/ed25519\";\nimport * as nobleHashes from \"@noble/hashes/sha512\";\n\n// Persist keys in memory via mapping of { address --> pk }\nlet inMemoryKeys = {};\n\n// Injected embedded key -- held in memory only, never persisted.\n// When set, decryptBundle uses this P-256 JWK instead of the iframe's embedded key.\nlet injectedEmbeddedKey = null;\n\nexport const DEFAULT_TTL_MILLISECONDS = 1000 * 24 * 60 * 60; // 24 hours or 86,400,000 milliseconds\n\n// Instantiate these once (for perf)\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\n/**\n * Verifies the enclave signature on a v1.0.0 bundle and returns the parsed signed data.\n * @param {string} bundle - JSON-stringified bundle\n * @param {string} organizationId - Expected organization ID\n * @returns {Promise} - The parsed signed data {organizationId, encappedPublic, ciphertext}\n */\nasync function verifyAndParseBundleData(bundle, organizationId) {\n const bundleObj = JSON.parse(bundle);\n\n if (bundleObj.version !== \"v1.0.0\") {\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n if (!bundleObj.data) {\n throw new Error('missing \"data\" in bundle');\n }\n if (!bundleObj.dataSignature) {\n throw new Error('missing \"dataSignature\" in bundle');\n }\n if (!bundleObj.enclaveQuorumPublic) {\n throw new Error('missing \"enclaveQuorumPublic\" in bundle');\n }\n\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method TKHQ.verifyEnclaveSignature not loaded\");\n }\n const verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(\n `failed to verify enclave signature. Got signature: ${bundleObj.dataSignature}, enclaveQuorumPublic: ${bundleObj.enclaveQuorumPublic}`\n );\n }\n\n const signedData = JSON.parse(\n textDecoder.decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n if (!organizationId) {\n throw new Error(\n `organization id is required. Please ensure you are using @turnkey/iframe-stamper >= v2.0.0 to pass \"organizationId\" for security purposes.`\n );\n } else if (\n !signedData.organizationId ||\n signedData.organizationId !== organizationId\n ) {\n throw new Error(\n `organization id does not match expected value. Expected: ${organizationId}. Found: ${signedData.organizationId}.`\n );\n }\n\n if (!signedData.encappedPublic) {\n throw new Error('missing \"encappedPublic\" in bundle signed data');\n }\n if (!signedData.ciphertext) {\n throw new Error('missing \"ciphertext\" in bundle signed data');\n }\n\n return signedData;\n}\n\n/**\n * Parse and decrypt the export bundle.\n * The `bundle` param is a JSON string of the encapsulated public\n * key, encapsulated public key signature, and the ciphertext.\n * @param {string} bundle\n * @param {string} organizationId\n * @param {Function} HpkeDecrypt\n */\nasync function decryptBundle(bundle, organizationId, HpkeDecrypt) {\n const signedData = await verifyAndParseBundleData(bundle, organizationId);\n\n const encappedKeyBuf = TKHQ.uint8arrayFromHexString(\n signedData.encappedPublic\n );\n const ciphertextBuf = TKHQ.uint8arrayFromHexString(signedData.ciphertext);\n\n // Use the injected embedded key if available, otherwise fall back to the embedded key\n const receiverPrivJwk = injectedEmbeddedKey || (await TKHQ.getEmbeddedKey());\n return await HpkeDecrypt({\n ciphertextBuf,\n encappedKeyBuf,\n receiverPrivJwk,\n });\n}\n\n/**\n * Function triggered when GET_EMBEDDED_PUBLIC_KEY event is received.\n * @param {string} requestId\n */\nasync function onGetPublicEmbeddedKey(requestId) {\n const embeddedKeyJwk = TKHQ.getEmbeddedKey();\n\n if (!embeddedKeyJwk) {\n TKHQ.sendMessageUp(\"EMBEDDED_PUBLIC_KEY\", \"\", requestId); // no key == empty string\n\n return;\n }\n\n const targetPubBuf = await TKHQ.p256JWKPrivateToPublic(embeddedKeyJwk);\n const targetPubHex = TKHQ.uint8arrayToHexString(targetPubBuf);\n\n // Send up EMBEDDED_PUBLIC_KEY message\n TKHQ.sendMessageUp(\"EMBEDDED_PUBLIC_KEY\", targetPubHex, requestId);\n}\n\n/**\n * Encodes raw key bytes and loads them into the in-memory key store.\n * @param {string} address - Wallet address (case-sensitive)\n * @param {ArrayBuffer} keyBytes - Raw decrypted private key bytes\n * @param {string} keyFormat - \"SOLANA\" | \"HEXADECIMAL\"\n * @param {string} organizationId - Organization ID\n */\nasync function loadKeyIntoMemory(address, keyBytes, keyFormat, organizationId) {\n let key;\n const privateKeyBytes = new Uint8Array(keyBytes);\n\n if (keyFormat === \"SOLANA\") {\n const privateKeyHex = TKHQ.uint8arrayToHexString(\n privateKeyBytes.subarray(0, 32)\n );\n const publicKeyBytes = TKHQ.getEd25519PublicKey(privateKeyHex);\n key = await TKHQ.encodeKey(privateKeyBytes, keyFormat, publicKeyBytes);\n } else {\n key = await TKHQ.encodeKey(privateKeyBytes, keyFormat);\n }\n\n const keyAddress = address || \"default\";\n\n // Cache keypair for improved signing perf\n let cachedKeypair;\n if (keyFormat === \"SOLANA\") {\n cachedKeypair = Keypair.fromSecretKey(TKHQ.base58Decode(key));\n } else if (keyFormat === \"HEXADECIMAL\") {\n cachedKeypair = await createSolanaKeypair(\n Array.from(TKHQ.uint8arrayFromHexString(key))\n );\n }\n\n inMemoryKeys = {\n ...inMemoryKeys,\n [keyAddress]: {\n organizationId,\n privateKey: key,\n format: keyFormat,\n expiry: new Date().getTime() + DEFAULT_TTL_MILLISECONDS,\n keypair: cachedKeypair,\n },\n };\n}\n\n/**\n * Function triggered when INJECT_KEY_EXPORT_BUNDLE event is received.\n * @param {string} requestId\n * @param {string} organizationId\n * @param {string} bundle\n * @param {string} keyFormat\n * @param {string} address\n * @param {Function} HpkeDecrypt // TODO: import this directly (instead of passing around)\n */\nasync function onInjectKeyBundle(\n requestId,\n organizationId,\n bundle,\n keyFormat,\n address,\n HpkeDecrypt\n) {\n // Decrypt the export bundle\n const keyBytes = await decryptBundle(bundle, organizationId, HpkeDecrypt);\n\n // Load decrypted key into memory\n await loadKeyIntoMemory(address, keyBytes, keyFormat, organizationId);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when APPLY_SETTINGS event is received.\n * For now, the only settings that can be applied are for \"styles\".\n * Persist them in local storage so they can be applied on every\n * page load.\n * @param {string} settings: JSON-stringified settings\n * @param {string} requestId\n */\nasync function onApplySettings(settings, requestId) {\n // Apply settings\n const validSettings = TKHQ.applySettings(settings);\n\n // Persist in local storage\n TKHQ.setSettings(validSettings);\n\n // Send up SETTINGS_APPLIED message\n TKHQ.sendMessageUp(\"SETTINGS_APPLIED\", true, requestId);\n}\n\n/**\n * Function triggered when SIGN_TRANSACTION event is received.\n * @param {string} requestId\n * @param {string} transaction (serialized)\n * @param {string} address (case-sensitive --> enforce this, optional for backwards compatibility)\n */\nasync function onSignTransaction(requestId, serializedTransaction, address) {\n // If no address provided, use \"default\"\n const keyAddress = address || \"default\";\n const key = inMemoryKeys[keyAddress];\n\n // Validate key exists and is valid/non-expired\n if (!validateKey(key, keyAddress, requestId)) {\n return;\n }\n\n // Get or create keypair (uses cached keypair if available)\n const keypair = await getOrCreateKeypair(key);\n\n const transactionWrapper = JSON.parse(serializedTransaction);\n const transactionToSign = transactionWrapper.transaction;\n const transactionType = transactionWrapper.type;\n\n let signedTransaction;\n\n if (transactionType === \"SOLANA\") {\n // Fetch the transaction and sign\n const transactionBytes = TKHQ.uint8arrayFromHexString(transactionToSign);\n const transaction = VersionedTransaction.deserialize(transactionBytes);\n transaction.sign([keypair]);\n\n signedTransaction = transaction.serialize();\n } else {\n throw new Error(\"unsupported transaction type\");\n }\n\n const signedTransactionHex = TKHQ.uint8arrayToHexString(signedTransaction);\n\n TKHQ.sendMessageUp(\"TRANSACTION_SIGNED\", signedTransactionHex, requestId);\n}\n\n/**\n * Function triggered when SIGN_MESSAGE event is received.\n * @param {string} requestId\n * @param {string} message (serialized, JSON-stringified)\n * @param {string} address (case-sensitive --> enforce this, optional for backwards compatibility)\n */\nasync function onSignMessage(requestId, serializedMessage, address) {\n // Backwards compatibility: if no address provided, use \"default\"\n const keyAddress = address || \"default\";\n const key = inMemoryKeys[keyAddress];\n\n // Validate key exists and has not expired\n if (!validateKey(key, keyAddress, requestId)) {\n return;\n }\n\n const messageWrapper = JSON.parse(serializedMessage);\n const messageToSign = messageWrapper.message;\n const messageType = messageWrapper.type;\n const messageBytes = textEncoder.encode(messageToSign);\n\n let signatureHex;\n\n // Get or create keypair (uses cached keypair if available)\n const keypair = await getOrCreateKeypair(key);\n\n if (messageType === \"SOLANA\") {\n // Set up sha512 for nobleEd25519 (required for signing)\n nobleEd25519.etc.sha512Sync = (...m) =>\n nobleHashes.sha512(nobleEd25519.etc.concatBytes(...m));\n\n // Extract the 32-byte private key from the 64-byte secretKey\n // Solana keypair.secretKey format: [32-byte private key][32-byte public key]\n const privateKey = keypair.secretKey.slice(0, 32);\n // Sign the message using nobleEd25519\n const signature = nobleEd25519.sign(messageBytes, privateKey);\n\n // Note: Signature verification is skipped for performance. The signature will always be valid if signing succeeds with a valid keypair.\n // Clients can verify the signature returned.\n\n signatureHex = TKHQ.uint8arrayToHexString(signature);\n } else {\n TKHQ.sendMessageUp(\"ERROR\", \"unsupported message type\", requestId);\n\n return;\n }\n\n TKHQ.sendMessageUp(\"MESSAGE_SIGNED\", signatureHex, requestId);\n}\n\n/**\n * Function triggered when CLEAR_EMBEDDED_PRIVATE_KEY event is received.\n * @param {string} requestId\n * @param {string} address - Optional: The address of the key to clear (case-sensitive). If not provided, clears all keys.\n */\nasync function onClearEmbeddedPrivateKey(requestId, address) {\n // If no address is provided, clear all keys\n if (!address) {\n inMemoryKeys = {};\n TKHQ.sendMessageUp(\"EMBEDDED_PRIVATE_KEY_CLEARED\", true, requestId);\n\n return;\n }\n\n // Check if key exists for the specific address\n if (!inMemoryKeys[address]) {\n TKHQ.sendMessageUp(\n \"ERROR\",\n new Error(\n `key not found for address ${address}. Note that address is case sensitive.`\n ).toString(),\n requestId\n );\n\n return;\n }\n\n // Clear the specific key from memory\n delete inMemoryKeys[address];\n\n TKHQ.sendMessageUp(\"EMBEDDED_PRIVATE_KEY_CLEARED\", true, requestId);\n}\n\n/**\n * Handler for SET_EMBEDDED_KEY_OVERRIDE events.\n * Decrypts a P-256 private key bundle using the iframe's embedded key and\n * overrides the embedded key with it for subsequent bundle decryptions.\n * @param {string} requestId\n * @param {string} organizationId\n * @param {string} bundle - v1.0.0 bundle containing the P-256 private key\n * @param {Function} HpkeDecrypt\n */\nasync function onSetEmbeddedKeyOverride(\n requestId,\n organizationId,\n bundle,\n HpkeDecrypt\n) {\n // Decrypt the private key using the iframe's embedded key.\n // The decrypted payload is a raw 32-byte P-256 private key scalar.\n const keyBytes = await decryptBundle(bundle, organizationId, HpkeDecrypt);\n\n // Convert raw P-256 bytes to a full JWK (derives public key via WebCrypto)\n const keyJwk = await rawP256PrivateKeyToJwk(new Uint8Array(keyBytes));\n\n // Store in module-level variable (memory only)\n injectedEmbeddedKey = keyJwk;\n\n TKHQ.sendMessageUp(\"EMBEDDED_KEY_OVERRIDE_SET\", true, requestId);\n}\n\n/**\n * Handler for RESET_TO_DEFAULT_EMBEDDED_KEY events.\n * Clears the embedded key from memory, replacing it with the iframe's default embedded key.\n * @param {string} requestId\n */\nfunction onResetToDefaultEmbeddedKey(requestId) {\n injectedEmbeddedKey = null;\n TKHQ.sendMessageUp(\"RESET_TO_DEFAULT_EMBEDDED_KEY\", true, requestId);\n}\n\n// Utility functions\nasync function createSolanaKeypair(privateKey) {\n const privateKeyBytes = TKHQ.parsePrivateKey(privateKey);\n\n let keypair;\n if (privateKeyBytes.length === 32) {\n // 32-byte private key (seed)\n keypair = Keypair.fromSeed(privateKeyBytes);\n } else if (privateKeyBytes.length === 64) {\n // 64-byte secret key (private + public)\n keypair = Keypair.fromSecretKey(privateKeyBytes);\n } else {\n throw new Error(\n `Invalid private key length: ${privateKeyBytes.length}. Expected 32 or 64 bytes.`\n );\n }\n\n return keypair;\n}\n\n/**\n * Converts raw P-256 private key bytes (32-byte scalar) to a JWK.\n * Constructs a PKCS8 wrapper around the raw bytes, imports via WebCrypto\n * (which derives the public key), then exports as JWK.\n * @param {Uint8Array} rawPrivateKeyBytes - 32-byte P-256 private key scalar\n * @returns {Promise} - Full P-256 ECDH private key JWK\n */\nasync function rawP256PrivateKeyToJwk(rawPrivateKeyBytes) {\n if (rawPrivateKeyBytes.length !== 32) {\n throw new Error(\n `invalid decryption key length: expected 32 bytes, got ${rawPrivateKeyBytes.length}`\n );\n }\n\n // Fixed PKCS#8 DER prefix for a P-256 private key (36 bytes).\n // This wraps a raw 32-byte scalar into the PrivateKeyInfo structure\n // that WebCrypto's importKey(\"pkcs8\", ...) expects.\n //\n // Structure (per RFC 5958 §2 / RFC 5208 §5):\n // SEQUENCE {\n // INTEGER 0 -- version (v1)\n // SEQUENCE { -- AlgorithmIdentifier (RFC 5480 §2.1.1)\n // OID 1.2.840.10045.2.1 -- id-ecPublicKey\n // OID 1.2.840.10045.3.1.7 -- secp256r1 (P-256)\n // }\n // OCTET STRING { -- privateKey (SEC 1 §C.4 / RFC 5915 §3)\n // SEQUENCE {\n // INTEGER 1 -- version\n // OCTET STRING (32 bytes) -- raw private key scalar\n // }\n // }\n // }\n //\n // References:\n // - RFC 5958 / RFC 5208: PKCS#8 PrivateKeyInfo\n // - RFC 5480 §2.1.1: ECC AlgorithmIdentifier (OIDs)\n // - RFC 5915 / SEC 1 v2 §C.4: ECPrivateKey encoding\n const pkcs8Prefix = new Uint8Array([\n 0x30, 0x41, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48,\n 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03,\n 0x01, 0x07, 0x04, 0x27, 0x30, 0x25, 0x02, 0x01, 0x01, 0x04, 0x20,\n ]);\n\n const pkcs8 = new Uint8Array(pkcs8Prefix.length + 32);\n pkcs8.set(pkcs8Prefix);\n pkcs8.set(rawPrivateKeyBytes, pkcs8Prefix.length);\n\n const cryptoKey = await crypto.subtle.importKey(\n \"pkcs8\",\n pkcs8,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n true,\n [\"deriveBits\"]\n );\n\n return await crypto.subtle.exportKey(\"jwk\", cryptoKey);\n}\n\n/**\n * Generates the error message for missing or expired keys.\n * @param {string} keyAddress - The address of the key\n * @returns {string} - The error message string\n */\nexport function getKeyNotFoundErrorMessage(keyAddress) {\n return `key bytes have expired. Please re-inject export bundle for address ${keyAddress} into iframe. Note that address is case sensitive.`;\n}\n\n/**\n * Clears an expired key from memory. This is an internal helper function\n * that clears the key without sending messages to the parent frame.\n * @param {string} keyAddress - The address of the key to clear\n */\nfunction clearExpiredKey(keyAddress) {\n if (inMemoryKeys[keyAddress]) {\n delete inMemoryKeys[keyAddress];\n }\n}\n\n/**\n * Clears all expired keys from memory.\n * This function iterates through all keys and removes any that have expired.\n */\nfunction clearAllExpiredKeys() {\n const now = new Date().getTime();\n const addressesToRemove = [];\n\n for (const [address, key] of Object.entries(inMemoryKeys)) {\n if (key.expiry && now >= key.expiry) {\n addressesToRemove.push(address);\n }\n }\n\n for (const address of addressesToRemove) {\n clearExpiredKey(address);\n }\n}\n\n/**\n * Validates that a key exists and has not expired.\n * Clears the key from memory if it has expired.\n * Throws error if validation fails (and caller will send message up back to parent).\n * @param {Object} key - The key object from inMemoryKeys\n * @param {string} keyAddress - The address of the key\n * @returns {boolean} - True if key is valid, false otherwise\n */\nfunction validateKey(key, keyAddress) {\n if (!key) {\n throw new Error(\n `key bytes not found. Please re-inject export bundle for address ${keyAddress} into iframe. Note that address is case sensitive.`\n ).toString();\n }\n\n const now = new Date().getTime();\n if (now >= key.expiry) {\n // Clear all expired keys before processing the signing request\n clearAllExpiredKeys();\n throw new Error(getKeyNotFoundErrorMessage(keyAddress)).toString();\n }\n\n return true;\n}\n\n/**\n * Gets or creates a Solana keypair from a key object.\n * Uses cached keypair if available, otherwise creates a new one.\n * @param {Object} key - The key object containing format and privateKey\n * @returns {Promise} - The Solana keypair\n */\nasync function getOrCreateKeypair(key) {\n if (key.keypair) {\n return key.keypair;\n }\n\n if (key.format === \"SOLANA\") {\n return Keypair.fromSecretKey(TKHQ.base58Decode(key.privateKey));\n } else {\n return await createSolanaKeypair(\n Array.from(TKHQ.uint8arrayFromHexString(key.privateKey))\n );\n }\n}\n\n/**\n * DOM Event handlers to power the export flow in standalone mode\n * Instead of receiving events from the parent page, forms trigger them.\n * This is useful for debugging as well.\n */\nfunction addDOMEventListeners() {\n // only support injected keys, not wallets\n document.getElementById(\"inject-key\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"INJECT_KEY_EXPORT_BUNDLE\",\n value: document.getElementById(\"key-export-bundle\").value,\n keyFormat: document.getElementById(\"key-export-format\").value,\n organizationId: document.getElementById(\"key-organization-id\").value,\n });\n },\n false\n );\n document.getElementById(\"sign-transaction\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"SIGN_TRANSACTION\",\n value: document.getElementById(\"transaction-to-sign\").value,\n });\n },\n false\n );\n document.getElementById(\"sign-message\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"SIGN_MESSAGE\",\n value: document.getElementById(\"message-to-sign\").value,\n });\n },\n false\n );\n document.getElementById(\"reset\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({ type: \"RESET_EMBEDDED_KEY\" });\n },\n false\n );\n\n // Add wallet injection support\n const injectWalletBtn = document.getElementById(\"inject-wallet\");\n if (injectWalletBtn) {\n injectWalletBtn.addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"INJECT_WALLET_EXPORT_BUNDLE\",\n value: document.getElementById(\"wallet-export-bundle\").value,\n organizationId: document.getElementById(\"wallet-organization-id\")\n .value,\n });\n },\n false\n );\n }\n}\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nfunction initMessageEventListener(HpkeDecrypt) {\n return async function messageEventListener(event) {\n if (event.data && event.data[\"type\"] == \"INJECT_KEY_EXPORT_BUNDLE\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}, ${event.data[\"keyFormat\"]}, ${event.data[\"organizationId\"]}`\n );\n try {\n await onInjectKeyBundle(\n event.data[\"requestId\"],\n event.data[\"organizationId\"],\n event.data[\"value\"], // bundle\n event.data[\"keyFormat\"],\n event.data[\"address\"],\n HpkeDecrypt\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"INJECT_WALLET_EXPORT_BUNDLE\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}, ${event.data[\"organizationId\"]}`\n );\n try {\n await onInjectKeyBundle(\n event.data[\"requestId\"],\n event.data[\"organizationId\"],\n event.data[\"value\"],\n undefined, // keyFormat - default to HEXADECIMAL\n undefined, // address - default to \"default\"\n HpkeDecrypt\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"APPLY_SETTINGS\") {\n try {\n await onApplySettings(event.data[\"value\"], event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"RESET_EMBEDDED_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n TKHQ.onResetEmbeddedKey();\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString());\n }\n }\n if (event.data && event.data[\"type\"] == \"SIGN_TRANSACTION\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}`\n );\n try {\n await onSignTransaction(\n event.data[\"requestId\"],\n event.data[\"value\"],\n event.data[\"address\"] // signing address (case sensitive)\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"SIGN_MESSAGE\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}`\n );\n try {\n await onSignMessage(\n event.data[\"requestId\"],\n event.data[\"value\"],\n event.data[\"address\"] // signing address (case sensitive)\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"CLEAR_EMBEDDED_PRIVATE_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n await onClearEmbeddedPrivateKey(\n event.data[\"requestId\"],\n event.data[\"address\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"GET_EMBEDDED_PUBLIC_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n await onGetPublicEmbeddedKey(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"SET_EMBEDDED_KEY_OVERRIDE\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n await onSetEmbeddedKeyOverride(\n event.data[\"requestId\"],\n event.data[\"organizationId\"],\n event.data[\"value\"],\n HpkeDecrypt\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"RESET_TO_DEFAULT_EMBEDDED_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n onResetToDefaultEmbeddedKey(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n };\n}\n\n/**\n * Set up event handlers for both DOM and message events\n * @param {Function} HpkeDecrypt\n */\nexport function initEventHandlers(HpkeDecrypt) {\n const messageEventListener = initMessageEventListener(HpkeDecrypt);\n\n // controllers to remove event listeners\n const messageListenerController = new AbortController();\n const turnkeyInitController = new AbortController();\n\n // Add DOM event listeners for standalone mode\n addDOMEventListeners();\n\n // Add window message listener for iframe mode\n window.addEventListener(\"message\", messageEventListener, {\n capture: false,\n signal: messageListenerController.signal,\n });\n\n // Handle MessageChannel initialization for iframe communication\n window.addEventListener(\n \"message\",\n async function (event) {\n /**\n * @turnkey/iframe-stamper >= v2.1.0 is using a MessageChannel to communicate with the parent frame.\n * The parent frame sends a TURNKEY_INIT_MESSAGE_CHANNEL event with the MessagePort.\n * If we receive this event, we want to remove the message event listener that was added in the DOMContentLoaded event to avoid processing messages twice.\n * We persist the MessagePort so we can use it to communicate with the parent window in subsequent calls to TKHQ.sendMessageUp\n */\n if (\n event.data &&\n event.data[\"type\"] == \"TURNKEY_INIT_MESSAGE_CHANNEL\" &&\n event.ports?.[0]\n ) {\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n const iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n await TKHQ.initEmbeddedKey(event.origin);\n var embeddedKeyJwk = await TKHQ.getEmbeddedKey();\n var targetPubBuf = await TKHQ.p256JWKPrivateToPublic(embeddedKeyJwk);\n var targetPubHex = TKHQ.uint8arrayToHexString(targetPubBuf);\n document.getElementById(\"embedded-key\").value = targetPubHex;\n\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", targetPubHex);\n\n // remove the listener for TURNKEY_INIT_MESSAGE_CHANNEL after it's been processed\n turnkeyInitController.abort();\n }\n },\n { signal: turnkeyInitController.signal }\n );\n\n return { messageEventListener };\n}\n/**\n * Expose internal handlers for targeted testing.\n */\nexport {\n onInjectKeyBundle,\n onSignTransaction,\n onSignMessage,\n onClearEmbeddedPrivateKey,\n onSetEmbeddedKeyOverride,\n onResetToDefaultEmbeddedKey,\n};\n","/**\n * Crypto Utilities - Shared\n * Contains HPKE encryption and decryption functions\n */\n\nimport {\n p256JWKPrivateToPublic,\n additionalAssociatedData,\n uint8arrayToHexString,\n} from \"./turnkey-core.js\";\nimport {\n CipherSuite,\n DhkemP256HkdfSha256,\n HkdfSha256,\n Aes256Gcm,\n} from \"@hpke/core\";\n\n// Pre-compute const (for perf)\nconst TURNKEY_HPKE_INFO = new TextEncoder().encode(\"turnkey_hpke\");\n\n/**\n * Decrypt the ciphertext (ArrayBuffer) given an encapsulation key (ArrayBuffer)\n * and the receivers private key (JSON Web Key).\n */\nexport async function HpkeDecrypt({\n ciphertextBuf,\n encappedKeyBuf,\n receiverPrivJwk,\n}) {\n const kemContext = new DhkemP256HkdfSha256();\n var receiverPriv = await kemContext.importKey(\n \"jwk\",\n { ...receiverPrivJwk },\n false\n );\n\n var suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n var recipientCtx = await suite.createRecipientContext({\n recipientKey: receiverPriv,\n enc: encappedKeyBuf,\n info: TURNKEY_HPKE_INFO,\n });\n\n var receiverPubBuf = await p256JWKPrivateToPublic(receiverPrivJwk);\n var aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n var res;\n try {\n res = await recipientCtx.open(ciphertextBuf, aad);\n } catch (e) {\n throw new Error(\n \"unable to decrypt bundle using embedded key. the bundle may be incorrect. failed with error: \" +\n e.toString()\n );\n }\n return res;\n}\n\n/**\n * Encrypt plaintext using HPKE with the receiver's public key.\n * @param {Object} params\n * @param {Uint8Array} params.plaintextBuf - Plaintext to encrypt\n * @param {JsonWebKey} params.receiverPubJwk - Receiver's public key in JWK format\n * @returns {Promise} JSON stringified encrypted bundle with encappedPublic and ciphertext\n */\nexport async function HpkeEncrypt({ plaintextBuf, receiverPubJwk }) {\n const kemContext = new DhkemP256HkdfSha256();\n const receiverPub = await kemContext.importKey(\n \"jwk\",\n { ...receiverPubJwk },\n true\n );\n\n const suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n const senderCtx = await suite.createSenderContext({\n recipientPublicKey: receiverPub,\n info: TURNKEY_HPKE_INFO,\n });\n\n // Need to import the key again as a JWK to export as a raw key, the format needed to\n // create the aad with the newly generated raw encapped key.\n const receiverPubCryptoKey = await crypto.subtle.importKey(\n \"jwk\",\n receiverPubJwk,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n const receiverPubRaw = await crypto.subtle.exportKey(\n \"raw\",\n receiverPubCryptoKey\n );\n const receiverPubBuf = new Uint8Array(receiverPubRaw);\n\n const encappedKeyBuf = new Uint8Array(senderCtx.enc);\n\n const aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n\n var ciphertextBuf;\n try {\n ciphertextBuf = await senderCtx.seal(plaintextBuf, aad);\n } catch (e) {\n throw new Error(\"failed to encrypt import bundle: \" + e.toString());\n }\n\n const ciphertextHex = uint8arrayToHexString(new Uint8Array(ciphertextBuf));\n const encappedKeyBufHex = uint8arrayToHexString(encappedKeyBuf);\n const encryptedBundle = JSON.stringify({\n encappedPublic: encappedKeyBufHex,\n ciphertext: ciphertextHex,\n });\n return encryptedBundle;\n}\n","// This file is the main entrypoint of the webpack-bundled application\n\n// Import relevant modules\nimport { TKHQ } from \"./turnkey-core.js\";\nimport { initEventHandlers } from \"./event-handlers.js\";\nimport { HpkeDecrypt } from \"@shared/crypto-utils.js\";\nimport \"./styles.css\";\n\n// Surface TKHQ for external access\nwindow.TKHQ = TKHQ;\n\n// Init app\ndocument.addEventListener(\"DOMContentLoaded\", async function () {\n await TKHQ.initEmbeddedKey();\n const embeddedKeyJwk = await TKHQ.getEmbeddedKey();\n const targetPubBuf = await TKHQ.p256JWKPrivateToPublic(embeddedKeyJwk);\n const targetPubHex = TKHQ.uint8arrayToHexString(targetPubBuf);\n document.getElementById(\"embedded-key\").value = targetPubHex;\n\n initEventHandlers(HpkeDecrypt);\n\n // If styles are saved in local storage, sanitize and apply them\n const styleSettings = TKHQ.getSettings();\n if (styleSettings) {\n TKHQ.applySettings(styleSettings);\n }\n\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", targetPubHex);\n});\n","module.exports = crypto;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\tloaded: false,\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Flag the module as loaded\n\tmodule.loaded = true;\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"bundle.\" + {\"291\":\"3eaea85f4001b9cc63c3\",\"825\":\"aaba32bf7338e3d0f1cc\"}[chunkId] + \".js\";\n};","// This function allow to reference async chunks\n__webpack_require__.miniCssF = (chunkId) => {\n\t// return url for filenames based on template\n\treturn undefined;\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.nmd = (module) => {\n\tmodule.paths = [];\n\tif (!module.children) module.children = [];\n\treturn module;\n};","__webpack_require__.p = \"/\";","\n__webpack_require__.sriHashes = {\"291\":\"*-*-*-CHUNK-SRI-HASH-r3NPGwA4ft5fHgGXhVIptCiDVf06qPa+sxzG6L+8GwPuhn89e/\",\"825\":\"*-*-*-CHUNK-SRI-HASH-mfog3UJdGPOmSk4QZbKxsxHPFZtt298WnZNc1aQ1MCgc6YirFj\"};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t792: 0\n};\n\n__webpack_require__.f.j = (chunkId, promises) => {\n\t\t// JSONP chunk loading for javascript\n\t\tvar installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n\t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n\t\t\t// a Promise means \"currently loading\".\n\t\t\tif(installedChunkData) {\n\t\t\t\tpromises.push(installedChunkData[2]);\n\t\t\t} else {\n\t\t\t\tif(true) { // all chunks have JS\n\t\t\t\t\t// setup Promise in chunk cache\n\t\t\t\t\tvar promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));\n\t\t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n\t\t\t\t\t// start chunk loading\n\t\t\t\t\tvar url = __webpack_require__.p + __webpack_require__.u(chunkId);\n\t\t\t\t\t// create error before stack unwound to get useful stacktrace later\n\t\t\t\t\tvar error = new Error();\n\t\t\t\t\tvar loadingEnded = (event) => {\n\t\t\t\t\t\tif(__webpack_require__.o(installedChunks, chunkId)) {\n\t\t\t\t\t\t\tinstalledChunkData = installedChunks[chunkId];\n\t\t\t\t\t\t\tif(installedChunkData !== 0) installedChunks[chunkId] = undefined;\n\t\t\t\t\t\t\tif(installedChunkData) {\n\t\t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n\t\t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n\t\t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n\t\t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n\t\t\t\t\t\t\t\terror.type = errorType;\n\t\t\t\t\t\t\t\terror.request = realSrc;\n\t\t\t\t\t\t\t\tinstalledChunkData[1](error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t__webpack_require__.l(url, loadingEnded, \"chunk-\" + chunkId, chunkId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n};\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkexport_and_sign\"] = self[\"webpackChunkexport_and_sign\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [96], () => (__webpack_require__(560)))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["deferred","leafPrototypes","getProto","inProgress","dataWebpackPrefix","e","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","_regenerator","w","m","defineProperty","_invoke","enumerable","configurable","writable","_toConsumableArray","Array","isArray","_arrayLikeToArray","_arrayWithoutHoles","from","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","toString","slice","constructor","name","test","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","TURNKEY_EMBEDDED_KEY","TURNKEY_SETTINGS","parentFrameMessageChannelPort","getSubtleCrypto","globalThis","crypto","subtle","window","global","isDoublyIframed","undefined","location","ancestorOrigins","parent","top","_loadQuorumKey","_callee","quorumPublic","_context","Error","importKey","namedCurve","_initEmbeddedKey","_callee3","_context3","getEmbeddedKey","generateTargetKey","setEmbeddedKey","_generateTargetKey","_callee4","p256key","_context4","generateKey","exportKey","privateKey","jwtKey","getItemWithExpiry","JSON","parse","targetKey","setItemWithExpiry","stringify","key","ttl","item","expiry","Date","getTime","localStorage","setItem","itemStr","getItem","hasOwnProperty","removeItem","uint8arrayFromHexString","hexString","hexWithoutPrefix","startsWith","Uint8Array","match","map","h","parseInt","uint8arrayToHexString","buffer","x","padStart","join","additionalAssociatedData","senderPubBuf","receiverPubBuf","s","concat","logMessage","content","messageLog","document","getElementById","message","createElement","innerText","appendChild","p256JWKPrivateToPublic","_x6","_p256JWKPrivateToPublic","_callee6","jwkPrivate","jwkPrivateCopy","publicKey","_context6","_objectSpread","key_ops","base58Encode","bytes","result","digits","carry","j","push","k","base58Decode","alphabet","decodedBytes","leadingZeros","indexOf","currentByte","reverse","_encodeKey","_callee9","privateKeyBytes","keyFormat","publicKeyBytes","concatenatedBytes","_t2","_context9","set","console","warn","sharedInitEmbeddedKey","SharedTKHQ","validateStyles","styles","element","validStyles","cssValidationRegex","padding","margin","borderWidth","borderStyle","borderColor","borderRadius","fontSize","fontWeight","fontFamily","color","labelColor","backgroundColor","width","height","maxWidth","maxHeight","lineHeight","boxShadow","textAlign","overflowWrap","wordWrap","resize","entries","forEach","_ref","_ref2","_arrayWithHoles","next","_iterableToArrayLimit","_nonIterableRest","property","styleProperty","trim","styleRegexStr","styleRegex","RegExp","styleValue","loadQuorumKey","_x","_verifyEnclaveSignature","_callee2","enclaveQuorumPublic","publicSignature","signedData","TURNKEY_SIGNERS_ENCLAVES","environment","meta","TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY","encryptionQuorumPublicBuf","quorumKey","publicSignatureBuf","signedDataBuf","_context2","prod","preprod","querySelector","__TURNKEY_SIGNER_ENVIRONMENT__","fromDerSignature","verify","hash","TKHQ","initEmbeddedKey","onResetEmbeddedKey","encodeKey","_x0","_x1","_x10","sendMessageUp","type","requestId","postMessage","setParentFrameMessageChannelPort","port","normalizePadding","byteArray","targetLength","paddingLength","fill","expectedZeroCount","zeroCount","verifyEnclaveSignature","_x2","_x3","getEd25519PublicKey","privateKeyHex","nobleEd25519","sha512Sync","_nobleEd25519$etc","nobleHashes","concatBytes","applySettings","settings","validSettings","settingsObj","keyDivTextarea","style","getSettings","setSettings","parsePrivateKey","error","_slicedToArray","inMemoryKeys","injectedEmbeddedKey","textEncoder","TextEncoder","textDecoder","TextDecoder","verifyAndParseBundleData","_verifyAndParseBundleData","_callee8","bundle","organizationId","bundleObj","_context8","version","data","dataSignature","decode","encappedPublic","ciphertext","decryptBundle","_x4","_x5","_decryptBundle","HpkeDecrypt","encappedKeyBuf","ciphertextBuf","receiverPrivJwk","_t9","onGetPublicEmbeddedKey","_onGetPublicEmbeddedKey","_callee0","embeddedKeyJwk","targetPubBuf","targetPubHex","_context0","loadKeyIntoMemory","_x7","_x8","_x9","_loadKeyIntoMemory","_callee1","address","keyBytes","keyAddress","cachedKeypair","_context1","subarray","Keypair","fromSecretKey","createSolanaKeypair","_defineProperty","format","keypair","onInjectKeyBundle","_x11","_x12","_x13","_x14","_onInjectKeyBundle","_callee10","_context10","onApplySettings","_x15","_x16","_onApplySettings","_callee11","_context11","onSignTransaction","_x17","_x18","_x19","_onSignTransaction","_callee12","serializedTransaction","transactionWrapper","transactionToSign","signedTransaction","transactionBytes","transaction","signedTransactionHex","_context12","validateKey","getOrCreateKeypair","VersionedTransaction","deserialize","sign","serialize","onSignMessage","_x20","_x21","_x22","_onSignMessage","_callee13","serializedMessage","messageWrapper","messageToSign","messageType","messageBytes","signatureHex","signature","_context13","encode","secretKey","onClearEmbeddedPrivateKey","_x23","_x24","_onClearEmbeddedPrivateKey","_callee14","_context14","onSetEmbeddedKeyOverride","_x25","_x26","_x27","_x28","_onSetEmbeddedKeyOverride","_callee15","keyJwk","_context15","rawP256PrivateKeyToJwk","onResetToDefaultEmbeddedKey","_x29","_createSolanaKeypair","_callee16","_context16","fromSeed","_x30","_rawP256PrivateKeyToJwk","_callee17","rawPrivateKeyBytes","pkcs8Prefix","pkcs8","cryptoKey","_context17","clearExpiredKey","now","addressesToRemove","_i","_Object$entries","_Object$entries$_i","_i2","_addressesToRemove","clearAllExpiredKeys","getKeyNotFoundErrorMessage","_x31","_getOrCreateKeypair","_callee18","_context18","initEventHandlers","messageEventListener","_messageEventListener","event","_t","_t3","_t4","_t5","_t6","_t7","_t8","_x37","initMessageEventListener","messageListenerController","AbortController","turnkeyInitController","addEventListener","preventDefault","_x32","_x33","_ref3","_x34","_ref4","_x35","injectWalletBtn","_ref5","_callee5","_context5","_x36","addDOMEventListeners","capture","signal","_ref6","_callee7","_event$ports","iframeMessagePort","_context7","ports","abort","onmessage","origin","_x38","ownKeys","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","getOwnPropertyDescriptors","defineProperties","_typeof","toPrimitive","String","_toPrimitive","_toPropertyKey","TURNKEY_HPKE_INFO","_HpkeDecrypt","kemContext","receiverPriv","suite","recipientCtx","aad","res","DhkemP256HkdfSha256","CipherSuite","kem","kdf","HkdfSha256","aead","Aes256Gcm","createRecipientContext","recipientKey","enc","info","open","styleSettings","module","exports","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","id","loaded","__webpack_modules__","O","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","every","splice","getter","__esModule","obj","mode","this","ns","def","current","getOwnPropertyNames","definition","get","chunkId","all","reduce","promises","miniCssF","g","Function","prop","url","script","needAttach","scripts","getElementsByTagName","getAttribute","charset","nc","setAttribute","src","crossOrigin","integrity","sriHashes","onScriptComplete","prev","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","target","head","nmd","paths","children","installedChunks","installedChunkData","promise","reject","errorType","realSrc","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"bundle.9876c027ef7327c209f1.js","mappings":";UAAIA,ECCAC,EADAC,ECAAC,EACAC,E,svCCAJ,IAAAC,EAAAC,EAAAC,EAAA,mBAAAC,OAAAA,OAAA,GAAAC,EAAAF,EAAAG,UAAA,aAAAC,EAAAJ,EAAAK,a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AW6P,EAASA,EAE/D,GAYH1B,EAAoBM,EAAExW,EAAK4X,GAA0C,IAA7BoC,EAAgBpC,GAGxD,IAAI2C,EAAuB,CAACC,EAA4BzR,KACvD,IAGIoN,EAAUyB,GAHTnB,EAAUgE,EAAaC,GAAW3R,EAGhB3S,EAAI,EAC3B,GAAGqgB,EAASkE,KAAMtE,GAAgC,IAAxB2D,EAAgB3D,IAAa,CACtD,IAAIF,KAAYsE,EACZvE,EAAoBhgB,EAAEukB,EAAatE,KACrCD,EAAoBhe,EAAEie,GAAYsE,EAAYtE,IAGhD,GAAGuE,EAAS,IAAI7a,EAAS6a,EAAQxE,EAClC,CAEA,IADGsE,GAA4BA,EAA2BzR,GACrD3S,EAAIqgB,EAASrf,OAAQhB,IACzBwhB,EAAUnB,EAASrgB,GAChB8f,EAAoBhgB,EAAE8jB,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAO1B,EAAoBM,EAAE3W,IAG1B+a,EAAqBC,KAAkC,4BAAIA,KAAkC,6BAAK,GACtGD,EAAmBzX,QAAQoX,EAAqBpjB,KAAK,KAAM,IAC3DyjB,EAAmB3a,KAAOsa,EAAqBpjB,KAAK,KAAMyjB,EAAmB3a,KAAK9I,KAAKyjB,G,KClFvF,IAAIE,EAAsB5E,EAAoBM,OAAE/b,EAAW,CAAC,IAAK,IAAOyb,EAAoB,MAC5F4E,EAAsB5E,EAAoBM,EAAEsE,E","sources":["webpack://export-and-sign/webpack/runtime/chunk loaded","webpack://export-and-sign/webpack/runtime/create fake namespace object","webpack://export-and-sign/webpack/runtime/load script","webpack://export-and-sign/../shared/turnkey-core.js","webpack://export-and-sign/./src/turnkey-core.js","webpack://export-and-sign/./src/event-handlers.js","webpack://export-and-sign/../shared/crypto-utils.js","webpack://export-and-sign/./src/index.js","webpack://export-and-sign/external var \"crypto\"","webpack://export-and-sign/webpack/bootstrap","webpack://export-and-sign/webpack/runtime/compat get default export","webpack://export-and-sign/webpack/runtime/define property getters","webpack://export-and-sign/webpack/runtime/ensure chunk","webpack://export-and-sign/webpack/runtime/get javascript chunk filename","webpack://export-and-sign/webpack/runtime/get mini-css chunk filename","webpack://export-and-sign/webpack/runtime/global","webpack://export-and-sign/webpack/runtime/hasOwnProperty shorthand","webpack://export-and-sign/webpack/runtime/make namespace object","webpack://export-and-sign/webpack/runtime/node module decorator","webpack://export-and-sign/webpack/runtime/publicPath","webpack://export-and-sign/webpack/runtime/compat","webpack://export-and-sign/webpack/runtime/jsonp chunk loading","webpack://export-and-sign/webpack/startup"],"sourcesContent":["var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);\nvar leafPrototypes;\n// create a fake namespace object\n// mode & 1: value is a module id, require it\n// mode & 2: merge all properties of value into the ns\n// mode & 4: return value when already ns object\n// mode & 16: return value when it's Promise-like\n// mode & 8|1: behave like require\n__webpack_require__.t = function(value, mode) {\n\tif(mode & 1) value = this(value);\n\tif(mode & 8) return value;\n\tif(typeof value === 'object' && value) {\n\t\tif((mode & 4) && value.__esModule) return value;\n\t\tif((mode & 16) && typeof value.then === 'function') return value;\n\t}\n\tvar ns = Object.create(null);\n\t__webpack_require__.r(ns);\n\tvar def = {};\n\tleafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];\n\tfor(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {\n\t\tObject.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));\n\t}\n\tdef['default'] = () => (value);\n\t__webpack_require__.d(ns, def);\n\treturn ns;\n};","var inProgress = {};\nvar dataWebpackPrefix = \"export-and-sign:\";\n// loadScript function to load a script via script tag\n__webpack_require__.l = (url, done, key, chunkId) => {\n\tif(inProgress[url]) { inProgress[url].push(done); return; }\n\tvar script, needAttach;\n\tif(key !== undefined) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tfor(var i = 0; i < scripts.length; i++) {\n\t\t\tvar s = scripts[i];\n\t\t\tif(s.getAttribute(\"src\") == url || s.getAttribute(\"data-webpack\") == dataWebpackPrefix + key) { script = s; break; }\n\t\t}\n\t}\n\tif(!script) {\n\t\tneedAttach = true;\n\t\tscript = document.createElement('script');\n\n\t\tscript.charset = 'utf-8';\n\t\tif (__webpack_require__.nc) {\n\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n\t\t}\n\t\tscript.setAttribute(\"data-webpack\", dataWebpackPrefix + key);\n\n\t\tscript.src = url;\n\t\tif (script.src.indexOf(window.location.origin + '/') !== 0) {\n\t\t\tscript.crossOrigin = \"anonymous\";\n\t\t}\n\t\tscript.integrity = __webpack_require__.sriHashes[chunkId];\n\t\tscript.crossOrigin = \"anonymous\";\n\t}\n\tinProgress[url] = [done];\n\tvar onScriptComplete = (prev, event) => {\n\t\t// avoid mem leaks in IE.\n\t\tscript.onerror = script.onload = null;\n\t\tclearTimeout(timeout);\n\t\tvar doneFns = inProgress[url];\n\t\tdelete inProgress[url];\n\t\tscript.parentNode && script.parentNode.removeChild(script);\n\t\tdoneFns && doneFns.forEach((fn) => (fn(event)));\n\t\tif(prev) return prev(event);\n\t}\n\tvar timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);\n\tscript.onerror = onScriptComplete.bind(null, script.onerror);\n\tscript.onload = onScriptComplete.bind(null, script.onload);\n\tneedAttach && document.head.appendChild(script);\n};","import { bech32 } from \"bech32\";\n\n/**\n * Turnkey Core Module - Shared\n * Contains all the core cryptographic and utility functions shared across frames\n */\n\n/** constants for LocalStorage */\nconst TURNKEY_EMBEDDED_KEY = \"TURNKEY_EMBEDDED_KEY\";\nconst TURNKEY_TARGET_EMBEDDED_KEY = \"TURNKEY_TARGET_EMBEDDED_KEY\";\nconst TURNKEY_SETTINGS = \"TURNKEY_SETTINGS\";\n/** 48 hours in milliseconds */\nconst TURNKEY_EMBEDDED_KEY_TTL_IN_MILLIS = 1000 * 60 * 60 * 48;\nconst TURNKEY_EMBEDDED_KEY_ORIGIN = \"TURNKEY_EMBEDDED_KEY_ORIGIN\";\n\nlet parentFrameMessageChannelPort = null;\nvar cryptoProviderOverride = null;\n\n/*\n * Returns a reference to the WebCrypto subtle interface regardless of the host environment.\n */\nfunction getSubtleCrypto() {\n if (cryptoProviderOverride && cryptoProviderOverride.subtle) {\n return cryptoProviderOverride.subtle;\n }\n if (\n typeof globalThis !== \"undefined\" &&\n globalThis.crypto &&\n globalThis.crypto.subtle\n ) {\n return globalThis.crypto.subtle;\n }\n if (typeof window !== \"undefined\" && window.crypto && window.crypto.subtle) {\n return window.crypto.subtle;\n }\n if (typeof global !== \"undefined\" && global.crypto && global.crypto.subtle) {\n return global.crypto.subtle;\n }\n if (typeof crypto !== \"undefined\" && crypto.subtle) {\n return crypto.subtle;\n }\n\n return null;\n}\n\n/*\n * Allows tests to explicitly set the crypto provider (e.g. crypto.webcrypto) when the runtime\n * environment does not expose one on the global/window objects.\n */\nfunction setCryptoProvider(cryptoProvider) {\n cryptoProviderOverride = cryptoProvider || null;\n}\n\n/* Security functions */\n\nfunction isDoublyIframed() {\n if (window.location.ancestorOrigins !== undefined) {\n // Does not exist in IE and firefox.\n // See https://developer.mozilla.org/en-US/docs/Web/API/Location/ancestorOrigins for how this works\n return window.location.ancestorOrigins.length > 1;\n } else {\n return window.parent !== window.top;\n }\n}\n\n/*\n * Loads the quorum public key as a CryptoKey.\n */\nasync function loadQuorumKey(quorumPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.importKey(\n \"raw\",\n quorumPublic,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n [\"verify\"]\n );\n}\n\n/*\n * Load a key to encrypt to as a CryptoKey and return it as a JSON Web Key.\n */\nasync function loadTargetKey(targetPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const targetKey = await subtle.importKey(\n \"raw\",\n targetPublic,\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n\n return await subtle.exportKey(\"jwk\", targetKey);\n}\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n */\nasync function initEmbeddedKey() {\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n const retrievedKey = await getEmbeddedKey();\n if (retrievedKey === null) {\n const targetKey = await generateTargetKey();\n setEmbeddedKey(targetKey);\n }\n // Nothing to do, key is correctly initialized!\n}\n\n/*\n * Generate a key to encrypt to and export it as a JSON Web Key.\n */\nasync function generateTargetKey() {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const p256key = await subtle.generateKey(\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n [\"deriveBits\"]\n );\n\n return await subtle.exportKey(\"jwk\", p256key.privateKey);\n}\n\n/**\n * Gets the current embedded private key JWK. Returns `null` if not found.\n */\nfunction getEmbeddedKey() {\n const jwtKey = getItemWithExpiry(TURNKEY_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the embedded private key JWK with the default expiration time.\n * @param {JsonWebKey} targetKey\n */\nfunction setEmbeddedKey(targetKey) {\n setItemWithExpiry(\n TURNKEY_EMBEDDED_KEY,\n JSON.stringify(targetKey),\n TURNKEY_EMBEDDED_KEY_TTL_IN_MILLIS\n );\n}\n\n/**\n * Gets the current target embedded private key JWK. Returns `null` if not found.\n */\nfunction getTargetEmbeddedKey() {\n const jwtKey = window.localStorage.getItem(TURNKEY_TARGET_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the target embedded public key JWK.\n * @param {JsonWebKey} targetKey\n */\nfunction setTargetEmbeddedKey(targetKey) {\n window.localStorage.setItem(\n TURNKEY_TARGET_EMBEDDED_KEY,\n JSON.stringify(targetKey)\n );\n}\n\n/**\n * Resets the current embedded private key JWK.\n */\nfunction onResetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY);\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY_ORIGIN);\n}\n\n/**\n * Resets the current target embedded private key JWK.\n */\nfunction resetTargetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_TARGET_EMBEDDED_KEY);\n}\n\nfunction setParentFrameMessageChannelPort(port) {\n parentFrameMessageChannelPort = port;\n}\n\n/**\n * Gets the current settings.\n */\nfunction getSettings() {\n const settings = window.localStorage.getItem(TURNKEY_SETTINGS);\n return settings ? JSON.parse(settings) : null;\n}\n\n/**\n * Sets the settings object.\n * @param {Object} settings\n */\nfunction setSettings(settings) {\n window.localStorage.setItem(TURNKEY_SETTINGS, JSON.stringify(settings));\n}\n\n/**\n * Set an item in localStorage with an expiration time\n * @param {string} key\n * @param {string} value\n * @param {number} ttl expiration time in milliseconds\n */\nfunction setItemWithExpiry(key, value, ttl) {\n const now = new Date();\n const item = {\n value: value,\n expiry: now.getTime() + ttl,\n };\n window.localStorage.setItem(key, JSON.stringify(item));\n}\n\n/**\n * Get an item from localStorage. Returns `null` and\n * removes the item from localStorage if expired or\n * expiry time is missing.\n * @param {string} key\n */\nfunction getItemWithExpiry(key) {\n const itemStr = window.localStorage.getItem(key);\n if (!itemStr) {\n return null;\n }\n const item = JSON.parse(itemStr);\n if (\n !Object.prototype.hasOwnProperty.call(item, \"expiry\") ||\n !Object.prototype.hasOwnProperty.call(item, \"value\")\n ) {\n window.localStorage.removeItem(key);\n return null;\n }\n const now = new Date();\n if (now.getTime() > item.expiry) {\n window.localStorage.removeItem(key);\n return null;\n }\n return item.value;\n}\n\n/**\n * Takes a hex string (e.g. \"e4567ab\" or \"0xe4567ab\") and returns an array buffer (Uint8Array)\n * @param {string} hexString - Hex string with or without \"0x\" prefix\n * @returns {Uint8Array}\n */\nfunction uint8arrayFromHexString(hexString) {\n if (!hexString || typeof hexString !== \"string\") {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n\n // Remove 0x prefix if present\n const hexWithoutPrefix =\n hexString.startsWith(\"0x\") || hexString.startsWith(\"0X\")\n ? hexString.slice(2)\n : hexString;\n\n var hexRegex = /^[0-9A-Fa-f]+$/;\n if (hexWithoutPrefix.length % 2 != 0 || !hexRegex.test(hexWithoutPrefix)) {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n return new Uint8Array(\n hexWithoutPrefix.match(/../g).map((h) => parseInt(h, 16))\n );\n}\n\n/**\n * Takes a Uint8Array and returns a hex string\n * @param {Uint8Array} buffer\n * @return {string}\n */\nfunction uint8arrayToHexString(buffer) {\n return [...buffer].map((x) => x.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Function to normalize padding of byte array with 0's to a target length\n */\nfunction normalizePadding(byteArray, targetLength) {\n const paddingLength = targetLength - byteArray.length;\n\n // Add leading 0's to array\n if (paddingLength > 0) {\n const padding = new Uint8Array(paddingLength).fill(0);\n return new Uint8Array([...padding, ...byteArray]);\n }\n\n // Remove leading 0's from array\n if (paddingLength < 0) {\n const expectedZeroCount = paddingLength * -1;\n let zeroCount = 0;\n for (let i = 0; i < expectedZeroCount && i < byteArray.length; i++) {\n if (byteArray[i] === 0) {\n zeroCount++;\n }\n }\n // Check if the number of zeros found equals the number of zeroes expected\n if (zeroCount !== expectedZeroCount) {\n throw new Error(\n `invalid number of starting zeroes. Expected number of zeroes: ${expectedZeroCount}. Found: ${zeroCount}.`\n );\n }\n return byteArray.slice(expectedZeroCount, expectedZeroCount + targetLength);\n }\n return byteArray;\n}\n\n/**\n * Additional Associated Data (AAD) in the format dictated by the enclave_encrypt crate.\n */\nfunction additionalAssociatedData(senderPubBuf, receiverPubBuf) {\n const s = Array.from(new Uint8Array(senderPubBuf));\n const r = Array.from(new Uint8Array(receiverPubBuf));\n return new Uint8Array([...s, ...r]);\n}\n\n/**\n * Converts an ASN.1 DER-encoded ECDSA signature to the raw format that WebCrypto uses.\n */\nfunction fromDerSignature(derSignature) {\n const derSignatureBuf = uint8arrayFromHexString(derSignature);\n\n // Check and skip the sequence tag (0x30)\n let index = 2;\n\n // Parse 'r' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for r\"\n );\n }\n index++; // Move past the INTEGER tag\n const rLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const r = derSignatureBuf.slice(index, index + rLength);\n index += rLength; // Move to the start of s\n\n // Parse 's' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for s\"\n );\n }\n index++; // Move past the INTEGER tag\n const sLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const s = derSignatureBuf.slice(index, index + sLength);\n\n // Normalize 'r' and 's' to 32 bytes each\n const rPadded = normalizePadding(r, 32);\n const sPadded = normalizePadding(s, 32);\n\n // Concatenate and return the raw signature\n return new Uint8Array([...rPadded, ...sPadded]);\n}\n\n/**\n * Function to verify enclave signature on import bundle received from the server.\n * @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature\n * @param {string} publicSignature signature bytes encoded as a hexadecimal string\n * @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes\n */\nasync function verifyEnclaveSignature(\n enclaveQuorumPublic,\n publicSignature,\n signedData\n) {\n /** Turnkey Signer enclave's public keys */\n const TURNKEY_SIGNERS_ENCLAVES = {\n prod: \"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\",\n preprod:\n \"04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212\",\n dev: \"048cf9ed5f579298cc1571823a3222b82d80c529c551f6070fbe712ae1a9e8d1a23b7006e306d27190358dfcd9c44624918a00f23c920a33cb14f5b026eafc865d\",\n };\n\n // Use window.__TURNKEY_SIGNER_ENVIRONMENT__ if available (for testing), otherwise use the webpack replacement\n const environment =\n (typeof window !== \"undefined\" && window.__TURNKEY_SIGNER_ENVIRONMENT__) ||\n \"__TURNKEY_SIGNER_ENVIRONMENT__\";\n const TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY =\n TURNKEY_SIGNERS_ENCLAVES[environment];\n\n if (TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY === undefined) {\n throw new Error(\n `Configuration error: TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY is undefined`\n );\n }\n\n // todo(olivia): throw error if enclave quorum public is null once server changes are deployed\n if (enclaveQuorumPublic) {\n if (enclaveQuorumPublic !== TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY) {\n throw new Error(\n `enclave quorum public keys from client and bundle do not match. Client: ${TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY}. Bundle: ${enclaveQuorumPublic}.`\n );\n }\n }\n\n const encryptionQuorumPublicBuf = new Uint8Array(\n uint8arrayFromHexString(TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY)\n );\n const quorumKey = await loadQuorumKey(encryptionQuorumPublicBuf);\n if (!quorumKey) {\n throw new Error(\"failed to load quorum key\");\n }\n\n // The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format\n const publicSignatureBuf = fromDerSignature(publicSignature);\n const signedDataBuf = uint8arrayFromHexString(signedData);\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.verify(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n quorumKey,\n publicSignatureBuf,\n signedDataBuf\n );\n}\n\n/**\n * Function to send a message.\n *\n * If this page is embedded as an iframe we'll send a postMessage\n * in one of two ways depending on the version of @turnkey/iframe-stamper:\n * 1. newer versions (>=v2.1.0) pass a MessageChannel MessagePort from the parent frame for postMessages.\n * 2. older versions ( 0) {\n digits.push(carry % 58);\n carry = (carry / 58) | 0;\n }\n }\n // Convert digits to a base58 string\n for (let k = 0; k < digits.length; k++) {\n result = alphabet[digits[k]] + result;\n }\n\n // Add '1' for each leading 0 byte\n for (let i = 0; bytes[i] === 0 && i < bytes.length - 1; i++) {\n result = \"1\" + result;\n }\n return result;\n}\n\n/**\n * Decodes a base58-encoded string into a buffer\n * This function throws an error when the string contains invalid characters.\n * @param {string} s The base58-encoded string.\n * @return {Uint8Array} The decoded buffer.\n */\nfunction base58Decode(s) {\n // See https://en.bitcoin.it/wiki/Base58Check_encoding\n var alphabet = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n var decodedBytes = [];\n var leadingZeros = [];\n for (var i = 0; i < s.length; i++) {\n if (alphabet.indexOf(s[i]) === -1) {\n throw new Error(`cannot base58-decode: ${s[i]} isn't a valid character`);\n }\n var carry = alphabet.indexOf(s[i]);\n\n // If the current base58 digit is 0, append a 0 byte.\n // \"i == leadingZeros.length\" can only be true if we have not seen non-zero bytes so far.\n // If we had seen a non-zero byte, carry wouldn't be 0, and i would be strictly more than `leadingZeros.length`\n if (carry == 0 && i === leadingZeros.length) {\n leadingZeros.push(0);\n }\n\n var j = 0;\n while (j < decodedBytes.length || carry > 0) {\n var currentByte = decodedBytes[j];\n\n // shift the current byte 58 units and add the carry amount\n // (or just add the carry amount if this is a new byte -- undefined case)\n if (currentByte === undefined) {\n currentByte = carry;\n } else {\n currentByte = currentByte * 58 + carry;\n }\n\n // find the new carry amount (1-byte shift of current byte value)\n carry = currentByte >> 8;\n // reset the current byte to the remainder (the carry amount will pass on the overflow)\n decodedBytes[j] = currentByte % 256;\n j++;\n }\n }\n\n var result = leadingZeros.concat(decodedBytes.reverse());\n return new Uint8Array(result);\n}\n\n/**\n * Decodes a base58check-encoded string and verifies the checksum.\n * Base58Check encoding includes a 4-byte checksum at the end to detect errors.\n * The checksum is the first 4 bytes of SHA256(SHA256(payload)).\n * This function throws an error if the checksum is invalid.\n * @param {string} s The base58check-encoded string.\n * @return {Promise} The decoded payload (without checksum).\n */\nasync function base58CheckDecode(s) {\n const decoded = base58Decode(s);\n\n if (decoded.length < 5) {\n throw new Error(\n `invalid base58check length: expected at least 5 bytes, got ${decoded.length}`\n );\n }\n\n const payload = decoded.subarray(0, decoded.length - 4);\n const checksum = decoded.subarray(decoded.length - 4);\n\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n\n // Compute double SHA256 hash\n const hash1Buf = await subtle.digest(\"SHA-256\", payload);\n const hash1 = new Uint8Array(hash1Buf);\n const hash2Buf = await subtle.digest(\"SHA-256\", hash1);\n const hash2 = new Uint8Array(hash2Buf);\n const computedChecksum = hash2.subarray(0, 4);\n\n // Verify checksum\n const mismatch =\n (checksum[0] ^ computedChecksum[0]) |\n (checksum[1] ^ computedChecksum[1]) |\n (checksum[2] ^ computedChecksum[2]) |\n (checksum[3] ^ computedChecksum[3]);\n if (mismatch !== 0) {\n throw new Error(\"invalid base58check checksum\");\n }\n\n return payload;\n}\n\n/**\n * Returns private key bytes from a private key, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {string} privateKey\n * @param {string} keyFormat Can be \"HEXADECIMAL\", \"SUI_BECH32\", \"BITCOIN_MAINNET_WIF\", \"BITCOIN_TESTNET_WIF\" or \"SOLANA\"\n * @return {Promise}\n */\nasync function decodeKey(privateKey, keyFormat) {\n switch (keyFormat) {\n case \"SOLANA\": {\n const decodedKeyBytes = base58Decode(privateKey);\n if (decodedKeyBytes.length !== 64) {\n throw new Error(\n `invalid key length. Expected 64 bytes. Got ${decodedKeyBytes.length}.`\n );\n }\n return decodedKeyBytes.subarray(0, 32);\n }\n case \"HEXADECIMAL\":\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n case \"BITCOIN_MAINNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0x80 = mainnet\n if (version !== 0x80) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0x80 (mainnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"BITCOIN_TESTNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0xEF = testnet\n if (version !== 0xef) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0xEF (testnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"SUI_BECH32\": {\n const { prefix, words } = bech32.decode(privateKey);\n\n if (prefix !== \"suiprivkey\") {\n throw new Error(\n `invalid SUI private key human-readable part (HRP): expected \"suiprivkey\"`\n );\n }\n\n const bytes = bech32.fromWords(words);\n if (bytes.length !== 33) {\n throw new Error(\n `invalid SUI private key length: expected 33 bytes, got ${bytes.length}`\n );\n }\n\n const schemeFlag = bytes[0];\n const privkey = bytes.slice(1);\n\n // schemeFlag = 0 is Ed25519; We currently only support Ed25519 keys for SUI.\n if (schemeFlag !== 0) {\n throw new Error(\n `invalid SUI private key scheme flag: expected 0 (Ed25519). Turnkey only supports Ed25519 keys for SUI.`\n );\n }\n\n return new Uint8Array(privkey);\n }\n default:\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n }\n}\n\n/**\n * Returns a private key from private key bytes, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {Uint8Array} privateKeyBytes\n * @param {string} keyFormat Can be \"HEXADECIMAL\" or \"SOLANA\"\n */\nasync function encodeKey(privateKeyBytes, keyFormat, publicKeyBytes) {\n switch (keyFormat) {\n case \"SOLANA\":\n if (!publicKeyBytes) {\n throw new Error(\"public key must be specified for SOLANA key format\");\n }\n if (privateKeyBytes.length !== 32) {\n throw new Error(\n `invalid private key length. Expected 32 bytes. Got ${privateKeyBytes.length}.`\n );\n }\n if (publicKeyBytes.length !== 32) {\n throw new Error(\n `invalid public key length. Expected 32 bytes. Got ${publicKeyBytes.length}.`\n );\n }\n {\n const concatenatedBytes = new Uint8Array(64);\n concatenatedBytes.set(privateKeyBytes, 0);\n concatenatedBytes.set(publicKeyBytes, 32);\n return base58Encode(concatenatedBytes);\n }\n case \"HEXADECIMAL\":\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n default:\n // keeping console.warn for debugging purposes.\n // eslint-disable-next-line no-console\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n }\n}\n\n// Helper to parse a private key into a Solana base58 private key.\n// To be used if a wallet account is exported without the `SOLANA` address format.\nfunction parsePrivateKey(privateKey) {\n if (Array.isArray(privateKey)) {\n return new Uint8Array(privateKey);\n }\n\n if (typeof privateKey === \"string\") {\n // Remove 0x prefix if present\n if (privateKey.startsWith(\"0x\")) {\n privateKey = privateKey.slice(2);\n }\n\n // Check if it's hex-formatted correctly (i.e. 64 hex chars)\n if (privateKey.length === 64 && /^[0-9a-fA-F]+$/.test(privateKey)) {\n return uint8arrayFromHexString(privateKey);\n }\n\n // Otherwise assume it's base58 format (for Solana)\n try {\n return base58Decode(privateKey);\n } catch (error) {\n throw new Error(\n \"Invalid private key format. Use hex (64 chars) or base58 format.\"\n );\n }\n }\n\n throw new Error(\"Private key must be a string (hex/base58) or number array\");\n}\n\n/**\n * Function to validate and sanitize the styles object using the accepted map of style keys and values (as regular expressions).\n * Any invalid style throws an error. Returns an object of valid styles.\n * @param {Object} styles\n * @param {HTMLElement} element - Optional element parameter (for import frame)\n * @return {Object}\n */\nfunction validateStyles(styles, element) {\n const validStyles = {};\n\n const cssValidationRegex = {\n padding: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n margin: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n borderWidth: \"^(\\\\d+(px|em|rem) ?){1,4}$\",\n borderStyle:\n \"^(none|solid|dashed|dotted|double|groove|ridge|inset|outset)$\",\n borderColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n borderRadius: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n fontSize: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax))$\",\n fontWeight: \"^(normal|bold|bolder|lighter|\\\\d{3})$\",\n fontFamily: '^[^\";<>]*$', // checks for the absence of some characters that could lead to CSS/HTML injection\n color:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n labelColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n backgroundColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n width: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n height: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n maxWidth: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n maxHeight:\n \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n lineHeight:\n \"^(\\\\d+(\\\\.\\\\d+)?(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|normal)$\",\n boxShadow:\n \"^(none|(\\\\d+(px|em|rem) ?){2,4} (#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)) ?(inset)?)$\",\n textAlign: \"^(left|right|center|justify|initial|inherit)$\",\n overflowWrap: \"^(normal|break-word|anywhere)$\",\n wordWrap: \"^(normal|break-word)$\",\n resize: \"^(none|both|horizontal|vertical|block|inline)$\",\n };\n\n Object.entries(styles).forEach(([property, value]) => {\n const styleProperty = property.trim();\n if (styleProperty.length === 0) {\n throw new Error(\"css style property cannot be empty\");\n }\n const styleRegexStr = cssValidationRegex[styleProperty];\n if (!styleRegexStr) {\n throw new Error(\n `invalid or unsupported css style property: \"${styleProperty}\"`\n );\n }\n const styleRegex = new RegExp(styleRegexStr);\n const styleValue = value.trim();\n if (styleValue.length == 0) {\n throw new Error(`css style for \"${styleProperty}\" is empty`);\n }\n const isValidStyle = styleRegex.test(styleValue);\n if (!isValidStyle) {\n throw new Error(\n `invalid css style value for property \"${styleProperty}\"`\n );\n }\n validStyles[styleProperty] = styleValue;\n });\n\n return validStyles;\n}\n\n// Export all shared functions\nexport {\n setCryptoProvider,\n getSubtleCrypto,\n isDoublyIframed,\n loadQuorumKey,\n loadTargetKey,\n initEmbeddedKey,\n generateTargetKey,\n getEmbeddedKey,\n setEmbeddedKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n onResetEmbeddedKey,\n resetTargetEmbeddedKey,\n setParentFrameMessageChannelPort,\n getSettings,\n setSettings,\n setItemWithExpiry,\n getItemWithExpiry,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n normalizePadding,\n additionalAssociatedData,\n fromDerSignature,\n verifyEnclaveSignature,\n sendMessageUp,\n logMessage,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n encodeKey,\n parsePrivateKey,\n validateStyles,\n};\n","import * as nobleEd25519 from \"@noble/ed25519\";\nimport * as nobleHashes from \"@noble/hashes/sha512\";\nimport { fromDerSignature } from \"@turnkey/crypto\";\nimport * as SharedTKHQ from \"@shared/turnkey-core.js\";\n\nconst {\n initEmbeddedKey: sharedInitEmbeddedKey,\n generateTargetKey,\n setItemWithExpiry,\n getItemWithExpiry,\n getEmbeddedKey,\n setEmbeddedKey,\n onResetEmbeddedKey,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n encodeKey,\n sendMessageUp,\n logMessage,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n setParentFrameMessageChannelPort,\n normalizePadding,\n additionalAssociatedData,\n getSettings,\n setSettings,\n parsePrivateKey,\n validateStyles,\n isDoublyIframed,\n loadQuorumKey,\n} = SharedTKHQ;\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n */\nasync function initEmbeddedKey() {\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n return await sharedInitEmbeddedKey();\n}\n\n/**\n * Function to verify enclave signature on import bundle received from the server.\n * @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature\n * @param {string} publicSignature signature bytes encoded as a hexadecimal string\n * @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes\n */\nasync function verifyEnclaveSignature(\n enclaveQuorumPublic,\n publicSignature,\n signedData\n) {\n /** Turnkey Signer enclave's public keys */\n const TURNKEY_SIGNERS_ENCLAVES = {\n prod: \"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\",\n preprod:\n \"04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212\",\n };\n\n // Read environment from meta tag (templated at deploy time), fall back to window variable (for testing)\n let environment = null;\n if (typeof document !== \"undefined\") {\n const meta = document.querySelector(\n 'meta[name=\"turnkey-signer-environment\"]'\n );\n if (\n meta &&\n meta.content &&\n meta.content !== \"__TURNKEY_SIGNER_ENVIRONMENT__\"\n ) {\n environment = meta.content;\n }\n }\n if (!environment && typeof window !== \"undefined\") {\n environment = window.__TURNKEY_SIGNER_ENVIRONMENT__;\n }\n const TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY =\n TURNKEY_SIGNERS_ENCLAVES[environment];\n\n if (TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY === undefined) {\n throw new Error(\n `Configuration error: TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY is undefined`\n );\n }\n\n if (enclaveQuorumPublic !== TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY) {\n throw new Error(\n `enclave quorum public keys from client and bundle do not match. Client: ${TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY}. Bundle: ${enclaveQuorumPublic}.`\n );\n }\n\n const encryptionQuorumPublicBuf = new Uint8Array(\n uint8arrayFromHexString(TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY)\n );\n const quorumKey = await loadQuorumKey(encryptionQuorumPublicBuf);\n if (!quorumKey) {\n throw new Error(\"failed to load quorum key\");\n }\n\n // The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format\n const publicSignatureBuf = fromDerSignature(publicSignature);\n const signedDataBuf = uint8arrayFromHexString(signedData);\n return await crypto.subtle.verify(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n quorumKey,\n publicSignatureBuf,\n signedDataBuf\n );\n}\n\n/**\n * Returns the public key bytes for a hex-encoded Ed25519 private key.\n * @param {string} privateKeyHex\n */\nfunction getEd25519PublicKey(privateKeyHex) {\n nobleEd25519.etc.sha512Sync = (...m) =>\n nobleHashes.sha512(nobleEd25519.etc.concatBytes(...m));\n return nobleEd25519.getPublicKey(privateKeyHex);\n}\n\n/**\n * Function to apply settings on this page. For now, the only settings that can be applied\n * are for \"styles\". Upon successful application, return the valid, sanitized settings JSON string.\n * @param {string} settings\n * @return {string}\n */\nfunction applySettings(settings) {\n const validSettings = {};\n if (!settings) {\n return JSON.stringify(validSettings);\n }\n const settingsObj = JSON.parse(settings);\n if (settingsObj.styles) {\n // Valid styles will be applied the \"key-div\" div HTML element.\n const keyDivTextarea = document.getElementById(\"key-div\");\n if (!keyDivTextarea) {\n throw new Error(\"no key-div HTML element found to apply settings to.\");\n }\n\n // Validate, sanitize, and apply the styles to the \"key-div\" div element.\n const validStyles = validateStyles(settingsObj.styles);\n Object.entries(validStyles).forEach(([key, value]) => {\n keyDivTextarea.style[key] = value;\n });\n\n validSettings[\"styles\"] = validStyles;\n }\n\n return JSON.stringify(validSettings);\n}\n\nexport const TKHQ = {\n initEmbeddedKey,\n generateTargetKey,\n setItemWithExpiry,\n getItemWithExpiry,\n getEmbeddedKey,\n setEmbeddedKey,\n onResetEmbeddedKey,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n encodeKey,\n sendMessageUp,\n logMessage,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n setParentFrameMessageChannelPort,\n normalizePadding,\n fromDerSignature,\n additionalAssociatedData,\n verifyEnclaveSignature,\n getEd25519PublicKey,\n applySettings,\n validateStyles,\n getSettings,\n setSettings,\n parsePrivateKey,\n};\n","import { TKHQ } from \"./turnkey-core.js\";\nimport { Keypair, VersionedTransaction } from \"@solana/web3.js\";\nimport * as nobleEd25519 from \"@noble/ed25519\";\nimport * as nobleHashes from \"@noble/hashes/sha512\";\n\n// Persist keys in memory via mapping of { address --> pk }\nlet inMemoryKeys = {};\n\n// Injected embedded key -- held in memory only, never persisted.\n// When set, decryptBundle uses this P-256 JWK instead of the iframe's embedded key.\nlet injectedEmbeddedKey = null;\n\nexport const DEFAULT_TTL_MILLISECONDS = 1000 * 24 * 60 * 60; // 24 hours or 86,400,000 milliseconds\n\n// Instantiate these once (for perf)\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\n/**\n * Verifies the enclave signature on a v1.0.0 bundle and returns the parsed signed data.\n * @param {string} bundle - JSON-stringified bundle\n * @param {string} organizationId - Expected organization ID\n * @returns {Promise} - The parsed signed data {organizationId, encappedPublic, ciphertext}\n */\nasync function verifyAndParseBundleData(bundle, organizationId) {\n const bundleObj = JSON.parse(bundle);\n\n if (bundleObj.version !== \"v1.0.0\") {\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n if (!bundleObj.data) {\n throw new Error('missing \"data\" in bundle');\n }\n if (!bundleObj.dataSignature) {\n throw new Error('missing \"dataSignature\" in bundle');\n }\n if (!bundleObj.enclaveQuorumPublic) {\n throw new Error('missing \"enclaveQuorumPublic\" in bundle');\n }\n\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method TKHQ.verifyEnclaveSignature not loaded\");\n }\n const verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(\n `failed to verify enclave signature. Got signature: ${bundleObj.dataSignature}, enclaveQuorumPublic: ${bundleObj.enclaveQuorumPublic}`\n );\n }\n\n const signedData = JSON.parse(\n textDecoder.decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n if (!organizationId) {\n throw new Error(\n `organization id is required. Please ensure you are using @turnkey/iframe-stamper >= v2.0.0 to pass \"organizationId\" for security purposes.`\n );\n } else if (\n !signedData.organizationId ||\n signedData.organizationId !== organizationId\n ) {\n throw new Error(\n `organization id does not match expected value. Expected: ${organizationId}. Found: ${signedData.organizationId}.`\n );\n }\n\n if (!signedData.encappedPublic) {\n throw new Error('missing \"encappedPublic\" in bundle signed data');\n }\n if (!signedData.ciphertext) {\n throw new Error('missing \"ciphertext\" in bundle signed data');\n }\n\n return signedData;\n}\n\n/**\n * Parse and decrypt the export bundle.\n * The `bundle` param is a JSON string of the encapsulated public\n * key, encapsulated public key signature, and the ciphertext.\n * @param {string} bundle\n * @param {string} organizationId\n * @param {Function} HpkeDecrypt\n */\nasync function decryptBundle(bundle, organizationId, HpkeDecrypt) {\n const signedData = await verifyAndParseBundleData(bundle, organizationId);\n\n const encappedKeyBuf = TKHQ.uint8arrayFromHexString(\n signedData.encappedPublic\n );\n const ciphertextBuf = TKHQ.uint8arrayFromHexString(signedData.ciphertext);\n\n // Use the injected embedded key if available, otherwise fall back to the embedded key\n const receiverPrivJwk = injectedEmbeddedKey || (await TKHQ.getEmbeddedKey());\n return await HpkeDecrypt({\n ciphertextBuf,\n encappedKeyBuf,\n receiverPrivJwk,\n });\n}\n\n/**\n * Function triggered when GET_EMBEDDED_PUBLIC_KEY event is received.\n * @param {string} requestId\n */\nasync function onGetPublicEmbeddedKey(requestId) {\n const embeddedKeyJwk = TKHQ.getEmbeddedKey();\n\n if (!embeddedKeyJwk) {\n TKHQ.sendMessageUp(\"EMBEDDED_PUBLIC_KEY\", \"\", requestId); // no key == empty string\n\n return;\n }\n\n const targetPubBuf = await TKHQ.p256JWKPrivateToPublic(embeddedKeyJwk);\n const targetPubHex = TKHQ.uint8arrayToHexString(targetPubBuf);\n\n // Send up EMBEDDED_PUBLIC_KEY message\n TKHQ.sendMessageUp(\"EMBEDDED_PUBLIC_KEY\", targetPubHex, requestId);\n}\n\n/**\n * Encodes raw key bytes and loads them into the in-memory key store.\n * @param {string} address - Wallet address (case-sensitive)\n * @param {ArrayBuffer} keyBytes - Raw decrypted private key bytes\n * @param {string} keyFormat - \"SOLANA\" | \"HEXADECIMAL\"\n * @param {string} organizationId - Organization ID\n */\nasync function loadKeyIntoMemory(address, keyBytes, keyFormat, organizationId) {\n let key;\n const privateKeyBytes = new Uint8Array(keyBytes);\n\n if (keyFormat === \"SOLANA\") {\n const privateKeyHex = TKHQ.uint8arrayToHexString(\n privateKeyBytes.subarray(0, 32)\n );\n const publicKeyBytes = TKHQ.getEd25519PublicKey(privateKeyHex);\n key = await TKHQ.encodeKey(privateKeyBytes, keyFormat, publicKeyBytes);\n } else {\n key = await TKHQ.encodeKey(privateKeyBytes, keyFormat);\n }\n\n const keyAddress = address || \"default\";\n\n // Cache keypair for improved signing perf\n let cachedKeypair;\n if (keyFormat === \"SOLANA\") {\n cachedKeypair = Keypair.fromSecretKey(TKHQ.base58Decode(key));\n } else if (keyFormat === \"HEXADECIMAL\") {\n cachedKeypair = await createSolanaKeypair(\n Array.from(TKHQ.uint8arrayFromHexString(key))\n );\n }\n\n inMemoryKeys = {\n ...inMemoryKeys,\n [keyAddress]: {\n organizationId,\n privateKey: key,\n format: keyFormat,\n expiry: new Date().getTime() + DEFAULT_TTL_MILLISECONDS,\n keypair: cachedKeypair,\n },\n };\n}\n\n/**\n * Function triggered when INJECT_KEY_EXPORT_BUNDLE event is received.\n * @param {string} requestId\n * @param {string} organizationId\n * @param {string} bundle\n * @param {string} keyFormat\n * @param {string} address\n * @param {Function} HpkeDecrypt // TODO: import this directly (instead of passing around)\n */\nasync function onInjectKeyBundle(\n requestId,\n organizationId,\n bundle,\n keyFormat,\n address,\n HpkeDecrypt\n) {\n // Decrypt the export bundle\n const keyBytes = await decryptBundle(bundle, organizationId, HpkeDecrypt);\n\n // Load decrypted key into memory\n await loadKeyIntoMemory(address, keyBytes, keyFormat, organizationId);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when APPLY_SETTINGS event is received.\n * For now, the only settings that can be applied are for \"styles\".\n * Persist them in local storage so they can be applied on every\n * page load.\n * @param {string} settings: JSON-stringified settings\n * @param {string} requestId\n */\nasync function onApplySettings(settings, requestId) {\n // Apply settings\n const validSettings = TKHQ.applySettings(settings);\n\n // Persist in local storage\n TKHQ.setSettings(validSettings);\n\n // Send up SETTINGS_APPLIED message\n TKHQ.sendMessageUp(\"SETTINGS_APPLIED\", true, requestId);\n}\n\n/**\n * Function triggered when SIGN_TRANSACTION event is received.\n * @param {string} requestId\n * @param {string} transaction (serialized)\n * @param {string} address (case-sensitive --> enforce this, optional for backwards compatibility)\n */\nasync function onSignTransaction(requestId, serializedTransaction, address) {\n // If no address provided, use \"default\"\n const keyAddress = address || \"default\";\n const key = inMemoryKeys[keyAddress];\n\n // Validate key exists and is valid/non-expired\n if (!validateKey(key, keyAddress, requestId)) {\n return;\n }\n\n // Get or create keypair (uses cached keypair if available)\n const keypair = await getOrCreateKeypair(key);\n\n const transactionWrapper = JSON.parse(serializedTransaction);\n const transactionToSign = transactionWrapper.transaction;\n const transactionType = transactionWrapper.type;\n\n let signedTransaction;\n\n if (transactionType === \"SOLANA\") {\n // Fetch the transaction and sign\n const transactionBytes = TKHQ.uint8arrayFromHexString(transactionToSign);\n const transaction = VersionedTransaction.deserialize(transactionBytes);\n transaction.sign([keypair]);\n\n signedTransaction = transaction.serialize();\n } else {\n throw new Error(\"unsupported transaction type\");\n }\n\n const signedTransactionHex = TKHQ.uint8arrayToHexString(signedTransaction);\n\n TKHQ.sendMessageUp(\"TRANSACTION_SIGNED\", signedTransactionHex, requestId);\n}\n\n/**\n * Function triggered when SIGN_MESSAGE event is received.\n * @param {string} requestId\n * @param {string} message (serialized, JSON-stringified)\n * @param {string} address (case-sensitive --> enforce this, optional for backwards compatibility)\n */\nasync function onSignMessage(requestId, serializedMessage, address) {\n // Backwards compatibility: if no address provided, use \"default\"\n const keyAddress = address || \"default\";\n const key = inMemoryKeys[keyAddress];\n\n // Validate key exists and has not expired\n if (!validateKey(key, keyAddress, requestId)) {\n return;\n }\n\n const messageWrapper = JSON.parse(serializedMessage);\n const messageToSign = messageWrapper.message;\n const messageType = messageWrapper.type;\n const messageBytes = textEncoder.encode(messageToSign);\n\n let signatureHex;\n\n // Get or create keypair (uses cached keypair if available)\n const keypair = await getOrCreateKeypair(key);\n\n if (messageType === \"SOLANA\") {\n // Set up sha512 for nobleEd25519 (required for signing)\n nobleEd25519.etc.sha512Sync = (...m) =>\n nobleHashes.sha512(nobleEd25519.etc.concatBytes(...m));\n\n // Extract the 32-byte private key from the 64-byte secretKey\n // Solana keypair.secretKey format: [32-byte private key][32-byte public key]\n const privateKey = keypair.secretKey.slice(0, 32);\n // Sign the message using nobleEd25519\n const signature = nobleEd25519.sign(messageBytes, privateKey);\n\n // Note: Signature verification is skipped for performance. The signature will always be valid if signing succeeds with a valid keypair.\n // Clients can verify the signature returned.\n\n signatureHex = TKHQ.uint8arrayToHexString(signature);\n } else {\n TKHQ.sendMessageUp(\"ERROR\", \"unsupported message type\", requestId);\n\n return;\n }\n\n TKHQ.sendMessageUp(\"MESSAGE_SIGNED\", signatureHex, requestId);\n}\n\n/**\n * Function triggered when CLEAR_EMBEDDED_PRIVATE_KEY event is received.\n * @param {string} requestId\n * @param {string} address - Optional: The address of the key to clear (case-sensitive). If not provided, clears all keys.\n */\nasync function onClearEmbeddedPrivateKey(requestId, address) {\n // If no address is provided, clear all keys\n if (!address) {\n inMemoryKeys = {};\n TKHQ.sendMessageUp(\"EMBEDDED_PRIVATE_KEY_CLEARED\", true, requestId);\n\n return;\n }\n\n // Check if key exists for the specific address\n if (!inMemoryKeys[address]) {\n TKHQ.sendMessageUp(\n \"ERROR\",\n new Error(\n `key not found for address ${address}. Note that address is case sensitive.`\n ).toString(),\n requestId\n );\n\n return;\n }\n\n // Clear the specific key from memory\n delete inMemoryKeys[address];\n\n TKHQ.sendMessageUp(\"EMBEDDED_PRIVATE_KEY_CLEARED\", true, requestId);\n}\n\n/**\n * Handler for SET_EMBEDDED_KEY_OVERRIDE events.\n * Decrypts a P-256 private key bundle using the iframe's embedded key and\n * overrides the embedded key with it for subsequent bundle decryptions.\n * @param {string} requestId\n * @param {string} organizationId\n * @param {string} bundle - v1.0.0 bundle containing the P-256 private key\n * @param {Function} HpkeDecrypt\n */\nasync function onSetEmbeddedKeyOverride(\n requestId,\n organizationId,\n bundle,\n HpkeDecrypt\n) {\n // Decrypt the private key using the iframe's embedded key.\n // The decrypted payload is a raw 32-byte P-256 private key scalar.\n const keyBytes = await decryptBundle(bundle, organizationId, HpkeDecrypt);\n\n // Convert raw P-256 bytes to a full JWK (derives public key via WebCrypto)\n const keyJwk = await rawP256PrivateKeyToJwk(new Uint8Array(keyBytes));\n\n // Store in module-level variable (memory only)\n injectedEmbeddedKey = keyJwk;\n\n TKHQ.sendMessageUp(\"EMBEDDED_KEY_OVERRIDE_SET\", true, requestId);\n}\n\n/**\n * Handler for RESET_TO_DEFAULT_EMBEDDED_KEY events.\n * Clears the embedded key from memory, replacing it with the iframe's default embedded key.\n * @param {string} requestId\n */\nfunction onResetToDefaultEmbeddedKey(requestId) {\n injectedEmbeddedKey = null;\n TKHQ.sendMessageUp(\"RESET_TO_DEFAULT_EMBEDDED_KEY\", true, requestId);\n}\n\n// Utility functions\nasync function createSolanaKeypair(privateKey) {\n const privateKeyBytes = TKHQ.parsePrivateKey(privateKey);\n\n let keypair;\n if (privateKeyBytes.length === 32) {\n // 32-byte private key (seed)\n keypair = Keypair.fromSeed(privateKeyBytes);\n } else if (privateKeyBytes.length === 64) {\n // 64-byte secret key (private + public)\n keypair = Keypair.fromSecretKey(privateKeyBytes);\n } else {\n throw new Error(\n `Invalid private key length: ${privateKeyBytes.length}. Expected 32 or 64 bytes.`\n );\n }\n\n return keypair;\n}\n\n/**\n * Converts raw P-256 private key bytes (32-byte scalar) to a JWK.\n * Constructs a PKCS8 wrapper around the raw bytes, imports via WebCrypto\n * (which derives the public key), then exports as JWK.\n * @param {Uint8Array} rawPrivateKeyBytes - 32-byte P-256 private key scalar\n * @returns {Promise} - Full P-256 ECDH private key JWK\n */\nasync function rawP256PrivateKeyToJwk(rawPrivateKeyBytes) {\n if (rawPrivateKeyBytes.length !== 32) {\n throw new Error(\n `invalid decryption key length: expected 32 bytes, got ${rawPrivateKeyBytes.length}`\n );\n }\n\n // Fixed PKCS#8 DER prefix for a P-256 private key (36 bytes).\n // This wraps a raw 32-byte scalar into the PrivateKeyInfo structure\n // that WebCrypto's importKey(\"pkcs8\", ...) expects.\n //\n // Structure (per RFC 5958 §2 / RFC 5208 §5):\n // SEQUENCE {\n // INTEGER 0 -- version (v1)\n // SEQUENCE { -- AlgorithmIdentifier (RFC 5480 §2.1.1)\n // OID 1.2.840.10045.2.1 -- id-ecPublicKey\n // OID 1.2.840.10045.3.1.7 -- secp256r1 (P-256)\n // }\n // OCTET STRING { -- privateKey (SEC 1 §C.4 / RFC 5915 §3)\n // SEQUENCE {\n // INTEGER 1 -- version\n // OCTET STRING (32 bytes) -- raw private key scalar\n // }\n // }\n // }\n //\n // References:\n // - RFC 5958 / RFC 5208: PKCS#8 PrivateKeyInfo\n // - RFC 5480 §2.1.1: ECC AlgorithmIdentifier (OIDs)\n // - RFC 5915 / SEC 1 v2 §C.4: ECPrivateKey encoding\n const pkcs8Prefix = new Uint8Array([\n 0x30, 0x41, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48,\n 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03,\n 0x01, 0x07, 0x04, 0x27, 0x30, 0x25, 0x02, 0x01, 0x01, 0x04, 0x20,\n ]);\n\n const pkcs8 = new Uint8Array(pkcs8Prefix.length + 32);\n pkcs8.set(pkcs8Prefix);\n pkcs8.set(rawPrivateKeyBytes, pkcs8Prefix.length);\n\n const cryptoKey = await crypto.subtle.importKey(\n \"pkcs8\",\n pkcs8,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n true,\n [\"deriveBits\"]\n );\n\n return await crypto.subtle.exportKey(\"jwk\", cryptoKey);\n}\n\n/**\n * Generates the error message for missing or expired keys.\n * @param {string} keyAddress - The address of the key\n * @returns {string} - The error message string\n */\nexport function getKeyNotFoundErrorMessage(keyAddress) {\n return `key bytes have expired. Please re-inject export bundle for address ${keyAddress} into iframe. Note that address is case sensitive.`;\n}\n\n/**\n * Clears an expired key from memory. This is an internal helper function\n * that clears the key without sending messages to the parent frame.\n * @param {string} keyAddress - The address of the key to clear\n */\nfunction clearExpiredKey(keyAddress) {\n if (inMemoryKeys[keyAddress]) {\n delete inMemoryKeys[keyAddress];\n }\n}\n\n/**\n * Clears all expired keys from memory.\n * This function iterates through all keys and removes any that have expired.\n */\nfunction clearAllExpiredKeys() {\n const now = new Date().getTime();\n const addressesToRemove = [];\n\n for (const [address, key] of Object.entries(inMemoryKeys)) {\n if (key.expiry && now >= key.expiry) {\n addressesToRemove.push(address);\n }\n }\n\n for (const address of addressesToRemove) {\n clearExpiredKey(address);\n }\n}\n\n/**\n * Validates that a key exists and has not expired.\n * Clears the key from memory if it has expired.\n * Throws error if validation fails (and caller will send message up back to parent).\n * @param {Object} key - The key object from inMemoryKeys\n * @param {string} keyAddress - The address of the key\n * @returns {boolean} - True if key is valid, false otherwise\n */\nfunction validateKey(key, keyAddress) {\n if (!key) {\n throw new Error(\n `key bytes not found. Please re-inject export bundle for address ${keyAddress} into iframe. Note that address is case sensitive.`\n ).toString();\n }\n\n const now = new Date().getTime();\n if (now >= key.expiry) {\n // Clear all expired keys before processing the signing request\n clearAllExpiredKeys();\n throw new Error(getKeyNotFoundErrorMessage(keyAddress)).toString();\n }\n\n return true;\n}\n\n/**\n * Gets or creates a Solana keypair from a key object.\n * Uses cached keypair if available, otherwise creates a new one.\n * @param {Object} key - The key object containing format and privateKey\n * @returns {Promise} - The Solana keypair\n */\nasync function getOrCreateKeypair(key) {\n if (key.keypair) {\n return key.keypair;\n }\n\n if (key.format === \"SOLANA\") {\n return Keypair.fromSecretKey(TKHQ.base58Decode(key.privateKey));\n } else {\n return await createSolanaKeypair(\n Array.from(TKHQ.uint8arrayFromHexString(key.privateKey))\n );\n }\n}\n\n/**\n * DOM Event handlers to power the export flow in standalone mode\n * Instead of receiving events from the parent page, forms trigger them.\n * This is useful for debugging as well.\n */\nfunction addDOMEventListeners() {\n // only support injected keys, not wallets\n document.getElementById(\"inject-key\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"INJECT_KEY_EXPORT_BUNDLE\",\n value: document.getElementById(\"key-export-bundle\").value,\n keyFormat: document.getElementById(\"key-export-format\").value,\n organizationId: document.getElementById(\"key-organization-id\").value,\n });\n },\n false\n );\n document.getElementById(\"sign-transaction\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"SIGN_TRANSACTION\",\n value: document.getElementById(\"transaction-to-sign\").value,\n });\n },\n false\n );\n document.getElementById(\"sign-message\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"SIGN_MESSAGE\",\n value: document.getElementById(\"message-to-sign\").value,\n });\n },\n false\n );\n document.getElementById(\"reset\").addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({ type: \"RESET_EMBEDDED_KEY\" });\n },\n false\n );\n\n // Add wallet injection support\n const injectWalletBtn = document.getElementById(\"inject-wallet\");\n if (injectWalletBtn) {\n injectWalletBtn.addEventListener(\n \"click\",\n async (e) => {\n e.preventDefault();\n window.postMessage({\n type: \"INJECT_WALLET_EXPORT_BUNDLE\",\n value: document.getElementById(\"wallet-export-bundle\").value,\n organizationId: document.getElementById(\"wallet-organization-id\")\n .value,\n });\n },\n false\n );\n }\n}\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nfunction initMessageEventListener(HpkeDecrypt) {\n return async function messageEventListener(event) {\n if (event.data && event.data[\"type\"] == \"INJECT_KEY_EXPORT_BUNDLE\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}, ${event.data[\"keyFormat\"]}, ${event.data[\"organizationId\"]}`\n );\n try {\n await onInjectKeyBundle(\n event.data[\"requestId\"],\n event.data[\"organizationId\"],\n event.data[\"value\"], // bundle\n event.data[\"keyFormat\"],\n event.data[\"address\"],\n HpkeDecrypt\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"INJECT_WALLET_EXPORT_BUNDLE\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}, ${event.data[\"organizationId\"]}`\n );\n try {\n await onInjectKeyBundle(\n event.data[\"requestId\"],\n event.data[\"organizationId\"],\n event.data[\"value\"],\n undefined, // keyFormat - default to HEXADECIMAL\n undefined, // address - default to \"default\"\n HpkeDecrypt\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"APPLY_SETTINGS\") {\n try {\n await onApplySettings(event.data[\"value\"], event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"RESET_EMBEDDED_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n TKHQ.onResetEmbeddedKey();\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString());\n }\n }\n if (event.data && event.data[\"type\"] == \"SIGN_TRANSACTION\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}`\n );\n try {\n await onSignTransaction(\n event.data[\"requestId\"],\n event.data[\"value\"],\n event.data[\"address\"] // signing address (case sensitive)\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"SIGN_MESSAGE\") {\n TKHQ.logMessage(\n `⬇️ Received message ${event.data[\"type\"]}: ${event.data[\"value\"]}`\n );\n try {\n await onSignMessage(\n event.data[\"requestId\"],\n event.data[\"value\"],\n event.data[\"address\"] // signing address (case sensitive)\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"CLEAR_EMBEDDED_PRIVATE_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n await onClearEmbeddedPrivateKey(\n event.data[\"requestId\"],\n event.data[\"address\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"GET_EMBEDDED_PUBLIC_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n await onGetPublicEmbeddedKey(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"SET_EMBEDDED_KEY_OVERRIDE\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n await onSetEmbeddedKeyOverride(\n event.data[\"requestId\"],\n event.data[\"organizationId\"],\n event.data[\"value\"],\n HpkeDecrypt\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"RESET_TO_DEFAULT_EMBEDDED_KEY\") {\n TKHQ.logMessage(`⬇️ Received message ${event.data[\"type\"]}`);\n try {\n onResetToDefaultEmbeddedKey(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n };\n}\n\n/**\n * Set up event handlers for both DOM and message events\n * @param {Function} HpkeDecrypt\n */\nexport function initEventHandlers(HpkeDecrypt) {\n const messageEventListener = initMessageEventListener(HpkeDecrypt);\n\n // controllers to remove event listeners\n const messageListenerController = new AbortController();\n const turnkeyInitController = new AbortController();\n\n // Add DOM event listeners for standalone mode\n addDOMEventListeners();\n\n // Add window message listener for iframe mode\n window.addEventListener(\"message\", messageEventListener, {\n capture: false,\n signal: messageListenerController.signal,\n });\n\n // Handle MessageChannel initialization for iframe communication\n window.addEventListener(\n \"message\",\n async function (event) {\n /**\n * @turnkey/iframe-stamper >= v2.1.0 is using a MessageChannel to communicate with the parent frame.\n * The parent frame sends a TURNKEY_INIT_MESSAGE_CHANNEL event with the MessagePort.\n * If we receive this event, we want to remove the message event listener that was added in the DOMContentLoaded event to avoid processing messages twice.\n * We persist the MessagePort so we can use it to communicate with the parent window in subsequent calls to TKHQ.sendMessageUp\n */\n if (\n event.data &&\n event.data[\"type\"] == \"TURNKEY_INIT_MESSAGE_CHANNEL\" &&\n event.ports?.[0]\n ) {\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n const iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n await TKHQ.initEmbeddedKey(event.origin);\n var embeddedKeyJwk = await TKHQ.getEmbeddedKey();\n var targetPubBuf = await TKHQ.p256JWKPrivateToPublic(embeddedKeyJwk);\n var targetPubHex = TKHQ.uint8arrayToHexString(targetPubBuf);\n document.getElementById(\"embedded-key\").value = targetPubHex;\n\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", targetPubHex);\n\n // remove the listener for TURNKEY_INIT_MESSAGE_CHANNEL after it's been processed\n turnkeyInitController.abort();\n }\n },\n { signal: turnkeyInitController.signal }\n );\n\n return { messageEventListener };\n}\n/**\n * Expose internal handlers for targeted testing.\n */\nexport {\n onInjectKeyBundle,\n onSignTransaction,\n onSignMessage,\n onClearEmbeddedPrivateKey,\n onSetEmbeddedKeyOverride,\n onResetToDefaultEmbeddedKey,\n};\n","/**\n * Crypto Utilities - Shared\n * Contains HPKE encryption and decryption functions\n */\n\nimport {\n p256JWKPrivateToPublic,\n additionalAssociatedData,\n uint8arrayToHexString,\n} from \"./turnkey-core.js\";\nimport {\n CipherSuite,\n DhkemP256HkdfSha256,\n HkdfSha256,\n Aes256Gcm,\n} from \"@hpke/core\";\n\n// Pre-compute const (for perf)\nconst TURNKEY_HPKE_INFO = new TextEncoder().encode(\"turnkey_hpke\");\n\n/**\n * Decrypt the ciphertext (ArrayBuffer) given an encapsulation key (ArrayBuffer)\n * and the receivers private key (JSON Web Key).\n */\nexport async function HpkeDecrypt({\n ciphertextBuf,\n encappedKeyBuf,\n receiverPrivJwk,\n}) {\n const kemContext = new DhkemP256HkdfSha256();\n var receiverPriv = await kemContext.importKey(\n \"jwk\",\n { ...receiverPrivJwk },\n false\n );\n\n var suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n var recipientCtx = await suite.createRecipientContext({\n recipientKey: receiverPriv,\n enc: encappedKeyBuf,\n info: TURNKEY_HPKE_INFO,\n });\n\n var receiverPubBuf = await p256JWKPrivateToPublic(receiverPrivJwk);\n var aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n var res;\n try {\n res = await recipientCtx.open(ciphertextBuf, aad);\n } catch (e) {\n throw new Error(\n \"unable to decrypt bundle using embedded key. the bundle may be incorrect. failed with error: \" +\n e.toString()\n );\n }\n return res;\n}\n\n/**\n * Encrypt plaintext using HPKE with the receiver's public key.\n * @param {Object} params\n * @param {Uint8Array} params.plaintextBuf - Plaintext to encrypt\n * @param {JsonWebKey} params.receiverPubJwk - Receiver's public key in JWK format\n * @returns {Promise} JSON stringified encrypted bundle with encappedPublic and ciphertext\n */\nexport async function HpkeEncrypt({ plaintextBuf, receiverPubJwk }) {\n const kemContext = new DhkemP256HkdfSha256();\n const receiverPub = await kemContext.importKey(\n \"jwk\",\n { ...receiverPubJwk },\n true\n );\n\n const suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n const senderCtx = await suite.createSenderContext({\n recipientPublicKey: receiverPub,\n info: TURNKEY_HPKE_INFO,\n });\n\n // Need to import the key again as a JWK to export as a raw key, the format needed to\n // create the aad with the newly generated raw encapped key.\n const receiverPubCryptoKey = await crypto.subtle.importKey(\n \"jwk\",\n receiverPubJwk,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n const receiverPubRaw = await crypto.subtle.exportKey(\n \"raw\",\n receiverPubCryptoKey\n );\n const receiverPubBuf = new Uint8Array(receiverPubRaw);\n\n const encappedKeyBuf = new Uint8Array(senderCtx.enc);\n\n const aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n\n var ciphertextBuf;\n try {\n ciphertextBuf = await senderCtx.seal(plaintextBuf, aad);\n } catch (e) {\n throw new Error(\"failed to encrypt import bundle: \" + e.toString());\n }\n\n const ciphertextHex = uint8arrayToHexString(new Uint8Array(ciphertextBuf));\n const encappedKeyBufHex = uint8arrayToHexString(encappedKeyBuf);\n const encryptedBundle = JSON.stringify({\n encappedPublic: encappedKeyBufHex,\n ciphertext: ciphertextHex,\n });\n return encryptedBundle;\n}\n","// This file is the main entrypoint of the webpack-bundled application\n\n// Import relevant modules\nimport { TKHQ } from \"./turnkey-core.js\";\nimport { initEventHandlers } from \"./event-handlers.js\";\nimport { HpkeDecrypt } from \"@shared/crypto-utils.js\";\nimport \"./styles.css\";\n\n// Surface TKHQ for external access\nwindow.TKHQ = TKHQ;\n\n// Init app\ndocument.addEventListener(\"DOMContentLoaded\", async function () {\n await TKHQ.initEmbeddedKey();\n const embeddedKeyJwk = await TKHQ.getEmbeddedKey();\n const targetPubBuf = await TKHQ.p256JWKPrivateToPublic(embeddedKeyJwk);\n const targetPubHex = TKHQ.uint8arrayToHexString(targetPubBuf);\n document.getElementById(\"embedded-key\").value = targetPubHex;\n\n initEventHandlers(HpkeDecrypt);\n\n // If styles are saved in local storage, sanitize and apply them\n const styleSettings = TKHQ.getSettings();\n if (styleSettings) {\n TKHQ.applySettings(styleSettings);\n }\n\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", targetPubHex);\n});\n","module.exports = crypto;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\tloaded: false,\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Flag the module as loaded\n\tmodule.loaded = true;\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"bundle.\" + {\"291\":\"3eaea85f4001b9cc63c3\",\"825\":\"aaba32bf7338e3d0f1cc\"}[chunkId] + \".js\";\n};","// This function allow to reference async chunks\n__webpack_require__.miniCssF = (chunkId) => {\n\t// return url for filenames based on template\n\treturn undefined;\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.nmd = (module) => {\n\tmodule.paths = [];\n\tif (!module.children) module.children = [];\n\treturn module;\n};","__webpack_require__.p = \"/\";","\n__webpack_require__.sriHashes = {\"291\":\"*-*-*-CHUNK-SRI-HASH-r3NPGwA4ft5fHgGXhVIptCiDVf06qPa+sxzG6L+8GwPuhn89e/\",\"825\":\"*-*-*-CHUNK-SRI-HASH-mfog3UJdGPOmSk4QZbKxsxHPFZtt298WnZNc1aQ1MCgc6YirFj\"};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t792: 0\n};\n\n__webpack_require__.f.j = (chunkId, promises) => {\n\t\t// JSONP chunk loading for javascript\n\t\tvar installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n\t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n\t\t\t// a Promise means \"currently loading\".\n\t\t\tif(installedChunkData) {\n\t\t\t\tpromises.push(installedChunkData[2]);\n\t\t\t} else {\n\t\t\t\tif(true) { // all chunks have JS\n\t\t\t\t\t// setup Promise in chunk cache\n\t\t\t\t\tvar promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));\n\t\t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n\t\t\t\t\t// start chunk loading\n\t\t\t\t\tvar url = __webpack_require__.p + __webpack_require__.u(chunkId);\n\t\t\t\t\t// create error before stack unwound to get useful stacktrace later\n\t\t\t\t\tvar error = new Error();\n\t\t\t\t\tvar loadingEnded = (event) => {\n\t\t\t\t\t\tif(__webpack_require__.o(installedChunks, chunkId)) {\n\t\t\t\t\t\t\tinstalledChunkData = installedChunks[chunkId];\n\t\t\t\t\t\t\tif(installedChunkData !== 0) installedChunks[chunkId] = undefined;\n\t\t\t\t\t\t\tif(installedChunkData) {\n\t\t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n\t\t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n\t\t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n\t\t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n\t\t\t\t\t\t\t\terror.type = errorType;\n\t\t\t\t\t\t\t\terror.request = realSrc;\n\t\t\t\t\t\t\t\tinstalledChunkData[1](error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t__webpack_require__.l(url, loadingEnded, \"chunk-\" + chunkId, chunkId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n};\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkexport_and_sign\"] = self[\"webpackChunkexport_and_sign\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [96], () => (__webpack_require__(560)))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["deferred","leafPrototypes","getProto","inProgress","dataWebpackPrefix","e","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","_regenerator","w","m","defineProperty","_invoke","enumerable","configurable","writable","_toConsumableArray","Array","isArray","_arrayLikeToArray","_arrayWithoutHoles","from","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","toString","slice","constructor","name","test","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","TURNKEY_EMBEDDED_KEY","TURNKEY_SETTINGS","parentFrameMessageChannelPort","getSubtleCrypto","globalThis","crypto","subtle","window","global","isDoublyIframed","undefined","location","ancestorOrigins","parent","top","_loadQuorumKey","_callee","quorumPublic","_context","Error","importKey","namedCurve","_initEmbeddedKey","_callee3","_context3","getEmbeddedKey","generateTargetKey","setEmbeddedKey","_generateTargetKey","_callee4","p256key","_context4","generateKey","exportKey","privateKey","jwtKey","getItemWithExpiry","JSON","parse","targetKey","setItemWithExpiry","stringify","key","ttl","item","expiry","Date","getTime","localStorage","setItem","itemStr","getItem","hasOwnProperty","removeItem","uint8arrayFromHexString","hexString","hexWithoutPrefix","startsWith","Uint8Array","match","map","h","parseInt","uint8arrayToHexString","buffer","x","padStart","join","additionalAssociatedData","senderPubBuf","receiverPubBuf","s","concat","logMessage","content","messageLog","document","getElementById","message","createElement","innerText","appendChild","p256JWKPrivateToPublic","_x6","_p256JWKPrivateToPublic","_callee6","jwkPrivate","jwkPrivateCopy","publicKey","_context6","_objectSpread","key_ops","base58Encode","bytes","result","digits","carry","j","push","k","base58Decode","alphabet","decodedBytes","leadingZeros","indexOf","currentByte","reverse","_encodeKey","_callee9","privateKeyBytes","keyFormat","publicKeyBytes","concatenatedBytes","_t2","_context9","set","console","warn","sharedInitEmbeddedKey","SharedTKHQ","validateStyles","styles","element","validStyles","cssValidationRegex","padding","margin","borderWidth","borderStyle","borderColor","borderRadius","fontSize","fontWeight","fontFamily","color","labelColor","backgroundColor","width","height","maxWidth","maxHeight","lineHeight","boxShadow","textAlign","overflowWrap","wordWrap","resize","entries","forEach","_ref","_ref2","_arrayWithHoles","next","_iterableToArrayLimit","_nonIterableRest","property","styleProperty","trim","styleRegexStr","styleRegex","RegExp","styleValue","loadQuorumKey","_x","_verifyEnclaveSignature","_callee2","enclaveQuorumPublic","publicSignature","signedData","TURNKEY_SIGNERS_ENCLAVES","environment","meta","TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY","encryptionQuorumPublicBuf","quorumKey","publicSignatureBuf","signedDataBuf","_context2","prod","preprod","querySelector","__TURNKEY_SIGNER_ENVIRONMENT__","fromDerSignature","verify","hash","TKHQ","initEmbeddedKey","onResetEmbeddedKey","encodeKey","_x0","_x1","_x10","sendMessageUp","type","requestId","postMessage","setParentFrameMessageChannelPort","port","normalizePadding","byteArray","targetLength","paddingLength","fill","expectedZeroCount","zeroCount","verifyEnclaveSignature","_x2","_x3","getEd25519PublicKey","privateKeyHex","nobleEd25519","sha512Sync","_nobleEd25519$etc","nobleHashes","concatBytes","applySettings","settings","validSettings","settingsObj","keyDivTextarea","style","getSettings","setSettings","parsePrivateKey","error","_slicedToArray","inMemoryKeys","injectedEmbeddedKey","textEncoder","TextEncoder","textDecoder","TextDecoder","verifyAndParseBundleData","_verifyAndParseBundleData","_callee8","bundle","organizationId","bundleObj","_context8","version","data","dataSignature","decode","encappedPublic","ciphertext","decryptBundle","_x4","_x5","_decryptBundle","HpkeDecrypt","encappedKeyBuf","ciphertextBuf","receiverPrivJwk","_t9","onGetPublicEmbeddedKey","_onGetPublicEmbeddedKey","_callee0","embeddedKeyJwk","targetPubBuf","targetPubHex","_context0","loadKeyIntoMemory","_x7","_x8","_x9","_loadKeyIntoMemory","_callee1","address","keyBytes","keyAddress","cachedKeypair","_context1","subarray","Keypair","fromSecretKey","createSolanaKeypair","_defineProperty","format","keypair","onInjectKeyBundle","_x11","_x12","_x13","_x14","_onInjectKeyBundle","_callee10","_context10","onApplySettings","_x15","_x16","_onApplySettings","_callee11","_context11","onSignTransaction","_x17","_x18","_x19","_onSignTransaction","_callee12","serializedTransaction","transactionWrapper","transactionToSign","signedTransaction","transactionBytes","transaction","signedTransactionHex","_context12","validateKey","getOrCreateKeypair","VersionedTransaction","deserialize","sign","serialize","onSignMessage","_x20","_x21","_x22","_onSignMessage","_callee13","serializedMessage","messageWrapper","messageToSign","messageType","messageBytes","signatureHex","signature","_context13","encode","secretKey","onClearEmbeddedPrivateKey","_x23","_x24","_onClearEmbeddedPrivateKey","_callee14","_context14","onSetEmbeddedKeyOverride","_x25","_x26","_x27","_x28","_onSetEmbeddedKeyOverride","_callee15","keyJwk","_context15","rawP256PrivateKeyToJwk","onResetToDefaultEmbeddedKey","_x29","_createSolanaKeypair","_callee16","_context16","fromSeed","_x30","_rawP256PrivateKeyToJwk","_callee17","rawPrivateKeyBytes","pkcs8Prefix","pkcs8","cryptoKey","_context17","clearExpiredKey","now","addressesToRemove","_i","_Object$entries","_Object$entries$_i","_i2","_addressesToRemove","clearAllExpiredKeys","getKeyNotFoundErrorMessage","_x31","_getOrCreateKeypair","_callee18","_context18","initEventHandlers","messageEventListener","_messageEventListener","event","_t","_t3","_t4","_t5","_t6","_t7","_t8","_x37","initMessageEventListener","messageListenerController","AbortController","turnkeyInitController","addEventListener","preventDefault","_x32","_x33","_ref3","_x34","_ref4","_x35","injectWalletBtn","_ref5","_callee5","_context5","_x36","addDOMEventListeners","capture","signal","_ref6","_callee7","_event$ports","iframeMessagePort","_context7","ports","abort","onmessage","origin","_x38","ownKeys","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","getOwnPropertyDescriptors","defineProperties","_typeof","toPrimitive","String","_toPrimitive","_toPropertyKey","TURNKEY_HPKE_INFO","_HpkeDecrypt","kemContext","receiverPriv","suite","recipientCtx","aad","res","DhkemP256HkdfSha256","CipherSuite","kem","kdf","HkdfSha256","aead","Aes256Gcm","createRecipientContext","recipientKey","enc","info","open","styleSettings","module","exports","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","id","loaded","__webpack_modules__","O","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","every","splice","getter","__esModule","obj","mode","this","ns","def","current","getOwnPropertyNames","definition","get","chunkId","all","reduce","promises","miniCssF","g","Function","prop","url","script","needAttach","scripts","getElementsByTagName","getAttribute","charset","nc","setAttribute","src","crossOrigin","integrity","sriHashes","onScriptComplete","prev","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","target","head","nmd","paths","children","installedChunks","installedChunkData","promise","reject","errorType","realSrc","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/export/index.template.html b/export/index.template.html index e9d2324..3fc8233 100644 --- a/export/index.template.html +++ b/export/index.template.html @@ -778,6 +778,7 @@

Message log

prod: "04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569", preprod: "04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212", + dev: "048cf9ed5f579298cc1571823a3222b82d80c529c551f6070fbe712ae1a9e8d1a23b7006e306d27190358dfcd9c44624918a00f23c920a33cb14f5b026eafc865d", }; const TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY = TURNKEY_SIGNERS_ENCLAVES["${TURNKEY_SIGNER_ENVIRONMENT}"]; diff --git a/import/dist/551.bundle.27da59437a4e403e3c24.js b/import/dist/551.bundle.27da59437a4e403e3c24.js deleted file mode 100644 index 42c6ce2..0000000 --- a/import/dist/551.bundle.27da59437a4e403e3c24.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! For license information please see 551.bundle.27da59437a4e403e3c24.js.LICENSE.txt */ -"use strict";(self.webpackChunkimport=self.webpackChunkimport||[]).push([[551],{275:(e,t,r)=>{r.d(t,{Di:()=>$,FZ:()=>A,MO:()=>_,P2:()=>T,Rx:()=>B,Sb:()=>G,Tn:()=>H,VU:()=>N,Wq:()=>F,Y$:()=>R,ZX:()=>M,Z_:()=>X,b6:()=>k,fX:()=>D,fw:()=>P,g8:()=>W,mt:()=>C,oc:()=>U,y3:()=>J});var n=r(343);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(){var e=f(),t=e.m(a),r=(Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__).constructor;function n(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===r||"GeneratorFunction"===(t.displayName||t.name))}var o={throw:1,return:2,break:3,continue:3};function p(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,o[e],t)},delegateYield:function(e,o,a){return t.resultName=o,r(n.d,i(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(a=function(){return{wrap:function(t,r,n,o){return e.w(p(t),r,n,o&&o.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new d(e,t)},AsyncIterator:s,async:function(e,t,r,o,a){return(n(t)?l:c)(p(e),t,r,o,a)},keys:u,values:i}})()}function i(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(o(e)+" is not iterable")}function u(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}}function c(e,t,r,n,o){var a=l(e,t,r,n,o);return a.next().then(function(e){return e.done?e.value:a.next()})}function l(e,t,r,n,o){return new s(f().w(e,t,r,n),o||Promise)}function s(e,t){function r(n,o,a,i){try{var u=e[n](o),c=u.value;return c instanceof d?t.resolve(c.v).then(function(e){r("next",e,a,i)},function(e){r("throw",e,a,i)}):t.resolve(c).then(function(e){u.value=e,a(u)},function(e){return r("throw",e,a,i)})}catch(e){i(e)}}var n;this.next||(p(s.prototype),p(s.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),p(this,"_invoke",function(e,o,a){function i(){return new t(function(t,n){r(e,a,t,n)})}return n=n?n.then(i,i):i()},!0)}function f(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return p(l,"_invoke",function(r,n,o){var a,u,c,l=0,s=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return a=t,u=0,c=e,p.n=r,i}};function d(r,n){for(u=r,c=n,t=0;!f&&l&&!o&&t3?(o=y===n)&&(c=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=r<2&&dn||n>y)&&(a[4]=r,a[5]=n,p.n=y,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,s,y){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,y),u=s,c=y;(t=u<2?e:c)||!f;){a||(u?u<3?(u>1&&(p.n=-1),d(u,c)):p.n=c:p.v=c);try{if(l=2,a){if(u||(o="next"),t=a[o]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=a.return)&&t.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=e}else if((t=(f=p.n<0)?c:r.call(n,p))!==i)break}catch(t){a=e,u=1,c=t}finally{l=1}}return{value:t,done:f}}}(r,o,a),!0),l}var i={};function u(){}function c(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(p(t={},n,function(){return this}),t),d=l.prototype=u.prototype=Object.create(s);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,p(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=l,p(d,"constructor",l),p(l,"constructor",c),c.displayName="GeneratorFunction",p(l,o,"GeneratorFunction"),p(d),p(d,o,"Generator"),p(d,n,function(){return this}),p(d,"toString",function(){return"[object Generator]"}),(f=function(){return{w:a,m:y}})()}function p(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}p=function(e,t,r,n){function a(t,r){p(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},p(e,t,r,n)}function d(e,t){this.v=e,this.k=t}function y(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){if(e){if("string"==typeof e)return v(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,t):void 0}}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r0){var n=new Uint8Array(r).fill(0);return new Uint8Array([].concat(y(n),y(e)))}if(r<0){for(var o=-1*r,a=0,i=0;i0;){var u=r[i];a=(u=void 0===u?a:58*u+a)>>8,r[i]=u%256,i++}}var c=n.concat(r.reverse());return new Uint8Array(c)}function H(e){return Y.apply(this,arguments)}function Y(){return(Y=m(a().mark(function e(t){var r,n,o,i,u,c,l,s,f;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!((r=B(t)).length<5)){e.next=3;break}throw new Error("invalid base58check length: expected at least 5 bytes, got ".concat(r.length));case 3:if(n=r.subarray(0,r.length-4),o=r.subarray(r.length-4),i=S()){e.next=8;break}throw new Error("WebCrypto subtle API is unavailable");case 8:return e.next=10,i.digest("SHA-256",n);case 10:return u=e.sent,c=new Uint8Array(u),e.next=14,i.digest("SHA-256",c);case 14:if(l=e.sent,s=new Uint8Array(l),f=s.subarray(0,4),0===(o[0]^f[0]|o[1]^f[1]|o[2]^f[2]|o[3]^f[3])){e.next=20;break}throw new Error("invalid base58check checksum");case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}},e)}))).apply(this,arguments)}function J(e,t){return L.apply(this,arguments)}function L(){return(L=m(a().mark(function e(t,r){var o,i,u,c,l,s,f,p,d,y,b,v,h;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=r,e.next="SOLANA"===e.t0?3:"HEXADECIMAL"===e.t0?7:"BITCOIN_MAINNET_WIF"===e.t0?10:"BITCOIN_TESTNET_WIF"===e.t0?22:"SUI_BECH32"===e.t0?34:45;break;case 3:if(64===(o=B(t)).length){e.next=6;break}throw new Error("invalid key length. Expected 64 bytes. Got ".concat(o.length,"."));case 6:return e.abrupt("return",o.subarray(0,32));case 7:if(!t.startsWith("0x")){e.next=9;break}return e.abrupt("return",F(t.slice(2)));case 9:case 48:return e.abrupt("return",F(t));case 10:return e.next=12,H(t);case 12:if(i=e.sent,u=i[0],c=i.subarray(1),128===u){e.next=17;break}throw new Error("invalid WIF version byte: ".concat(u,". Expected 0x80 (mainnet)."));case 17:if(32!==c.length){e.next=19;break}throw new Error("uncompressed WIF keys not supported");case 19:if(33===c.length&&1===c[32]){e.next=21;break}throw new Error("invalid WIF format: expected compressed private key");case 21:return e.abrupt("return",c.subarray(0,32));case 22:return e.next=24,H(t);case 24:if(l=e.sent,s=l[0],f=l.subarray(1),239===s){e.next=29;break}throw new Error("invalid WIF version byte: ".concat(s,". Expected 0xEF (testnet)."));case 29:if(32!==f.length){e.next=31;break}throw new Error("uncompressed WIF keys not supported");case 31:if(33===f.length&&1===f[32]){e.next=33;break}throw new Error("invalid WIF format: expected compressed private key");case 33:return e.abrupt("return",f.subarray(0,32));case 34:if(p=n.I.decode(t),d=p.prefix,y=p.words,"suiprivkey"===d){e.next=37;break}throw new Error('invalid SUI private key human-readable part (HRP): expected "suiprivkey"');case 37:if(33===(b=n.I.fromWords(y)).length){e.next=40;break}throw new Error("invalid SUI private key length: expected 33 bytes, got ".concat(b.length));case 40:if(v=b[0],h=b.slice(1),0===v){e.next=44;break}throw new Error("invalid SUI private key scheme flag: expected 0 (Ed25519). Turnkey only supports Ed25519 keys for SUI.");case 44:return e.abrupt("return",new Uint8Array(h));case 45:if(console.warn("invalid key format: ".concat(r,". Defaulting to HEXADECIMAL.")),!t.startsWith("0x")){e.next=48;break}return e.abrupt("return",F(t.slice(2)));case 49:case"end":return e.stop()}},e)}))).apply(this,arguments)}function X(e,t){var r={},n={padding:"^(\\d+(px|em|%|rem) ?){1,4}$",margin:"^(\\d+(px|em|%|rem) ?){1,4}$",borderWidth:"^(\\d+(px|em|rem) ?){1,4}$",borderStyle:"^(none|solid|dashed|dotted|double|groove|ridge|inset|outset)$",borderColor:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",borderRadius:"^(\\d+(px|em|%|rem) ?){1,4}$",fontSize:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax))$",fontWeight:"^(normal|bold|bolder|lighter|\\d{3})$",fontFamily:'^[^";<>]*$',color:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",labelColor:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",backgroundColor:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",width:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$",height:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$",maxWidth:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$",maxHeight:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$",lineHeight:"^(\\d+(\\.\\d+)?(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|normal)$",boxShadow:"^(none|(\\d+(px|em|rem) ?){2,4} (#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)) ?(inset)?)$",textAlign:"^(left|right|center|justify|initial|inherit)$",overflowWrap:"^(normal|break-word|anywhere)$",wordWrap:"^(normal|break-word)$",resize:"^(none|both|horizontal|vertical|block|inline)$"};return Object.entries(e).forEach(function(e){var t,o,a=(o=2,function(e){if(Array.isArray(e))return e}(t=e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,u=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(t,o)||b(t,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=a[0],u=a[1],c=i.trim();if(0===c.length)throw new Error("css style property cannot be empty");var l=n[c];if(!l)throw new Error('invalid or unsupported css style property: "'.concat(c,'"'));var s=new RegExp(l),f=u.trim();if(0==f.length)throw new Error('css style for "'.concat(c,'" is empty'));if(!s.test(f))throw new Error('invalid css style value for property "'.concat(c,'"'));r[c]=f}),r}},482:(e,t,r)=>{r.r(t),r.d(t,{additionalAssociatedData:()=>E,applySettings:()=>O,base58CheckDecode:()=>h,base58Decode:()=>v,decodeKey:()=>m,fromDerSignature:()=>x,getSettings:()=>f,getTargetEmbeddedKey:()=>c,loadTargetKey:()=>u,normalizePadding:()=>g,resetTargetEmbeddedKey:()=>s,sendMessageUp:()=>d,setCryptoProvider:()=>i,setParentFrameMessageChannelPort:()=>w,setSettings:()=>p,setTargetEmbeddedKey:()=>l,uint8arrayFromHexString:()=>y,uint8arrayToHexString:()=>b,validateStyles:()=>k,verifyEnclaveSignature:()=>S});var n=r(275);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,u=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{r.d(t,{q:()=>g});var n=r(275),o=r(255);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(){var e=p(),t=e.m(i),r=(Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__).constructor;function n(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===r||"GeneratorFunction"===(t.displayName||t.name))}var o={throw:1,return:2,break:3,continue:3};function a(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,o[e],t)},delegateYield:function(e,o,a){return t.resultName=o,r(n.d,u(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(i=function(){return{wrap:function(t,r,n,o){return e.w(a(t),r,n,o&&o.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new y(e,t)},AsyncIterator:f,async:function(e,t,r,o,i){return(n(t)?s:l)(a(e),t,r,o,i)},keys:c,values:u}})()}function u(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(a(e)+" is not iterable")}function c(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}}function l(e,t,r,n,o){var a=s(e,t,r,n,o);return a.next().then(function(e){return e.done?e.value:a.next()})}function s(e,t,r,n,o){return new f(p().w(e,t,r,n),o||Promise)}function f(e,t){function r(n,o,a,i){try{var u=e[n](o),c=u.value;return c instanceof y?t.resolve(c.v).then(function(e){r("next",e,a,i)},function(e){r("throw",e,a,i)}):t.resolve(c).then(function(e){u.value=e,a(u)},function(e){return r("throw",e,a,i)})}catch(e){i(e)}}var n;this.next||(d(f.prototype),d(f.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),d(this,"_invoke",function(e,o,a){function i(){return new t(function(t,n){r(e,a,t,n)})}return n=n?n.then(i,i):i()},!0)}function p(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return d(l,"_invoke",function(r,n,o){var a,u,c,l=0,s=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return a=t,u=0,c=e,p.n=r,i}};function d(r,n){for(u=r,c=n,t=0;!f&&l&&!o&&t3?(o=y===n)&&(c=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=r<2&&dn||n>y)&&(a[4]=r,a[5]=n,p.n=y,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,s,y){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,y),u=s,c=y;(t=u<2?e:c)||!f;){a||(u?u<3?(u>1&&(p.n=-1),d(u,c)):p.n=c:p.v=c);try{if(l=2,a){if(u||(o="next"),t=a[o]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=a.return)&&t.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=e}else if((t=(f=p.n<0)?c:r.call(n,p))!==i)break}catch(t){a=e,u=1,c=t}finally{l=1}}return{value:t,done:f}}}(r,o,a),!0),l}var i={};function u(){}function c(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(d(t={},n,function(){return this}),t),f=l.prototype=u.prototype=Object.create(s);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,d(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=l,d(f,"constructor",l),d(l,"constructor",c),c.displayName="GeneratorFunction",d(l,o,"GeneratorFunction"),d(f),d(f,o,"Generator"),d(f,n,function(){return this}),d(f,"toString",function(){return"[object Generator]"}),(p=function(){return{w:a,m:y}})()}function d(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}d=function(e,t,r,n){function a(t,r){d(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},d(e,t,r,n)}function y(e,t){this.v=e,this.k=t}function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t 1;\n } else {\n return window.parent !== window.top;\n }\n}\n\n/*\n * Loads the quorum public key as a CryptoKey.\n */\nasync function loadQuorumKey(quorumPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.importKey(\n \"raw\",\n quorumPublic,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n [\"verify\"]\n );\n}\n\n/*\n * Load a key to encrypt to as a CryptoKey and return it as a JSON Web Key.\n */\nasync function loadTargetKey(targetPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const targetKey = await subtle.importKey(\n \"raw\",\n targetPublic,\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n\n return await subtle.exportKey(\"jwk\", targetKey);\n}\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n */\nasync function initEmbeddedKey() {\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n const retrievedKey = await getEmbeddedKey();\n if (retrievedKey === null) {\n const targetKey = await generateTargetKey();\n setEmbeddedKey(targetKey);\n }\n // Nothing to do, key is correctly initialized!\n}\n\n/*\n * Generate a key to encrypt to and export it as a JSON Web Key.\n */\nasync function generateTargetKey() {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const p256key = await subtle.generateKey(\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n [\"deriveBits\"]\n );\n\n return await subtle.exportKey(\"jwk\", p256key.privateKey);\n}\n\n/**\n * Gets the current embedded private key JWK. Returns `null` if not found.\n */\nfunction getEmbeddedKey() {\n const jwtKey = getItemWithExpiry(TURNKEY_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the embedded private key JWK with the default expiration time.\n * @param {JsonWebKey} targetKey\n */\nfunction setEmbeddedKey(targetKey) {\n setItemWithExpiry(\n TURNKEY_EMBEDDED_KEY,\n JSON.stringify(targetKey),\n TURNKEY_EMBEDDED_KEY_TTL_IN_MILLIS\n );\n}\n\n/**\n * Gets the current target embedded private key JWK. Returns `null` if not found.\n */\nfunction getTargetEmbeddedKey() {\n const jwtKey = window.localStorage.getItem(TURNKEY_TARGET_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the target embedded public key JWK.\n * @param {JsonWebKey} targetKey\n */\nfunction setTargetEmbeddedKey(targetKey) {\n window.localStorage.setItem(\n TURNKEY_TARGET_EMBEDDED_KEY,\n JSON.stringify(targetKey)\n );\n}\n\n/**\n * Resets the current embedded private key JWK.\n */\nfunction onResetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY);\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY_ORIGIN);\n}\n\n/**\n * Resets the current target embedded private key JWK.\n */\nfunction resetTargetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_TARGET_EMBEDDED_KEY);\n}\n\nfunction setParentFrameMessageChannelPort(port) {\n parentFrameMessageChannelPort = port;\n}\n\n/**\n * Gets the current settings.\n */\nfunction getSettings() {\n const settings = window.localStorage.getItem(TURNKEY_SETTINGS);\n return settings ? JSON.parse(settings) : null;\n}\n\n/**\n * Sets the settings object.\n * @param {Object} settings\n */\nfunction setSettings(settings) {\n window.localStorage.setItem(TURNKEY_SETTINGS, JSON.stringify(settings));\n}\n\n/**\n * Set an item in localStorage with an expiration time\n * @param {string} key\n * @param {string} value\n * @param {number} ttl expiration time in milliseconds\n */\nfunction setItemWithExpiry(key, value, ttl) {\n const now = new Date();\n const item = {\n value: value,\n expiry: now.getTime() + ttl,\n };\n window.localStorage.setItem(key, JSON.stringify(item));\n}\n\n/**\n * Get an item from localStorage. Returns `null` and\n * removes the item from localStorage if expired or\n * expiry time is missing.\n * @param {string} key\n */\nfunction getItemWithExpiry(key) {\n const itemStr = window.localStorage.getItem(key);\n if (!itemStr) {\n return null;\n }\n const item = JSON.parse(itemStr);\n if (\n !Object.prototype.hasOwnProperty.call(item, \"expiry\") ||\n !Object.prototype.hasOwnProperty.call(item, \"value\")\n ) {\n window.localStorage.removeItem(key);\n return null;\n }\n const now = new Date();\n if (now.getTime() > item.expiry) {\n window.localStorage.removeItem(key);\n return null;\n }\n return item.value;\n}\n\n/**\n * Takes a hex string (e.g. \"e4567ab\" or \"0xe4567ab\") and returns an array buffer (Uint8Array)\n * @param {string} hexString - Hex string with or without \"0x\" prefix\n * @returns {Uint8Array}\n */\nfunction uint8arrayFromHexString(hexString) {\n if (!hexString || typeof hexString !== \"string\") {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n\n // Remove 0x prefix if present\n const hexWithoutPrefix =\n hexString.startsWith(\"0x\") || hexString.startsWith(\"0X\")\n ? hexString.slice(2)\n : hexString;\n\n var hexRegex = /^[0-9A-Fa-f]+$/;\n if (hexWithoutPrefix.length % 2 != 0 || !hexRegex.test(hexWithoutPrefix)) {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n return new Uint8Array(\n hexWithoutPrefix.match(/../g).map((h) => parseInt(h, 16))\n );\n}\n\n/**\n * Takes a Uint8Array and returns a hex string\n * @param {Uint8Array} buffer\n * @return {string}\n */\nfunction uint8arrayToHexString(buffer) {\n return [...buffer].map((x) => x.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Function to normalize padding of byte array with 0's to a target length\n */\nfunction normalizePadding(byteArray, targetLength) {\n const paddingLength = targetLength - byteArray.length;\n\n // Add leading 0's to array\n if (paddingLength > 0) {\n const padding = new Uint8Array(paddingLength).fill(0);\n return new Uint8Array([...padding, ...byteArray]);\n }\n\n // Remove leading 0's from array\n if (paddingLength < 0) {\n const expectedZeroCount = paddingLength * -1;\n let zeroCount = 0;\n for (let i = 0; i < expectedZeroCount && i < byteArray.length; i++) {\n if (byteArray[i] === 0) {\n zeroCount++;\n }\n }\n // Check if the number of zeros found equals the number of zeroes expected\n if (zeroCount !== expectedZeroCount) {\n throw new Error(\n `invalid number of starting zeroes. Expected number of zeroes: ${expectedZeroCount}. Found: ${zeroCount}.`\n );\n }\n return byteArray.slice(expectedZeroCount, expectedZeroCount + targetLength);\n }\n return byteArray;\n}\n\n/**\n * Additional Associated Data (AAD) in the format dictated by the enclave_encrypt crate.\n */\nfunction additionalAssociatedData(senderPubBuf, receiverPubBuf) {\n const s = Array.from(new Uint8Array(senderPubBuf));\n const r = Array.from(new Uint8Array(receiverPubBuf));\n return new Uint8Array([...s, ...r]);\n}\n\n/**\n * Converts an ASN.1 DER-encoded ECDSA signature to the raw format that WebCrypto uses.\n */\nfunction fromDerSignature(derSignature) {\n const derSignatureBuf = uint8arrayFromHexString(derSignature);\n\n // Check and skip the sequence tag (0x30)\n let index = 2;\n\n // Parse 'r' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for r\"\n );\n }\n index++; // Move past the INTEGER tag\n const rLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const r = derSignatureBuf.slice(index, index + rLength);\n index += rLength; // Move to the start of s\n\n // Parse 's' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for s\"\n );\n }\n index++; // Move past the INTEGER tag\n const sLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const s = derSignatureBuf.slice(index, index + sLength);\n\n // Normalize 'r' and 's' to 32 bytes each\n const rPadded = normalizePadding(r, 32);\n const sPadded = normalizePadding(s, 32);\n\n // Concatenate and return the raw signature\n return new Uint8Array([...rPadded, ...sPadded]);\n}\n\n/**\n * Function to verify enclave signature on import bundle received from the server.\n * @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature\n * @param {string} publicSignature signature bytes encoded as a hexadecimal string\n * @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes\n */\nasync function verifyEnclaveSignature(\n enclaveQuorumPublic,\n publicSignature,\n signedData\n) {\n /** Turnkey Signer enclave's public keys */\n const TURNKEY_SIGNERS_ENCLAVES = {\n prod: \"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\",\n preprod:\n \"04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212\",\n };\n\n // Use window.__TURNKEY_SIGNER_ENVIRONMENT__ if available (for testing), otherwise use the webpack replacement\n const environment =\n (typeof window !== \"undefined\" && window.__TURNKEY_SIGNER_ENVIRONMENT__) ||\n \"__TURNKEY_SIGNER_ENVIRONMENT__\";\n const TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY =\n TURNKEY_SIGNERS_ENCLAVES[environment];\n\n if (TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY === undefined) {\n throw new Error(\n `Configuration error: TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY is undefined`\n );\n }\n\n // todo(olivia): throw error if enclave quorum public is null once server changes are deployed\n if (enclaveQuorumPublic) {\n if (enclaveQuorumPublic !== TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY) {\n throw new Error(\n `enclave quorum public keys from client and bundle do not match. Client: ${TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY}. Bundle: ${enclaveQuorumPublic}.`\n );\n }\n }\n\n const encryptionQuorumPublicBuf = new Uint8Array(\n uint8arrayFromHexString(TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY)\n );\n const quorumKey = await loadQuorumKey(encryptionQuorumPublicBuf);\n if (!quorumKey) {\n throw new Error(\"failed to load quorum key\");\n }\n\n // The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format\n const publicSignatureBuf = fromDerSignature(publicSignature);\n const signedDataBuf = uint8arrayFromHexString(signedData);\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.verify(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n quorumKey,\n publicSignatureBuf,\n signedDataBuf\n );\n}\n\n/**\n * Function to send a message.\n *\n * If this page is embedded as an iframe we'll send a postMessage\n * in one of two ways depending on the version of @turnkey/iframe-stamper:\n * 1. newer versions (>=v2.1.0) pass a MessageChannel MessagePort from the parent frame for postMessages.\n * 2. older versions ( 0) {\n digits.push(carry % 58);\n carry = (carry / 58) | 0;\n }\n }\n // Convert digits to a base58 string\n for (let k = 0; k < digits.length; k++) {\n result = alphabet[digits[k]] + result;\n }\n\n // Add '1' for each leading 0 byte\n for (let i = 0; bytes[i] === 0 && i < bytes.length - 1; i++) {\n result = \"1\" + result;\n }\n return result;\n}\n\n/**\n * Decodes a base58-encoded string into a buffer\n * This function throws an error when the string contains invalid characters.\n * @param {string} s The base58-encoded string.\n * @return {Uint8Array} The decoded buffer.\n */\nfunction base58Decode(s) {\n // See https://en.bitcoin.it/wiki/Base58Check_encoding\n var alphabet = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n var decodedBytes = [];\n var leadingZeros = [];\n for (var i = 0; i < s.length; i++) {\n if (alphabet.indexOf(s[i]) === -1) {\n throw new Error(`cannot base58-decode: ${s[i]} isn't a valid character`);\n }\n var carry = alphabet.indexOf(s[i]);\n\n // If the current base58 digit is 0, append a 0 byte.\n // \"i == leadingZeros.length\" can only be true if we have not seen non-zero bytes so far.\n // If we had seen a non-zero byte, carry wouldn't be 0, and i would be strictly more than `leadingZeros.length`\n if (carry == 0 && i === leadingZeros.length) {\n leadingZeros.push(0);\n }\n\n var j = 0;\n while (j < decodedBytes.length || carry > 0) {\n var currentByte = decodedBytes[j];\n\n // shift the current byte 58 units and add the carry amount\n // (or just add the carry amount if this is a new byte -- undefined case)\n if (currentByte === undefined) {\n currentByte = carry;\n } else {\n currentByte = currentByte * 58 + carry;\n }\n\n // find the new carry amount (1-byte shift of current byte value)\n carry = currentByte >> 8;\n // reset the current byte to the remainder (the carry amount will pass on the overflow)\n decodedBytes[j] = currentByte % 256;\n j++;\n }\n }\n\n var result = leadingZeros.concat(decodedBytes.reverse());\n return new Uint8Array(result);\n}\n\n/**\n * Decodes a base58check-encoded string and verifies the checksum.\n * Base58Check encoding includes a 4-byte checksum at the end to detect errors.\n * The checksum is the first 4 bytes of SHA256(SHA256(payload)).\n * This function throws an error if the checksum is invalid.\n * @param {string} s The base58check-encoded string.\n * @return {Promise} The decoded payload (without checksum).\n */\nasync function base58CheckDecode(s) {\n const decoded = base58Decode(s);\n\n if (decoded.length < 5) {\n throw new Error(\n `invalid base58check length: expected at least 5 bytes, got ${decoded.length}`\n );\n }\n\n const payload = decoded.subarray(0, decoded.length - 4);\n const checksum = decoded.subarray(decoded.length - 4);\n\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n\n // Compute double SHA256 hash\n const hash1Buf = await subtle.digest(\"SHA-256\", payload);\n const hash1 = new Uint8Array(hash1Buf);\n const hash2Buf = await subtle.digest(\"SHA-256\", hash1);\n const hash2 = new Uint8Array(hash2Buf);\n const computedChecksum = hash2.subarray(0, 4);\n\n // Verify checksum\n const mismatch =\n (checksum[0] ^ computedChecksum[0]) |\n (checksum[1] ^ computedChecksum[1]) |\n (checksum[2] ^ computedChecksum[2]) |\n (checksum[3] ^ computedChecksum[3]);\n if (mismatch !== 0) {\n throw new Error(\"invalid base58check checksum\");\n }\n\n return payload;\n}\n\n/**\n * Returns private key bytes from a private key, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {string} privateKey\n * @param {string} keyFormat Can be \"HEXADECIMAL\", \"SUI_BECH32\", \"BITCOIN_MAINNET_WIF\", \"BITCOIN_TESTNET_WIF\" or \"SOLANA\"\n * @return {Promise}\n */\nasync function decodeKey(privateKey, keyFormat) {\n switch (keyFormat) {\n case \"SOLANA\": {\n const decodedKeyBytes = base58Decode(privateKey);\n if (decodedKeyBytes.length !== 64) {\n throw new Error(\n `invalid key length. Expected 64 bytes. Got ${decodedKeyBytes.length}.`\n );\n }\n return decodedKeyBytes.subarray(0, 32);\n }\n case \"HEXADECIMAL\":\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n case \"BITCOIN_MAINNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0x80 = mainnet\n if (version !== 0x80) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0x80 (mainnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"BITCOIN_TESTNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0xEF = testnet\n if (version !== 0xef) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0xEF (testnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"SUI_BECH32\": {\n const { prefix, words } = bech32.decode(privateKey);\n\n if (prefix !== \"suiprivkey\") {\n throw new Error(\n `invalid SUI private key human-readable part (HRP): expected \"suiprivkey\"`\n );\n }\n\n const bytes = bech32.fromWords(words);\n if (bytes.length !== 33) {\n throw new Error(\n `invalid SUI private key length: expected 33 bytes, got ${bytes.length}`\n );\n }\n\n const schemeFlag = bytes[0];\n const privkey = bytes.slice(1);\n\n // schemeFlag = 0 is Ed25519; We currently only support Ed25519 keys for SUI.\n if (schemeFlag !== 0) {\n throw new Error(\n `invalid SUI private key scheme flag: expected 0 (Ed25519). Turnkey only supports Ed25519 keys for SUI.`\n );\n }\n\n return new Uint8Array(privkey);\n }\n default:\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n }\n}\n\n/**\n * Returns a private key from private key bytes, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {Uint8Array} privateKeyBytes\n * @param {string} keyFormat Can be \"HEXADECIMAL\" or \"SOLANA\"\n */\nasync function encodeKey(privateKeyBytes, keyFormat, publicKeyBytes) {\n switch (keyFormat) {\n case \"SOLANA\":\n if (!publicKeyBytes) {\n throw new Error(\"public key must be specified for SOLANA key format\");\n }\n if (privateKeyBytes.length !== 32) {\n throw new Error(\n `invalid private key length. Expected 32 bytes. Got ${privateKeyBytes.length}.`\n );\n }\n if (publicKeyBytes.length !== 32) {\n throw new Error(\n `invalid public key length. Expected 32 bytes. Got ${publicKeyBytes.length}.`\n );\n }\n {\n const concatenatedBytes = new Uint8Array(64);\n concatenatedBytes.set(privateKeyBytes, 0);\n concatenatedBytes.set(publicKeyBytes, 32);\n return base58Encode(concatenatedBytes);\n }\n case \"HEXADECIMAL\":\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n default:\n // keeping console.warn for debugging purposes.\n // eslint-disable-next-line no-console\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n }\n}\n\n// Helper to parse a private key into a Solana base58 private key.\n// To be used if a wallet account is exported without the `SOLANA` address format.\nfunction parsePrivateKey(privateKey) {\n if (Array.isArray(privateKey)) {\n return new Uint8Array(privateKey);\n }\n\n if (typeof privateKey === \"string\") {\n // Remove 0x prefix if present\n if (privateKey.startsWith(\"0x\")) {\n privateKey = privateKey.slice(2);\n }\n\n // Check if it's hex-formatted correctly (i.e. 64 hex chars)\n if (privateKey.length === 64 && /^[0-9a-fA-F]+$/.test(privateKey)) {\n return uint8arrayFromHexString(privateKey);\n }\n\n // Otherwise assume it's base58 format (for Solana)\n try {\n return base58Decode(privateKey);\n } catch (error) {\n throw new Error(\n \"Invalid private key format. Use hex (64 chars) or base58 format.\"\n );\n }\n }\n\n throw new Error(\"Private key must be a string (hex/base58) or number array\");\n}\n\n/**\n * Function to validate and sanitize the styles object using the accepted map of style keys and values (as regular expressions).\n * Any invalid style throws an error. Returns an object of valid styles.\n * @param {Object} styles\n * @param {HTMLElement} element - Optional element parameter (for import frame)\n * @return {Object}\n */\nfunction validateStyles(styles, element) {\n const validStyles = {};\n\n const cssValidationRegex = {\n padding: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n margin: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n borderWidth: \"^(\\\\d+(px|em|rem) ?){1,4}$\",\n borderStyle:\n \"^(none|solid|dashed|dotted|double|groove|ridge|inset|outset)$\",\n borderColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n borderRadius: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n fontSize: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax))$\",\n fontWeight: \"^(normal|bold|bolder|lighter|\\\\d{3})$\",\n fontFamily: '^[^\";<>]*$', // checks for the absence of some characters that could lead to CSS/HTML injection\n color:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n labelColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n backgroundColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n width: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n height: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n maxWidth: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n maxHeight:\n \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n lineHeight:\n \"^(\\\\d+(\\\\.\\\\d+)?(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|normal)$\",\n boxShadow:\n \"^(none|(\\\\d+(px|em|rem) ?){2,4} (#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)) ?(inset)?)$\",\n textAlign: \"^(left|right|center|justify|initial|inherit)$\",\n overflowWrap: \"^(normal|break-word|anywhere)$\",\n wordWrap: \"^(normal|break-word)$\",\n resize: \"^(none|both|horizontal|vertical|block|inline)$\",\n };\n\n Object.entries(styles).forEach(([property, value]) => {\n const styleProperty = property.trim();\n if (styleProperty.length === 0) {\n throw new Error(\"css style property cannot be empty\");\n }\n const styleRegexStr = cssValidationRegex[styleProperty];\n if (!styleRegexStr) {\n throw new Error(\n `invalid or unsupported css style property: \"${styleProperty}\"`\n );\n }\n const styleRegex = new RegExp(styleRegexStr);\n const styleValue = value.trim();\n if (styleValue.length == 0) {\n throw new Error(`css style for \"${styleProperty}\" is empty`);\n }\n const isValidStyle = styleRegex.test(styleValue);\n if (!isValidStyle) {\n throw new Error(\n `invalid css style value for property \"${styleProperty}\"`\n );\n }\n validStyles[styleProperty] = styleValue;\n });\n\n return validStyles;\n}\n\n// Export all shared functions\nexport {\n setCryptoProvider,\n getSubtleCrypto,\n isDoublyIframed,\n loadQuorumKey,\n loadTargetKey,\n initEmbeddedKey,\n generateTargetKey,\n getEmbeddedKey,\n setEmbeddedKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n onResetEmbeddedKey,\n resetTargetEmbeddedKey,\n setParentFrameMessageChannelPort,\n getSettings,\n setSettings,\n setItemWithExpiry,\n getItemWithExpiry,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n normalizePadding,\n additionalAssociatedData,\n fromDerSignature,\n verifyEnclaveSignature,\n sendMessageUp,\n logMessage,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n encodeKey,\n parsePrivateKey,\n validateStyles,\n};\n","import * as SharedTKHQ from \"@shared/turnkey-core.js\";\n\nconst {\n setCryptoProvider,\n loadTargetKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n resetTargetEmbeddedKey,\n getSettings,\n setSettings,\n sendMessageUp,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n setParentFrameMessageChannelPort,\n normalizePadding,\n fromDerSignature,\n additionalAssociatedData,\n verifyEnclaveSignature,\n validateStyles,\n} = SharedTKHQ;\n\n/**\n * Function to apply settings on this page. For now, the only settings that can be applied\n * are for \"styles\". Upon successful application, return the valid, sanitized settings JSON string.\n * @param {string} settings\n * @return {string}\n */\nfunction applySettings(settings) {\n const validSettings = {};\n const settingsObj = JSON.parse(settings);\n\n const passphraseLabel = document.getElementById(\"passphrase-label\");\n const mnemonicLabel = document.getElementById(\"mnemonic-label\");\n const passphraseTextarea = document.getElementById(\"passphrase\");\n\n if (!passphraseLabel || !passphraseTextarea) {\n throw new Error(\"no passphrase HTML elements found to apply settings to.\");\n }\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) {\n throw new Error(\n \"no plaintext textarea HTML element found to apply settings to.\"\n );\n }\n\n // Apply enablePassphrase setting\n if (settingsObj.enablePassphrase === true) {\n passphraseLabel.style.display = \"inline-block\";\n passphraseTextarea.style.display = \"inline-block\";\n passphraseTextarea.style.border = \"solid 1px #ccc\";\n passphraseTextarea.style.borderRadius = \"4px\";\n\n mnemonicLabel.style.display = \"inline-block\";\n plaintextTextarea.style.border = \"solid 1px #ccc\";\n plaintextTextarea.style.borderRadius = \"4px\";\n\n validSettings[\"enablePassphrase\"] = true;\n } else {\n passphraseLabel.style.display = \"none\";\n passphraseTextarea.style.display = \"none\";\n mnemonicLabel.style.display = \"none\";\n\n plaintextTextarea.style.border = \"none\";\n validSettings[\"enablePassphrase\"] = false;\n }\n\n if (settingsObj.styles) {\n // Validate, sanitize, and apply the styles to the \"plaintext\" textarea.\n const validStyles = validateStyles(settingsObj.styles);\n Object.entries(validStyles).forEach(([key, value]) => {\n plaintextTextarea.style[key] = value;\n });\n\n if (validStyles.backgroundColor) {\n // Apply background color to document and body as well.\n document.documentElement.style.backgroundColor =\n validStyles.backgroundColor;\n document.body.style.backgroundColor = validStyles.backgroundColor;\n }\n\n if (validStyles.labelColor) {\n document.getElementById(\"mnemonic-label\").style.color =\n validStyles.labelColor;\n }\n\n validSettings[\"styles\"] = validStyles;\n }\n\n if (settingsObj.passphraseStyles) {\n // Validate, sanitize, and apply the styles to the \"passphrase\" textarea.\n const validStyles = validateStyles(settingsObj.passphraseStyles);\n Object.entries(validStyles).forEach(([key, value]) => {\n passphraseTextarea.style[key] = value;\n });\n\n if (validStyles.labelColor) {\n document.getElementById(\"passphrase-label\").style.color =\n validStyles.labelColor;\n }\n\n validSettings[\"passphraseStyles\"] = validStyles;\n }\n\n return JSON.stringify(validSettings);\n}\n\nexport {\n setCryptoProvider,\n loadTargetKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n resetTargetEmbeddedKey,\n getSettings,\n setSettings,\n sendMessageUp,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n setParentFrameMessageChannelPort,\n normalizePadding,\n fromDerSignature,\n additionalAssociatedData,\n verifyEnclaveSignature,\n validateStyles,\n applySettings,\n};\n","/**\n * Crypto Utilities - Shared\n * Contains HPKE encryption and decryption functions\n */\n\nimport {\n p256JWKPrivateToPublic,\n additionalAssociatedData,\n uint8arrayToHexString,\n} from \"./turnkey-core.js\";\nimport {\n CipherSuite,\n DhkemP256HkdfSha256,\n HkdfSha256,\n Aes256Gcm,\n} from \"@hpke/core\";\n\n// Pre-compute const (for perf)\nconst TURNKEY_HPKE_INFO = new TextEncoder().encode(\"turnkey_hpke\");\n\n/**\n * Decrypt the ciphertext (ArrayBuffer) given an encapsulation key (ArrayBuffer)\n * and the receivers private key (JSON Web Key).\n */\nexport async function HpkeDecrypt({\n ciphertextBuf,\n encappedKeyBuf,\n receiverPrivJwk,\n}) {\n const kemContext = new DhkemP256HkdfSha256();\n var receiverPriv = await kemContext.importKey(\n \"jwk\",\n { ...receiverPrivJwk },\n false\n );\n\n var suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n var recipientCtx = await suite.createRecipientContext({\n recipientKey: receiverPriv,\n enc: encappedKeyBuf,\n info: TURNKEY_HPKE_INFO,\n });\n\n var receiverPubBuf = await p256JWKPrivateToPublic(receiverPrivJwk);\n var aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n var res;\n try {\n res = await recipientCtx.open(ciphertextBuf, aad);\n } catch (e) {\n throw new Error(\n \"unable to decrypt bundle using embedded key. the bundle may be incorrect. failed with error: \" +\n e.toString()\n );\n }\n return res;\n}\n\n/**\n * Encrypt plaintext using HPKE with the receiver's public key.\n * @param {Object} params\n * @param {Uint8Array} params.plaintextBuf - Plaintext to encrypt\n * @param {JsonWebKey} params.receiverPubJwk - Receiver's public key in JWK format\n * @returns {Promise} JSON stringified encrypted bundle with encappedPublic and ciphertext\n */\nexport async function HpkeEncrypt({ plaintextBuf, receiverPubJwk }) {\n const kemContext = new DhkemP256HkdfSha256();\n const receiverPub = await kemContext.importKey(\n \"jwk\",\n { ...receiverPubJwk },\n true\n );\n\n const suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n const senderCtx = await suite.createSenderContext({\n recipientPublicKey: receiverPub,\n info: TURNKEY_HPKE_INFO,\n });\n\n // Need to import the key again as a JWK to export as a raw key, the format needed to\n // create the aad with the newly generated raw encapped key.\n const receiverPubCryptoKey = await crypto.subtle.importKey(\n \"jwk\",\n receiverPubJwk,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n const receiverPubRaw = await crypto.subtle.exportKey(\n \"raw\",\n receiverPubCryptoKey\n );\n const receiverPubBuf = new Uint8Array(receiverPubRaw);\n\n const encappedKeyBuf = new Uint8Array(senderCtx.enc);\n\n const aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n\n var ciphertextBuf;\n try {\n ciphertextBuf = await senderCtx.seal(plaintextBuf, aad);\n } catch (e) {\n throw new Error(\"failed to encrypt import bundle: \" + e.toString());\n }\n\n const ciphertextHex = uint8arrayToHexString(new Uint8Array(ciphertextBuf));\n const encappedKeyBufHex = uint8arrayToHexString(encappedKeyBuf);\n const encryptedBundle = JSON.stringify({\n encappedPublic: encappedKeyBufHex,\n ciphertext: ciphertextHex,\n });\n return encryptedBundle;\n}\n"],"names":["e","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","_regenerator","w","m","defineProperty","_invoke","enumerable","configurable","writable","_OverloadYield","k","_toConsumableArray","Array","isArray","_arrayLikeToArray","_arrayWithoutHoles","from","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","toString","slice","constructor","name","test","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","TURNKEY_TARGET_EMBEDDED_KEY","TURNKEY_SETTINGS","parentFrameMessageChannelPort","cryptoProviderOverride","getSubtleCrypto","subtle","globalThis","crypto","window","global","setCryptoProvider","cryptoProvider","loadQuorumKey","_x","_loadQuorumKey","_regeneratorRuntime","mark","_callee","quorumPublic","wrap","_context","prev","next","Error","importKey","namedCurve","abrupt","sent","stop","loadTargetKey","_x2","_loadTargetKey","_callee2","targetPublic","targetKey","_context2","exportKey","getTargetEmbeddedKey","jwtKey","localStorage","getItem","JSON","parse","setTargetEmbeddedKey","setItem","stringify","resetTargetEmbeddedKey","removeItem","setParentFrameMessageChannelPort","port","getSettings","settings","setSettings","uint8arrayFromHexString","hexString","hexWithoutPrefix","startsWith","Uint8Array","match","map","h","parseInt","uint8arrayToHexString","buffer","x","padStart","join","normalizePadding","byteArray","targetLength","paddingLength","padding","fill","concat","expectedZeroCount","zeroCount","additionalAssociatedData","senderPubBuf","receiverPubBuf","s","fromDerSignature","derSignature","derSignatureBuf","index","rLength","sLength","rPadded","sPadded","verifyEnclaveSignature","_x3","_x4","_x5","_verifyEnclaveSignature","_callee5","enclaveQuorumPublic","publicSignature","signedData","TURNKEY_SIGNERS_ENCLAVES","environment","TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY","encryptionQuorumPublicBuf","quorumKey","publicSignatureBuf","signedDataBuf","_context5","prod","preprod","__TURNKEY_SIGNER_ENVIRONMENT__","undefined","verify","hash","sendMessageUp","type","requestId","message","postMessage","parent","content","messageLog","document","getElementById","createElement","innerText","appendChild","logMessage","base58Decode","alphabet","decodedBytes","leadingZeros","indexOf","carry","push","j","currentByte","result","reverse","base58CheckDecode","_x7","_base58CheckDecode","_callee7","decoded","payload","checksum","hash1Buf","hash1","hash2Buf","hash2","computedChecksum","_context7","subarray","digest","decodeKey","_x8","_x9","_decodeKey","_callee8","privateKey","keyFormat","decodedKeyBytes","version","keyAndFlags","_payload","_version","_keyAndFlags","_bech32$decode","prefix","words","bytes","schemeFlag","privkey","_context8","t0","bech32","decode","fromWords","console","warn","validateStyles","styles","element","validStyles","cssValidationRegex","margin","borderWidth","borderStyle","borderColor","borderRadius","fontSize","fontWeight","fontFamily","color","labelColor","backgroundColor","width","height","maxWidth","maxHeight","lineHeight","boxShadow","textAlign","overflowWrap","wordWrap","resize","entries","forEach","_ref","_ref2","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","property","styleProperty","trim","styleRegexStr","styleRegex","RegExp","styleValue","SharedTKHQ","applySettings","validSettings","settingsObj","passphraseLabel","mnemonicLabel","passphraseTextarea","plaintextTextarea","enablePassphrase","style","display","border","_slicedToArray","key","documentElement","body","passphraseStyles","_ref3","_ref4","ownKeys","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","_objectSpread","_defineProperty","getOwnPropertyDescriptors","defineProperties","_typeof","toPrimitive","String","_toPrimitive","_toPropertyKey","TURNKEY_HPKE_INFO","TextEncoder","encode","HpkeEncrypt","_HpkeEncrypt","plaintextBuf","receiverPubJwk","kemContext","receiverPub","suite","senderCtx","receiverPubCryptoKey","receiverPubRaw","encappedKeyBuf","aad","ciphertextBuf","ciphertextHex","encappedKeyBufHex","encryptedBundle","DhkemP256HkdfSha256","CipherSuite","kem","kdf","HkdfSha256","aead","Aes256Gcm","createSenderContext","recipientPublicKey","info","enc","seal","encappedPublic","ciphertext"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/551.bundle.49402ee939a00be74d76.js b/import/dist/551.bundle.49402ee939a00be74d76.js new file mode 100644 index 0000000..b6d7a0e --- /dev/null +++ b/import/dist/551.bundle.49402ee939a00be74d76.js @@ -0,0 +1,3 @@ +/*! For license information please see 551.bundle.49402ee939a00be74d76.js.LICENSE.txt */ +"use strict";(self.webpackChunkimport=self.webpackChunkimport||[]).push([[551],{275:(e,t,r)=>{r.d(t,{Di:()=>$,FZ:()=>A,MO:()=>_,P2:()=>T,Rx:()=>B,Sb:()=>G,Tn:()=>H,VU:()=>N,Wq:()=>F,Y$:()=>R,ZX:()=>M,Z_:()=>X,b6:()=>k,fX:()=>D,fw:()=>P,g8:()=>W,mt:()=>C,oc:()=>U,y3:()=>J});var n=r(343);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(){var e=f(),t=e.m(a),r=(Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__).constructor;function n(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===r||"GeneratorFunction"===(t.displayName||t.name))}var o={throw:1,return:2,break:3,continue:3};function p(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,o[e],t)},delegateYield:function(e,o,a){return t.resultName=o,r(n.d,i(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(a=function(){return{wrap:function(t,r,n,o){return e.w(p(t),r,n,o&&o.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new d(e,t)},AsyncIterator:s,async:function(e,t,r,o,a){return(n(t)?l:u)(p(e),t,r,o,a)},keys:c,values:i}})()}function i(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(o(e)+" is not iterable")}function c(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}}function u(e,t,r,n,o){var a=l(e,t,r,n,o);return a.next().then(function(e){return e.done?e.value:a.next()})}function l(e,t,r,n,o){return new s(f().w(e,t,r,n),o||Promise)}function s(e,t){function r(n,o,a,i){try{var c=e[n](o),u=c.value;return u instanceof d?t.resolve(u.v).then(function(e){r("next",e,a,i)},function(e){r("throw",e,a,i)}):t.resolve(u).then(function(e){c.value=e,a(c)},function(e){return r("throw",e,a,i)})}catch(e){i(e)}}var n;this.next||(p(s.prototype),p(s.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),p(this,"_invoke",function(e,o,a){function i(){return new t(function(t,n){r(e,a,t,n)})}return n=n?n.then(i,i):i()},!0)}function f(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return p(l,"_invoke",function(r,n,o){var a,c,u,l=0,s=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return a=t,c=0,u=e,p.n=r,i}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t3?(o=y===n)&&(u=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=r<2&&dn||n>y)&&(a[4]=r,a[5]=n,p.n=y,c=0))}if(o||r>1)return i;throw f=!0,n}return function(o,s,y){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,y),c=s,u=y;(t=c<2?e:u)||!f;){a||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(l=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(f=p.n<0)?u:r.call(n,p))!==i)break}catch(t){a=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,a),!0),l}var i={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(p(t={},n,function(){return this}),t),d=l.prototype=c.prototype=Object.create(s);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,p(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,p(d,"constructor",l),p(l,"constructor",u),u.displayName="GeneratorFunction",p(l,o,"GeneratorFunction"),p(d),p(d,o,"Generator"),p(d,n,function(){return this}),p(d,"toString",function(){return"[object Generator]"}),(f=function(){return{w:a,m:y}})()}function p(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}p=function(e,t,r,n){function a(t,r){p(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},p(e,t,r,n)}function d(e,t){this.v=e,this.k=t}function y(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){if(e){if("string"==typeof e)return v(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,t):void 0}}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r0){var n=new Uint8Array(r).fill(0);return new Uint8Array([].concat(y(n),y(e)))}if(r<0){for(var o=-1*r,a=0,i=0;i0;){var c=r[i];a=(c=void 0===c?a:58*c+a)>>8,r[i]=c%256,i++}}var u=n.concat(r.reverse());return new Uint8Array(u)}function H(e){return Y.apply(this,arguments)}function Y(){return(Y=m(a().mark(function e(t){var r,n,o,i,c,u,l,s,f;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!((r=B(t)).length<5)){e.next=3;break}throw new Error("invalid base58check length: expected at least 5 bytes, got ".concat(r.length));case 3:if(n=r.subarray(0,r.length-4),o=r.subarray(r.length-4),i=S()){e.next=8;break}throw new Error("WebCrypto subtle API is unavailable");case 8:return e.next=10,i.digest("SHA-256",n);case 10:return c=e.sent,u=new Uint8Array(c),e.next=14,i.digest("SHA-256",u);case 14:if(l=e.sent,s=new Uint8Array(l),f=s.subarray(0,4),0===(o[0]^f[0]|o[1]^f[1]|o[2]^f[2]|o[3]^f[3])){e.next=20;break}throw new Error("invalid base58check checksum");case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}},e)}))).apply(this,arguments)}function J(e,t){return L.apply(this,arguments)}function L(){return(L=m(a().mark(function e(t,r){var o,i,c,u,l,s,f,p,d,y,b,v,h;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=r,e.next="SOLANA"===e.t0?3:"HEXADECIMAL"===e.t0?7:"BITCOIN_MAINNET_WIF"===e.t0?10:"BITCOIN_TESTNET_WIF"===e.t0?22:"SUI_BECH32"===e.t0?34:45;break;case 3:if(64===(o=B(t)).length){e.next=6;break}throw new Error("invalid key length. Expected 64 bytes. Got ".concat(o.length,"."));case 6:return e.abrupt("return",o.subarray(0,32));case 7:if(!t.startsWith("0x")){e.next=9;break}return e.abrupt("return",F(t.slice(2)));case 9:case 48:return e.abrupt("return",F(t));case 10:return e.next=12,H(t);case 12:if(i=e.sent,c=i[0],u=i.subarray(1),128===c){e.next=17;break}throw new Error("invalid WIF version byte: ".concat(c,". Expected 0x80 (mainnet)."));case 17:if(32!==u.length){e.next=19;break}throw new Error("uncompressed WIF keys not supported");case 19:if(33===u.length&&1===u[32]){e.next=21;break}throw new Error("invalid WIF format: expected compressed private key");case 21:return e.abrupt("return",u.subarray(0,32));case 22:return e.next=24,H(t);case 24:if(l=e.sent,s=l[0],f=l.subarray(1),239===s){e.next=29;break}throw new Error("invalid WIF version byte: ".concat(s,". Expected 0xEF (testnet)."));case 29:if(32!==f.length){e.next=31;break}throw new Error("uncompressed WIF keys not supported");case 31:if(33===f.length&&1===f[32]){e.next=33;break}throw new Error("invalid WIF format: expected compressed private key");case 33:return e.abrupt("return",f.subarray(0,32));case 34:if(p=n.I.decode(t),d=p.prefix,y=p.words,"suiprivkey"===d){e.next=37;break}throw new Error('invalid SUI private key human-readable part (HRP): expected "suiprivkey"');case 37:if(33===(b=n.I.fromWords(y)).length){e.next=40;break}throw new Error("invalid SUI private key length: expected 33 bytes, got ".concat(b.length));case 40:if(v=b[0],h=b.slice(1),0===v){e.next=44;break}throw new Error("invalid SUI private key scheme flag: expected 0 (Ed25519). Turnkey only supports Ed25519 keys for SUI.");case 44:return e.abrupt("return",new Uint8Array(h));case 45:if(console.warn("invalid key format: ".concat(r,". Defaulting to HEXADECIMAL.")),!t.startsWith("0x")){e.next=48;break}return e.abrupt("return",F(t.slice(2)));case 49:case"end":return e.stop()}},e)}))).apply(this,arguments)}function X(e,t){var r={},n={padding:"^(\\d+(px|em|%|rem) ?){1,4}$",margin:"^(\\d+(px|em|%|rem) ?){1,4}$",borderWidth:"^(\\d+(px|em|rem) ?){1,4}$",borderStyle:"^(none|solid|dashed|dotted|double|groove|ridge|inset|outset)$",borderColor:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",borderRadius:"^(\\d+(px|em|%|rem) ?){1,4}$",fontSize:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax))$",fontWeight:"^(normal|bold|bolder|lighter|\\d{3})$",fontFamily:'^[^";<>]*$',color:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",labelColor:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",backgroundColor:"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)|hsla?\\(\\d{1,3}, \\d{1,3}%, \\d{1,3}%(, \\d?(\\.\\d{1,2})?)?\\))$",width:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$",height:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$",maxWidth:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$",maxHeight:"^(\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$",lineHeight:"^(\\d+(\\.\\d+)?(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|normal)$",boxShadow:"^(none|(\\d+(px|em|rem) ?){2,4} (#[0-9a-f]{3,8}|rgba?\\(\\d{1,3}, \\d{1,3}, \\d{1,3}(, \\d?(\\.\\d{1,2})?)?\\)) ?(inset)?)$",textAlign:"^(left|right|center|justify|initial|inherit)$",overflowWrap:"^(normal|break-word|anywhere)$",wordWrap:"^(normal|break-word)$",resize:"^(none|both|horizontal|vertical|block|inline)$"};return Object.entries(e).forEach(function(e){var t,o,a=(o=2,function(e){if(Array.isArray(e))return e}(t=e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(t,o)||b(t,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=a[0],c=a[1],u=i.trim();if(0===u.length)throw new Error("css style property cannot be empty");var l=n[u];if(!l)throw new Error('invalid or unsupported css style property: "'.concat(u,'"'));var s=new RegExp(l),f=c.trim();if(0==f.length)throw new Error('css style for "'.concat(u,'" is empty'));if(!s.test(f))throw new Error('invalid css style value for property "'.concat(u,'"'));r[u]=f}),r}},482:(e,t,r)=>{r.r(t),r.d(t,{additionalAssociatedData:()=>E,applySettings:()=>O,base58CheckDecode:()=>h,base58Decode:()=>v,decodeKey:()=>m,fromDerSignature:()=>x,getSettings:()=>f,getTargetEmbeddedKey:()=>u,loadTargetKey:()=>c,normalizePadding:()=>g,resetTargetEmbeddedKey:()=>s,sendMessageUp:()=>d,setCryptoProvider:()=>i,setParentFrameMessageChannelPort:()=>w,setSettings:()=>p,setTargetEmbeddedKey:()=>l,uint8arrayFromHexString:()=>y,uint8arrayToHexString:()=>b,validateStyles:()=>k,verifyEnclaveSignature:()=>S});var n=r(275);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{r.d(t,{q:()=>g});var n=r(275),o=r(255);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(){var e=p(),t=e.m(i),r=(Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__).constructor;function n(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===r||"GeneratorFunction"===(t.displayName||t.name))}var o={throw:1,return:2,break:3,continue:3};function a(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,o[e],t)},delegateYield:function(e,o,a){return t.resultName=o,r(n.d,c(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(i=function(){return{wrap:function(t,r,n,o){return e.w(a(t),r,n,o&&o.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new y(e,t)},AsyncIterator:f,async:function(e,t,r,o,i){return(n(t)?s:l)(a(e),t,r,o,i)},keys:u,values:c}})()}function c(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(a(e)+" is not iterable")}function u(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}}function l(e,t,r,n,o){var a=s(e,t,r,n,o);return a.next().then(function(e){return e.done?e.value:a.next()})}function s(e,t,r,n,o){return new f(p().w(e,t,r,n),o||Promise)}function f(e,t){function r(n,o,a,i){try{var c=e[n](o),u=c.value;return u instanceof y?t.resolve(u.v).then(function(e){r("next",e,a,i)},function(e){r("throw",e,a,i)}):t.resolve(u).then(function(e){c.value=e,a(c)},function(e){return r("throw",e,a,i)})}catch(e){i(e)}}var n;this.next||(d(f.prototype),d(f.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),d(this,"_invoke",function(e,o,a){function i(){return new t(function(t,n){r(e,a,t,n)})}return n=n?n.then(i,i):i()},!0)}function p(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return d(l,"_invoke",function(r,n,o){var a,c,u,l=0,s=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return a=t,c=0,u=e,p.n=r,i}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t3?(o=y===n)&&(u=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=r<2&&dn||n>y)&&(a[4]=r,a[5]=n,p.n=y,c=0))}if(o||r>1)return i;throw f=!0,n}return function(o,s,y){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,y),c=s,u=y;(t=c<2?e:u)||!f;){a||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(l=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(f=p.n<0)?u:r.call(n,p))!==i)break}catch(t){a=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,a),!0),l}var i={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(d(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,d(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,d(f,"constructor",l),d(l,"constructor",u),u.displayName="GeneratorFunction",d(l,o,"GeneratorFunction"),d(f),d(f,o,"Generator"),d(f,n,function(){return this}),d(f,"toString",function(){return"[object Generator]"}),(p=function(){return{w:a,m:y}})()}function d(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}d=function(e,t,r,n){function a(t,r){d(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},d(e,t,r,n)}function y(e,t){this.v=e,this.k=t}function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t 1;\n } else {\n return window.parent !== window.top;\n }\n}\n\n/*\n * Loads the quorum public key as a CryptoKey.\n */\nasync function loadQuorumKey(quorumPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.importKey(\n \"raw\",\n quorumPublic,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n [\"verify\"]\n );\n}\n\n/*\n * Load a key to encrypt to as a CryptoKey and return it as a JSON Web Key.\n */\nasync function loadTargetKey(targetPublic) {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const targetKey = await subtle.importKey(\n \"raw\",\n targetPublic,\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n\n return await subtle.exportKey(\"jwk\", targetKey);\n}\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n */\nasync function initEmbeddedKey() {\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n const retrievedKey = await getEmbeddedKey();\n if (retrievedKey === null) {\n const targetKey = await generateTargetKey();\n setEmbeddedKey(targetKey);\n }\n // Nothing to do, key is correctly initialized!\n}\n\n/*\n * Generate a key to encrypt to and export it as a JSON Web Key.\n */\nasync function generateTargetKey() {\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n const p256key = await subtle.generateKey(\n {\n name: \"ECDH\",\n namedCurve: \"P-256\",\n },\n true,\n [\"deriveBits\"]\n );\n\n return await subtle.exportKey(\"jwk\", p256key.privateKey);\n}\n\n/**\n * Gets the current embedded private key JWK. Returns `null` if not found.\n */\nfunction getEmbeddedKey() {\n const jwtKey = getItemWithExpiry(TURNKEY_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the embedded private key JWK with the default expiration time.\n * @param {JsonWebKey} targetKey\n */\nfunction setEmbeddedKey(targetKey) {\n setItemWithExpiry(\n TURNKEY_EMBEDDED_KEY,\n JSON.stringify(targetKey),\n TURNKEY_EMBEDDED_KEY_TTL_IN_MILLIS\n );\n}\n\n/**\n * Gets the current target embedded private key JWK. Returns `null` if not found.\n */\nfunction getTargetEmbeddedKey() {\n const jwtKey = window.localStorage.getItem(TURNKEY_TARGET_EMBEDDED_KEY);\n return jwtKey ? JSON.parse(jwtKey) : null;\n}\n\n/**\n * Sets the target embedded public key JWK.\n * @param {JsonWebKey} targetKey\n */\nfunction setTargetEmbeddedKey(targetKey) {\n window.localStorage.setItem(\n TURNKEY_TARGET_EMBEDDED_KEY,\n JSON.stringify(targetKey)\n );\n}\n\n/**\n * Resets the current embedded private key JWK.\n */\nfunction onResetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY);\n window.localStorage.removeItem(TURNKEY_EMBEDDED_KEY_ORIGIN);\n}\n\n/**\n * Resets the current target embedded private key JWK.\n */\nfunction resetTargetEmbeddedKey() {\n window.localStorage.removeItem(TURNKEY_TARGET_EMBEDDED_KEY);\n}\n\nfunction setParentFrameMessageChannelPort(port) {\n parentFrameMessageChannelPort = port;\n}\n\n/**\n * Gets the current settings.\n */\nfunction getSettings() {\n const settings = window.localStorage.getItem(TURNKEY_SETTINGS);\n return settings ? JSON.parse(settings) : null;\n}\n\n/**\n * Sets the settings object.\n * @param {Object} settings\n */\nfunction setSettings(settings) {\n window.localStorage.setItem(TURNKEY_SETTINGS, JSON.stringify(settings));\n}\n\n/**\n * Set an item in localStorage with an expiration time\n * @param {string} key\n * @param {string} value\n * @param {number} ttl expiration time in milliseconds\n */\nfunction setItemWithExpiry(key, value, ttl) {\n const now = new Date();\n const item = {\n value: value,\n expiry: now.getTime() + ttl,\n };\n window.localStorage.setItem(key, JSON.stringify(item));\n}\n\n/**\n * Get an item from localStorage. Returns `null` and\n * removes the item from localStorage if expired or\n * expiry time is missing.\n * @param {string} key\n */\nfunction getItemWithExpiry(key) {\n const itemStr = window.localStorage.getItem(key);\n if (!itemStr) {\n return null;\n }\n const item = JSON.parse(itemStr);\n if (\n !Object.prototype.hasOwnProperty.call(item, \"expiry\") ||\n !Object.prototype.hasOwnProperty.call(item, \"value\")\n ) {\n window.localStorage.removeItem(key);\n return null;\n }\n const now = new Date();\n if (now.getTime() > item.expiry) {\n window.localStorage.removeItem(key);\n return null;\n }\n return item.value;\n}\n\n/**\n * Takes a hex string (e.g. \"e4567ab\" or \"0xe4567ab\") and returns an array buffer (Uint8Array)\n * @param {string} hexString - Hex string with or without \"0x\" prefix\n * @returns {Uint8Array}\n */\nfunction uint8arrayFromHexString(hexString) {\n if (!hexString || typeof hexString !== \"string\") {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n\n // Remove 0x prefix if present\n const hexWithoutPrefix =\n hexString.startsWith(\"0x\") || hexString.startsWith(\"0X\")\n ? hexString.slice(2)\n : hexString;\n\n var hexRegex = /^[0-9A-Fa-f]+$/;\n if (hexWithoutPrefix.length % 2 != 0 || !hexRegex.test(hexWithoutPrefix)) {\n throw new Error(\"cannot create uint8array from invalid hex string\");\n }\n return new Uint8Array(\n hexWithoutPrefix.match(/../g).map((h) => parseInt(h, 16))\n );\n}\n\n/**\n * Takes a Uint8Array and returns a hex string\n * @param {Uint8Array} buffer\n * @return {string}\n */\nfunction uint8arrayToHexString(buffer) {\n return [...buffer].map((x) => x.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Function to normalize padding of byte array with 0's to a target length\n */\nfunction normalizePadding(byteArray, targetLength) {\n const paddingLength = targetLength - byteArray.length;\n\n // Add leading 0's to array\n if (paddingLength > 0) {\n const padding = new Uint8Array(paddingLength).fill(0);\n return new Uint8Array([...padding, ...byteArray]);\n }\n\n // Remove leading 0's from array\n if (paddingLength < 0) {\n const expectedZeroCount = paddingLength * -1;\n let zeroCount = 0;\n for (let i = 0; i < expectedZeroCount && i < byteArray.length; i++) {\n if (byteArray[i] === 0) {\n zeroCount++;\n }\n }\n // Check if the number of zeros found equals the number of zeroes expected\n if (zeroCount !== expectedZeroCount) {\n throw new Error(\n `invalid number of starting zeroes. Expected number of zeroes: ${expectedZeroCount}. Found: ${zeroCount}.`\n );\n }\n return byteArray.slice(expectedZeroCount, expectedZeroCount + targetLength);\n }\n return byteArray;\n}\n\n/**\n * Additional Associated Data (AAD) in the format dictated by the enclave_encrypt crate.\n */\nfunction additionalAssociatedData(senderPubBuf, receiverPubBuf) {\n const s = Array.from(new Uint8Array(senderPubBuf));\n const r = Array.from(new Uint8Array(receiverPubBuf));\n return new Uint8Array([...s, ...r]);\n}\n\n/**\n * Converts an ASN.1 DER-encoded ECDSA signature to the raw format that WebCrypto uses.\n */\nfunction fromDerSignature(derSignature) {\n const derSignatureBuf = uint8arrayFromHexString(derSignature);\n\n // Check and skip the sequence tag (0x30)\n let index = 2;\n\n // Parse 'r' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for r\"\n );\n }\n index++; // Move past the INTEGER tag\n const rLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const r = derSignatureBuf.slice(index, index + rLength);\n index += rLength; // Move to the start of s\n\n // Parse 's' and check for integer tag (0x02)\n if (derSignatureBuf[index] !== 0x02) {\n throw new Error(\n \"failed to convert DER-encoded signature: invalid tag for s\"\n );\n }\n index++; // Move past the INTEGER tag\n const sLength = derSignatureBuf[index];\n index++; // Move past the length byte\n const s = derSignatureBuf.slice(index, index + sLength);\n\n // Normalize 'r' and 's' to 32 bytes each\n const rPadded = normalizePadding(r, 32);\n const sPadded = normalizePadding(s, 32);\n\n // Concatenate and return the raw signature\n return new Uint8Array([...rPadded, ...sPadded]);\n}\n\n/**\n * Function to verify enclave signature on import bundle received from the server.\n * @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature\n * @param {string} publicSignature signature bytes encoded as a hexadecimal string\n * @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes\n */\nasync function verifyEnclaveSignature(\n enclaveQuorumPublic,\n publicSignature,\n signedData\n) {\n /** Turnkey Signer enclave's public keys */\n const TURNKEY_SIGNERS_ENCLAVES = {\n prod: \"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\",\n preprod:\n \"04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212\",\n dev: \"048cf9ed5f579298cc1571823a3222b82d80c529c551f6070fbe712ae1a9e8d1a23b7006e306d27190358dfcd9c44624918a00f23c920a33cb14f5b026eafc865d\",\n };\n\n // Use window.__TURNKEY_SIGNER_ENVIRONMENT__ if available (for testing), otherwise use the webpack replacement\n const environment =\n (typeof window !== \"undefined\" && window.__TURNKEY_SIGNER_ENVIRONMENT__) ||\n \"__TURNKEY_SIGNER_ENVIRONMENT__\";\n const TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY =\n TURNKEY_SIGNERS_ENCLAVES[environment];\n\n if (TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY === undefined) {\n throw new Error(\n `Configuration error: TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY is undefined`\n );\n }\n\n // todo(olivia): throw error if enclave quorum public is null once server changes are deployed\n if (enclaveQuorumPublic) {\n if (enclaveQuorumPublic !== TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY) {\n throw new Error(\n `enclave quorum public keys from client and bundle do not match. Client: ${TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY}. Bundle: ${enclaveQuorumPublic}.`\n );\n }\n }\n\n const encryptionQuorumPublicBuf = new Uint8Array(\n uint8arrayFromHexString(TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY)\n );\n const quorumKey = await loadQuorumKey(encryptionQuorumPublicBuf);\n if (!quorumKey) {\n throw new Error(\"failed to load quorum key\");\n }\n\n // The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format\n const publicSignatureBuf = fromDerSignature(publicSignature);\n const signedDataBuf = uint8arrayFromHexString(signedData);\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n return await subtle.verify(\n { name: \"ECDSA\", hash: \"SHA-256\" },\n quorumKey,\n publicSignatureBuf,\n signedDataBuf\n );\n}\n\n/**\n * Function to send a message.\n *\n * If this page is embedded as an iframe we'll send a postMessage\n * in one of two ways depending on the version of @turnkey/iframe-stamper:\n * 1. newer versions (>=v2.1.0) pass a MessageChannel MessagePort from the parent frame for postMessages.\n * 2. older versions ( 0) {\n digits.push(carry % 58);\n carry = (carry / 58) | 0;\n }\n }\n // Convert digits to a base58 string\n for (let k = 0; k < digits.length; k++) {\n result = alphabet[digits[k]] + result;\n }\n\n // Add '1' for each leading 0 byte\n for (let i = 0; bytes[i] === 0 && i < bytes.length - 1; i++) {\n result = \"1\" + result;\n }\n return result;\n}\n\n/**\n * Decodes a base58-encoded string into a buffer\n * This function throws an error when the string contains invalid characters.\n * @param {string} s The base58-encoded string.\n * @return {Uint8Array} The decoded buffer.\n */\nfunction base58Decode(s) {\n // See https://en.bitcoin.it/wiki/Base58Check_encoding\n var alphabet = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n var decodedBytes = [];\n var leadingZeros = [];\n for (var i = 0; i < s.length; i++) {\n if (alphabet.indexOf(s[i]) === -1) {\n throw new Error(`cannot base58-decode: ${s[i]} isn't a valid character`);\n }\n var carry = alphabet.indexOf(s[i]);\n\n // If the current base58 digit is 0, append a 0 byte.\n // \"i == leadingZeros.length\" can only be true if we have not seen non-zero bytes so far.\n // If we had seen a non-zero byte, carry wouldn't be 0, and i would be strictly more than `leadingZeros.length`\n if (carry == 0 && i === leadingZeros.length) {\n leadingZeros.push(0);\n }\n\n var j = 0;\n while (j < decodedBytes.length || carry > 0) {\n var currentByte = decodedBytes[j];\n\n // shift the current byte 58 units and add the carry amount\n // (or just add the carry amount if this is a new byte -- undefined case)\n if (currentByte === undefined) {\n currentByte = carry;\n } else {\n currentByte = currentByte * 58 + carry;\n }\n\n // find the new carry amount (1-byte shift of current byte value)\n carry = currentByte >> 8;\n // reset the current byte to the remainder (the carry amount will pass on the overflow)\n decodedBytes[j] = currentByte % 256;\n j++;\n }\n }\n\n var result = leadingZeros.concat(decodedBytes.reverse());\n return new Uint8Array(result);\n}\n\n/**\n * Decodes a base58check-encoded string and verifies the checksum.\n * Base58Check encoding includes a 4-byte checksum at the end to detect errors.\n * The checksum is the first 4 bytes of SHA256(SHA256(payload)).\n * This function throws an error if the checksum is invalid.\n * @param {string} s The base58check-encoded string.\n * @return {Promise} The decoded payload (without checksum).\n */\nasync function base58CheckDecode(s) {\n const decoded = base58Decode(s);\n\n if (decoded.length < 5) {\n throw new Error(\n `invalid base58check length: expected at least 5 bytes, got ${decoded.length}`\n );\n }\n\n const payload = decoded.subarray(0, decoded.length - 4);\n const checksum = decoded.subarray(decoded.length - 4);\n\n const subtle = getSubtleCrypto();\n if (!subtle) {\n throw new Error(\"WebCrypto subtle API is unavailable\");\n }\n\n // Compute double SHA256 hash\n const hash1Buf = await subtle.digest(\"SHA-256\", payload);\n const hash1 = new Uint8Array(hash1Buf);\n const hash2Buf = await subtle.digest(\"SHA-256\", hash1);\n const hash2 = new Uint8Array(hash2Buf);\n const computedChecksum = hash2.subarray(0, 4);\n\n // Verify checksum\n const mismatch =\n (checksum[0] ^ computedChecksum[0]) |\n (checksum[1] ^ computedChecksum[1]) |\n (checksum[2] ^ computedChecksum[2]) |\n (checksum[3] ^ computedChecksum[3]);\n if (mismatch !== 0) {\n throw new Error(\"invalid base58check checksum\");\n }\n\n return payload;\n}\n\n/**\n * Returns private key bytes from a private key, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {string} privateKey\n * @param {string} keyFormat Can be \"HEXADECIMAL\", \"SUI_BECH32\", \"BITCOIN_MAINNET_WIF\", \"BITCOIN_TESTNET_WIF\" or \"SOLANA\"\n * @return {Promise}\n */\nasync function decodeKey(privateKey, keyFormat) {\n switch (keyFormat) {\n case \"SOLANA\": {\n const decodedKeyBytes = base58Decode(privateKey);\n if (decodedKeyBytes.length !== 64) {\n throw new Error(\n `invalid key length. Expected 64 bytes. Got ${decodedKeyBytes.length}.`\n );\n }\n return decodedKeyBytes.subarray(0, 32);\n }\n case \"HEXADECIMAL\":\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n case \"BITCOIN_MAINNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0x80 = mainnet\n if (version !== 0x80) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0x80 (mainnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"BITCOIN_TESTNET_WIF\": {\n const payload = await base58CheckDecode(privateKey);\n\n const version = payload[0];\n const keyAndFlags = payload.subarray(1);\n\n // 0xEF = testnet\n if (version !== 0xef) {\n throw new Error(\n `invalid WIF version byte: ${version}. Expected 0xEF (testnet).`\n );\n }\n\n // Check for common mistake: uncompressed keys\n if (keyAndFlags.length === 32) {\n throw new Error(\"uncompressed WIF keys not supported\");\n }\n\n // Validate compressed format\n if (keyAndFlags.length !== 33 || keyAndFlags[32] !== 0x01) {\n throw new Error(\"invalid WIF format: expected compressed private key\");\n }\n\n return keyAndFlags.subarray(0, 32);\n }\n case \"SUI_BECH32\": {\n const { prefix, words } = bech32.decode(privateKey);\n\n if (prefix !== \"suiprivkey\") {\n throw new Error(\n `invalid SUI private key human-readable part (HRP): expected \"suiprivkey\"`\n );\n }\n\n const bytes = bech32.fromWords(words);\n if (bytes.length !== 33) {\n throw new Error(\n `invalid SUI private key length: expected 33 bytes, got ${bytes.length}`\n );\n }\n\n const schemeFlag = bytes[0];\n const privkey = bytes.slice(1);\n\n // schemeFlag = 0 is Ed25519; We currently only support Ed25519 keys for SUI.\n if (schemeFlag !== 0) {\n throw new Error(\n `invalid SUI private key scheme flag: expected 0 (Ed25519). Turnkey only supports Ed25519 keys for SUI.`\n );\n }\n\n return new Uint8Array(privkey);\n }\n default:\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n if (privateKey.startsWith(\"0x\")) {\n return uint8arrayFromHexString(privateKey.slice(2));\n }\n return uint8arrayFromHexString(privateKey);\n }\n}\n\n/**\n * Returns a private key from private key bytes, represented in\n * the encoding and format specified by `keyFormat`. Defaults to\n * hex-encoding if `keyFormat` isn't passed.\n * @param {Uint8Array} privateKeyBytes\n * @param {string} keyFormat Can be \"HEXADECIMAL\" or \"SOLANA\"\n */\nasync function encodeKey(privateKeyBytes, keyFormat, publicKeyBytes) {\n switch (keyFormat) {\n case \"SOLANA\":\n if (!publicKeyBytes) {\n throw new Error(\"public key must be specified for SOLANA key format\");\n }\n if (privateKeyBytes.length !== 32) {\n throw new Error(\n `invalid private key length. Expected 32 bytes. Got ${privateKeyBytes.length}.`\n );\n }\n if (publicKeyBytes.length !== 32) {\n throw new Error(\n `invalid public key length. Expected 32 bytes. Got ${publicKeyBytes.length}.`\n );\n }\n {\n const concatenatedBytes = new Uint8Array(64);\n concatenatedBytes.set(privateKeyBytes, 0);\n concatenatedBytes.set(publicKeyBytes, 32);\n return base58Encode(concatenatedBytes);\n }\n case \"HEXADECIMAL\":\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n default:\n // keeping console.warn for debugging purposes.\n // eslint-disable-next-line no-console\n console.warn(\n `invalid key format: ${keyFormat}. Defaulting to HEXADECIMAL.`\n );\n return \"0x\" + uint8arrayToHexString(privateKeyBytes);\n }\n}\n\n// Helper to parse a private key into a Solana base58 private key.\n// To be used if a wallet account is exported without the `SOLANA` address format.\nfunction parsePrivateKey(privateKey) {\n if (Array.isArray(privateKey)) {\n return new Uint8Array(privateKey);\n }\n\n if (typeof privateKey === \"string\") {\n // Remove 0x prefix if present\n if (privateKey.startsWith(\"0x\")) {\n privateKey = privateKey.slice(2);\n }\n\n // Check if it's hex-formatted correctly (i.e. 64 hex chars)\n if (privateKey.length === 64 && /^[0-9a-fA-F]+$/.test(privateKey)) {\n return uint8arrayFromHexString(privateKey);\n }\n\n // Otherwise assume it's base58 format (for Solana)\n try {\n return base58Decode(privateKey);\n } catch (error) {\n throw new Error(\n \"Invalid private key format. Use hex (64 chars) or base58 format.\"\n );\n }\n }\n\n throw new Error(\"Private key must be a string (hex/base58) or number array\");\n}\n\n/**\n * Function to validate and sanitize the styles object using the accepted map of style keys and values (as regular expressions).\n * Any invalid style throws an error. Returns an object of valid styles.\n * @param {Object} styles\n * @param {HTMLElement} element - Optional element parameter (for import frame)\n * @return {Object}\n */\nfunction validateStyles(styles, element) {\n const validStyles = {};\n\n const cssValidationRegex = {\n padding: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n margin: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n borderWidth: \"^(\\\\d+(px|em|rem) ?){1,4}$\",\n borderStyle:\n \"^(none|solid|dashed|dotted|double|groove|ridge|inset|outset)$\",\n borderColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n borderRadius: \"^(\\\\d+(px|em|%|rem) ?){1,4}$\",\n fontSize: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax))$\",\n fontWeight: \"^(normal|bold|bolder|lighter|\\\\d{3})$\",\n fontFamily: '^[^\";<>]*$', // checks for the absence of some characters that could lead to CSS/HTML injection\n color:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n labelColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n backgroundColor:\n \"^(transparent|inherit|initial|#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)|hsla?\\\\(\\\\d{1,3}, \\\\d{1,3}%, \\\\d{1,3}%(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\))$\",\n width: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n height: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|auto)$\",\n maxWidth: \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n maxHeight:\n \"^(\\\\d+(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|none)$\",\n lineHeight:\n \"^(\\\\d+(\\\\.\\\\d+)?(px|em|rem|%|vh|vw|in|cm|mm|pt|pc|ex|ch|vmin|vmax)|normal)$\",\n boxShadow:\n \"^(none|(\\\\d+(px|em|rem) ?){2,4} (#[0-9a-f]{3,8}|rgba?\\\\(\\\\d{1,3}, \\\\d{1,3}, \\\\d{1,3}(, \\\\d?(\\\\.\\\\d{1,2})?)?\\\\)) ?(inset)?)$\",\n textAlign: \"^(left|right|center|justify|initial|inherit)$\",\n overflowWrap: \"^(normal|break-word|anywhere)$\",\n wordWrap: \"^(normal|break-word)$\",\n resize: \"^(none|both|horizontal|vertical|block|inline)$\",\n };\n\n Object.entries(styles).forEach(([property, value]) => {\n const styleProperty = property.trim();\n if (styleProperty.length === 0) {\n throw new Error(\"css style property cannot be empty\");\n }\n const styleRegexStr = cssValidationRegex[styleProperty];\n if (!styleRegexStr) {\n throw new Error(\n `invalid or unsupported css style property: \"${styleProperty}\"`\n );\n }\n const styleRegex = new RegExp(styleRegexStr);\n const styleValue = value.trim();\n if (styleValue.length == 0) {\n throw new Error(`css style for \"${styleProperty}\" is empty`);\n }\n const isValidStyle = styleRegex.test(styleValue);\n if (!isValidStyle) {\n throw new Error(\n `invalid css style value for property \"${styleProperty}\"`\n );\n }\n validStyles[styleProperty] = styleValue;\n });\n\n return validStyles;\n}\n\n// Export all shared functions\nexport {\n setCryptoProvider,\n getSubtleCrypto,\n isDoublyIframed,\n loadQuorumKey,\n loadTargetKey,\n initEmbeddedKey,\n generateTargetKey,\n getEmbeddedKey,\n setEmbeddedKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n onResetEmbeddedKey,\n resetTargetEmbeddedKey,\n setParentFrameMessageChannelPort,\n getSettings,\n setSettings,\n setItemWithExpiry,\n getItemWithExpiry,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n normalizePadding,\n additionalAssociatedData,\n fromDerSignature,\n verifyEnclaveSignature,\n sendMessageUp,\n logMessage,\n p256JWKPrivateToPublic,\n base58Encode,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n encodeKey,\n parsePrivateKey,\n validateStyles,\n};\n","import * as SharedTKHQ from \"@shared/turnkey-core.js\";\n\nconst {\n setCryptoProvider,\n loadTargetKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n resetTargetEmbeddedKey,\n getSettings,\n setSettings,\n sendMessageUp,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n setParentFrameMessageChannelPort,\n normalizePadding,\n fromDerSignature,\n additionalAssociatedData,\n verifyEnclaveSignature,\n validateStyles,\n} = SharedTKHQ;\n\n/**\n * Function to apply settings on this page. For now, the only settings that can be applied\n * are for \"styles\". Upon successful application, return the valid, sanitized settings JSON string.\n * @param {string} settings\n * @return {string}\n */\nfunction applySettings(settings) {\n const validSettings = {};\n const settingsObj = JSON.parse(settings);\n\n const passphraseLabel = document.getElementById(\"passphrase-label\");\n const mnemonicLabel = document.getElementById(\"mnemonic-label\");\n const passphraseTextarea = document.getElementById(\"passphrase\");\n\n if (!passphraseLabel || !passphraseTextarea) {\n throw new Error(\"no passphrase HTML elements found to apply settings to.\");\n }\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) {\n throw new Error(\n \"no plaintext textarea HTML element found to apply settings to.\"\n );\n }\n\n // Apply enablePassphrase setting\n if (settingsObj.enablePassphrase === true) {\n passphraseLabel.style.display = \"inline-block\";\n passphraseTextarea.style.display = \"inline-block\";\n passphraseTextarea.style.border = \"solid 1px #ccc\";\n passphraseTextarea.style.borderRadius = \"4px\";\n\n mnemonicLabel.style.display = \"inline-block\";\n plaintextTextarea.style.border = \"solid 1px #ccc\";\n plaintextTextarea.style.borderRadius = \"4px\";\n\n validSettings[\"enablePassphrase\"] = true;\n } else {\n passphraseLabel.style.display = \"none\";\n passphraseTextarea.style.display = \"none\";\n mnemonicLabel.style.display = \"none\";\n\n plaintextTextarea.style.border = \"none\";\n validSettings[\"enablePassphrase\"] = false;\n }\n\n if (settingsObj.styles) {\n // Validate, sanitize, and apply the styles to the \"plaintext\" textarea.\n const validStyles = validateStyles(settingsObj.styles);\n Object.entries(validStyles).forEach(([key, value]) => {\n plaintextTextarea.style[key] = value;\n });\n\n if (validStyles.backgroundColor) {\n // Apply background color to document and body as well.\n document.documentElement.style.backgroundColor =\n validStyles.backgroundColor;\n document.body.style.backgroundColor = validStyles.backgroundColor;\n }\n\n if (validStyles.labelColor) {\n document.getElementById(\"mnemonic-label\").style.color =\n validStyles.labelColor;\n }\n\n validSettings[\"styles\"] = validStyles;\n }\n\n if (settingsObj.passphraseStyles) {\n // Validate, sanitize, and apply the styles to the \"passphrase\" textarea.\n const validStyles = validateStyles(settingsObj.passphraseStyles);\n Object.entries(validStyles).forEach(([key, value]) => {\n passphraseTextarea.style[key] = value;\n });\n\n if (validStyles.labelColor) {\n document.getElementById(\"passphrase-label\").style.color =\n validStyles.labelColor;\n }\n\n validSettings[\"passphraseStyles\"] = validStyles;\n }\n\n return JSON.stringify(validSettings);\n}\n\nexport {\n setCryptoProvider,\n loadTargetKey,\n getTargetEmbeddedKey,\n setTargetEmbeddedKey,\n resetTargetEmbeddedKey,\n getSettings,\n setSettings,\n sendMessageUp,\n uint8arrayFromHexString,\n uint8arrayToHexString,\n base58Decode,\n base58CheckDecode,\n decodeKey,\n setParentFrameMessageChannelPort,\n normalizePadding,\n fromDerSignature,\n additionalAssociatedData,\n verifyEnclaveSignature,\n validateStyles,\n applySettings,\n};\n","/**\n * Crypto Utilities - Shared\n * Contains HPKE encryption and decryption functions\n */\n\nimport {\n p256JWKPrivateToPublic,\n additionalAssociatedData,\n uint8arrayToHexString,\n} from \"./turnkey-core.js\";\nimport {\n CipherSuite,\n DhkemP256HkdfSha256,\n HkdfSha256,\n Aes256Gcm,\n} from \"@hpke/core\";\n\n// Pre-compute const (for perf)\nconst TURNKEY_HPKE_INFO = new TextEncoder().encode(\"turnkey_hpke\");\n\n/**\n * Decrypt the ciphertext (ArrayBuffer) given an encapsulation key (ArrayBuffer)\n * and the receivers private key (JSON Web Key).\n */\nexport async function HpkeDecrypt({\n ciphertextBuf,\n encappedKeyBuf,\n receiverPrivJwk,\n}) {\n const kemContext = new DhkemP256HkdfSha256();\n var receiverPriv = await kemContext.importKey(\n \"jwk\",\n { ...receiverPrivJwk },\n false\n );\n\n var suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n var recipientCtx = await suite.createRecipientContext({\n recipientKey: receiverPriv,\n enc: encappedKeyBuf,\n info: TURNKEY_HPKE_INFO,\n });\n\n var receiverPubBuf = await p256JWKPrivateToPublic(receiverPrivJwk);\n var aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n var res;\n try {\n res = await recipientCtx.open(ciphertextBuf, aad);\n } catch (e) {\n throw new Error(\n \"unable to decrypt bundle using embedded key. the bundle may be incorrect. failed with error: \" +\n e.toString()\n );\n }\n return res;\n}\n\n/**\n * Encrypt plaintext using HPKE with the receiver's public key.\n * @param {Object} params\n * @param {Uint8Array} params.plaintextBuf - Plaintext to encrypt\n * @param {JsonWebKey} params.receiverPubJwk - Receiver's public key in JWK format\n * @returns {Promise} JSON stringified encrypted bundle with encappedPublic and ciphertext\n */\nexport async function HpkeEncrypt({ plaintextBuf, receiverPubJwk }) {\n const kemContext = new DhkemP256HkdfSha256();\n const receiverPub = await kemContext.importKey(\n \"jwk\",\n { ...receiverPubJwk },\n true\n );\n\n const suite = new CipherSuite({\n kem: kemContext,\n kdf: new HkdfSha256(),\n aead: new Aes256Gcm(),\n });\n\n const senderCtx = await suite.createSenderContext({\n recipientPublicKey: receiverPub,\n info: TURNKEY_HPKE_INFO,\n });\n\n // Need to import the key again as a JWK to export as a raw key, the format needed to\n // create the aad with the newly generated raw encapped key.\n const receiverPubCryptoKey = await crypto.subtle.importKey(\n \"jwk\",\n receiverPubJwk,\n {\n name: \"ECDSA\",\n namedCurve: \"P-256\",\n },\n true,\n []\n );\n const receiverPubRaw = await crypto.subtle.exportKey(\n \"raw\",\n receiverPubCryptoKey\n );\n const receiverPubBuf = new Uint8Array(receiverPubRaw);\n\n const encappedKeyBuf = new Uint8Array(senderCtx.enc);\n\n const aad = additionalAssociatedData(encappedKeyBuf, receiverPubBuf);\n\n var ciphertextBuf;\n try {\n ciphertextBuf = await senderCtx.seal(plaintextBuf, aad);\n } catch (e) {\n throw new Error(\"failed to encrypt import bundle: \" + e.toString());\n }\n\n const ciphertextHex = uint8arrayToHexString(new Uint8Array(ciphertextBuf));\n const encappedKeyBufHex = uint8arrayToHexString(encappedKeyBuf);\n const encryptedBundle = JSON.stringify({\n encappedPublic: encappedKeyBufHex,\n ciphertext: ciphertextHex,\n });\n return encryptedBundle;\n}\n"],"names":["e","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","_regenerator","w","m","defineProperty","_invoke","enumerable","configurable","writable","_OverloadYield","k","_toConsumableArray","Array","isArray","_arrayLikeToArray","_arrayWithoutHoles","from","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","toString","slice","constructor","name","test","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","TURNKEY_TARGET_EMBEDDED_KEY","TURNKEY_SETTINGS","parentFrameMessageChannelPort","cryptoProviderOverride","getSubtleCrypto","subtle","globalThis","crypto","window","global","setCryptoProvider","cryptoProvider","loadQuorumKey","_x","_loadQuorumKey","_regeneratorRuntime","mark","_callee","quorumPublic","wrap","_context","prev","next","Error","importKey","namedCurve","abrupt","sent","stop","loadTargetKey","_x2","_loadTargetKey","_callee2","targetPublic","targetKey","_context2","exportKey","getTargetEmbeddedKey","jwtKey","localStorage","getItem","JSON","parse","setTargetEmbeddedKey","setItem","stringify","resetTargetEmbeddedKey","removeItem","setParentFrameMessageChannelPort","port","getSettings","settings","setSettings","uint8arrayFromHexString","hexString","hexWithoutPrefix","startsWith","Uint8Array","match","map","h","parseInt","uint8arrayToHexString","buffer","x","padStart","join","normalizePadding","byteArray","targetLength","paddingLength","padding","fill","concat","expectedZeroCount","zeroCount","additionalAssociatedData","senderPubBuf","receiverPubBuf","s","fromDerSignature","derSignature","derSignatureBuf","index","rLength","sLength","rPadded","sPadded","verifyEnclaveSignature","_x3","_x4","_x5","_verifyEnclaveSignature","_callee5","enclaveQuorumPublic","publicSignature","signedData","TURNKEY_SIGNERS_ENCLAVES","environment","TURNKEY_SIGNER_ENCLAVE_QUORUM_PUBLIC_KEY","encryptionQuorumPublicBuf","quorumKey","publicSignatureBuf","signedDataBuf","_context5","prod","preprod","dev","__TURNKEY_SIGNER_ENVIRONMENT__","undefined","verify","hash","sendMessageUp","type","requestId","message","postMessage","parent","content","messageLog","document","getElementById","createElement","innerText","appendChild","logMessage","base58Decode","alphabet","decodedBytes","leadingZeros","indexOf","carry","push","j","currentByte","result","reverse","base58CheckDecode","_x7","_base58CheckDecode","_callee7","decoded","payload","checksum","hash1Buf","hash1","hash2Buf","hash2","computedChecksum","_context7","subarray","digest","decodeKey","_x8","_x9","_decodeKey","_callee8","privateKey","keyFormat","decodedKeyBytes","version","keyAndFlags","_payload","_version","_keyAndFlags","_bech32$decode","prefix","words","bytes","schemeFlag","privkey","_context8","t0","bech32","decode","fromWords","console","warn","validateStyles","styles","element","validStyles","cssValidationRegex","margin","borderWidth","borderStyle","borderColor","borderRadius","fontSize","fontWeight","fontFamily","color","labelColor","backgroundColor","width","height","maxWidth","maxHeight","lineHeight","boxShadow","textAlign","overflowWrap","wordWrap","resize","entries","forEach","_ref","_ref2","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","property","styleProperty","trim","styleRegexStr","styleRegex","RegExp","styleValue","SharedTKHQ","applySettings","validSettings","settingsObj","passphraseLabel","mnemonicLabel","passphraseTextarea","plaintextTextarea","enablePassphrase","style","display","border","_slicedToArray","key","documentElement","body","passphraseStyles","_ref3","_ref4","ownKeys","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","_objectSpread","_defineProperty","getOwnPropertyDescriptors","defineProperties","_typeof","toPrimitive","String","_toPrimitive","_toPropertyKey","TURNKEY_HPKE_INFO","TextEncoder","encode","HpkeEncrypt","_HpkeEncrypt","plaintextBuf","receiverPubJwk","kemContext","receiverPub","suite","senderCtx","receiverPubCryptoKey","receiverPubRaw","encappedKeyBuf","aad","ciphertextBuf","ciphertextHex","encappedKeyBufHex","encryptedBundle","DhkemP256HkdfSha256","CipherSuite","kem","kdf","HkdfSha256","aead","Aes256Gcm","createSenderContext","recipientPublicKey","info","enc","seal","encappedPublic","ciphertext"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/index.html b/import/dist/index.html index 6866efe..b390360 100644 --- a/import/dist/index.html +++ b/import/dist/index.html @@ -1 +1 @@ -Turnkey Import
\ No newline at end of file +Turnkey Import
\ No newline at end of file diff --git a/import/dist/standalone.html b/import/dist/standalone.html index 5cad7ed..4651ff0 100644 --- a/import/dist/standalone.html +++ b/import/dist/standalone.html @@ -1 +1 @@ -Turnkey Import (Standalone Mode)

Initialize Import




Import Wallet


Import Private Key



Message log

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 postMessage API.

\ No newline at end of file +Turnkey Import (Standalone Mode)

Initialize Import




Import Wallet


Import Private Key



Message log

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 postMessage API.

\ No newline at end of file diff --git a/shared/turnkey-core.js b/shared/turnkey-core.js index 131ca98..97071c1 100644 --- a/shared/turnkey-core.js +++ b/shared/turnkey-core.js @@ -387,6 +387,7 @@ async function verifyEnclaveSignature( prod: "04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569", preprod: "04f3422b8afbe425d6ece77b8d2469954715a2ff273ab7ac89f1ed70e0a9325eaa1698b4351fd1b23734e65c0b6a86b62dd49d70b37c94606aac402cbd84353212", + dev: "048cf9ed5f579298cc1571823a3222b82d80c529c551f6070fbe712ae1a9e8d1a23b7006e306d27190358dfcd9c44624918a00f23c920a33cb14f5b026eafc865d", }; // Use window.__TURNKEY_SIGNER_ENVIRONMENT__ if available (for testing), otherwise use the webpack replacement