From f1647aef41d89777641113f1989a75a927b858df Mon Sep 17 00:00:00 2001 From: Justin Formentin Date: Fri, 7 Aug 2026 15:07:11 -0400 Subject: [PATCH 1/3] fix(import): extend INT-697 cross-origin MessageChannel validation to import frame Mirrors the TURNKEY_INIT_MESSAGE_CHANNEL gate added to export-and-sign in PR #129 (https://github.com/tkhq/frames/pull/129). The import frame's handler previously only checked event.ports?.[0]; it now also validates: - event.source === window.parent (direct parent only) - event.origin && event.origin !== "null" (concrete, non-opaque origin) - event.ports?.length === 1 (exactly one transferred port) Closes the identical class of vulnerability INT-697 fixed in export-and-sign. Pre-existing gap; not introduced by PR #129. Also adds six Jest tests for the new gate conditions and rebuilds the production bundle (content hash: 45de86a592cd0d80ccd0). Linear: INT-783 https://linear.app/turnkey/issue/INT-783 --- ...s => index.bundle.45de86a592cd0d80ccd0.js} | 6 +- ...undle.45de86a592cd0d80ccd0.js.LICENSE.txt} | 0 .../index.bundle.45de86a592cd0d80ccd0.js.map | 1 + .../index.bundle.5f5e5ca1b811d13b75e8.js.map | 1 - import/dist/index.html | 2 +- import/index.test.js | 142 ++++++++++++++++++ import/src/index.js | 5 +- 7 files changed, 151 insertions(+), 6 deletions(-) rename import/dist/{index.bundle.5f5e5ca1b811d13b75e8.js => index.bundle.45de86a592cd0d80ccd0.js} (63%) rename import/dist/{index.bundle.5f5e5ca1b811d13b75e8.js.LICENSE.txt => index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt} (100%) create mode 100644 import/dist/index.bundle.45de86a592cd0d80ccd0.js.map delete mode 100644 import/dist/index.bundle.5f5e5ca1b811d13b75e8.js.map diff --git a/import/dist/index.bundle.5f5e5ca1b811d13b75e8.js b/import/dist/index.bundle.45de86a592cd0d80ccd0.js similarity index 63% rename from import/dist/index.bundle.5f5e5ca1b811d13b75e8.js rename to import/dist/index.bundle.45de86a592cd0d80ccd0.js index 8fd39dd5..f36b19d2 100644 --- a/import/dist/index.bundle.5f5e5ca1b811d13b75e8.js +++ b/import/dist/index.bundle.45de86a592cd0d80ccd0.js @@ -1,3 +1,3 @@ -/*! For license information please see index.bundle.5f5e5ca1b811d13b75e8.js.LICENSE.txt */ -(()=>{"use strict";var e,t,r,n,a,o={954:(e,t,r)=>{var n=r(482),a=r(584);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 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 a={throw:1,return:2,break:3,continue:3};function o(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,a[e],t)},delegateYield:function(e,a,o){return t.resultName=a,r(n.d,u(e),o)},finish:function(e){return r(n.f,e)}},r=function(e,r,a){n.p=t.prev,n.n=t.next;try{return e(r,a)}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,a){return e.w(o(t),r,n,a&&a.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new v(e,t)},AsyncIterator:d,async:function(e,t,r,a,i){return(n(t)?f:s)(o(e),t,r,a,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(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 s(e,t,r,n,a){var o=f(e,t,r,n,a);return o.next().then(function(e){return e.done?e.value:o.next()})}function f(e,t,r,n,a){return new d(p().w(e,t,r,n),a||Promise)}function d(e,t){function r(n,a,o,i){try{var u=e[n](a),c=u.value;return c instanceof v?t.resolve(c.v).then(function(e){r("next",e,o,i)},function(e){r("throw",e,o,i)}):t.resolve(c).then(function(e){u.value=e,o(u)},function(e){return r("throw",e,o,i)})}catch(e){i(e)}}var n;this.next||(l(d.prototype),l(d.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),l(this,"_invoke",function(e,a,o){function i(){return new t(function(t,n){r(e,o,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",a=r.toStringTag||"@@toStringTag";function o(r,n,a,o){var c=n&&n.prototype instanceof u?n:u,s=Object.create(c.prototype);return l(s,"_invoke",function(r,n,a){var o,u,c,s=0,f=a||[],d=!1,p={p:0,n:0,v:e,a:l,f:l.bind(e,4),d:function(t,r){return o=t,u=0,c=e,p.n=r,i}};function l(r,n){for(u=r,c=n,t=0;!d&&s&&!a&&t3?(a=v===n)&&(c=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=l&&((a=r<2&&ln||n>v)&&(o[4]=r,o[5]=n,p.n=v,u=0))}if(a||r>1)return i;throw d=!0,n}return function(a,f,v){if(s>1)throw TypeError("Generator is already running");for(d&&1===f&&l(f,v),u=f,c=v;(t=u<2?e:c)||!d;){o||(u?u<3?(u>1&&(p.n=-1),l(u,c)):p.n=c:p.v=c);try{if(s=2,o){if(u||(a="next"),t=o[a]){if(!(t=t.call(o,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=o.return)&&t.call(o),u<2&&(c=TypeError("The iterator does not provide a '"+a+"' method"),u=1);o=e}else if((t=(d=p.n<0)?c:r.call(n,p))!==i)break}catch(t){o=e,u=1,c=t}finally{s=1}}return{value:t,done:d}}}(r,a,o),!0),s}var i={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(l(t={},n,function(){return this}),t),d=s.prototype=u.prototype=Object.create(f);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,l(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=s,l(d,"constructor",s),l(s,"constructor",c),c.displayName="GeneratorFunction",l(s,a,"GeneratorFunction"),l(d),l(d,a,"Generator"),l(d,n,function(){return this}),l(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:o,m:v}})()}function l(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}l=function(e,t,r,n){function o(t,r){l(e,t,function(e){return this._invoke(t,r,e)})}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(o("next",0),o("throw",1),o("return",2))},l(e,t,r,n)}function v(e,t){this.v=e,this.k=t}function y(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){y(o,n,a,i,u,"next",e)}function u(e){y(o,n,a,i,u,"throw",e)}i(void 0)})}}window.TKHQ=n;var h=null,m=new AbortController,g=new AbortController,w=!1,E=function(){var e=b(i().mark(function e(t){return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"INJECT_IMPORT_BUNDLE"!=t.data.type){e.next=9;break}return e.prev=1,e.next=4,k(t.data.value,t.data.organizationId,t.data.userId,t.data.requestId);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.sendMessageUp("ERROR",e.t0.toString(),t.data.requestId);case 9:if(!t.data||"EXTRACT_WALLET_ENCRYPTED_BUNDLE"!=t.data.type){e.next=18;break}return e.prev=10,e.next=13,T(t.data.requestId);case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(10),n.sendMessageUp("ERROR",e.t1.toString(),t.data.requestId);case 18:if(!t.data||"EXTRACT_KEY_ENCRYPTED_BUNDLE"!=t.data.type){e.next=27;break}return e.prev=19,e.next=22,P(t.data.keyFormat,t.data.requestId);case 22:e.next=27;break;case 24:e.prev=24,e.t2=e.catch(19),n.sendMessageUp("ERROR",e.t2.toString(),t.data.requestId);case 27:if(!t.data||"APPLY_SETTINGS"!=t.data.type){e.next=36;break}return e.prev=28,e.next=31,I(t.data.value,t.data.requestId);case 31:e.next=36;break;case 33:e.prev=33,e.t3=e.catch(28),n.sendMessageUp("ERROR",e.t3.toString(),t.data.requestId);case 36:case"end":return e.stop()}},e,null,[[1,6],[10,15],[19,24],[28,33]])}));return function(t){return e.apply(this,arguments)}}();function x(e){if(e.includes("\n--PASS--\n"))throw new Error('mnemonic cannot include the string "\\n--PASS--\\n"');if(e.includes("\n"))throw new Error("mnemonic cannot include newline characters")}function k(e,t,r,n){return S.apply(this,arguments)}function S(){return(S=b(i().mark(function e(t,r,a,o){var u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:c=JSON.parse(t),e.t0=c.version,e.next="v1.0.0"===e.t0?4:34;break;case 4:if(c.data){e.next=6;break}throw new Error('missing "data" in bundle');case 6:if(c.dataSignature){e.next=8;break}throw new Error('missing "dataSignature" in bundle');case 8:if(c.enclaveQuorumPublic){e.next=10;break}throw new Error('missing "enclaveQuorumPublic" in bundle');case 10:if(n.verifyEnclaveSignature){e.next=12;break}throw new Error("method not loaded");case 12:return e.next=14,n.verifyEnclaveSignature(c.enclaveQuorumPublic,c.dataSignature,c.data);case 14:if(e.sent){e.next=17;break}throw new Error("failed to verify enclave signature: ".concat(t));case 17:if(s=JSON.parse((new TextDecoder).decode(n.uint8arrayFromHexString(c.data))),r){e.next=22;break}console.warn('we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "organizationId" for security purposes.'),e.next=24;break;case 22:if(s.organizationId&&s.organizationId===r){e.next=24;break}throw new Error("organization id does not match expected value. Expected: ".concat(r,". Found: ").concat(s.organizationId,"."));case 24:if(a){e.next=28;break}console.warn('we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "userId" for security purposes.'),e.next=30;break;case 28:if(s.userId&&s.userId===a){e.next=30;break}throw new Error("user id does not match expected value. Expected: ".concat(a,". Found: ").concat(s.userId,"."));case 30:if(s.targetPublic){e.next=32;break}throw new Error('missing "targetPublic" in bundle signed data');case 32:return u=n.uint8arrayFromHexString(s.targetPublic),e.abrupt("break",35);case 34:throw new Error("unsupported version: ".concat(c.version));case 35:return e.next=37,n.loadTargetKey(new Uint8Array(u));case 37:f=e.sent,n.setTargetEmbeddedKey(f),n.sendMessageUp("BUNDLE_INJECTED",!0,o);case 40:case"end":return e.stop()}},e)}))).apply(this,arguments)}function T(e){return O.apply(this,arguments)}function O(){return(O=b(i().mark(function e(t){var r,o,u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(o=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no wallet mnemonic entered");case 6:return u=document.getElementById("passphrase").value,x(o),c=""===u?o:"".concat(o,"\n--PASS--\n").concat(u),s=(new TextEncoder).encode(c),e.next=12,(0,a.q)({plaintextBuf:s,receiverPubJwk:r});case 12:f=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",f,t);case 15:case"end":return e.stop()}},e)}))).apply(this,arguments)}function P(e,t){return _.apply(this,arguments)}function _(){return(_=b(i().mark(function e(t,r){var o,u,c,s;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(u=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no private key entered");case 6:return e.next=8,n.decodeKey(u,t);case 8:return c=e.sent,e.next=11,(0,a.q)({plaintextBuf:c,receiverPubJwk:o});case 11:s=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",s,r);case 14:case"end":return e.stop()}},e)}))).apply(this,arguments)}function I(e,t){return N.apply(this,arguments)}function N(){return(N=b(i().mark(function e(t,r){var a;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=n.applySettings(t),n.setSettings(a),n.sendMessageUp("SETTINGS_APPLIED",!0,r);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}document.addEventListener("DOMContentLoaded",b(i().mark(function e(){var t,r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window.addEventListener("message",E,{capture:!1,signal:m.signal}),m.signal.aborted){e.next=9;break}if((t=n.getSettings())&&n.applySettings(t),n.sendMessageUp("PUBLIC_KEY_READY",""),r=document.getElementById("plaintext")){e.next=8;break}return e.abrupt("return");case 8:r.addEventListener("paste",b(i().mark(function e(){var t;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"}).catch(function(){return null});case 3:if("granted"!==(null==(t=e.sent)?void 0:t.state)&&"prompt"!==(null==t?void 0:t.state)){e.next=7;break}return e.next=7,navigator.clipboard.writeText("");case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}},e,null,[[0,9]])})));case 9:case"end":return e.stop()}},e)})),!1),window.addEventListener("message",function(){var e=b(i().mark(function e(t){var r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"TURNKEY_INIT_MESSAGE_CHANNEL"!=t.data.type||null===(r=t.ports)||void 0===r||!r[0]){e.next=10;break}if(!w){e.next=3;break}return e.abrupt("return");case 3:w=!0,m.abort(),(h=t.ports[0]).onmessage=E,n.setParentFrameMessageChannelPort(h),n.sendMessageUp("PUBLIC_KEY_READY",""),g.abort();case 10:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),{signal:g.signal})}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.m=o,e=[],u.O=(t,r,n,a)=>{if(!r){var o=1/0;for(f=0;f=a)&&Object.keys(u.O).every(e=>u.O[e](r[c]))?r.splice(c--,1):(i=!1,a0&&e[f-1][2]>a;f--)e[f]=e[f-1];e[f]=[r,n,a]},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,u.t=function(e,n){if(1&n&&(e=this(e)),8&n)return e;if("object"==typeof e&&e){if(4&n&&e.__esModule)return e;if(16&n&&"function"==typeof e.then)return e}var a=Object.create(null);u.r(a);var o={};t=t||[null,r({}),r([]),r(r)];for(var i=2&n&&e;("object"==typeof i||"function"==typeof i)&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,u.d(a,o),a},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.f={},u.e=e=>Promise.all(Object.keys(u.f).reduce((t,r)=>(u.f[r](e,t),t),[])),u.u=e=>e+".bundle."+{291:"b62abe64ba4ebf68e89b",825:"3a4aff0e743a7540fe25"}[e]+".js",u.miniCssF=e=>{},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},a="import:",u.l=(e,t,r,o)=>{if(n[e])n[e].push(t);else{var i,c;if(void 0!==r)for(var s=document.getElementsByTagName("script"),f=0;f{i.onerror=i.onload=null,clearTimeout(l);var a=n[e];if(delete n[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(e=>e(r)),t)return t(r)},l=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),c&&document.head.appendChild(i)}},u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="/",(()=>{var e={57:0};u.f.j=(t,r)=>{var n=u.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var a=new Promise((r,a)=>n=e[t]=[r,a]);r.push(n[2]=a);var o=u.p+u.u(t),i=new Error;u.l(o,r=>{if(u.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}},"chunk-"+t,t)}},u.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,[o,i,c]=r,s=0;if(o.some(t=>0!==e[t])){for(n in i)u.o(i,n)&&(u.m[n]=i[n]);if(c)var f=c(u)}for(t&&t(r);su(954));c=u.O(c)})(); -//# sourceMappingURL=index.bundle.5f5e5ca1b811d13b75e8.js.map \ No newline at end of file +/*! For license information please see index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt */ +(()=>{"use strict";var e,t,r,n,a,o={954:(e,t,r)=>{var n=r(482),a=r(584);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 i(){var e=l(),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 a={throw:1,return:2,break:3,continue:3};function o(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,a[e],t)},delegateYield:function(e,a,o){return t.resultName=a,r(n.d,u(e),o)},finish:function(e){return r(n.f,e)}},r=function(e,r,a){n.p=t.prev,n.n=t.next;try{return e(r,a)}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,a){return e.w(o(t),r,n,a&&a.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new v(e,t)},AsyncIterator:d,async:function(e,t,r,a,i){return(n(t)?f:s)(o(e),t,r,a,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(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 s(e,t,r,n,a){var o=f(e,t,r,n,a);return o.next().then(function(e){return e.done?e.value:o.next()})}function f(e,t,r,n,a){return new d(l().w(e,t,r,n),a||Promise)}function d(e,t){function r(n,a,o,i){try{var u=e[n](a),c=u.value;return c instanceof v?t.resolve(c.v).then(function(e){r("next",e,o,i)},function(e){r("throw",e,o,i)}):t.resolve(c).then(function(e){u.value=e,o(u)},function(e){return r("throw",e,o,i)})}catch(e){i(e)}}var n;this.next||(p(d.prototype),p(d.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),p(this,"_invoke",function(e,a,o){function i(){return new t(function(t,n){r(e,o,t,n)})}return n=n?n.then(i,i):i()},!0)}function l(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function o(r,n,a,o){var c=n&&n.prototype instanceof u?n:u,s=Object.create(c.prototype);return p(s,"_invoke",function(r,n,a){var o,u,c,s=0,f=a||[],d=!1,l={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return o=t,u=0,c=e,l.n=r,i}};function p(r,n){for(u=r,c=n,t=0;!d&&s&&!a&&t3?(a=v===n)&&(c=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=p&&((a=r<2&&pn||n>v)&&(o[4]=r,o[5]=n,l.n=v,u=0))}if(a||r>1)return i;throw d=!0,n}return function(a,f,v){if(s>1)throw TypeError("Generator is already running");for(d&&1===f&&p(f,v),u=f,c=v;(t=u<2?e:c)||!d;){o||(u?u<3?(u>1&&(l.n=-1),p(u,c)):l.n=c:l.v=c);try{if(s=2,o){if(u||(a="next"),t=o[a]){if(!(t=t.call(o,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=o.return)&&t.call(o),u<2&&(c=TypeError("The iterator does not provide a '"+a+"' method"),u=1);o=e}else if((t=(d=l.n<0)?c:r.call(n,l))!==i)break}catch(t){o=e,u=1,c=t}finally{s=1}}return{value:t,done:d}}}(r,a,o),!0),s}var i={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(p(t={},n,function(){return this}),t),d=s.prototype=u.prototype=Object.create(f);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,p(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=s,p(d,"constructor",s),p(s,"constructor",c),c.displayName="GeneratorFunction",p(s,a,"GeneratorFunction"),p(d),p(d,a,"Generator"),p(d,n,function(){return this}),p(d,"toString",function(){return"[object Generator]"}),(l=function(){return{w:o,m:v}})()}function p(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}p=function(e,t,r,n){function o(t,r){p(e,t,function(e){return this._invoke(t,r,e)})}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(o("next",0),o("throw",1),o("return",2))},p(e,t,r,n)}function v(e,t){this.v=e,this.k=t}function y(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){y(o,n,a,i,u,"next",e)}function u(e){y(o,n,a,i,u,"throw",e)}i(void 0)})}}window.TKHQ=n;var h=null,g=new AbortController,m=new AbortController,w=!1,E=function(){var e=b(i().mark(function e(t){return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"INJECT_IMPORT_BUNDLE"!=t.data.type){e.next=9;break}return e.prev=1,e.next=4,k(t.data.value,t.data.organizationId,t.data.userId,t.data.requestId);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.sendMessageUp("ERROR",e.t0.toString(),t.data.requestId);case 9:if(!t.data||"EXTRACT_WALLET_ENCRYPTED_BUNDLE"!=t.data.type){e.next=18;break}return e.prev=10,e.next=13,T(t.data.requestId);case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(10),n.sendMessageUp("ERROR",e.t1.toString(),t.data.requestId);case 18:if(!t.data||"EXTRACT_KEY_ENCRYPTED_BUNDLE"!=t.data.type){e.next=27;break}return e.prev=19,e.next=22,P(t.data.keyFormat,t.data.requestId);case 22:e.next=27;break;case 24:e.prev=24,e.t2=e.catch(19),n.sendMessageUp("ERROR",e.t2.toString(),t.data.requestId);case 27:if(!t.data||"APPLY_SETTINGS"!=t.data.type){e.next=36;break}return e.prev=28,e.next=31,I(t.data.value,t.data.requestId);case 31:e.next=36;break;case 33:e.prev=33,e.t3=e.catch(28),n.sendMessageUp("ERROR",e.t3.toString(),t.data.requestId);case 36:case"end":return e.stop()}},e,null,[[1,6],[10,15],[19,24],[28,33]])}));return function(t){return e.apply(this,arguments)}}();function x(e){if(e.includes("\n--PASS--\n"))throw new Error('mnemonic cannot include the string "\\n--PASS--\\n"');if(e.includes("\n"))throw new Error("mnemonic cannot include newline characters")}function k(e,t,r,n){return S.apply(this,arguments)}function S(){return(S=b(i().mark(function e(t,r,a,o){var u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:c=JSON.parse(t),e.t0=c.version,e.next="v1.0.0"===e.t0?4:34;break;case 4:if(c.data){e.next=6;break}throw new Error('missing "data" in bundle');case 6:if(c.dataSignature){e.next=8;break}throw new Error('missing "dataSignature" in bundle');case 8:if(c.enclaveQuorumPublic){e.next=10;break}throw new Error('missing "enclaveQuorumPublic" in bundle');case 10:if(n.verifyEnclaveSignature){e.next=12;break}throw new Error("method not loaded");case 12:return e.next=14,n.verifyEnclaveSignature(c.enclaveQuorumPublic,c.dataSignature,c.data);case 14:if(e.sent){e.next=17;break}throw new Error("failed to verify enclave signature: ".concat(t));case 17:if(s=JSON.parse((new TextDecoder).decode(n.uint8arrayFromHexString(c.data))),r){e.next=22;break}console.warn('we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "organizationId" for security purposes.'),e.next=24;break;case 22:if(s.organizationId&&s.organizationId===r){e.next=24;break}throw new Error("organization id does not match expected value. Expected: ".concat(r,". Found: ").concat(s.organizationId,"."));case 24:if(a){e.next=28;break}console.warn('we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "userId" for security purposes.'),e.next=30;break;case 28:if(s.userId&&s.userId===a){e.next=30;break}throw new Error("user id does not match expected value. Expected: ".concat(a,". Found: ").concat(s.userId,"."));case 30:if(s.targetPublic){e.next=32;break}throw new Error('missing "targetPublic" in bundle signed data');case 32:return u=n.uint8arrayFromHexString(s.targetPublic),e.abrupt("break",35);case 34:throw new Error("unsupported version: ".concat(c.version));case 35:return e.next=37,n.loadTargetKey(new Uint8Array(u));case 37:f=e.sent,n.setTargetEmbeddedKey(f),n.sendMessageUp("BUNDLE_INJECTED",!0,o);case 40:case"end":return e.stop()}},e)}))).apply(this,arguments)}function T(e){return O.apply(this,arguments)}function O(){return(O=b(i().mark(function e(t){var r,o,u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(o=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no wallet mnemonic entered");case 6:return u=document.getElementById("passphrase").value,x(o),c=""===u?o:"".concat(o,"\n--PASS--\n").concat(u),s=(new TextEncoder).encode(c),e.next=12,(0,a.q)({plaintextBuf:s,receiverPubJwk:r});case 12:f=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",f,t);case 15:case"end":return e.stop()}},e)}))).apply(this,arguments)}function P(e,t){return _.apply(this,arguments)}function _(){return(_=b(i().mark(function e(t,r){var o,u,c,s;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(u=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no private key entered");case 6:return e.next=8,n.decodeKey(u,t);case 8:return c=e.sent,e.next=11,(0,a.q)({plaintextBuf:c,receiverPubJwk:o});case 11:s=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",s,r);case 14:case"end":return e.stop()}},e)}))).apply(this,arguments)}function I(e,t){return N.apply(this,arguments)}function N(){return(N=b(i().mark(function e(t,r){var a;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=n.applySettings(t),n.setSettings(a),n.sendMessageUp("SETTINGS_APPLIED",!0,r);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}document.addEventListener("DOMContentLoaded",b(i().mark(function e(){var t,r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window.addEventListener("message",E,{capture:!1,signal:g.signal}),g.signal.aborted){e.next=9;break}if((t=n.getSettings())&&n.applySettings(t),n.sendMessageUp("PUBLIC_KEY_READY",""),r=document.getElementById("plaintext")){e.next=8;break}return e.abrupt("return");case 8:r.addEventListener("paste",b(i().mark(function e(){var t;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"}).catch(function(){return null});case 3:if("granted"!==(null==(t=e.sent)?void 0:t.state)&&"prompt"!==(null==t?void 0:t.state)){e.next=7;break}return e.next=7,navigator.clipboard.writeText("");case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}},e,null,[[0,9]])})));case 9:case"end":return e.stop()}},e)})),!1),window.addEventListener("message",function(){var e=b(i().mark(function e(t){var r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"TURNKEY_INIT_MESSAGE_CHANNEL"!=t.data.type||t.source!==window.parent||!t.origin||"null"===t.origin||1!==(null===(r=t.ports)||void 0===r?void 0:r.length)){e.next=10;break}if(!w){e.next=3;break}return e.abrupt("return");case 3:w=!0,g.abort(),(h=t.ports[0]).onmessage=E,n.setParentFrameMessageChannelPort(h),n.sendMessageUp("PUBLIC_KEY_READY",""),m.abort();case 10:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),{signal:m.signal})}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.m=o,e=[],u.O=(t,r,n,a)=>{if(!r){var o=1/0;for(f=0;f=a)&&Object.keys(u.O).every(e=>u.O[e](r[c]))?r.splice(c--,1):(i=!1,a0&&e[f-1][2]>a;f--)e[f]=e[f-1];e[f]=[r,n,a]},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,u.t=function(e,n){if(1&n&&(e=this(e)),8&n)return e;if("object"==typeof e&&e){if(4&n&&e.__esModule)return e;if(16&n&&"function"==typeof e.then)return e}var a=Object.create(null);u.r(a);var o={};t=t||[null,r({}),r([]),r(r)];for(var i=2&n&&e;("object"==typeof i||"function"==typeof i)&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,u.d(a,o),a},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.f={},u.e=e=>Promise.all(Object.keys(u.f).reduce((t,r)=>(u.f[r](e,t),t),[])),u.u=e=>e+".bundle."+{291:"b62abe64ba4ebf68e89b",825:"3a4aff0e743a7540fe25"}[e]+".js",u.miniCssF=e=>{},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},a="import:",u.l=(e,t,r,o)=>{if(n[e])n[e].push(t);else{var i,c;if(void 0!==r)for(var s=document.getElementsByTagName("script"),f=0;f{i.onerror=i.onload=null,clearTimeout(p);var a=n[e];if(delete n[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(e=>e(r)),t)return t(r)},p=setTimeout(l.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=l.bind(null,i.onerror),i.onload=l.bind(null,i.onload),c&&document.head.appendChild(i)}},u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="/",(()=>{var e={57:0};u.f.j=(t,r)=>{var n=u.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var a=new Promise((r,a)=>n=e[t]=[r,a]);r.push(n[2]=a);var o=u.p+u.u(t),i=new Error;u.l(o,r=>{if(u.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}},"chunk-"+t,t)}},u.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,[o,i,c]=r,s=0;if(o.some(t=>0!==e[t])){for(n in i)u.o(i,n)&&(u.m[n]=i[n]);if(c)var f=c(u)}for(t&&t(r);su(954));c=u.O(c)})(); +//# sourceMappingURL=index.bundle.45de86a592cd0d80ccd0.js.map \ No newline at end of file diff --git a/import/dist/index.bundle.5f5e5ca1b811d13b75e8.js.LICENSE.txt b/import/dist/index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt similarity index 100% rename from import/dist/index.bundle.5f5e5ca1b811d13b75e8.js.LICENSE.txt rename to import/dist/index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt diff --git a/import/dist/index.bundle.45de86a592cd0d80ccd0.js.map b/import/dist/index.bundle.45de86a592cd0d80ccd0.js.map new file mode 100644 index 00000000..bcf2c89d --- /dev/null +++ b/import/dist/index.bundle.45de86a592cd0d80ccd0.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.bundle.45de86a592cd0d80ccd0.js","mappings":";uBAAIA,ECCAC,EADAC,ECAAC,EACAC,E,24ECAJ,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,OAAAL,EAAAC,WAAA,OAAAK,EAAAH,EAAA,mBAAAV,EAAAE,EAAAE,GAAA,IAAAE,EAAAC,EAAAG,EAAAI,EAAA,EAAAC,EAAAX,GAAA,GAAAY,GAAA,EAAAC,EAAA,CAAAF,EAAA,EAAAb,EAAA,EAAAgB,EAAApB,EAAAqB,EAAAC,EAAAN,EAAAM,EAAAC,KAAAvB,EAAA,GAAAsB,EAAA,SAAArB,EAAAC,GAAA,OAAAM,EAAAP,EAAAQ,EAAA,EAAAG,EAAAZ,EAAAmB,EAAAf,EAAAF,EAAAmB,CAAA,YAAAC,EAAApB,EAAAE,GAAA,IAAAK,EAAAP,EAAAU,EAAAR,EAAAH,EAAA,GAA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,IAAa,CACtD,IAAIjF,KAAY8E,EACZ/E,EAAoB1K,EAAEyP,EAAa9E,KACrCD,EAAoB1I,EAAE2I,GAAY8E,EAAY9E,IAGhD,GAAG+E,EAAS,IAAIxE,EAASwE,EAAQhF,EAClC,CAEA,IADG8E,GAA4BA,EAA2BtL,GACrDhE,EAAIiL,EAASjK,OAAQhB,IACzBwM,EAAUvB,EAASjL,GAChBwK,EAAoB1K,EAAE8O,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAOhC,EAAoBO,EAAEC,IAG1B2E,EAAqBC,KAAyB,mBAAIA,KAAyB,oBAAK,GACpFD,EAAmBtD,QAAQgD,EAAqBtO,KAAK,KAAM,IAC3D4O,EAAmBxC,KAAOkC,EAAqBtO,KAAK,KAAM4O,EAAmBxC,KAAKpM,KAAK4O,G,KClFvF,IAAIE,EAAsBrF,EAAoBO,OAAEJ,EAAW,CAAC,GAAG,KAAM,IAAOH,EAAoB,MAChGqF,EAAsBrF,EAAoBO,EAAE8E,E","sources":["webpack://import/webpack/runtime/chunk loaded","webpack://import/webpack/runtime/create fake namespace object","webpack://import/webpack/runtime/load script","webpack://import/./src/index.js","webpack://import/webpack/bootstrap","webpack://import/webpack/runtime/define property getters","webpack://import/webpack/runtime/ensure chunk","webpack://import/webpack/runtime/get javascript chunk filename","webpack://import/webpack/runtime/get mini-css chunk filename","webpack://import/webpack/runtime/global","webpack://import/webpack/runtime/hasOwnProperty shorthand","webpack://import/webpack/runtime/make namespace object","webpack://import/webpack/runtime/publicPath","webpack://import/webpack/runtime/jsonp chunk loading","webpack://import/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 = \"import:\";\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}\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 \"./styles.css\";\nimport * as TKHQ from \"./turnkey-core.js\";\nimport { HpkeEncrypt } from \"@shared/crypto-utils.js\";\n\n// Make TKHQ available globally for backwards compatibility\nwindow.TKHQ = TKHQ;\n\n// persist the MessageChannel object so we can use it to communicate with the parent window\nvar iframeMessagePort = null;\n\n// controllers to remove event listeners\nconst messageListenerController = new AbortController();\nconst turnkeyInitController = new AbortController();\n\n// Guard to prevent concurrent channel establishment from multiple senders\nlet channelEstablished = false;\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nvar messageEventListener = async function (event) {\n if (event.data && event.data[\"type\"] == \"INJECT_IMPORT_BUNDLE\") {\n try {\n await onInjectImportBundle(\n event.data[\"value\"],\n event.data[\"organizationId\"],\n event.data[\"userId\"],\n event.data[\"requestId\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_WALLET_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractWalletEncryptedBundle(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_KEY_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractKeyEncryptedBundle(\n event.data[\"keyFormat\"],\n event.data[\"requestId\"]\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};\n\n/**\n * Broadcast that the frame is ready and set up the message event listeners\n */\ndocument.addEventListener(\n \"DOMContentLoaded\",\n async function () {\n window.addEventListener(\"message\", messageEventListener, {\n capture: false,\n signal: messageListenerController.signal,\n });\n\n if (!messageListenerController.signal.aborted) {\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 // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\n\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) return;\n // Clear clipboard after paste to avoid sensitive data lingering in clipboard.\n\n plaintextTextarea.addEventListener(\"paste\", async () => {\n // Let the paste happen first\n try {\n // Check clipboard-write permission first. In new versions of iframe-stamper, we add this permission when creating the iframe. In older versions, this permission is not added.\n const permStatus = await navigator.permissions\n .query({ name: \"clipboard-write\" }) // This is required to avoid error on clipboard write\n .catch(() => null);\n\n // Proceed only if granted or promptable\n if (\n permStatus?.state === \"granted\" ||\n permStatus?.state === \"prompt\"\n ) {\n await navigator.clipboard.writeText(\"\");\n }\n } catch {\n // Silently ignore any errors — no warnings or console noise\n }\n });\n }\n },\n false\n);\n\nwindow.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.source === window.parent &&\n event.origin &&\n event.origin !== \"null\" &&\n event.ports?.length === 1\n ) {\n // Synchronously check-and-set the flag before any await. This prevents\n // a second concurrent invocation from racing through while the first is\n // suspended at an await, which would allow multiple origins to establish\n // a channel before turnkeyInitController.abort() is reached.\n if (channelEstablished) {\n return;\n }\n channelEstablished = true;\n\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\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// make sure the mnemonic does not include our splitter (\\n--PASS--\\n) string or \\n characters\nfunction validateMnemonic(mnemonic) {\n if (mnemonic.includes(\"\\n--PASS--\\n\")) {\n throw new Error('mnemonic cannot include the string \"\\\\n--PASS--\\\\n\"');\n }\n if (mnemonic.includes(\"\\n\")) {\n throw new Error(\"mnemonic cannot include newline characters\");\n }\n}\n\n/**\n * Function triggered when INJECT_IMPORT_BUNDLE event is received.\n * Parses the `import_bundle` and stores the target public key as a JWK\n * in local storage. Sends true upon success.\n * @param {string} bundle\n * Example bundle: {\"targetPublic\":\"0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f\",\"targetPublicSignature\":\"3045022100cefc333c330c9fa300d1aa10a439a76539b4d6967301638ab9edc9fd9468bfdb0220339bba7e2b00b45d52e941d068ecd3bfd16fd1926da69dd7769893268990d62f\",\"enclaveQuorumPublic\":\"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\"}\n * @param {string} organizationId\n * @param {string} userId\n * @param {string} requestId\n */\nasync function onInjectImportBundle(bundle, organizationId, userId, requestId) {\n let targetPublicBuf;\n let verified;\n\n // Parse the import bundle\n const bundleObj = JSON.parse(bundle);\n\n switch (bundleObj.version) {\n case \"v1.0.0\": {\n // Validate fields exist\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 // Verify enclave signature\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method not loaded\");\n }\n verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(`failed to verify enclave signature: ${bundle}`);\n }\n\n // Parse the signed data. The data is produced by JSON encoding followed by hex encoding. We reverse this here.\n const signedData = JSON.parse(\n new TextDecoder().decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n // Validate fields match\n if (!organizationId) {\n // TODO: throw error if organization id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper\n console.warn(\n 'we highly recommend a version of @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 if (!userId) {\n // TODO: throw error if user id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper\n console.warn(\n 'we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass \"userId\" for security purposes.'\n );\n } else if (!signedData.userId || signedData.userId !== userId) {\n throw new Error(\n `user id does not match expected value. Expected: ${userId}. Found: ${signedData.userId}.`\n );\n }\n\n if (!signedData.targetPublic) {\n throw new Error('missing \"targetPublic\" in bundle signed data');\n }\n\n // Load target public key generated from enclave and set in local storage\n targetPublicBuf = TKHQ.uint8arrayFromHexString(signedData.targetPublic);\n break;\n }\n default:\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n\n const targetPublicKeyJwk = await TKHQ.loadTargetKey(\n new Uint8Array(targetPublicBuf)\n );\n TKHQ.setTargetEmbeddedKey(targetPublicKeyJwk);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_WALLET_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} requestId\n */\nasync function onExtractWalletEncryptedBundle(requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext wallet mnemonic\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no wallet mnemonic entered\");\n }\n\n const passphrase = document.getElementById(\"passphrase\").value;\n\n validateMnemonic(plaintext);\n\n const combined =\n passphrase === \"\" ? plaintext : `${plaintext}\\n--PASS--\\n${passphrase}`;\n const plaintextBuf = new TextEncoder().encode(combined);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_KEY_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} keyFormat\n * @param {string} requestId\n */\nasync function onExtractKeyEncryptedBundle(keyFormat, requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext private key\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no private key entered\");\n }\n const plaintextBuf = await TKHQ.decodeKey(plaintext, keyFormat);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, 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","// 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\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\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","// 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 \"\" + chunkId + \".bundle.\" + {\"291\":\"b62abe64ba4ebf68e89b\",\"825\":\"3a4aff0e743a7540fe25\"}[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__.p = \"/\";","// 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\t57: 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[\"webpackChunkimport\"] = self[\"webpackChunkimport\"] || [];\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,551], () => (__webpack_require__(954)))\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","_OverloadYield","k","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","window","TKHQ","iframeMessagePort","messageListenerController","AbortController","turnkeyInitController","channelEstablished","messageEventListener","_ref","_regeneratorRuntime","mark","_callee","event","wrap","_context","prev","next","data","onInjectImportBundle","t0","toString","onExtractWalletEncryptedBundle","t1","onExtractKeyEncryptedBundle","t2","onApplySettings","t3","stop","_x","validateMnemonic","mnemonic","includes","Error","_x3","_x4","_x5","_x6","_onInjectImportBundle","_callee5","bundle","organizationId","userId","requestId","targetPublicBuf","bundleObj","signedData","targetPublicKeyJwk","_context5","JSON","parse","version","dataSignature","enclaveQuorumPublic","sent","concat","TextDecoder","decode","console","warn","targetPublic","abrupt","Uint8Array","_x7","_onExtractWalletEncryptedBundle","_callee6","plaintext","passphrase","combined","plaintextBuf","encryptedBundle","_context6","document","getElementById","trim","TextEncoder","encode","HpkeEncrypt","receiverPubJwk","_x8","_x9","_onExtractKeyEncryptedBundle","_callee7","keyFormat","_context7","_x10","_x11","_onApplySettings","_callee8","settings","validSettings","_context8","addEventListener","_callee3","styleSettings","plaintextTextarea","_context3","capture","signal","aborted","_callee2","permStatus","_context2","navigator","permissions","query","name","state","clipboard","writeText","_ref4","_callee4","_event$ports","_context4","source","parent","origin","ports","abort","onmessage","_x2","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","key","splice","obj","mode","this","__esModule","ns","def","current","indexOf","getOwnPropertyNames","forEach","definition","get","chunkId","all","reduce","promises","miniCssF","g","globalThis","Function","prop","hasOwnProperty","url","push","script","needAttach","scripts","getElementsByTagName","s","getAttribute","createElement","charset","nc","setAttribute","src","onScriptComplete","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","type","target","head","appendChild","installedChunks","installedChunkData","promise","reject","error","errorType","realSrc","message","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","id","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/index.bundle.5f5e5ca1b811d13b75e8.js.map b/import/dist/index.bundle.5f5e5ca1b811d13b75e8.js.map deleted file mode 100644 index 6168da4e..00000000 --- a/import/dist/index.bundle.5f5e5ca1b811d13b75e8.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.bundle.5f5e5ca1b811d13b75e8.js","mappings":";uBAAIA,ECCAC,EADAC,ECAAC,EACAC,E,24ECAJ,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,OAAAL,EAAAC,WAAA,OAAAK,EAAAH,EAAA,mBAAAV,EAAAE,EAAAE,GAAA,IAAAE,EAAAC,EAAAG,EAAAI,EAAA,EAAAC,EAAAX,GAAA,GAAAY,GAAA,EAAAC,EAAA,CAAAF,EAAA,EAAAb,EAAA,EAAAgB,EAAApB,EAAAqB,EAAAC,EAAAN,EAAAM,EAAAC,KAAAvB,EAAA,GAAAsB,EAAA,SAAArB,EAAAC,GAAA,OAAAM,EAAAP,EAAAQ,EAAA,EAAAG,EAA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8K,EAASwE,KAAMC,GAAgC,IAAxBd,EAAgBc,IAAa,CACtD,IAAIjF,KAAY8E,EACZ/E,EAAoBvK,EAAEsP,EAAa9E,KACrCD,EAAoBvI,EAAEwI,GAAY8E,EAAY9E,IAGhD,GAAG+E,EAAS,IAAIxE,EAASwE,EAAQhF,EAClC,CAEA,IADG8E,GAA4BA,EAA2BnL,GACrDhE,EAAI8K,EAAS9J,OAAQhB,IACzBqM,EAAUvB,EAAS9K,GAChBqK,EAAoBvK,EAAE2O,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAOhC,EAAoBO,EAAEC,IAG1B2E,EAAqBC,KAAyB,mBAAIA,KAAyB,oBAAK,GACpFD,EAAmBtD,QAAQgD,EAAqBnO,KAAK,KAAM,IAC3DyO,EAAmBxC,KAAOkC,EAAqBnO,KAAK,KAAMyO,EAAmBxC,KAAKjM,KAAKyO,G,KClFvF,IAAIE,EAAsBrF,EAAoBO,OAAEJ,EAAW,CAAC,GAAG,KAAM,IAAOH,EAAoB,MAChGqF,EAAsBrF,EAAoBO,EAAE8E,E","sources":["webpack://import/webpack/runtime/chunk loaded","webpack://import/webpack/runtime/create fake namespace object","webpack://import/webpack/runtime/load script","webpack://import/./src/index.js","webpack://import/webpack/bootstrap","webpack://import/webpack/runtime/define property getters","webpack://import/webpack/runtime/ensure chunk","webpack://import/webpack/runtime/get javascript chunk filename","webpack://import/webpack/runtime/get mini-css chunk filename","webpack://import/webpack/runtime/global","webpack://import/webpack/runtime/hasOwnProperty shorthand","webpack://import/webpack/runtime/make namespace object","webpack://import/webpack/runtime/publicPath","webpack://import/webpack/runtime/jsonp chunk loading","webpack://import/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 = \"import:\";\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}\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 \"./styles.css\";\nimport * as TKHQ from \"./turnkey-core.js\";\nimport { HpkeEncrypt } from \"@shared/crypto-utils.js\";\n\n// Make TKHQ available globally for backwards compatibility\nwindow.TKHQ = TKHQ;\n\n// persist the MessageChannel object so we can use it to communicate with the parent window\nvar iframeMessagePort = null;\n\n// controllers to remove event listeners\nconst messageListenerController = new AbortController();\nconst turnkeyInitController = new AbortController();\n\n// Guard to prevent concurrent channel establishment from multiple senders\nlet channelEstablished = false;\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nvar messageEventListener = async function (event) {\n if (event.data && event.data[\"type\"] == \"INJECT_IMPORT_BUNDLE\") {\n try {\n await onInjectImportBundle(\n event.data[\"value\"],\n event.data[\"organizationId\"],\n event.data[\"userId\"],\n event.data[\"requestId\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_WALLET_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractWalletEncryptedBundle(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_KEY_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractKeyEncryptedBundle(\n event.data[\"keyFormat\"],\n event.data[\"requestId\"]\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};\n\n/**\n * Broadcast that the frame is ready and set up the message event listeners\n */\ndocument.addEventListener(\n \"DOMContentLoaded\",\n async function () {\n window.addEventListener(\"message\", messageEventListener, {\n capture: false,\n signal: messageListenerController.signal,\n });\n\n if (!messageListenerController.signal.aborted) {\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 // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\n\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) return;\n // Clear clipboard after paste to avoid sensitive data lingering in clipboard.\n\n plaintextTextarea.addEventListener(\"paste\", async () => {\n // Let the paste happen first\n try {\n // Check clipboard-write permission first. In new versions of iframe-stamper, we add this permission when creating the iframe. In older versions, this permission is not added.\n const permStatus = await navigator.permissions\n .query({ name: \"clipboard-write\" }) // This is required to avoid error on clipboard write\n .catch(() => null);\n\n // Proceed only if granted or promptable\n if (\n permStatus?.state === \"granted\" ||\n permStatus?.state === \"prompt\"\n ) {\n await navigator.clipboard.writeText(\"\");\n }\n } catch {\n // Silently ignore any errors — no warnings or console noise\n }\n });\n }\n },\n false\n);\n\nwindow.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 // Synchronously check-and-set the flag before any await. This prevents\n // a second concurrent invocation from racing through while the first is\n // suspended at an await, which would allow multiple origins to establish\n // a channel before turnkeyInitController.abort() is reached.\n if (channelEstablished) {\n return;\n }\n channelEstablished = true;\n\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\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// make sure the mnemonic does not include our splitter (\\n--PASS--\\n) string or \\n characters\nfunction validateMnemonic(mnemonic) {\n if (mnemonic.includes(\"\\n--PASS--\\n\")) {\n throw new Error('mnemonic cannot include the string \"\\\\n--PASS--\\\\n\"');\n }\n if (mnemonic.includes(\"\\n\")) {\n throw new Error(\"mnemonic cannot include newline characters\");\n }\n}\n\n/**\n * Function triggered when INJECT_IMPORT_BUNDLE event is received.\n * Parses the `import_bundle` and stores the target public key as a JWK\n * in local storage. Sends true upon success.\n * @param {string} bundle\n * Example bundle: {\"targetPublic\":\"0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f\",\"targetPublicSignature\":\"3045022100cefc333c330c9fa300d1aa10a439a76539b4d6967301638ab9edc9fd9468bfdb0220339bba7e2b00b45d52e941d068ecd3bfd16fd1926da69dd7769893268990d62f\",\"enclaveQuorumPublic\":\"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\"}\n * @param {string} organizationId\n * @param {string} userId\n * @param {string} requestId\n */\nasync function onInjectImportBundle(bundle, organizationId, userId, requestId) {\n let targetPublicBuf;\n let verified;\n\n // Parse the import bundle\n const bundleObj = JSON.parse(bundle);\n\n switch (bundleObj.version) {\n case \"v1.0.0\": {\n // Validate fields exist\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 // Verify enclave signature\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method not loaded\");\n }\n verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(`failed to verify enclave signature: ${bundle}`);\n }\n\n // Parse the signed data. The data is produced by JSON encoding followed by hex encoding. We reverse this here.\n const signedData = JSON.parse(\n new TextDecoder().decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n // Validate fields match\n if (!organizationId) {\n // TODO: throw error if organization id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper\n console.warn(\n 'we highly recommend a version of @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 if (!userId) {\n // TODO: throw error if user id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper\n console.warn(\n 'we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass \"userId\" for security purposes.'\n );\n } else if (!signedData.userId || signedData.userId !== userId) {\n throw new Error(\n `user id does not match expected value. Expected: ${userId}. Found: ${signedData.userId}.`\n );\n }\n\n if (!signedData.targetPublic) {\n throw new Error('missing \"targetPublic\" in bundle signed data');\n }\n\n // Load target public key generated from enclave and set in local storage\n targetPublicBuf = TKHQ.uint8arrayFromHexString(signedData.targetPublic);\n break;\n }\n default:\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n\n const targetPublicKeyJwk = await TKHQ.loadTargetKey(\n new Uint8Array(targetPublicBuf)\n );\n TKHQ.setTargetEmbeddedKey(targetPublicKeyJwk);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_WALLET_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} requestId\n */\nasync function onExtractWalletEncryptedBundle(requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext wallet mnemonic\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no wallet mnemonic entered\");\n }\n\n const passphrase = document.getElementById(\"passphrase\").value;\n\n validateMnemonic(plaintext);\n\n const combined =\n passphrase === \"\" ? plaintext : `${plaintext}\\n--PASS--\\n${passphrase}`;\n const plaintextBuf = new TextEncoder().encode(combined);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_KEY_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} keyFormat\n * @param {string} requestId\n */\nasync function onExtractKeyEncryptedBundle(keyFormat, requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext private key\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no private key entered\");\n }\n const plaintextBuf = await TKHQ.decodeKey(plaintext, keyFormat);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, 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","// 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\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\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","// 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 \"\" + chunkId + \".bundle.\" + {\"291\":\"b62abe64ba4ebf68e89b\",\"825\":\"3a4aff0e743a7540fe25\"}[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__.p = \"/\";","// 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\t57: 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[\"webpackChunkimport\"] = self[\"webpackChunkimport\"] || [];\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,551], () => (__webpack_require__(954)))\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","_OverloadYield","k","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","window","TKHQ","iframeMessagePort","messageListenerController","AbortController","turnkeyInitController","channelEstablished","messageEventListener","_ref","_regeneratorRuntime","mark","_callee","event","wrap","_context","prev","next","data","onInjectImportBundle","t0","toString","onExtractWalletEncryptedBundle","t1","onExtractKeyEncryptedBundle","t2","onApplySettings","t3","stop","_x","validateMnemonic","mnemonic","includes","Error","_x3","_x4","_x5","_x6","_onInjectImportBundle","_callee5","bundle","organizationId","userId","requestId","targetPublicBuf","bundleObj","signedData","targetPublicKeyJwk","_context5","JSON","parse","version","dataSignature","enclaveQuorumPublic","sent","concat","TextDecoder","decode","console","warn","targetPublic","abrupt","Uint8Array","_x7","_onExtractWalletEncryptedBundle","_callee6","plaintext","passphrase","combined","plaintextBuf","encryptedBundle","_context6","document","getElementById","trim","TextEncoder","encode","HpkeEncrypt","receiverPubJwk","_x8","_x9","_onExtractKeyEncryptedBundle","_callee7","keyFormat","_context7","_x10","_x11","_onApplySettings","_callee8","settings","validSettings","_context8","addEventListener","_callee3","styleSettings","plaintextTextarea","_context3","capture","signal","aborted","_callee2","permStatus","_context2","navigator","permissions","query","name","state","clipboard","writeText","_ref4","_callee4","_event$ports","_context4","ports","abort","onmessage","_x2","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","key","splice","obj","mode","this","__esModule","ns","def","current","indexOf","getOwnPropertyNames","forEach","definition","get","chunkId","all","reduce","promises","miniCssF","g","globalThis","Function","prop","hasOwnProperty","url","push","script","needAttach","scripts","getElementsByTagName","s","getAttribute","createElement","charset","nc","setAttribute","src","onScriptComplete","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","type","target","head","appendChild","installedChunks","installedChunkData","promise","reject","error","errorType","realSrc","message","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","id","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/index.html b/import/dist/index.html index 2d6f67f1..76b4ba4d 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/index.test.js b/import/index.test.js index 0fafc3e8..cde4f6f3 100644 --- a/import/index.test.js +++ b/import/index.test.js @@ -425,3 +425,145 @@ describe("TKHQ", () => { expect(TKHQ.validateStyles(allStylesValid)).toEqual(allStylesValid); }); }); + +// --------------------------------------------------------------------------- +// TURNKEY_INIT_MESSAGE_CHANNEL gate validation (INT-783) +// +// These tests verify that the second window.addEventListener("message", ...) +// handler in index.js — the one that establishes the MessageChannel — now +// enforces the same cross-origin gate added to export-and-sign in PR #129: +// • event.source === window.parent (direct parent only) +// • event.origin && event.origin !== "null" (no opaque origins) +// • event.ports?.length === 1 (exactly one transferred port) +// --------------------------------------------------------------------------- + +describe("TURNKEY_INIT_MESSAGE_CHANNEL gate (import frame)", () => { + let dom; + let TKHQModule; + let parentWindow; + + /** + * index.js registers its listeners as module-level side effects. + * We use jest.isolateModules + require() to force a fresh module evaluation + * per test. The listeners bind to the jest-environment's built-in `window` + * (which is already JSDOM), so AbortSignal instanceof checks pass correctly. + */ + beforeEach(async () => { + parentWindow = {}; + + // Override window.parent on the jest-environment window so that + // `event.source === window.parent` comparisons work as expected. + Object.defineProperty(window, "parent", { + configurable: true, + value: parentWindow, + }); + + global.crypto = crypto.webcrypto; + + // Isolate and load the module so its top-level addEventListener calls fire + // against the jest-env window. + await new Promise((resolve) => { + jest.isolateModules(() => { + jest.mock("./src/styles.css", () => {}, { virtual: true }); + jest.mock("@shared/crypto-utils.js", () => ({ + HpkeEncrypt: jest.fn(), + })); + + // Load turnkey-core inside isolation so we can spy on it. + TKHQModule = require("./src/turnkey-core.js"); + jest.spyOn(TKHQModule, "sendMessageUp").mockImplementation(() => {}); + jest + .spyOn(TKHQModule, "setParentFrameMessageChannelPort") + .mockImplementation(() => {}); + + require("./src/index.js"); + resolve(); + }); + }); + }); + + afterEach(() => { + jest.restoreAllMocks(); + // Restore window.parent to its original value (itself, in standalone JSDOM) + Object.defineProperty(window, "parent", { + configurable: true, + value: window, + }); + }); + + /** Build a well-formed TURNKEY_INIT_MESSAGE_CHANNEL MessageEvent. */ + function makeInitEvent( + origin = "https://app.turnkey.com", + source = parentWindow, + portCount = 1 + ) { + const ports = Array.from({ length: portCount }, () => ({ + onmessage: null, + postMessage: jest.fn(), + })); + const event = new window.MessageEvent("message", { + data: { type: "TURNKEY_INIT_MESSAGE_CHANNEL" }, + ports, + origin, + }); + Object.defineProperty(event, "source", { value: source }); + return { event, ports }; + } + + it("accepts a valid TURNKEY_INIT_MESSAGE_CHANNEL from the parent", async () => { + const { event } = makeInitEvent(); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(TKHQModule.setParentFrameMessageChannelPort).toHaveBeenCalledTimes( + 1 + ); + expect(TKHQModule.sendMessageUp).toHaveBeenCalledWith( + "PUBLIC_KEY_READY", + "" + ); + }); + + it("rejects a message whose source is not window.parent", async () => { + const { event } = makeInitEvent( + "https://app.turnkey.com", + {} // a different object — not parentWindow + ); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(TKHQModule.setParentFrameMessageChannelPort).not.toHaveBeenCalled(); + }); + + it("rejects a message with an opaque ('null') origin", async () => { + const { event } = makeInitEvent("null"); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(TKHQModule.setParentFrameMessageChannelPort).not.toHaveBeenCalled(); + }); + + it("rejects a message with an empty origin", async () => { + const { event } = makeInitEvent(""); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(TKHQModule.setParentFrameMessageChannelPort).not.toHaveBeenCalled(); + }); + + it("rejects a message with zero transferred ports", async () => { + const { event } = makeInitEvent("https://app.turnkey.com", parentWindow, 0); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(TKHQModule.setParentFrameMessageChannelPort).not.toHaveBeenCalled(); + }); + + it("rejects a message with more than one transferred port", async () => { + const { event } = makeInitEvent("https://app.turnkey.com", parentWindow, 2); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(TKHQModule.setParentFrameMessageChannelPort).not.toHaveBeenCalled(); + }); +}); diff --git a/import/src/index.js b/import/src/index.js index 6898e78f..7f6bd6c8 100644 --- a/import/src/index.js +++ b/import/src/index.js @@ -121,7 +121,10 @@ window.addEventListener( if ( event.data && event.data["type"] == "TURNKEY_INIT_MESSAGE_CHANNEL" && - event.ports?.[0] + event.source === window.parent && + event.origin && + event.origin !== "null" && + event.ports?.length === 1 ) { // Synchronously check-and-set the flag before any await. This prevents // a second concurrent invocation from racing through while the first is From e0a04e07735411898f493883cc89428bcd46e487 Mon Sep 17 00:00:00 2001 From: Justin Formentin Date: Mon, 10 Aug 2026 11:00:53 -0400 Subject: [PATCH 2/3] fix(import): reject import bundles missing organizationId/userId binding (ENG-4597) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, onInjectImportBundle() in the v1.0.0 path would only log a console.warn when organizationId or userId was omitted by the caller, allowing signed import bundles to be accepted without org/user binding. This change converts both warnings into hard errors: - Missing organizationId → throws with message indicating iframe-stamper >= v2.0.0 is required - Missing userId → throws with same guidance The existing equality checks (signedData must match the supplied values) are preserved unchanged. The now-obsolete TODO comments and console.warn calls are removed. Tests: new describe block 'onInjectImportBundle org/user binding (import frame)' in import/index.test.js covers: - missing organizationId (undefined and empty string) - missing userId (undefined and empty string) - mismatched organizationId / userId still throws - valid matching bundle succeeds (BUNDLE_INJECTED) Bundle rebuilt: index.bundle.808edbe601034931b90e.js --- .../dist/index.bundle.45de86a592cd0d80ccd0.js | 3 - .../index.bundle.45de86a592cd0d80ccd0.js.map | 1 - .../dist/index.bundle.808edbe601034931b90e.js | 3 + ...undle.808edbe601034931b90e.js.LICENSE.txt} | 0 .../index.bundle.808edbe601034931b90e.js.map | 1 + import/dist/index.html | 2 +- import/index.test.js | 208 ++++++++++++++++++ import/src/index.js | 10 +- 8 files changed, 217 insertions(+), 11 deletions(-) delete mode 100644 import/dist/index.bundle.45de86a592cd0d80ccd0.js delete mode 100644 import/dist/index.bundle.45de86a592cd0d80ccd0.js.map create mode 100644 import/dist/index.bundle.808edbe601034931b90e.js rename import/dist/{index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt => index.bundle.808edbe601034931b90e.js.LICENSE.txt} (100%) create mode 100644 import/dist/index.bundle.808edbe601034931b90e.js.map diff --git a/import/dist/index.bundle.45de86a592cd0d80ccd0.js b/import/dist/index.bundle.45de86a592cd0d80ccd0.js deleted file mode 100644 index f36b19d2..00000000 --- a/import/dist/index.bundle.45de86a592cd0d80ccd0.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! For license information please see index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt */ -(()=>{"use strict";var e,t,r,n,a,o={954:(e,t,r)=>{var n=r(482),a=r(584);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 i(){var e=l(),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 a={throw:1,return:2,break:3,continue:3};function o(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,a[e],t)},delegateYield:function(e,a,o){return t.resultName=a,r(n.d,u(e),o)},finish:function(e){return r(n.f,e)}},r=function(e,r,a){n.p=t.prev,n.n=t.next;try{return e(r,a)}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,a){return e.w(o(t),r,n,a&&a.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new v(e,t)},AsyncIterator:d,async:function(e,t,r,a,i){return(n(t)?f:s)(o(e),t,r,a,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(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 s(e,t,r,n,a){var o=f(e,t,r,n,a);return o.next().then(function(e){return e.done?e.value:o.next()})}function f(e,t,r,n,a){return new d(l().w(e,t,r,n),a||Promise)}function d(e,t){function r(n,a,o,i){try{var u=e[n](a),c=u.value;return c instanceof v?t.resolve(c.v).then(function(e){r("next",e,o,i)},function(e){r("throw",e,o,i)}):t.resolve(c).then(function(e){u.value=e,o(u)},function(e){return r("throw",e,o,i)})}catch(e){i(e)}}var n;this.next||(p(d.prototype),p(d.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),p(this,"_invoke",function(e,a,o){function i(){return new t(function(t,n){r(e,o,t,n)})}return n=n?n.then(i,i):i()},!0)}function l(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function o(r,n,a,o){var c=n&&n.prototype instanceof u?n:u,s=Object.create(c.prototype);return p(s,"_invoke",function(r,n,a){var o,u,c,s=0,f=a||[],d=!1,l={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return o=t,u=0,c=e,l.n=r,i}};function p(r,n){for(u=r,c=n,t=0;!d&&s&&!a&&t3?(a=v===n)&&(c=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=p&&((a=r<2&&pn||n>v)&&(o[4]=r,o[5]=n,l.n=v,u=0))}if(a||r>1)return i;throw d=!0,n}return function(a,f,v){if(s>1)throw TypeError("Generator is already running");for(d&&1===f&&p(f,v),u=f,c=v;(t=u<2?e:c)||!d;){o||(u?u<3?(u>1&&(l.n=-1),p(u,c)):l.n=c:l.v=c);try{if(s=2,o){if(u||(a="next"),t=o[a]){if(!(t=t.call(o,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=o.return)&&t.call(o),u<2&&(c=TypeError("The iterator does not provide a '"+a+"' method"),u=1);o=e}else if((t=(d=l.n<0)?c:r.call(n,l))!==i)break}catch(t){o=e,u=1,c=t}finally{s=1}}return{value:t,done:d}}}(r,a,o),!0),s}var i={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(p(t={},n,function(){return this}),t),d=s.prototype=u.prototype=Object.create(f);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,p(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=s,p(d,"constructor",s),p(s,"constructor",c),c.displayName="GeneratorFunction",p(s,a,"GeneratorFunction"),p(d),p(d,a,"Generator"),p(d,n,function(){return this}),p(d,"toString",function(){return"[object Generator]"}),(l=function(){return{w:o,m:v}})()}function p(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}p=function(e,t,r,n){function o(t,r){p(e,t,function(e){return this._invoke(t,r,e)})}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(o("next",0),o("throw",1),o("return",2))},p(e,t,r,n)}function v(e,t){this.v=e,this.k=t}function y(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){y(o,n,a,i,u,"next",e)}function u(e){y(o,n,a,i,u,"throw",e)}i(void 0)})}}window.TKHQ=n;var h=null,g=new AbortController,m=new AbortController,w=!1,E=function(){var e=b(i().mark(function e(t){return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"INJECT_IMPORT_BUNDLE"!=t.data.type){e.next=9;break}return e.prev=1,e.next=4,k(t.data.value,t.data.organizationId,t.data.userId,t.data.requestId);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.sendMessageUp("ERROR",e.t0.toString(),t.data.requestId);case 9:if(!t.data||"EXTRACT_WALLET_ENCRYPTED_BUNDLE"!=t.data.type){e.next=18;break}return e.prev=10,e.next=13,T(t.data.requestId);case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(10),n.sendMessageUp("ERROR",e.t1.toString(),t.data.requestId);case 18:if(!t.data||"EXTRACT_KEY_ENCRYPTED_BUNDLE"!=t.data.type){e.next=27;break}return e.prev=19,e.next=22,P(t.data.keyFormat,t.data.requestId);case 22:e.next=27;break;case 24:e.prev=24,e.t2=e.catch(19),n.sendMessageUp("ERROR",e.t2.toString(),t.data.requestId);case 27:if(!t.data||"APPLY_SETTINGS"!=t.data.type){e.next=36;break}return e.prev=28,e.next=31,I(t.data.value,t.data.requestId);case 31:e.next=36;break;case 33:e.prev=33,e.t3=e.catch(28),n.sendMessageUp("ERROR",e.t3.toString(),t.data.requestId);case 36:case"end":return e.stop()}},e,null,[[1,6],[10,15],[19,24],[28,33]])}));return function(t){return e.apply(this,arguments)}}();function x(e){if(e.includes("\n--PASS--\n"))throw new Error('mnemonic cannot include the string "\\n--PASS--\\n"');if(e.includes("\n"))throw new Error("mnemonic cannot include newline characters")}function k(e,t,r,n){return S.apply(this,arguments)}function S(){return(S=b(i().mark(function e(t,r,a,o){var u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:c=JSON.parse(t),e.t0=c.version,e.next="v1.0.0"===e.t0?4:34;break;case 4:if(c.data){e.next=6;break}throw new Error('missing "data" in bundle');case 6:if(c.dataSignature){e.next=8;break}throw new Error('missing "dataSignature" in bundle');case 8:if(c.enclaveQuorumPublic){e.next=10;break}throw new Error('missing "enclaveQuorumPublic" in bundle');case 10:if(n.verifyEnclaveSignature){e.next=12;break}throw new Error("method not loaded");case 12:return e.next=14,n.verifyEnclaveSignature(c.enclaveQuorumPublic,c.dataSignature,c.data);case 14:if(e.sent){e.next=17;break}throw new Error("failed to verify enclave signature: ".concat(t));case 17:if(s=JSON.parse((new TextDecoder).decode(n.uint8arrayFromHexString(c.data))),r){e.next=22;break}console.warn('we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "organizationId" for security purposes.'),e.next=24;break;case 22:if(s.organizationId&&s.organizationId===r){e.next=24;break}throw new Error("organization id does not match expected value. Expected: ".concat(r,". Found: ").concat(s.organizationId,"."));case 24:if(a){e.next=28;break}console.warn('we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "userId" for security purposes.'),e.next=30;break;case 28:if(s.userId&&s.userId===a){e.next=30;break}throw new Error("user id does not match expected value. Expected: ".concat(a,". Found: ").concat(s.userId,"."));case 30:if(s.targetPublic){e.next=32;break}throw new Error('missing "targetPublic" in bundle signed data');case 32:return u=n.uint8arrayFromHexString(s.targetPublic),e.abrupt("break",35);case 34:throw new Error("unsupported version: ".concat(c.version));case 35:return e.next=37,n.loadTargetKey(new Uint8Array(u));case 37:f=e.sent,n.setTargetEmbeddedKey(f),n.sendMessageUp("BUNDLE_INJECTED",!0,o);case 40:case"end":return e.stop()}},e)}))).apply(this,arguments)}function T(e){return O.apply(this,arguments)}function O(){return(O=b(i().mark(function e(t){var r,o,u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(o=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no wallet mnemonic entered");case 6:return u=document.getElementById("passphrase").value,x(o),c=""===u?o:"".concat(o,"\n--PASS--\n").concat(u),s=(new TextEncoder).encode(c),e.next=12,(0,a.q)({plaintextBuf:s,receiverPubJwk:r});case 12:f=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",f,t);case 15:case"end":return e.stop()}},e)}))).apply(this,arguments)}function P(e,t){return _.apply(this,arguments)}function _(){return(_=b(i().mark(function e(t,r){var o,u,c,s;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(u=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no private key entered");case 6:return e.next=8,n.decodeKey(u,t);case 8:return c=e.sent,e.next=11,(0,a.q)({plaintextBuf:c,receiverPubJwk:o});case 11:s=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",s,r);case 14:case"end":return e.stop()}},e)}))).apply(this,arguments)}function I(e,t){return N.apply(this,arguments)}function N(){return(N=b(i().mark(function e(t,r){var a;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=n.applySettings(t),n.setSettings(a),n.sendMessageUp("SETTINGS_APPLIED",!0,r);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}document.addEventListener("DOMContentLoaded",b(i().mark(function e(){var t,r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window.addEventListener("message",E,{capture:!1,signal:g.signal}),g.signal.aborted){e.next=9;break}if((t=n.getSettings())&&n.applySettings(t),n.sendMessageUp("PUBLIC_KEY_READY",""),r=document.getElementById("plaintext")){e.next=8;break}return e.abrupt("return");case 8:r.addEventListener("paste",b(i().mark(function e(){var t;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"}).catch(function(){return null});case 3:if("granted"!==(null==(t=e.sent)?void 0:t.state)&&"prompt"!==(null==t?void 0:t.state)){e.next=7;break}return e.next=7,navigator.clipboard.writeText("");case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}},e,null,[[0,9]])})));case 9:case"end":return e.stop()}},e)})),!1),window.addEventListener("message",function(){var e=b(i().mark(function e(t){var r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"TURNKEY_INIT_MESSAGE_CHANNEL"!=t.data.type||t.source!==window.parent||!t.origin||"null"===t.origin||1!==(null===(r=t.ports)||void 0===r?void 0:r.length)){e.next=10;break}if(!w){e.next=3;break}return e.abrupt("return");case 3:w=!0,g.abort(),(h=t.ports[0]).onmessage=E,n.setParentFrameMessageChannelPort(h),n.sendMessageUp("PUBLIC_KEY_READY",""),m.abort();case 10:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),{signal:m.signal})}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.m=o,e=[],u.O=(t,r,n,a)=>{if(!r){var o=1/0;for(f=0;f=a)&&Object.keys(u.O).every(e=>u.O[e](r[c]))?r.splice(c--,1):(i=!1,a0&&e[f-1][2]>a;f--)e[f]=e[f-1];e[f]=[r,n,a]},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,u.t=function(e,n){if(1&n&&(e=this(e)),8&n)return e;if("object"==typeof e&&e){if(4&n&&e.__esModule)return e;if(16&n&&"function"==typeof e.then)return e}var a=Object.create(null);u.r(a);var o={};t=t||[null,r({}),r([]),r(r)];for(var i=2&n&&e;("object"==typeof i||"function"==typeof i)&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,u.d(a,o),a},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.f={},u.e=e=>Promise.all(Object.keys(u.f).reduce((t,r)=>(u.f[r](e,t),t),[])),u.u=e=>e+".bundle."+{291:"b62abe64ba4ebf68e89b",825:"3a4aff0e743a7540fe25"}[e]+".js",u.miniCssF=e=>{},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},a="import:",u.l=(e,t,r,o)=>{if(n[e])n[e].push(t);else{var i,c;if(void 0!==r)for(var s=document.getElementsByTagName("script"),f=0;f{i.onerror=i.onload=null,clearTimeout(p);var a=n[e];if(delete n[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(e=>e(r)),t)return t(r)},p=setTimeout(l.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=l.bind(null,i.onerror),i.onload=l.bind(null,i.onload),c&&document.head.appendChild(i)}},u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="/",(()=>{var e={57:0};u.f.j=(t,r)=>{var n=u.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var a=new Promise((r,a)=>n=e[t]=[r,a]);r.push(n[2]=a);var o=u.p+u.u(t),i=new Error;u.l(o,r=>{if(u.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}},"chunk-"+t,t)}},u.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,[o,i,c]=r,s=0;if(o.some(t=>0!==e[t])){for(n in i)u.o(i,n)&&(u.m[n]=i[n]);if(c)var f=c(u)}for(t&&t(r);su(954));c=u.O(c)})(); -//# sourceMappingURL=index.bundle.45de86a592cd0d80ccd0.js.map \ No newline at end of file diff --git a/import/dist/index.bundle.45de86a592cd0d80ccd0.js.map b/import/dist/index.bundle.45de86a592cd0d80ccd0.js.map deleted file mode 100644 index bcf2c89d..00000000 --- a/import/dist/index.bundle.45de86a592cd0d80ccd0.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.bundle.45de86a592cd0d80ccd0.js","mappings":";uBAAIA,ECCAC,EADAC,ECAAC,EACAC,E,24ECAJ,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,OAAAL,EAAAC,WAAA,OAAAK,EAAAH,EAAA,mBAAAV,EAAAE,EAAAE,GAAA,IAAAE,EAAAC,EAAAG,EAAAI,EAAA,EAAAC,EAAAX,GAAA,GAAAY,GAAA,EAAAC,EAAA,CAAAF,EAAA,EAAAb,EAAA,EAAAgB,EAAApB,EAAAqB,EAAAC,EAAAN,EAAAM,EAAAC,KAAAvB,EAAA,GAAAsB,EAAA,SAAArB,EAAAC,GAAA,OAAAM,EAAAP,EAAAQ,EAAA,EAAAG,EAAAZ,EAAAmB,EAAAf,EAAAF,EAAAmB,CAAA,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WxL,EAGhBhE,EAAI,EAC3B,GAAGiL,EAASwE,KAAMC,GAAgC,IAAxBd,EAAgBc,IAAa,CACtD,IAAIjF,KAAY8E,EACZ/E,EAAoB1K,EAAEyP,EAAa9E,KACrCD,EAAoB1I,EAAE2I,GAAY8E,EAAY9E,IAGhD,GAAG+E,EAAS,IAAIxE,EAASwE,EAAQhF,EAClC,CAEA,IADG8E,GAA4BA,EAA2BtL,GACrDhE,EAAIiL,EAASjK,OAAQhB,IACzBwM,EAAUvB,EAASjL,GAChBwK,EAAoB1K,EAAE8O,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAOhC,EAAoBO,EAAEC,IAG1B2E,EAAqBC,KAAyB,mBAAIA,KAAyB,oBAAK,GACpFD,EAAmBtD,QAAQgD,EAAqBtO,KAAK,KAAM,IAC3D4O,EAAmBxC,KAAOkC,EAAqBtO,KAAK,KAAM4O,EAAmBxC,KAAKpM,KAAK4O,G,KClFvF,IAAIE,EAAsBrF,EAAoBO,OAAEJ,EAAW,CAAC,GAAG,KAAM,IAAOH,EAAoB,MAChGqF,EAAsBrF,EAAoBO,EAAE8E,E","sources":["webpack://import/webpack/runtime/chunk loaded","webpack://import/webpack/runtime/create fake namespace object","webpack://import/webpack/runtime/load script","webpack://import/./src/index.js","webpack://import/webpack/bootstrap","webpack://import/webpack/runtime/define property getters","webpack://import/webpack/runtime/ensure chunk","webpack://import/webpack/runtime/get javascript chunk filename","webpack://import/webpack/runtime/get mini-css chunk filename","webpack://import/webpack/runtime/global","webpack://import/webpack/runtime/hasOwnProperty shorthand","webpack://import/webpack/runtime/make namespace object","webpack://import/webpack/runtime/publicPath","webpack://import/webpack/runtime/jsonp chunk loading","webpack://import/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 = \"import:\";\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}\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 \"./styles.css\";\nimport * as TKHQ from \"./turnkey-core.js\";\nimport { HpkeEncrypt } from \"@shared/crypto-utils.js\";\n\n// Make TKHQ available globally for backwards compatibility\nwindow.TKHQ = TKHQ;\n\n// persist the MessageChannel object so we can use it to communicate with the parent window\nvar iframeMessagePort = null;\n\n// controllers to remove event listeners\nconst messageListenerController = new AbortController();\nconst turnkeyInitController = new AbortController();\n\n// Guard to prevent concurrent channel establishment from multiple senders\nlet channelEstablished = false;\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nvar messageEventListener = async function (event) {\n if (event.data && event.data[\"type\"] == \"INJECT_IMPORT_BUNDLE\") {\n try {\n await onInjectImportBundle(\n event.data[\"value\"],\n event.data[\"organizationId\"],\n event.data[\"userId\"],\n event.data[\"requestId\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_WALLET_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractWalletEncryptedBundle(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_KEY_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractKeyEncryptedBundle(\n event.data[\"keyFormat\"],\n event.data[\"requestId\"]\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};\n\n/**\n * Broadcast that the frame is ready and set up the message event listeners\n */\ndocument.addEventListener(\n \"DOMContentLoaded\",\n async function () {\n window.addEventListener(\"message\", messageEventListener, {\n capture: false,\n signal: messageListenerController.signal,\n });\n\n if (!messageListenerController.signal.aborted) {\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 // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\n\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) return;\n // Clear clipboard after paste to avoid sensitive data lingering in clipboard.\n\n plaintextTextarea.addEventListener(\"paste\", async () => {\n // Let the paste happen first\n try {\n // Check clipboard-write permission first. In new versions of iframe-stamper, we add this permission when creating the iframe. In older versions, this permission is not added.\n const permStatus = await navigator.permissions\n .query({ name: \"clipboard-write\" }) // This is required to avoid error on clipboard write\n .catch(() => null);\n\n // Proceed only if granted or promptable\n if (\n permStatus?.state === \"granted\" ||\n permStatus?.state === \"prompt\"\n ) {\n await navigator.clipboard.writeText(\"\");\n }\n } catch {\n // Silently ignore any errors — no warnings or console noise\n }\n });\n }\n },\n false\n);\n\nwindow.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.source === window.parent &&\n event.origin &&\n event.origin !== \"null\" &&\n event.ports?.length === 1\n ) {\n // Synchronously check-and-set the flag before any await. This prevents\n // a second concurrent invocation from racing through while the first is\n // suspended at an await, which would allow multiple origins to establish\n // a channel before turnkeyInitController.abort() is reached.\n if (channelEstablished) {\n return;\n }\n channelEstablished = true;\n\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\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// make sure the mnemonic does not include our splitter (\\n--PASS--\\n) string or \\n characters\nfunction validateMnemonic(mnemonic) {\n if (mnemonic.includes(\"\\n--PASS--\\n\")) {\n throw new Error('mnemonic cannot include the string \"\\\\n--PASS--\\\\n\"');\n }\n if (mnemonic.includes(\"\\n\")) {\n throw new Error(\"mnemonic cannot include newline characters\");\n }\n}\n\n/**\n * Function triggered when INJECT_IMPORT_BUNDLE event is received.\n * Parses the `import_bundle` and stores the target public key as a JWK\n * in local storage. Sends true upon success.\n * @param {string} bundle\n * Example bundle: {\"targetPublic\":\"0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f\",\"targetPublicSignature\":\"3045022100cefc333c330c9fa300d1aa10a439a76539b4d6967301638ab9edc9fd9468bfdb0220339bba7e2b00b45d52e941d068ecd3bfd16fd1926da69dd7769893268990d62f\",\"enclaveQuorumPublic\":\"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\"}\n * @param {string} organizationId\n * @param {string} userId\n * @param {string} requestId\n */\nasync function onInjectImportBundle(bundle, organizationId, userId, requestId) {\n let targetPublicBuf;\n let verified;\n\n // Parse the import bundle\n const bundleObj = JSON.parse(bundle);\n\n switch (bundleObj.version) {\n case \"v1.0.0\": {\n // Validate fields exist\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 // Verify enclave signature\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method not loaded\");\n }\n verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(`failed to verify enclave signature: ${bundle}`);\n }\n\n // Parse the signed data. The data is produced by JSON encoding followed by hex encoding. We reverse this here.\n const signedData = JSON.parse(\n new TextDecoder().decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n // Validate fields match\n if (!organizationId) {\n // TODO: throw error if organization id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper\n console.warn(\n 'we highly recommend a version of @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 if (!userId) {\n // TODO: throw error if user id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper\n console.warn(\n 'we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass \"userId\" for security purposes.'\n );\n } else if (!signedData.userId || signedData.userId !== userId) {\n throw new Error(\n `user id does not match expected value. Expected: ${userId}. Found: ${signedData.userId}.`\n );\n }\n\n if (!signedData.targetPublic) {\n throw new Error('missing \"targetPublic\" in bundle signed data');\n }\n\n // Load target public key generated from enclave and set in local storage\n targetPublicBuf = TKHQ.uint8arrayFromHexString(signedData.targetPublic);\n break;\n }\n default:\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n\n const targetPublicKeyJwk = await TKHQ.loadTargetKey(\n new Uint8Array(targetPublicBuf)\n );\n TKHQ.setTargetEmbeddedKey(targetPublicKeyJwk);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_WALLET_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} requestId\n */\nasync function onExtractWalletEncryptedBundle(requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext wallet mnemonic\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no wallet mnemonic entered\");\n }\n\n const passphrase = document.getElementById(\"passphrase\").value;\n\n validateMnemonic(plaintext);\n\n const combined =\n passphrase === \"\" ? plaintext : `${plaintext}\\n--PASS--\\n${passphrase}`;\n const plaintextBuf = new TextEncoder().encode(combined);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_KEY_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} keyFormat\n * @param {string} requestId\n */\nasync function onExtractKeyEncryptedBundle(keyFormat, requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext private key\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no private key entered\");\n }\n const plaintextBuf = await TKHQ.decodeKey(plaintext, keyFormat);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, 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","// 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\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\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","// 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 \"\" + chunkId + \".bundle.\" + {\"291\":\"b62abe64ba4ebf68e89b\",\"825\":\"3a4aff0e743a7540fe25\"}[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__.p = \"/\";","// 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\t57: 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[\"webpackChunkimport\"] = self[\"webpackChunkimport\"] || [];\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,551], () => (__webpack_require__(954)))\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","_OverloadYield","k","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","window","TKHQ","iframeMessagePort","messageListenerController","AbortController","turnkeyInitController","channelEstablished","messageEventListener","_ref","_regeneratorRuntime","mark","_callee","event","wrap","_context","prev","next","data","onInjectImportBundle","t0","toString","onExtractWalletEncryptedBundle","t1","onExtractKeyEncryptedBundle","t2","onApplySettings","t3","stop","_x","validateMnemonic","mnemonic","includes","Error","_x3","_x4","_x5","_x6","_onInjectImportBundle","_callee5","bundle","organizationId","userId","requestId","targetPublicBuf","bundleObj","signedData","targetPublicKeyJwk","_context5","JSON","parse","version","dataSignature","enclaveQuorumPublic","sent","concat","TextDecoder","decode","console","warn","targetPublic","abrupt","Uint8Array","_x7","_onExtractWalletEncryptedBundle","_callee6","plaintext","passphrase","combined","plaintextBuf","encryptedBundle","_context6","document","getElementById","trim","TextEncoder","encode","HpkeEncrypt","receiverPubJwk","_x8","_x9","_onExtractKeyEncryptedBundle","_callee7","keyFormat","_context7","_x10","_x11","_onApplySettings","_callee8","settings","validSettings","_context8","addEventListener","_callee3","styleSettings","plaintextTextarea","_context3","capture","signal","aborted","_callee2","permStatus","_context2","navigator","permissions","query","name","state","clipboard","writeText","_ref4","_callee4","_event$ports","_context4","source","parent","origin","ports","abort","onmessage","_x2","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","key","splice","obj","mode","this","__esModule","ns","def","current","indexOf","getOwnPropertyNames","forEach","definition","get","chunkId","all","reduce","promises","miniCssF","g","globalThis","Function","prop","hasOwnProperty","url","push","script","needAttach","scripts","getElementsByTagName","s","getAttribute","createElement","charset","nc","setAttribute","src","onScriptComplete","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","type","target","head","appendChild","installedChunks","installedChunkData","promise","reject","error","errorType","realSrc","message","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","id","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/index.bundle.808edbe601034931b90e.js b/import/dist/index.bundle.808edbe601034931b90e.js new file mode 100644 index 00000000..c7a41889 --- /dev/null +++ b/import/dist/index.bundle.808edbe601034931b90e.js @@ -0,0 +1,3 @@ +/*! For license information please see index.bundle.808edbe601034931b90e.js.LICENSE.txt */ +(()=>{"use strict";var e,t,r,n,a,o={954:(e,t,r)=>{var n=r(482),a=r(584);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 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 a={throw:1,return:2,break:3,continue:3};function o(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,a[e],t)},delegateYield:function(e,a,o){return t.resultName=a,r(n.d,u(e),o)},finish:function(e){return r(n.f,e)}},r=function(e,r,a){n.p=t.prev,n.n=t.next;try{return e(r,a)}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,a){return e.w(o(t),r,n,a&&a.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new v(e,t)},AsyncIterator:d,async:function(e,t,r,a,i){return(n(t)?f:s)(o(e),t,r,a,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(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 s(e,t,r,n,a){var o=f(e,t,r,n,a);return o.next().then(function(e){return e.done?e.value:o.next()})}function f(e,t,r,n,a){return new d(p().w(e,t,r,n),a||Promise)}function d(e,t){function r(n,a,o,i){try{var u=e[n](a),c=u.value;return c instanceof v?t.resolve(c.v).then(function(e){r("next",e,o,i)},function(e){r("throw",e,o,i)}):t.resolve(c).then(function(e){u.value=e,o(u)},function(e){return r("throw",e,o,i)})}catch(e){i(e)}}var n;this.next||(l(d.prototype),l(d.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),l(this,"_invoke",function(e,a,o){function i(){return new t(function(t,n){r(e,o,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",a=r.toStringTag||"@@toStringTag";function o(r,n,a,o){var c=n&&n.prototype instanceof u?n:u,s=Object.create(c.prototype);return l(s,"_invoke",function(r,n,a){var o,u,c,s=0,f=a||[],d=!1,p={p:0,n:0,v:e,a:l,f:l.bind(e,4),d:function(t,r){return o=t,u=0,c=e,p.n=r,i}};function l(r,n){for(u=r,c=n,t=0;!d&&s&&!a&&t3?(a=v===n)&&(c=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=l&&((a=r<2&&ln||n>v)&&(o[4]=r,o[5]=n,p.n=v,u=0))}if(a||r>1)return i;throw d=!0,n}return function(a,f,v){if(s>1)throw TypeError("Generator is already running");for(d&&1===f&&l(f,v),u=f,c=v;(t=u<2?e:c)||!d;){o||(u?u<3?(u>1&&(p.n=-1),l(u,c)):p.n=c:p.v=c);try{if(s=2,o){if(u||(a="next"),t=o[a]){if(!(t=t.call(o,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=o.return)&&t.call(o),u<2&&(c=TypeError("The iterator does not provide a '"+a+"' method"),u=1);o=e}else if((t=(d=p.n<0)?c:r.call(n,p))!==i)break}catch(t){o=e,u=1,c=t}finally{s=1}}return{value:t,done:d}}}(r,a,o),!0),s}var i={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(l(t={},n,function(){return this}),t),d=s.prototype=u.prototype=Object.create(f);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,l(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=s,l(d,"constructor",s),l(s,"constructor",c),c.displayName="GeneratorFunction",l(s,a,"GeneratorFunction"),l(d),l(d,a,"Generator"),l(d,n,function(){return this}),l(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:o,m:v}})()}function l(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}l=function(e,t,r,n){function o(t,r){l(e,t,function(e){return this._invoke(t,r,e)})}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(o("next",0),o("throw",1),o("return",2))},l(e,t,r,n)}function v(e,t){this.v=e,this.k=t}function y(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){y(o,n,a,i,u,"next",e)}function u(e){y(o,n,a,i,u,"throw",e)}i(void 0)})}}window.TKHQ=n;var h=null,g=new AbortController,m=new AbortController,w=!1,E=function(){var e=b(i().mark(function e(t){return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"INJECT_IMPORT_BUNDLE"!=t.data.type){e.next=9;break}return e.prev=1,e.next=4,k(t.data.value,t.data.organizationId,t.data.userId,t.data.requestId);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.sendMessageUp("ERROR",e.t0.toString(),t.data.requestId);case 9:if(!t.data||"EXTRACT_WALLET_ENCRYPTED_BUNDLE"!=t.data.type){e.next=18;break}return e.prev=10,e.next=13,T(t.data.requestId);case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(10),n.sendMessageUp("ERROR",e.t1.toString(),t.data.requestId);case 18:if(!t.data||"EXTRACT_KEY_ENCRYPTED_BUNDLE"!=t.data.type){e.next=27;break}return e.prev=19,e.next=22,P(t.data.keyFormat,t.data.requestId);case 22:e.next=27;break;case 24:e.prev=24,e.t2=e.catch(19),n.sendMessageUp("ERROR",e.t2.toString(),t.data.requestId);case 27:if(!t.data||"APPLY_SETTINGS"!=t.data.type){e.next=36;break}return e.prev=28,e.next=31,I(t.data.value,t.data.requestId);case 31:e.next=36;break;case 33:e.prev=33,e.t3=e.catch(28),n.sendMessageUp("ERROR",e.t3.toString(),t.data.requestId);case 36:case"end":return e.stop()}},e,null,[[1,6],[10,15],[19,24],[28,33]])}));return function(t){return e.apply(this,arguments)}}();function x(e){if(e.includes("\n--PASS--\n"))throw new Error('mnemonic cannot include the string "\\n--PASS--\\n"');if(e.includes("\n"))throw new Error("mnemonic cannot include newline characters")}function k(e,t,r,n){return S.apply(this,arguments)}function S(){return(S=b(i().mark(function e(t,r,a,o){var u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:c=JSON.parse(t),e.t0=c.version,e.next="v1.0.0"===e.t0?4:34;break;case 4:if(c.data){e.next=6;break}throw new Error('missing "data" in bundle');case 6:if(c.dataSignature){e.next=8;break}throw new Error('missing "dataSignature" in bundle');case 8:if(c.enclaveQuorumPublic){e.next=10;break}throw new Error('missing "enclaveQuorumPublic" in bundle');case 10:if(n.verifyEnclaveSignature){e.next=12;break}throw new Error("method not loaded");case 12:return e.next=14,n.verifyEnclaveSignature(c.enclaveQuorumPublic,c.dataSignature,c.data);case 14:if(e.sent){e.next=17;break}throw new Error("failed to verify enclave signature: ".concat(t));case 17:if(s=JSON.parse((new TextDecoder).decode(n.uint8arrayFromHexString(c.data))),r){e.next=22;break}throw new Error('missing "organizationId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "organizationId" for security purposes.');case 22:if(s.organizationId&&s.organizationId===r){e.next=24;break}throw new Error("organization id does not match expected value. Expected: ".concat(r,". Found: ").concat(s.organizationId,"."));case 24:if(a){e.next=28;break}throw new Error('missing "userId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "userId" for security purposes.');case 28:if(s.userId&&s.userId===a){e.next=30;break}throw new Error("user id does not match expected value. Expected: ".concat(a,". Found: ").concat(s.userId,"."));case 30:if(s.targetPublic){e.next=32;break}throw new Error('missing "targetPublic" in bundle signed data');case 32:return u=n.uint8arrayFromHexString(s.targetPublic),e.abrupt("break",35);case 34:throw new Error("unsupported version: ".concat(c.version));case 35:return e.next=37,n.loadTargetKey(new Uint8Array(u));case 37:f=e.sent,n.setTargetEmbeddedKey(f),n.sendMessageUp("BUNDLE_INJECTED",!0,o);case 40:case"end":return e.stop()}},e)}))).apply(this,arguments)}function T(e){return O.apply(this,arguments)}function O(){return(O=b(i().mark(function e(t){var r,o,u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(o=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no wallet mnemonic entered");case 6:return u=document.getElementById("passphrase").value,x(o),c=""===u?o:"".concat(o,"\n--PASS--\n").concat(u),s=(new TextEncoder).encode(c),e.next=12,(0,a.q)({plaintextBuf:s,receiverPubJwk:r});case 12:f=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",f,t);case 15:case"end":return e.stop()}},e)}))).apply(this,arguments)}function P(e,t){return _.apply(this,arguments)}function _(){return(_=b(i().mark(function e(t,r){var o,u,c,s;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(u=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no private key entered");case 6:return e.next=8,n.decodeKey(u,t);case 8:return c=e.sent,e.next=11,(0,a.q)({plaintextBuf:c,receiverPubJwk:o});case 11:s=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",s,r);case 14:case"end":return e.stop()}},e)}))).apply(this,arguments)}function I(e,t){return N.apply(this,arguments)}function N(){return(N=b(i().mark(function e(t,r){var a;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=n.applySettings(t),n.setSettings(a),n.sendMessageUp("SETTINGS_APPLIED",!0,r);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}document.addEventListener("DOMContentLoaded",b(i().mark(function e(){var t,r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window.addEventListener("message",E,{capture:!1,signal:g.signal}),g.signal.aborted){e.next=9;break}if((t=n.getSettings())&&n.applySettings(t),n.sendMessageUp("PUBLIC_KEY_READY",""),r=document.getElementById("plaintext")){e.next=8;break}return e.abrupt("return");case 8:r.addEventListener("paste",b(i().mark(function e(){var t;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"}).catch(function(){return null});case 3:if("granted"!==(null==(t=e.sent)?void 0:t.state)&&"prompt"!==(null==t?void 0:t.state)){e.next=7;break}return e.next=7,navigator.clipboard.writeText("");case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}},e,null,[[0,9]])})));case 9:case"end":return e.stop()}},e)})),!1),window.addEventListener("message",function(){var e=b(i().mark(function e(t){var r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"TURNKEY_INIT_MESSAGE_CHANNEL"!=t.data.type||t.source!==window.parent||!t.origin||"null"===t.origin||1!==(null===(r=t.ports)||void 0===r?void 0:r.length)){e.next=10;break}if(!w){e.next=3;break}return e.abrupt("return");case 3:w=!0,g.abort(),(h=t.ports[0]).onmessage=E,n.setParentFrameMessageChannelPort(h),n.sendMessageUp("PUBLIC_KEY_READY",""),m.abort();case 10:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),{signal:m.signal})}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.m=o,e=[],u.O=(t,r,n,a)=>{if(!r){var o=1/0;for(f=0;f=a)&&Object.keys(u.O).every(e=>u.O[e](r[c]))?r.splice(c--,1):(i=!1,a0&&e[f-1][2]>a;f--)e[f]=e[f-1];e[f]=[r,n,a]},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,u.t=function(e,n){if(1&n&&(e=this(e)),8&n)return e;if("object"==typeof e&&e){if(4&n&&e.__esModule)return e;if(16&n&&"function"==typeof e.then)return e}var a=Object.create(null);u.r(a);var o={};t=t||[null,r({}),r([]),r(r)];for(var i=2&n&&e;("object"==typeof i||"function"==typeof i)&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,u.d(a,o),a},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.f={},u.e=e=>Promise.all(Object.keys(u.f).reduce((t,r)=>(u.f[r](e,t),t),[])),u.u=e=>e+".bundle."+{291:"b62abe64ba4ebf68e89b",825:"3a4aff0e743a7540fe25"}[e]+".js",u.miniCssF=e=>{},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},a="import:",u.l=(e,t,r,o)=>{if(n[e])n[e].push(t);else{var i,c;if(void 0!==r)for(var s=document.getElementsByTagName("script"),f=0;f{i.onerror=i.onload=null,clearTimeout(l);var a=n[e];if(delete n[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(e=>e(r)),t)return t(r)},l=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),c&&document.head.appendChild(i)}},u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="/",(()=>{var e={57:0};u.f.j=(t,r)=>{var n=u.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var a=new Promise((r,a)=>n=e[t]=[r,a]);r.push(n[2]=a);var o=u.p+u.u(t),i=new Error;u.l(o,r=>{if(u.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}},"chunk-"+t,t)}},u.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,[o,i,c]=r,s=0;if(o.some(t=>0!==e[t])){for(n in i)u.o(i,n)&&(u.m[n]=i[n]);if(c)var f=c(u)}for(t&&t(r);su(954));c=u.O(c)})(); +//# sourceMappingURL=index.bundle.808edbe601034931b90e.js.map \ No newline at end of file diff --git a/import/dist/index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt b/import/dist/index.bundle.808edbe601034931b90e.js.LICENSE.txt similarity index 100% rename from import/dist/index.bundle.45de86a592cd0d80ccd0.js.LICENSE.txt rename to import/dist/index.bundle.808edbe601034931b90e.js.LICENSE.txt diff --git a/import/dist/index.bundle.808edbe601034931b90e.js.map b/import/dist/index.bundle.808edbe601034931b90e.js.map new file mode 100644 index 00000000..09070462 --- /dev/null +++ b/import/dist/index.bundle.808edbe601034931b90e.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.bundle.808edbe601034931b90e.js","mappings":";uBAAIA,ECCAC,EADAC,ECAAC,EACAC,E,24ECAJ,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,OAAAL,EAAAC,WAAA,OAAAK,EAAAH,EAAA,mBAAAV,EAAAE,EAAAE,GAAA,IAAAE,EAAAC,EAAAG,EAAAI,EAAA,EAAAC,EAAAX,GAAA,GAAAY,GAAA,EAAAC,EAAA,CAAAF,EAAA,EAAAb,EAAA,EAAAgB,EAAApB,EAAAqB,EAAAC,EAAAN,EAAAM,EAAAC,KAAAvB,EAAA,GAAAsB,EAAA,SAAArB,EAAAC,GAAA,OAAAM,EAAAP,EAAAQ,EAAA,EAAAG,EAAAZ,EAAAmB,EAAAf,EAAAF,EAAAmB,CAAA,YAAAC,EAAApB,EAAAE,GAAA,IAAAK,EAAAP,EAAAU,EAAAR,EAAAH,EAAA,GAAAiB,GAAAF,IAAAV,GAAAL,EAAAgB,EAAAO,OAAAvB,IAAA,KAAAK,EAAAE,EAAAS,EAAAhB,GAAAqB,EAAAH,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AIxE,EAASwE,EAAQhF,EAClC,CAEA,IADG8E,GAA4BA,EAA2BpL,GACrDhE,EAAI+K,EAAS/J,OAAQhB,IACzBsM,EAAUvB,EAAS/K,GAChBsK,EAAoBxK,EAAE4O,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAOhC,EAAoBO,EAAEC,IAG1B2E,EAAqBC,KAAyB,mBAAIA,KAAyB,oBAAK,GACpFD,EAAmBtD,QAAQgD,EAAqBpO,KAAK,KAAM,IAC3D0O,EAAmBxC,KAAOkC,EAAqBpO,KAAK,KAAM0O,EAAmBxC,KAAKlM,KAAK0O,G,KClFvF,IAAIE,EAAsBrF,EAAoBO,OAAEJ,EAAW,CAAC,GAAG,KAAM,IAAOH,EAAoB,MAChGqF,EAAsBrF,EAAoBO,EAAE8E,E","sources":["webpack://import/webpack/runtime/chunk loaded","webpack://import/webpack/runtime/create fake namespace object","webpack://import/webpack/runtime/load script","webpack://import/./src/index.js","webpack://import/webpack/bootstrap","webpack://import/webpack/runtime/define property getters","webpack://import/webpack/runtime/ensure chunk","webpack://import/webpack/runtime/get javascript chunk filename","webpack://import/webpack/runtime/get mini-css chunk filename","webpack://import/webpack/runtime/global","webpack://import/webpack/runtime/hasOwnProperty shorthand","webpack://import/webpack/runtime/make namespace object","webpack://import/webpack/runtime/publicPath","webpack://import/webpack/runtime/jsonp chunk loading","webpack://import/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 = \"import:\";\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}\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 \"./styles.css\";\nimport * as TKHQ from \"./turnkey-core.js\";\nimport { HpkeEncrypt } from \"@shared/crypto-utils.js\";\n\n// Make TKHQ available globally for backwards compatibility\nwindow.TKHQ = TKHQ;\n\n// persist the MessageChannel object so we can use it to communicate with the parent window\nvar iframeMessagePort = null;\n\n// controllers to remove event listeners\nconst messageListenerController = new AbortController();\nconst turnkeyInitController = new AbortController();\n\n// Guard to prevent concurrent channel establishment from multiple senders\nlet channelEstablished = false;\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nvar messageEventListener = async function (event) {\n if (event.data && event.data[\"type\"] == \"INJECT_IMPORT_BUNDLE\") {\n try {\n await onInjectImportBundle(\n event.data[\"value\"],\n event.data[\"organizationId\"],\n event.data[\"userId\"],\n event.data[\"requestId\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_WALLET_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractWalletEncryptedBundle(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_KEY_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractKeyEncryptedBundle(\n event.data[\"keyFormat\"],\n event.data[\"requestId\"]\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};\n\n/**\n * Broadcast that the frame is ready and set up the message event listeners\n */\ndocument.addEventListener(\n \"DOMContentLoaded\",\n async function () {\n window.addEventListener(\"message\", messageEventListener, {\n capture: false,\n signal: messageListenerController.signal,\n });\n\n if (!messageListenerController.signal.aborted) {\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 // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\n\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) return;\n // Clear clipboard after paste to avoid sensitive data lingering in clipboard.\n\n plaintextTextarea.addEventListener(\"paste\", async () => {\n // Let the paste happen first\n try {\n // Check clipboard-write permission first. In new versions of iframe-stamper, we add this permission when creating the iframe. In older versions, this permission is not added.\n const permStatus = await navigator.permissions\n .query({ name: \"clipboard-write\" }) // This is required to avoid error on clipboard write\n .catch(() => null);\n\n // Proceed only if granted or promptable\n if (\n permStatus?.state === \"granted\" ||\n permStatus?.state === \"prompt\"\n ) {\n await navigator.clipboard.writeText(\"\");\n }\n } catch {\n // Silently ignore any errors — no warnings or console noise\n }\n });\n }\n },\n false\n);\n\nwindow.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.source === window.parent &&\n event.origin &&\n event.origin !== \"null\" &&\n event.ports?.length === 1\n ) {\n // Synchronously check-and-set the flag before any await. This prevents\n // a second concurrent invocation from racing through while the first is\n // suspended at an await, which would allow multiple origins to establish\n // a channel before turnkeyInitController.abort() is reached.\n if (channelEstablished) {\n return;\n }\n channelEstablished = true;\n\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\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// make sure the mnemonic does not include our splitter (\\n--PASS--\\n) string or \\n characters\nfunction validateMnemonic(mnemonic) {\n if (mnemonic.includes(\"\\n--PASS--\\n\")) {\n throw new Error('mnemonic cannot include the string \"\\\\n--PASS--\\\\n\"');\n }\n if (mnemonic.includes(\"\\n\")) {\n throw new Error(\"mnemonic cannot include newline characters\");\n }\n}\n\n/**\n * Function triggered when INJECT_IMPORT_BUNDLE event is received.\n * Parses the `import_bundle` and stores the target public key as a JWK\n * in local storage. Sends true upon success.\n * @param {string} bundle\n * Example bundle: {\"targetPublic\":\"0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f\",\"targetPublicSignature\":\"3045022100cefc333c330c9fa300d1aa10a439a76539b4d6967301638ab9edc9fd9468bfdb0220339bba7e2b00b45d52e941d068ecd3bfd16fd1926da69dd7769893268990d62f\",\"enclaveQuorumPublic\":\"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\"}\n * @param {string} organizationId\n * @param {string} userId\n * @param {string} requestId\n */\nasync function onInjectImportBundle(bundle, organizationId, userId, requestId) {\n let targetPublicBuf;\n let verified;\n\n // Parse the import bundle\n const bundleObj = JSON.parse(bundle);\n\n switch (bundleObj.version) {\n case \"v1.0.0\": {\n // Validate fields exist\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 // Verify enclave signature\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method not loaded\");\n }\n verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(`failed to verify enclave signature: ${bundle}`);\n }\n\n // Parse the signed data. The data is produced by JSON encoding followed by hex encoding. We reverse this here.\n const signedData = JSON.parse(\n new TextDecoder().decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n // Validate fields match\n if (!organizationId) {\n throw new Error(\n 'missing \"organizationId\": @turnkey/iframe-stamper >= v2.0.0 is required 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 if (!userId) {\n throw new Error(\n 'missing \"userId\": @turnkey/iframe-stamper >= v2.0.0 is required to pass \"userId\" for security purposes.'\n );\n } else if (!signedData.userId || signedData.userId !== userId) {\n throw new Error(\n `user id does not match expected value. Expected: ${userId}. Found: ${signedData.userId}.`\n );\n }\n\n if (!signedData.targetPublic) {\n throw new Error('missing \"targetPublic\" in bundle signed data');\n }\n\n // Load target public key generated from enclave and set in local storage\n targetPublicBuf = TKHQ.uint8arrayFromHexString(signedData.targetPublic);\n break;\n }\n default:\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n\n const targetPublicKeyJwk = await TKHQ.loadTargetKey(\n new Uint8Array(targetPublicBuf)\n );\n TKHQ.setTargetEmbeddedKey(targetPublicKeyJwk);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_WALLET_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} requestId\n */\nasync function onExtractWalletEncryptedBundle(requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext wallet mnemonic\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no wallet mnemonic entered\");\n }\n\n const passphrase = document.getElementById(\"passphrase\").value;\n\n validateMnemonic(plaintext);\n\n const combined =\n passphrase === \"\" ? plaintext : `${plaintext}\\n--PASS--\\n${passphrase}`;\n const plaintextBuf = new TextEncoder().encode(combined);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_KEY_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} keyFormat\n * @param {string} requestId\n */\nasync function onExtractKeyEncryptedBundle(keyFormat, requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext private key\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no private key entered\");\n }\n const plaintextBuf = await TKHQ.decodeKey(plaintext, keyFormat);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, 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","// 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\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\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","// 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 \"\" + chunkId + \".bundle.\" + {\"291\":\"b62abe64ba4ebf68e89b\",\"825\":\"3a4aff0e743a7540fe25\"}[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__.p = \"/\";","// 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\t57: 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[\"webpackChunkimport\"] = self[\"webpackChunkimport\"] || [];\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,551], () => (__webpack_require__(954)))\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","_OverloadYield","k","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","window","TKHQ","iframeMessagePort","messageListenerController","AbortController","turnkeyInitController","channelEstablished","messageEventListener","_ref","_regeneratorRuntime","mark","_callee","event","wrap","_context","prev","next","data","onInjectImportBundle","t0","toString","onExtractWalletEncryptedBundle","t1","onExtractKeyEncryptedBundle","t2","onApplySettings","t3","stop","_x","validateMnemonic","mnemonic","includes","Error","_x3","_x4","_x5","_x6","_onInjectImportBundle","_callee5","bundle","organizationId","userId","requestId","targetPublicBuf","bundleObj","signedData","targetPublicKeyJwk","_context5","JSON","parse","version","dataSignature","enclaveQuorumPublic","sent","concat","TextDecoder","decode","targetPublic","abrupt","Uint8Array","_x7","_onExtractWalletEncryptedBundle","_callee6","plaintext","passphrase","combined","plaintextBuf","encryptedBundle","_context6","document","getElementById","trim","TextEncoder","encode","HpkeEncrypt","receiverPubJwk","_x8","_x9","_onExtractKeyEncryptedBundle","_callee7","keyFormat","_context7","_x10","_x11","_onApplySettings","_callee8","settings","validSettings","_context8","addEventListener","_callee3","styleSettings","plaintextTextarea","_context3","capture","signal","aborted","_callee2","permStatus","_context2","navigator","permissions","query","name","state","clipboard","writeText","_ref4","_callee4","_event$ports","_context4","source","parent","origin","ports","abort","onmessage","_x2","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","key","splice","obj","mode","this","__esModule","ns","def","current","indexOf","getOwnPropertyNames","forEach","definition","get","chunkId","all","reduce","promises","miniCssF","g","globalThis","Function","prop","hasOwnProperty","url","push","script","needAttach","scripts","getElementsByTagName","s","getAttribute","createElement","charset","nc","setAttribute","src","onScriptComplete","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","type","target","head","appendChild","installedChunks","installedChunkData","promise","reject","error","errorType","realSrc","message","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","id","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/index.html b/import/dist/index.html index 76b4ba4d..fca7b73e 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/index.test.js b/import/index.test.js index cde4f6f3..4cf73660 100644 --- a/import/index.test.js +++ b/import/index.test.js @@ -567,3 +567,211 @@ describe("TURNKEY_INIT_MESSAGE_CHANNEL gate (import frame)", () => { expect(TKHQModule.setParentFrameMessageChannelPort).not.toHaveBeenCalled(); }); }); + +// --------------------------------------------------------------------------- +// onInjectImportBundle org/user binding (ENG-4597) +// +// These tests verify that onInjectImportBundle now THROWS (instead of warning +// and proceeding) when organizationId or userId is missing from the caller. +// --------------------------------------------------------------------------- + +describe("onInjectImportBundle org/user binding (import frame)", () => { + let TKHQModule; + + /** + * Encode a JavaScript object as a hex string (matching what the server does: + * JSON.stringify → TextEncoder → hex). + */ + function hexEncodeData(obj) { + const jsonStr = JSON.stringify(obj); + const bytes = new TextEncoder().encode(jsonStr); + return Array.from(bytes) + .map((b) => b.toString(16).padStart(2, "0")) + .join(""); + } + + /** + * Build a minimal v1.0.0 import bundle whose enclave signature will be + * accepted (because we mock verifyEnclaveSignature to return true), and + * whose signed data contains the provided fields. + */ + function makeBundleV1(signedDataFields) { + const data = hexEncodeData(signedDataFields); + return JSON.stringify({ + version: "v1.0.0", + data, + dataSignature: "aabbcc", // value doesn't matter — we mock verify + enclaveQuorumPublic: "04aabbcc", // value doesn't matter — we mock verify + }); + } + + /** + * Dispatch an INJECT_IMPORT_BUNDLE message event and wait for the async + * handler to settle. Returns sendMessageUp call args since this dispatch. + */ + async function dispatchInjectBundle(bundle, organizationId, userId) { + // Clear previous calls (e.g. PUBLIC_KEY_READY from DOMContentLoaded) + TKHQModule.sendMessageUp.mockClear(); + + const event = new window.MessageEvent("message", { + data: { + type: "INJECT_IMPORT_BUNDLE", + value: bundle, + organizationId, + userId, + requestId: "req-test", + }, + }); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + return TKHQModule.sendMessageUp.mock.calls; + } + + beforeEach(async () => { + global.crypto = crypto.webcrypto; + + await new Promise((resolve) => { + jest.isolateModules(() => { + jest.mock("./src/styles.css", () => {}, { virtual: true }); + jest.mock("@shared/crypto-utils.js", () => ({ + HpkeEncrypt: jest.fn(), + })); + + TKHQModule = require("./src/turnkey-core.js"); + + // Mock sendMessageUp so we can assert which message type was sent + jest.spyOn(TKHQModule, "sendMessageUp").mockImplementation(() => {}); + jest + .spyOn(TKHQModule, "setParentFrameMessageChannelPort") + .mockImplementation(() => {}); + + // Mock verifyEnclaveSignature so ALL bundles pass the signature check. + // This lets us test the org/user binding logic in isolation. + jest + .spyOn(TKHQModule, "verifyEnclaveSignature") + .mockResolvedValue(true); + + // Mock loadTargetKey so we don't need a real crypto key + jest + .spyOn(TKHQModule, "loadTargetKey") + .mockResolvedValue({ kty: "EC" }); + jest + .spyOn(TKHQModule, "setTargetEmbeddedKey") + .mockImplementation(() => {}); + + require("./src/index.js"); + + // Trigger DOMContentLoaded so that index.js registers its + // window "message" listener for INJECT_IMPORT_BUNDLE events. + document.dispatchEvent(new Event("DOMContentLoaded")); + + resolve(); + }); + }); + }); + + afterEach(() => { + jest.restoreAllMocks(); + }); + + it("throws when organizationId is missing (undefined)", async () => { + const bundle = makeBundleV1({ + organizationId: "org-123", + userId: "user-456", + targetPublic: + "0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f", + }); + const calls = await dispatchInjectBundle(bundle, undefined, "user-456"); + + // The catch block in messageEventListener sends ERROR + expect(calls.length).toBeGreaterThan(0); + expect(calls[0][0]).toBe("ERROR"); + expect(calls[0][1]).toContain('missing "organizationId"'); + }); + + it("throws when organizationId is empty string", async () => { + const bundle = makeBundleV1({ + organizationId: "org-123", + userId: "user-456", + targetPublic: + "0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f", + }); + const calls = await dispatchInjectBundle(bundle, "", "user-456"); + + expect(calls.length).toBeGreaterThan(0); + expect(calls[0][0]).toBe("ERROR"); + expect(calls[0][1]).toContain('missing "organizationId"'); + }); + + it("throws when userId is missing (undefined)", async () => { + const bundle = makeBundleV1({ + organizationId: "org-123", + userId: "user-456", + targetPublic: + "0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f", + }); + const calls = await dispatchInjectBundle(bundle, "org-123", undefined); + + expect(calls.length).toBeGreaterThan(0); + expect(calls[0][0]).toBe("ERROR"); + expect(calls[0][1]).toContain('missing "userId"'); + }); + + it("throws when userId is empty string", async () => { + const bundle = makeBundleV1({ + organizationId: "org-123", + userId: "user-456", + targetPublic: + "0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f", + }); + const calls = await dispatchInjectBundle(bundle, "org-123", ""); + + expect(calls.length).toBeGreaterThan(0); + expect(calls[0][0]).toBe("ERROR"); + expect(calls[0][1]).toContain('missing "userId"'); + }); + + it("throws when organizationId does not match the bundle's signedData", async () => { + const bundle = makeBundleV1({ + organizationId: "org-DIFFERENT", + userId: "user-456", + targetPublic: + "0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f", + }); + const calls = await dispatchInjectBundle(bundle, "org-123", "user-456"); + + expect(calls.length).toBeGreaterThan(0); + expect(calls[0][0]).toBe("ERROR"); + expect(calls[0][1]).toContain( + "organization id does not match expected value" + ); + }); + + it("throws when userId does not match the bundle's signedData", async () => { + const bundle = makeBundleV1({ + organizationId: "org-123", + userId: "user-DIFFERENT", + targetPublic: + "0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f", + }); + const calls = await dispatchInjectBundle(bundle, "org-123", "user-456"); + + expect(calls.length).toBeGreaterThan(0); + expect(calls[0][0]).toBe("ERROR"); + expect(calls[0][1]).toContain("user id does not match expected value"); + }); + + it("succeeds (BUNDLE_INJECTED) when organizationId and userId match", async () => { + const bundle = makeBundleV1({ + organizationId: "org-123", + userId: "user-456", + targetPublic: + "0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f", + }); + const calls = await dispatchInjectBundle(bundle, "org-123", "user-456"); + + expect(calls.length).toBeGreaterThan(0); + expect(calls[0][0]).toBe("BUNDLE_INJECTED"); + expect(calls[0][1]).toBe(true); + }); +}); diff --git a/import/src/index.js b/import/src/index.js index 7f6bd6c8..e690c34b 100644 --- a/import/src/index.js +++ b/import/src/index.js @@ -217,9 +217,8 @@ async function onInjectImportBundle(bundle, organizationId, userId, requestId) { // Validate fields match if (!organizationId) { - // TODO: throw error if organization id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper - console.warn( - 'we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "organizationId" for security purposes.' + throw new Error( + 'missing "organizationId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "organizationId" for security purposes.' ); } else if ( !signedData.organizationId || @@ -230,9 +229,8 @@ async function onInjectImportBundle(bundle, organizationId, userId, requestId) { ); } if (!userId) { - // TODO: throw error if user id is undefined once we've fully transitioned to v1.0.0 server messages and v2.0.0 iframe-stamper - console.warn( - 'we highly recommend a version of @turnkey/iframe-stamper >= v2.0.0 to pass "userId" for security purposes.' + throw new Error( + 'missing "userId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "userId" for security purposes.' ); } else if (!signedData.userId || signedData.userId !== userId) { throw new Error( From ec45a90b5eaa998a356564da2b7d0ed420a7698c Mon Sep 17 00:00:00 2001 From: Justin Formentin Date: Tue, 11 Aug 2026 10:45:46 -0400 Subject: [PATCH 3/3] fix(import): harden legacy DOMContentLoaded listener against cross-origin messages Mirror PR #129's export-and-sign pattern to the import frame's legacy window.message listener (the path used by @turnkey/iframe-stamper < 2.1.0): 1. Require event.source === window.parent (direct parent only) 2. Reject empty and opaque ('null') origins 3. Bind legacyParentOrigin on the first accepted message; drop later messages from any other origin 4. Call TKHQ.setParentFrameOrigin(event.origin) on first bind so outbound window.parent.postMessage responses are scoped to that origin instead of '*' 5. Skip TURNKEY_INIT_MESSAGE_CHANNEL messages in the legacy listener (owned by the MessageChannel handshake handler) Also export setParentFrameOrigin from import/src/turnkey-core.js and add modulePaths to jest.config.js so @shared/* deps (bech32, etc.) can be resolved from import/node_modules. Adds 11 regression tests in 'Legacy listener cross-origin gate (import frame)' covering: non-parent sender, opaque origin, empty origin, second-origin-after-binding, origin binding/idempotency, and valid parent acceptance. Rebuilds dist bundles. --- .../dist/551.bundle.3bf0db01aff38b17d9e1.js | 3 - .../551.bundle.3bf0db01aff38b17d9e1.js.map | 1 - .../dist/551.bundle.946ab11e6dd2f38f3113.js | 3 + ...undle.946ab11e6dd2f38f3113.js.LICENSE.txt} | 0 .../551.bundle.946ab11e6dd2f38f3113.js.map | 1 + .../dist/index.bundle.808edbe601034931b90e.js | 3 - .../index.bundle.808edbe601034931b90e.js.map | 1 - .../dist/index.bundle.ee8eee9be6e64fec1fc8.js | 3 + ...undle.ee8eee9be6e64fec1fc8.js.LICENSE.txt} | 0 .../index.bundle.ee8eee9be6e64fec1fc8.js.map | 1 + import/dist/index.html | 2 +- import/dist/standalone.html | 2 +- import/index.test.js | 252 ++++++++++++++++++ import/jest.config.js | 3 + import/src/index.js | 51 +++- import/src/turnkey-core.js | 2 + 16 files changed, 314 insertions(+), 14 deletions(-) delete mode 100644 import/dist/551.bundle.3bf0db01aff38b17d9e1.js delete mode 100644 import/dist/551.bundle.3bf0db01aff38b17d9e1.js.map create mode 100644 import/dist/551.bundle.946ab11e6dd2f38f3113.js rename import/dist/{551.bundle.3bf0db01aff38b17d9e1.js.LICENSE.txt => 551.bundle.946ab11e6dd2f38f3113.js.LICENSE.txt} (100%) create mode 100644 import/dist/551.bundle.946ab11e6dd2f38f3113.js.map delete mode 100644 import/dist/index.bundle.808edbe601034931b90e.js delete mode 100644 import/dist/index.bundle.808edbe601034931b90e.js.map create mode 100644 import/dist/index.bundle.ee8eee9be6e64fec1fc8.js rename import/dist/{index.bundle.808edbe601034931b90e.js.LICENSE.txt => index.bundle.ee8eee9be6e64fec1fc8.js.LICENSE.txt} (100%) create mode 100644 import/dist/index.bundle.ee8eee9be6e64fec1fc8.js.map diff --git a/import/dist/551.bundle.3bf0db01aff38b17d9e1.js b/import/dist/551.bundle.3bf0db01aff38b17d9e1.js deleted file mode 100644 index 06f065c5..00000000 --- a/import/dist/551.bundle.3bf0db01aff38b17d9e1.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! For license information please see 551.bundle.3bf0db01aff38b17d9e1.js.LICENSE.txt */ -"use strict";(self.webpackChunkimport=self.webpackChunkimport||[]).push([[551],{275:(e,t,r)=>{r.d(t,{Di:()=>D,FZ:()=>j,MO:()=>N,P2:()=>P,Rx:()=>H,Sb:()=>W,Tn:()=>Y,VU:()=>C,Wq:()=>$,Y$:()=>K,ZX:()=>B,Z_:()=>q,b6:()=>O,fX:()=>G,fw:()=>_,g8:()=>R,mt:()=>U,oc:()=>F,y3:()=>L});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:l,async:function(e,t,r,o,a){return(n(t)?s: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=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 l(f().w(e,t,r,n),o||Promise)}function l(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(l.prototype),p(l.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,s=Object.create(u.prototype);return p(s,"_invoke",function(r,n,o){var a,c,u,s=0,l=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&&s&&!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,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,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(s=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{s=1}}return{value:t,done:f}}}(r,o,a),!0),s}var i={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(p(t={},n,function(){return this}),t),d=s.prototype=c.prototype=Object.create(l);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,p(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=s,p(d,"constructor",s),p(s,"constructor",u),u.displayName="GeneratorFunction",p(s,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 Y(e){return J.apply(this,arguments)}function J(){return(J=m(a().mark(function e(t){var r,n,o,i,c,u,s,l,f;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!((r=H(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=k()){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(s=e.sent,l=new Uint8Array(s),f=l.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 L(e,t){return X.apply(this,arguments)}function X(){return(X=m(a().mark(function e(t,r){var o,i,c,u,s,l,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=H(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",$(t.slice(2)));case 9:case 48:return e.abrupt("return",$(t));case 10:return e.next=12,Y(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,Y(t);case 24:if(s=e.sent,l=s[0],f=s.subarray(1),239===l){e.next=29;break}throw new Error("invalid WIF version byte: ".concat(l,". 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",$(t.slice(2)));case 49:case"end":return e.stop()}},e)}))).apply(this,arguments)}function q(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,s=!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){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)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 s=n[u];if(!s)throw new Error('invalid or unsupported css style property: "'.concat(u,'"'));var l=new RegExp(s),f=c.trim();if(0==f.length)throw new Error('css style for "'.concat(u,'" is empty'));if(!l.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:()=>l,sendMessageUp:()=>d,setCryptoProvider:()=>i,setParentFrameMessageChannelPort:()=>w,setSettings:()=>p,setTargetEmbeddedKey:()=>s,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,s=!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){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)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)?l:s)(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 s(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 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,s=Object.create(u.prototype);return d(s,"_invoke",function(r,n,o){var a,c,u,s=0,l=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&&s&&!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,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,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(s=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{s=1}}return{value:t,done:f}}}(r,o,a),!0),s}var i={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(d(t={},n,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,d(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,d(f,"constructor",s),d(s,"constructor",u),u.displayName="GeneratorFunction",d(s,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 * Throws unless the caller provided an explicit storage key. Consumers must\n * choose a key slot deliberately (e.g. scoped by parent origin); an implicit\n * global default is what enabled cross-origin bundle replay (INT-697).\n * @param {string} storageKey\n */\nfunction requireStorageKey(storageKey) {\n if (typeof storageKey !== \"string\" || storageKey.length === 0) {\n throw new Error(\"an explicit embedded key storage key is required\");\n }\n}\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n * @param {string} storageKey localStorage key used for persistence\n */\nasync function initEmbeddedKey(storageKey) {\n requireStorageKey(storageKey);\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n const retrievedKey = await getEmbeddedKey(storageKey);\n if (retrievedKey === null) {\n const targetKey = await generateTargetKey();\n setEmbeddedKey(targetKey, storageKey);\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 * @param {string} storageKey localStorage key used for persistence\n */\nfunction getEmbeddedKey(storageKey) {\n requireStorageKey(storageKey);\n const jwtKey = getItemWithExpiry(storageKey);\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 * @param {string} storageKey localStorage key used for persistence\n */\nfunction setEmbeddedKey(targetKey, storageKey) {\n requireStorageKey(storageKey);\n setItemWithExpiry(\n storageKey,\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 * @param {string} storageKey localStorage key used for persistence\n */\nfunction onResetEmbeddedKey(storageKey) {\n requireStorageKey(storageKey);\n window.localStorage.removeItem(storageKey);\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 * Restricts direct window.parent postMessages to the given origin. Used by\n * the legacy (< 2.1.0 iframe-stamper) path once the parent origin is bound,\n * so responses are only readable by that origin.\n * @param {string} origin\n */\nfunction setParentFrameOrigin(origin) {\n if (typeof origin !== \"string\" || origin.length === 0) {\n throw new Error(\"a canonical, non-opaque parent frame origin is required\");\n }\n\n let parsedOrigin;\n try {\n parsedOrigin = new URL(origin).origin;\n } catch {\n throw new Error(\"a canonical, non-opaque parent frame origin is required\");\n }\n\n if (parsedOrigin === \"null\" || parsedOrigin !== origin) {\n throw new Error(\"a canonical, non-opaque parent frame origin is required\");\n }\n parentFrameTargetOrigin = parsedOrigin;\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 setParentFrameOrigin,\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","parentFrameTargetOrigin","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","_x4","_x5","_x6","_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","_x8","_base58CheckDecode","_callee7","decoded","payload","checksum","hash1Buf","hash1","hash2Buf","hash2","computedChecksum","_context7","subarray","digest","decodeKey","_x9","_x10","_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.946ab11e6dd2f38f3113.js b/import/dist/551.bundle.946ab11e6dd2f38f3113.js new file mode 100644 index 00000000..173d97ca --- /dev/null +++ b/import/dist/551.bundle.946ab11e6dd2f38f3113.js @@ -0,0 +1,3 @@ +/*! For license information please see 551.bundle.946ab11e6dd2f38f3113.js.LICENSE.txt */ +"use strict";(self.webpackChunkimport=self.webpackChunkimport||[]).push([[551],{275:(e,t,r)=>{r.d(t,{Di:()=>D,FZ:()=>j,GP:()=>U,MO:()=>N,P2:()=>T,Rx:()=>q,Sb:()=>W,Tn:()=>Y,VU:()=>C,Wq:()=>$,Y$:()=>M,ZX:()=>H,Z_:()=>z,b6:()=>O,fX:()=>R,fw:()=>_,g8:()=>K,mt:()=>F,oc:()=>G,y3:()=>L});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 Y(e){return J.apply(this,arguments)}function J(){return(J=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=q(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=k()){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 L(e,t){return X.apply(this,arguments)}function X(){return(X=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=q(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",$(t.slice(2)));case 9:case 48:return e.abrupt("return",$(t));case 10:return e.next=12,Y(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,Y(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",$(t.slice(2)));case 49:case"end":return e.stop()}},e)}))).apply(this,arguments)}function z(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:()=>S,applySettings:()=>I,base58CheckDecode:()=>h,base58Decode:()=>v,decodeKey:()=>m,fromDerSignature:()=>E,getSettings:()=>f,getTargetEmbeddedKey:()=>u,loadTargetKey:()=>c,normalizePadding:()=>x,resetTargetEmbeddedKey:()=>s,sendMessageUp:()=>d,setCryptoProvider:()=>i,setParentFrameMessageChannelPort:()=>w,setParentFrameOrigin:()=>g,setSettings:()=>p,setTargetEmbeddedKey:()=>l,uint8arrayFromHexString:()=>y,uint8arrayToHexString:()=>b,validateStyles:()=>O,verifyEnclaveSignature:()=>k});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 * Throws unless the caller provided an explicit storage key. Consumers must\n * choose a key slot deliberately (e.g. scoped by parent origin); an implicit\n * global default is what enabled cross-origin bundle replay (INT-697).\n * @param {string} storageKey\n */\nfunction requireStorageKey(storageKey) {\n if (typeof storageKey !== \"string\" || storageKey.length === 0) {\n throw new Error(\"an explicit embedded key storage key is required\");\n }\n}\n\n/**\n * Creates a new public/private key pair and persists it in localStorage\n * @param {string} storageKey localStorage key used for persistence\n */\nasync function initEmbeddedKey(storageKey) {\n requireStorageKey(storageKey);\n if (isDoublyIframed()) {\n throw new Error(\"Doubly iframed\");\n }\n const retrievedKey = await getEmbeddedKey(storageKey);\n if (retrievedKey === null) {\n const targetKey = await generateTargetKey();\n setEmbeddedKey(targetKey, storageKey);\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 * @param {string} storageKey localStorage key used for persistence\n */\nfunction getEmbeddedKey(storageKey) {\n requireStorageKey(storageKey);\n const jwtKey = getItemWithExpiry(storageKey);\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 * @param {string} storageKey localStorage key used for persistence\n */\nfunction setEmbeddedKey(targetKey, storageKey) {\n requireStorageKey(storageKey);\n setItemWithExpiry(\n storageKey,\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 * @param {string} storageKey localStorage key used for persistence\n */\nfunction onResetEmbeddedKey(storageKey) {\n requireStorageKey(storageKey);\n window.localStorage.removeItem(storageKey);\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 * Restricts direct window.parent postMessages to the given origin. Used by\n * the legacy (< 2.1.0 iframe-stamper) path once the parent origin is bound,\n * so responses are only readable by that origin.\n * @param {string} origin\n */\nfunction setParentFrameOrigin(origin) {\n if (typeof origin !== \"string\" || origin.length === 0) {\n throw new Error(\"a canonical, non-opaque parent frame origin is required\");\n }\n\n let parsedOrigin;\n try {\n parsedOrigin = new URL(origin).origin;\n } catch {\n throw new Error(\"a canonical, non-opaque parent frame origin is required\");\n }\n\n if (parsedOrigin === \"null\" || parsedOrigin !== origin) {\n throw new Error(\"a canonical, non-opaque parent frame origin is required\");\n }\n parentFrameTargetOrigin = parsedOrigin;\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 setParentFrameOrigin,\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 setParentFrameOrigin,\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 setParentFrameOrigin,\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","parentFrameTargetOrigin","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","setParentFrameOrigin","origin","parsedOrigin","URL","_unused","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","_x4","_x5","_x6","_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","_x8","_base58CheckDecode","_callee7","decoded","payload","checksum","hash1Buf","hash1","hash2Buf","hash2","computedChecksum","_context7","subarray","digest","decodeKey","_x9","_x10","_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.bundle.808edbe601034931b90e.js b/import/dist/index.bundle.808edbe601034931b90e.js deleted file mode 100644 index c7a41889..00000000 --- a/import/dist/index.bundle.808edbe601034931b90e.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! For license information please see index.bundle.808edbe601034931b90e.js.LICENSE.txt */ -(()=>{"use strict";var e,t,r,n,a,o={954:(e,t,r)=>{var n=r(482),a=r(584);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 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 a={throw:1,return:2,break:3,continue:3};function o(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,a[e],t)},delegateYield:function(e,a,o){return t.resultName=a,r(n.d,u(e),o)},finish:function(e){return r(n.f,e)}},r=function(e,r,a){n.p=t.prev,n.n=t.next;try{return e(r,a)}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,a){return e.w(o(t),r,n,a&&a.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new v(e,t)},AsyncIterator:d,async:function(e,t,r,a,i){return(n(t)?f:s)(o(e),t,r,a,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(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 s(e,t,r,n,a){var o=f(e,t,r,n,a);return o.next().then(function(e){return e.done?e.value:o.next()})}function f(e,t,r,n,a){return new d(p().w(e,t,r,n),a||Promise)}function d(e,t){function r(n,a,o,i){try{var u=e[n](a),c=u.value;return c instanceof v?t.resolve(c.v).then(function(e){r("next",e,o,i)},function(e){r("throw",e,o,i)}):t.resolve(c).then(function(e){u.value=e,o(u)},function(e){return r("throw",e,o,i)})}catch(e){i(e)}}var n;this.next||(l(d.prototype),l(d.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),l(this,"_invoke",function(e,a,o){function i(){return new t(function(t,n){r(e,o,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",a=r.toStringTag||"@@toStringTag";function o(r,n,a,o){var c=n&&n.prototype instanceof u?n:u,s=Object.create(c.prototype);return l(s,"_invoke",function(r,n,a){var o,u,c,s=0,f=a||[],d=!1,p={p:0,n:0,v:e,a:l,f:l.bind(e,4),d:function(t,r){return o=t,u=0,c=e,p.n=r,i}};function l(r,n){for(u=r,c=n,t=0;!d&&s&&!a&&t3?(a=v===n)&&(c=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=l&&((a=r<2&&ln||n>v)&&(o[4]=r,o[5]=n,p.n=v,u=0))}if(a||r>1)return i;throw d=!0,n}return function(a,f,v){if(s>1)throw TypeError("Generator is already running");for(d&&1===f&&l(f,v),u=f,c=v;(t=u<2?e:c)||!d;){o||(u?u<3?(u>1&&(p.n=-1),l(u,c)):p.n=c:p.v=c);try{if(s=2,o){if(u||(a="next"),t=o[a]){if(!(t=t.call(o,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=o.return)&&t.call(o),u<2&&(c=TypeError("The iterator does not provide a '"+a+"' method"),u=1);o=e}else if((t=(d=p.n<0)?c:r.call(n,p))!==i)break}catch(t){o=e,u=1,c=t}finally{s=1}}return{value:t,done:d}}}(r,a,o),!0),s}var i={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(l(t={},n,function(){return this}),t),d=s.prototype=u.prototype=Object.create(f);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,l(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=s,l(d,"constructor",s),l(s,"constructor",c),c.displayName="GeneratorFunction",l(s,a,"GeneratorFunction"),l(d),l(d,a,"Generator"),l(d,n,function(){return this}),l(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:o,m:v}})()}function l(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}l=function(e,t,r,n){function o(t,r){l(e,t,function(e){return this._invoke(t,r,e)})}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(o("next",0),o("throw",1),o("return",2))},l(e,t,r,n)}function v(e,t){this.v=e,this.k=t}function y(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){y(o,n,a,i,u,"next",e)}function u(e){y(o,n,a,i,u,"throw",e)}i(void 0)})}}window.TKHQ=n;var h=null,g=new AbortController,m=new AbortController,w=!1,E=function(){var e=b(i().mark(function e(t){return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"INJECT_IMPORT_BUNDLE"!=t.data.type){e.next=9;break}return e.prev=1,e.next=4,k(t.data.value,t.data.organizationId,t.data.userId,t.data.requestId);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.sendMessageUp("ERROR",e.t0.toString(),t.data.requestId);case 9:if(!t.data||"EXTRACT_WALLET_ENCRYPTED_BUNDLE"!=t.data.type){e.next=18;break}return e.prev=10,e.next=13,T(t.data.requestId);case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(10),n.sendMessageUp("ERROR",e.t1.toString(),t.data.requestId);case 18:if(!t.data||"EXTRACT_KEY_ENCRYPTED_BUNDLE"!=t.data.type){e.next=27;break}return e.prev=19,e.next=22,P(t.data.keyFormat,t.data.requestId);case 22:e.next=27;break;case 24:e.prev=24,e.t2=e.catch(19),n.sendMessageUp("ERROR",e.t2.toString(),t.data.requestId);case 27:if(!t.data||"APPLY_SETTINGS"!=t.data.type){e.next=36;break}return e.prev=28,e.next=31,I(t.data.value,t.data.requestId);case 31:e.next=36;break;case 33:e.prev=33,e.t3=e.catch(28),n.sendMessageUp("ERROR",e.t3.toString(),t.data.requestId);case 36:case"end":return e.stop()}},e,null,[[1,6],[10,15],[19,24],[28,33]])}));return function(t){return e.apply(this,arguments)}}();function x(e){if(e.includes("\n--PASS--\n"))throw new Error('mnemonic cannot include the string "\\n--PASS--\\n"');if(e.includes("\n"))throw new Error("mnemonic cannot include newline characters")}function k(e,t,r,n){return S.apply(this,arguments)}function S(){return(S=b(i().mark(function e(t,r,a,o){var u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:c=JSON.parse(t),e.t0=c.version,e.next="v1.0.0"===e.t0?4:34;break;case 4:if(c.data){e.next=6;break}throw new Error('missing "data" in bundle');case 6:if(c.dataSignature){e.next=8;break}throw new Error('missing "dataSignature" in bundle');case 8:if(c.enclaveQuorumPublic){e.next=10;break}throw new Error('missing "enclaveQuorumPublic" in bundle');case 10:if(n.verifyEnclaveSignature){e.next=12;break}throw new Error("method not loaded");case 12:return e.next=14,n.verifyEnclaveSignature(c.enclaveQuorumPublic,c.dataSignature,c.data);case 14:if(e.sent){e.next=17;break}throw new Error("failed to verify enclave signature: ".concat(t));case 17:if(s=JSON.parse((new TextDecoder).decode(n.uint8arrayFromHexString(c.data))),r){e.next=22;break}throw new Error('missing "organizationId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "organizationId" for security purposes.');case 22:if(s.organizationId&&s.organizationId===r){e.next=24;break}throw new Error("organization id does not match expected value. Expected: ".concat(r,". Found: ").concat(s.organizationId,"."));case 24:if(a){e.next=28;break}throw new Error('missing "userId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "userId" for security purposes.');case 28:if(s.userId&&s.userId===a){e.next=30;break}throw new Error("user id does not match expected value. Expected: ".concat(a,". Found: ").concat(s.userId,"."));case 30:if(s.targetPublic){e.next=32;break}throw new Error('missing "targetPublic" in bundle signed data');case 32:return u=n.uint8arrayFromHexString(s.targetPublic),e.abrupt("break",35);case 34:throw new Error("unsupported version: ".concat(c.version));case 35:return e.next=37,n.loadTargetKey(new Uint8Array(u));case 37:f=e.sent,n.setTargetEmbeddedKey(f),n.sendMessageUp("BUNDLE_INJECTED",!0,o);case 40:case"end":return e.stop()}},e)}))).apply(this,arguments)}function T(e){return O.apply(this,arguments)}function O(){return(O=b(i().mark(function e(t){var r,o,u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(o=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no wallet mnemonic entered");case 6:return u=document.getElementById("passphrase").value,x(o),c=""===u?o:"".concat(o,"\n--PASS--\n").concat(u),s=(new TextEncoder).encode(c),e.next=12,(0,a.q)({plaintextBuf:s,receiverPubJwk:r});case 12:f=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",f,t);case 15:case"end":return e.stop()}},e)}))).apply(this,arguments)}function P(e,t){return _.apply(this,arguments)}function _(){return(_=b(i().mark(function e(t,r){var o,u,c,s;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(u=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no private key entered");case 6:return e.next=8,n.decodeKey(u,t);case 8:return c=e.sent,e.next=11,(0,a.q)({plaintextBuf:c,receiverPubJwk:o});case 11:s=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",s,r);case 14:case"end":return e.stop()}},e)}))).apply(this,arguments)}function I(e,t){return N.apply(this,arguments)}function N(){return(N=b(i().mark(function e(t,r){var a;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=n.applySettings(t),n.setSettings(a),n.sendMessageUp("SETTINGS_APPLIED",!0,r);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}document.addEventListener("DOMContentLoaded",b(i().mark(function e(){var t,r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window.addEventListener("message",E,{capture:!1,signal:g.signal}),g.signal.aborted){e.next=9;break}if((t=n.getSettings())&&n.applySettings(t),n.sendMessageUp("PUBLIC_KEY_READY",""),r=document.getElementById("plaintext")){e.next=8;break}return e.abrupt("return");case 8:r.addEventListener("paste",b(i().mark(function e(){var t;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"}).catch(function(){return null});case 3:if("granted"!==(null==(t=e.sent)?void 0:t.state)&&"prompt"!==(null==t?void 0:t.state)){e.next=7;break}return e.next=7,navigator.clipboard.writeText("");case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}},e,null,[[0,9]])})));case 9:case"end":return e.stop()}},e)})),!1),window.addEventListener("message",function(){var e=b(i().mark(function e(t){var r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"TURNKEY_INIT_MESSAGE_CHANNEL"!=t.data.type||t.source!==window.parent||!t.origin||"null"===t.origin||1!==(null===(r=t.ports)||void 0===r?void 0:r.length)){e.next=10;break}if(!w){e.next=3;break}return e.abrupt("return");case 3:w=!0,g.abort(),(h=t.ports[0]).onmessage=E,n.setParentFrameMessageChannelPort(h),n.sendMessageUp("PUBLIC_KEY_READY",""),m.abort();case 10:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),{signal:m.signal})}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.m=o,e=[],u.O=(t,r,n,a)=>{if(!r){var o=1/0;for(f=0;f=a)&&Object.keys(u.O).every(e=>u.O[e](r[c]))?r.splice(c--,1):(i=!1,a0&&e[f-1][2]>a;f--)e[f]=e[f-1];e[f]=[r,n,a]},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,u.t=function(e,n){if(1&n&&(e=this(e)),8&n)return e;if("object"==typeof e&&e){if(4&n&&e.__esModule)return e;if(16&n&&"function"==typeof e.then)return e}var a=Object.create(null);u.r(a);var o={};t=t||[null,r({}),r([]),r(r)];for(var i=2&n&&e;("object"==typeof i||"function"==typeof i)&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,u.d(a,o),a},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.f={},u.e=e=>Promise.all(Object.keys(u.f).reduce((t,r)=>(u.f[r](e,t),t),[])),u.u=e=>e+".bundle."+{291:"b62abe64ba4ebf68e89b",825:"3a4aff0e743a7540fe25"}[e]+".js",u.miniCssF=e=>{},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},a="import:",u.l=(e,t,r,o)=>{if(n[e])n[e].push(t);else{var i,c;if(void 0!==r)for(var s=document.getElementsByTagName("script"),f=0;f{i.onerror=i.onload=null,clearTimeout(l);var a=n[e];if(delete n[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(e=>e(r)),t)return t(r)},l=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),c&&document.head.appendChild(i)}},u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="/",(()=>{var e={57:0};u.f.j=(t,r)=>{var n=u.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var a=new Promise((r,a)=>n=e[t]=[r,a]);r.push(n[2]=a);var o=u.p+u.u(t),i=new Error;u.l(o,r=>{if(u.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}},"chunk-"+t,t)}},u.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,[o,i,c]=r,s=0;if(o.some(t=>0!==e[t])){for(n in i)u.o(i,n)&&(u.m[n]=i[n]);if(c)var f=c(u)}for(t&&t(r);su(954));c=u.O(c)})(); -//# sourceMappingURL=index.bundle.808edbe601034931b90e.js.map \ No newline at end of file diff --git a/import/dist/index.bundle.808edbe601034931b90e.js.map b/import/dist/index.bundle.808edbe601034931b90e.js.map deleted file mode 100644 index 09070462..00000000 --- a/import/dist/index.bundle.808edbe601034931b90e.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.bundle.808edbe601034931b90e.js","mappings":";uBAAIA,ECCAC,EADAC,ECAAC,EACAC,E,24ECAJ,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,OAAAL,EAAAC,WAAA,OAAAK,EAAAH,EAAA,mBAAAV,EAAAE,EAAAE,GAAA,IAAAE,EAAAC,EAAAG,EAAAI,EAAA,EAAAC,EAAAX,GAAA,GAAAY,GAAA,EAAAC,EAAA,CAAAF,EAAA,EAAAb,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AASA,EAE/D,GAYHhC,EAAoBO,EAAEQ,EAAKiB,GAA0C,IAA7BoC,EAAgBpC,GAGxD,IAAI6C,EAAuB,CAACC,EAA4BpL,KACvD,IAGIuG,EAAU+B,GAHTvB,EAAUsE,EAAaC,GAAWtL,EAGhBhE,EAAI,EAC3B,GAAG+K,EAASwE,KAAMC,GAAgC,IAAxBd,EAAgBc,IAAa,CACtD,IAAIjF,KAAY8E,EACZ/E,EAAoBxK,EAAEuP,EAAa9E,KACrCD,EAAoBxI,EAAEyI,GAAY8E,EAAY9E,IAGhD,GAAG+E,EAAS,IAAIxE,EAASwE,EAAQhF,EAClC,CAEA,IADG8E,GAA4BA,EAA2BpL,GACrDhE,EAAI+K,EAAS/J,OAAQhB,IACzBsM,EAAUvB,EAAS/K,GAChBsK,EAAoBxK,EAAE4O,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAOhC,EAAoBO,EAAEC,IAG1B2E,EAAqBC,KAAyB,mBAAIA,KAAyB,oBAAK,GACpFD,EAAmBtD,QAAQgD,EAAqBpO,KAAK,KAAM,IAC3D0O,EAAmBxC,KAAOkC,EAAqBpO,KAAK,KAAM0O,EAAmBxC,KAAKlM,KAAK0O,G,KClFvF,IAAIE,EAAsBrF,EAAoBO,OAAEJ,EAAW,CAAC,GAAG,KAAM,IAAOH,EAAoB,MAChGqF,EAAsBrF,EAAoBO,EAAE8E,E","sources":["webpack://import/webpack/runtime/chunk loaded","webpack://import/webpack/runtime/create fake namespace object","webpack://import/webpack/runtime/load script","webpack://import/./src/index.js","webpack://import/webpack/bootstrap","webpack://import/webpack/runtime/define property getters","webpack://import/webpack/runtime/ensure chunk","webpack://import/webpack/runtime/get javascript chunk filename","webpack://import/webpack/runtime/get mini-css chunk filename","webpack://import/webpack/runtime/global","webpack://import/webpack/runtime/hasOwnProperty shorthand","webpack://import/webpack/runtime/make namespace object","webpack://import/webpack/runtime/publicPath","webpack://import/webpack/runtime/jsonp chunk loading","webpack://import/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 = \"import:\";\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}\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 \"./styles.css\";\nimport * as TKHQ from \"./turnkey-core.js\";\nimport { HpkeEncrypt } from \"@shared/crypto-utils.js\";\n\n// Make TKHQ available globally for backwards compatibility\nwindow.TKHQ = TKHQ;\n\n// persist the MessageChannel object so we can use it to communicate with the parent window\nvar iframeMessagePort = null;\n\n// controllers to remove event listeners\nconst messageListenerController = new AbortController();\nconst turnkeyInitController = new AbortController();\n\n// Guard to prevent concurrent channel establishment from multiple senders\nlet channelEstablished = false;\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nvar messageEventListener = async function (event) {\n if (event.data && event.data[\"type\"] == \"INJECT_IMPORT_BUNDLE\") {\n try {\n await onInjectImportBundle(\n event.data[\"value\"],\n event.data[\"organizationId\"],\n event.data[\"userId\"],\n event.data[\"requestId\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_WALLET_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractWalletEncryptedBundle(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_KEY_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractKeyEncryptedBundle(\n event.data[\"keyFormat\"],\n event.data[\"requestId\"]\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};\n\n/**\n * Broadcast that the frame is ready and set up the message event listeners\n */\ndocument.addEventListener(\n \"DOMContentLoaded\",\n async function () {\n window.addEventListener(\"message\", messageEventListener, {\n capture: false,\n signal: messageListenerController.signal,\n });\n\n if (!messageListenerController.signal.aborted) {\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 // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\n\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) return;\n // Clear clipboard after paste to avoid sensitive data lingering in clipboard.\n\n plaintextTextarea.addEventListener(\"paste\", async () => {\n // Let the paste happen first\n try {\n // Check clipboard-write permission first. In new versions of iframe-stamper, we add this permission when creating the iframe. In older versions, this permission is not added.\n const permStatus = await navigator.permissions\n .query({ name: \"clipboard-write\" }) // This is required to avoid error on clipboard write\n .catch(() => null);\n\n // Proceed only if granted or promptable\n if (\n permStatus?.state === \"granted\" ||\n permStatus?.state === \"prompt\"\n ) {\n await navigator.clipboard.writeText(\"\");\n }\n } catch {\n // Silently ignore any errors — no warnings or console noise\n }\n });\n }\n },\n false\n);\n\nwindow.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.source === window.parent &&\n event.origin &&\n event.origin !== \"null\" &&\n event.ports?.length === 1\n ) {\n // Synchronously check-and-set the flag before any await. This prevents\n // a second concurrent invocation from racing through while the first is\n // suspended at an await, which would allow multiple origins to establish\n // a channel before turnkeyInitController.abort() is reached.\n if (channelEstablished) {\n return;\n }\n channelEstablished = true;\n\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\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// make sure the mnemonic does not include our splitter (\\n--PASS--\\n) string or \\n characters\nfunction validateMnemonic(mnemonic) {\n if (mnemonic.includes(\"\\n--PASS--\\n\")) {\n throw new Error('mnemonic cannot include the string \"\\\\n--PASS--\\\\n\"');\n }\n if (mnemonic.includes(\"\\n\")) {\n throw new Error(\"mnemonic cannot include newline characters\");\n }\n}\n\n/**\n * Function triggered when INJECT_IMPORT_BUNDLE event is received.\n * Parses the `import_bundle` and stores the target public key as a JWK\n * in local storage. Sends true upon success.\n * @param {string} bundle\n * Example bundle: {\"targetPublic\":\"0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f\",\"targetPublicSignature\":\"3045022100cefc333c330c9fa300d1aa10a439a76539b4d6967301638ab9edc9fd9468bfdb0220339bba7e2b00b45d52e941d068ecd3bfd16fd1926da69dd7769893268990d62f\",\"enclaveQuorumPublic\":\"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\"}\n * @param {string} organizationId\n * @param {string} userId\n * @param {string} requestId\n */\nasync function onInjectImportBundle(bundle, organizationId, userId, requestId) {\n let targetPublicBuf;\n let verified;\n\n // Parse the import bundle\n const bundleObj = JSON.parse(bundle);\n\n switch (bundleObj.version) {\n case \"v1.0.0\": {\n // Validate fields exist\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 // Verify enclave signature\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method not loaded\");\n }\n verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(`failed to verify enclave signature: ${bundle}`);\n }\n\n // Parse the signed data. The data is produced by JSON encoding followed by hex encoding. We reverse this here.\n const signedData = JSON.parse(\n new TextDecoder().decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n // Validate fields match\n if (!organizationId) {\n throw new Error(\n 'missing \"organizationId\": @turnkey/iframe-stamper >= v2.0.0 is required 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 if (!userId) {\n throw new Error(\n 'missing \"userId\": @turnkey/iframe-stamper >= v2.0.0 is required to pass \"userId\" for security purposes.'\n );\n } else if (!signedData.userId || signedData.userId !== userId) {\n throw new Error(\n `user id does not match expected value. Expected: ${userId}. Found: ${signedData.userId}.`\n );\n }\n\n if (!signedData.targetPublic) {\n throw new Error('missing \"targetPublic\" in bundle signed data');\n }\n\n // Load target public key generated from enclave and set in local storage\n targetPublicBuf = TKHQ.uint8arrayFromHexString(signedData.targetPublic);\n break;\n }\n default:\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n\n const targetPublicKeyJwk = await TKHQ.loadTargetKey(\n new Uint8Array(targetPublicBuf)\n );\n TKHQ.setTargetEmbeddedKey(targetPublicKeyJwk);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_WALLET_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} requestId\n */\nasync function onExtractWalletEncryptedBundle(requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext wallet mnemonic\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no wallet mnemonic entered\");\n }\n\n const passphrase = document.getElementById(\"passphrase\").value;\n\n validateMnemonic(plaintext);\n\n const combined =\n passphrase === \"\" ? plaintext : `${plaintext}\\n--PASS--\\n${passphrase}`;\n const plaintextBuf = new TextEncoder().encode(combined);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_KEY_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} keyFormat\n * @param {string} requestId\n */\nasync function onExtractKeyEncryptedBundle(keyFormat, requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext private key\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no private key entered\");\n }\n const plaintextBuf = await TKHQ.decodeKey(plaintext, keyFormat);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, 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","// 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\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\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","// 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 \"\" + chunkId + \".bundle.\" + {\"291\":\"b62abe64ba4ebf68e89b\",\"825\":\"3a4aff0e743a7540fe25\"}[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__.p = \"/\";","// 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\t57: 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[\"webpackChunkimport\"] = self[\"webpackChunkimport\"] || [];\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,551], () => (__webpack_require__(954)))\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","_OverloadYield","k","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","window","TKHQ","iframeMessagePort","messageListenerController","AbortController","turnkeyInitController","channelEstablished","messageEventListener","_ref","_regeneratorRuntime","mark","_callee","event","wrap","_context","prev","next","data","onInjectImportBundle","t0","toString","onExtractWalletEncryptedBundle","t1","onExtractKeyEncryptedBundle","t2","onApplySettings","t3","stop","_x","validateMnemonic","mnemonic","includes","Error","_x3","_x4","_x5","_x6","_onInjectImportBundle","_callee5","bundle","organizationId","userId","requestId","targetPublicBuf","bundleObj","signedData","targetPublicKeyJwk","_context5","JSON","parse","version","dataSignature","enclaveQuorumPublic","sent","concat","TextDecoder","decode","targetPublic","abrupt","Uint8Array","_x7","_onExtractWalletEncryptedBundle","_callee6","plaintext","passphrase","combined","plaintextBuf","encryptedBundle","_context6","document","getElementById","trim","TextEncoder","encode","HpkeEncrypt","receiverPubJwk","_x8","_x9","_onExtractKeyEncryptedBundle","_callee7","keyFormat","_context7","_x10","_x11","_onApplySettings","_callee8","settings","validSettings","_context8","addEventListener","_callee3","styleSettings","plaintextTextarea","_context3","capture","signal","aborted","_callee2","permStatus","_context2","navigator","permissions","query","name","state","clipboard","writeText","_ref4","_callee4","_event$ports","_context4","source","parent","origin","ports","abort","onmessage","_x2","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","key","splice","obj","mode","this","__esModule","ns","def","current","indexOf","getOwnPropertyNames","forEach","definition","get","chunkId","all","reduce","promises","miniCssF","g","globalThis","Function","prop","hasOwnProperty","url","push","script","needAttach","scripts","getElementsByTagName","s","getAttribute","createElement","charset","nc","setAttribute","src","onScriptComplete","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","type","target","head","appendChild","installedChunks","installedChunkData","promise","reject","error","errorType","realSrc","message","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","id","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/index.bundle.ee8eee9be6e64fec1fc8.js b/import/dist/index.bundle.ee8eee9be6e64fec1fc8.js new file mode 100644 index 00000000..965a6fd6 --- /dev/null +++ b/import/dist/index.bundle.ee8eee9be6e64fec1fc8.js @@ -0,0 +1,3 @@ +/*! For license information please see index.bundle.ee8eee9be6e64fec1fc8.js.LICENSE.txt */ +(()=>{"use strict";var e,t,r,n,a,o={954:(e,t,r)=>{var n=r(482),a=r(584);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 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 a={throw:1,return:2,break:3,continue:3};function o(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,a[e],t)},delegateYield:function(e,a,o){return t.resultName=a,r(n.d,u(e),o)},finish:function(e){return r(n.f,e)}},r=function(e,r,a){n.p=t.prev,n.n=t.next;try{return e(r,a)}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,a){return e.w(o(t),r,n,a&&a.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new v(e,t)},AsyncIterator:d,async:function(e,t,r,a,i){return(n(t)?f:s)(o(e),t,r,a,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(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 s(e,t,r,n,a){var o=f(e,t,r,n,a);return o.next().then(function(e){return e.done?e.value:o.next()})}function f(e,t,r,n,a){return new d(p().w(e,t,r,n),a||Promise)}function d(e,t){function r(n,a,o,i){try{var u=e[n](a),c=u.value;return c instanceof v?t.resolve(c.v).then(function(e){r("next",e,o,i)},function(e){r("throw",e,o,i)}):t.resolve(c).then(function(e){u.value=e,o(u)},function(e){return r("throw",e,o,i)})}catch(e){i(e)}}var n;this.next||(l(d.prototype),l(d.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),l(this,"_invoke",function(e,a,o){function i(){return new t(function(t,n){r(e,o,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",a=r.toStringTag||"@@toStringTag";function o(r,n,a,o){var c=n&&n.prototype instanceof u?n:u,s=Object.create(c.prototype);return l(s,"_invoke",function(r,n,a){var o,u,c,s=0,f=a||[],d=!1,p={p:0,n:0,v:e,a:l,f:l.bind(e,4),d:function(t,r){return o=t,u=0,c=e,p.n=r,i}};function l(r,n){for(u=r,c=n,t=0;!d&&s&&!a&&t3?(a=v===n)&&(c=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=l&&((a=r<2&&ln||n>v)&&(o[4]=r,o[5]=n,p.n=v,u=0))}if(a||r>1)return i;throw d=!0,n}return function(a,f,v){if(s>1)throw TypeError("Generator is already running");for(d&&1===f&&l(f,v),u=f,c=v;(t=u<2?e:c)||!d;){o||(u?u<3?(u>1&&(p.n=-1),l(u,c)):p.n=c:p.v=c);try{if(s=2,o){if(u||(a="next"),t=o[a]){if(!(t=t.call(o,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=o.return)&&t.call(o),u<2&&(c=TypeError("The iterator does not provide a '"+a+"' method"),u=1);o=e}else if((t=(d=p.n<0)?c:r.call(n,p))!==i)break}catch(t){o=e,u=1,c=t}finally{s=1}}return{value:t,done:d}}}(r,a,o),!0),s}var i={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(l(t={},n,function(){return this}),t),d=s.prototype=u.prototype=Object.create(f);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,l(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=s,l(d,"constructor",s),l(s,"constructor",c),c.displayName="GeneratorFunction",l(s,a,"GeneratorFunction"),l(d),l(d,a,"Generator"),l(d,n,function(){return this}),l(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:o,m:v}})()}function l(e,t,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}l=function(e,t,r,n){function o(t,r){l(e,t,function(e){return this._invoke(t,r,e)})}t?a?a(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(o("next",0),o("throw",1),o("return",2))},l(e,t,r,n)}function v(e,t){this.v=e,this.k=t}function b(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function y(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){b(o,n,a,i,u,"next",e)}function u(e){b(o,n,a,i,u,"throw",e)}i(void 0)})}}window.TKHQ=n;var g=null,h=new AbortController,m=new AbortController,w=!1,E=null,x=function(){var e=y(i().mark(function e(t){return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"INJECT_IMPORT_BUNDLE"!=t.data.type){e.next=9;break}return e.prev=1,e.next=4,S(t.data.value,t.data.organizationId,t.data.userId,t.data.requestId);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),n.sendMessageUp("ERROR",e.t0.toString(),t.data.requestId);case 9:if(!t.data||"EXTRACT_WALLET_ENCRYPTED_BUNDLE"!=t.data.type){e.next=18;break}return e.prev=10,e.next=13,O(t.data.requestId);case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(10),n.sendMessageUp("ERROR",e.t1.toString(),t.data.requestId);case 18:if(!t.data||"EXTRACT_KEY_ENCRYPTED_BUNDLE"!=t.data.type){e.next=27;break}return e.prev=19,e.next=22,P(t.data.keyFormat,t.data.requestId);case 22:e.next=27;break;case 24:e.prev=24,e.t2=e.catch(19),n.sendMessageUp("ERROR",e.t2.toString(),t.data.requestId);case 27:if(!t.data||"APPLY_SETTINGS"!=t.data.type){e.next=36;break}return e.prev=28,e.next=31,N(t.data.value,t.data.requestId);case 31:e.next=36;break;case 33:e.prev=33,e.t3=e.catch(28),n.sendMessageUp("ERROR",e.t3.toString(),t.data.requestId);case 36:case"end":return e.stop()}},e,null,[[1,6],[10,15],[19,24],[28,33]])}));return function(t){return e.apply(this,arguments)}}();function k(e){if(e.includes("\n--PASS--\n"))throw new Error('mnemonic cannot include the string "\\n--PASS--\\n"');if(e.includes("\n"))throw new Error("mnemonic cannot include newline characters")}function S(e,t,r,n){return T.apply(this,arguments)}function T(){return(T=y(i().mark(function e(t,r,a,o){var u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:c=JSON.parse(t),e.t0=c.version,e.next="v1.0.0"===e.t0?4:34;break;case 4:if(c.data){e.next=6;break}throw new Error('missing "data" in bundle');case 6:if(c.dataSignature){e.next=8;break}throw new Error('missing "dataSignature" in bundle');case 8:if(c.enclaveQuorumPublic){e.next=10;break}throw new Error('missing "enclaveQuorumPublic" in bundle');case 10:if(n.verifyEnclaveSignature){e.next=12;break}throw new Error("method not loaded");case 12:return e.next=14,n.verifyEnclaveSignature(c.enclaveQuorumPublic,c.dataSignature,c.data);case 14:if(e.sent){e.next=17;break}throw new Error("failed to verify enclave signature: ".concat(t));case 17:if(s=JSON.parse((new TextDecoder).decode(n.uint8arrayFromHexString(c.data))),r){e.next=22;break}throw new Error('missing "organizationId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "organizationId" for security purposes.');case 22:if(s.organizationId&&s.organizationId===r){e.next=24;break}throw new Error("organization id does not match expected value. Expected: ".concat(r,". Found: ").concat(s.organizationId,"."));case 24:if(a){e.next=28;break}throw new Error('missing "userId": @turnkey/iframe-stamper >= v2.0.0 is required to pass "userId" for security purposes.');case 28:if(s.userId&&s.userId===a){e.next=30;break}throw new Error("user id does not match expected value. Expected: ".concat(a,". Found: ").concat(s.userId,"."));case 30:if(s.targetPublic){e.next=32;break}throw new Error('missing "targetPublic" in bundle signed data');case 32:return u=n.uint8arrayFromHexString(s.targetPublic),e.abrupt("break",35);case 34:throw new Error("unsupported version: ".concat(c.version));case 35:return e.next=37,n.loadTargetKey(new Uint8Array(u));case 37:f=e.sent,n.setTargetEmbeddedKey(f),n.sendMessageUp("BUNDLE_INJECTED",!0,o);case 40:case"end":return e.stop()}},e)}))).apply(this,arguments)}function O(e){return _.apply(this,arguments)}function _(){return(_=y(i().mark(function e(t){var r,o,u,c,s,f;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(o=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no wallet mnemonic entered");case 6:return u=document.getElementById("passphrase").value,k(o),c=""===u?o:"".concat(o,"\n--PASS--\n").concat(u),s=(new TextEncoder).encode(c),e.next=12,(0,a.q)({plaintextBuf:s,receiverPubJwk:r});case 12:f=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",f,t);case 15:case"end":return e.stop()}},e)}))).apply(this,arguments)}function P(e,t){return I.apply(this,arguments)}function I(){return(I=y(i().mark(function e(t,r){var o,u,c,s;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=n.getTargetEmbeddedKey())){e.next=3;break}throw new Error("no target key found");case 3:if(u=document.getElementById("plaintext").value.trim()){e.next=6;break}throw new Error("no private key entered");case 6:return e.next=8,n.decodeKey(u,t);case 8:return c=e.sent,e.next=11,(0,a.q)({plaintextBuf:c,receiverPubJwk:o});case 11:s=e.sent,n.resetTargetEmbeddedKey(),n.sendMessageUp("ENCRYPTED_BUNDLE_EXTRACTED",s,r);case 14:case"end":return e.stop()}},e)}))).apply(this,arguments)}function N(e,t){return j.apply(this,arguments)}function j(){return(j=y(i().mark(function e(t,r){var a;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=n.applySettings(t),n.setSettings(a),n.sendMessageUp("SETTINGS_APPLIED",!0,r);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}document.addEventListener("DOMContentLoaded",y(i().mark(function e(){var t,r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window.addEventListener("message",function(){var e=y(i().mark(function e(t){return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.data&&t.data.type){e.next=2;break}return e.abrupt("return");case 2:if("TURNKEY_INIT_MESSAGE_CHANNEL"!==t.data.type){e.next=4;break}return e.abrupt("return");case 4:if(t.source===window.parent){e.next=6;break}return e.abrupt("return");case 6:if(t.origin&&"null"!==t.origin){e.next=8;break}return e.abrupt("return");case 8:if(null!==E){e.next=13;break}E=t.origin,n.setParentFrameOrigin(t.origin),e.next=15;break;case 13:if(t.origin===E){e.next=15;break}return e.abrupt("return");case 15:return e.next=17,x(t);case 17:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),{capture:!1,signal:h.signal}),h.signal.aborted){e.next=9;break}if((t=n.getSettings())&&n.applySettings(t),n.sendMessageUp("PUBLIC_KEY_READY",""),r=document.getElementById("plaintext")){e.next=8;break}return e.abrupt("return");case 8:r.addEventListener("paste",y(i().mark(function e(){var t;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"}).catch(function(){return null});case 3:if("granted"!==(null==(t=e.sent)?void 0:t.state)&&"prompt"!==(null==t?void 0:t.state)){e.next=7;break}return e.next=7,navigator.clipboard.writeText("");case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}},e,null,[[0,9]])})));case 9:case"end":return e.stop()}},e)})),!1),window.addEventListener("message",function(){var e=y(i().mark(function e(t){var r;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data||"TURNKEY_INIT_MESSAGE_CHANNEL"!=t.data.type||t.source!==window.parent||!t.origin||"null"===t.origin||1!==(null===(r=t.ports)||void 0===r?void 0:r.length)){e.next=10;break}if(!w){e.next=3;break}return e.abrupt("return");case 3:w=!0,h.abort(),(g=t.ports[0]).onmessage=x,n.setParentFrameMessageChannelPort(g),n.sendMessageUp("PUBLIC_KEY_READY",""),m.abort();case 10:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),{signal:m.signal})}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.m=o,e=[],u.O=(t,r,n,a)=>{if(!r){var o=1/0;for(f=0;f=a)&&Object.keys(u.O).every(e=>u.O[e](r[c]))?r.splice(c--,1):(i=!1,a0&&e[f-1][2]>a;f--)e[f]=e[f-1];e[f]=[r,n,a]},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,u.t=function(e,n){if(1&n&&(e=this(e)),8&n)return e;if("object"==typeof e&&e){if(4&n&&e.__esModule)return e;if(16&n&&"function"==typeof e.then)return e}var a=Object.create(null);u.r(a);var o={};t=t||[null,r({}),r([]),r(r)];for(var i=2&n&&e;("object"==typeof i||"function"==typeof i)&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,u.d(a,o),a},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.f={},u.e=e=>Promise.all(Object.keys(u.f).reduce((t,r)=>(u.f[r](e,t),t),[])),u.u=e=>e+".bundle."+{291:"b62abe64ba4ebf68e89b",825:"3a4aff0e743a7540fe25"}[e]+".js",u.miniCssF=e=>{},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},a="import:",u.l=(e,t,r,o)=>{if(n[e])n[e].push(t);else{var i,c;if(void 0!==r)for(var s=document.getElementsByTagName("script"),f=0;f{i.onerror=i.onload=null,clearTimeout(l);var a=n[e];if(delete n[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(e=>e(r)),t)return t(r)},l=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),c&&document.head.appendChild(i)}},u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="/",(()=>{var e={57:0};u.f.j=(t,r)=>{var n=u.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var a=new Promise((r,a)=>n=e[t]=[r,a]);r.push(n[2]=a);var o=u.p+u.u(t),i=new Error;u.l(o,r=>{if(u.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}},"chunk-"+t,t)}},u.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,[o,i,c]=r,s=0;if(o.some(t=>0!==e[t])){for(n in i)u.o(i,n)&&(u.m[n]=i[n]);if(c)var f=c(u)}for(t&&t(r);su(954));c=u.O(c)})(); +//# sourceMappingURL=index.bundle.ee8eee9be6e64fec1fc8.js.map \ No newline at end of file diff --git a/import/dist/index.bundle.808edbe601034931b90e.js.LICENSE.txt b/import/dist/index.bundle.ee8eee9be6e64fec1fc8.js.LICENSE.txt similarity index 100% rename from import/dist/index.bundle.808edbe601034931b90e.js.LICENSE.txt rename to import/dist/index.bundle.ee8eee9be6e64fec1fc8.js.LICENSE.txt diff --git a/import/dist/index.bundle.ee8eee9be6e64fec1fc8.js.map b/import/dist/index.bundle.ee8eee9be6e64fec1fc8.js.map new file mode 100644 index 00000000..17c82e02 --- /dev/null +++ b/import/dist/index.bundle.ee8eee9be6e64fec1fc8.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.bundle.ee8eee9be6e64fec1fc8.js","mappings":";uBAAIA,ECCAC,EADAC,ECAAC,EACAC,E,24ECAJ,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,OA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xBd,EAAgBc,IAAa,CACtD,IAAIjF,KAAY8E,EACZ/E,EAAoB7K,EAAE4P,EAAa9E,KACrCD,EAAoB7I,EAAE8I,GAAY8E,EAAY9E,IAGhD,GAAG+E,EAAS,IAAIxE,EAASwE,EAAQhF,EAClC,CAEA,IADG8E,GAA4BA,EAA2BxL,GACrDjE,EAAIoL,EAASpK,OAAQhB,IACzB2M,EAAUvB,EAASpL,GAChB2K,EAAoB7K,EAAEiP,EAAiBpC,IAAYoC,EAAgBpC,IACrEoC,EAAgBpC,GAAS,KAE1BoC,EAAgBpC,GAAW,EAE5B,OAAOhC,EAAoBO,EAAEC,IAG1B2E,EAAqBC,KAAyB,mBAAIA,KAAyB,oBAAK,GACpFD,EAAmBtD,QAAQgD,EAAqBzO,KAAK,KAAM,IAC3D+O,EAAmBxC,KAAOkC,EAAqBzO,KAAK,KAAM+O,EAAmBxC,KAAKvM,KAAK+O,G,KClFvF,IAAIE,EAAsBrF,EAAoBO,OAAEJ,EAAW,CAAC,GAAG,KAAM,IAAOH,EAAoB,MAChGqF,EAAsBrF,EAAoBO,EAAE8E,E","sources":["webpack://import/webpack/runtime/chunk loaded","webpack://import/webpack/runtime/create fake namespace object","webpack://import/webpack/runtime/load script","webpack://import/./src/index.js","webpack://import/webpack/bootstrap","webpack://import/webpack/runtime/define property getters","webpack://import/webpack/runtime/ensure chunk","webpack://import/webpack/runtime/get javascript chunk filename","webpack://import/webpack/runtime/get mini-css chunk filename","webpack://import/webpack/runtime/global","webpack://import/webpack/runtime/hasOwnProperty shorthand","webpack://import/webpack/runtime/make namespace object","webpack://import/webpack/runtime/publicPath","webpack://import/webpack/runtime/jsonp chunk loading","webpack://import/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 = \"import:\";\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}\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 \"./styles.css\";\nimport * as TKHQ from \"./turnkey-core.js\";\nimport { HpkeEncrypt } from \"@shared/crypto-utils.js\";\n\n// Make TKHQ available globally for backwards compatibility\nwindow.TKHQ = TKHQ;\n\n// persist the MessageChannel object so we can use it to communicate with the parent window\nvar iframeMessagePort = null;\n\n// controllers to remove event listeners\nconst messageListenerController = new AbortController();\nconst turnkeyInitController = new AbortController();\n\n// Guard to prevent concurrent channel establishment from multiple senders\nlet channelEstablished = false;\n\n// Origin of a legacy (@turnkey/iframe-stamper < 2.1.0) parent, bound on its\n// first valid message. A document belongs to exactly one embedder for its\n// lifetime, so every subsequent message must come from the same origin.\nlet legacyParentOrigin = null;\n\n/**\n * Message Event Handlers to process messages from the parent frame\n */\nvar messageEventListener = async function (event) {\n if (event.data && event.data[\"type\"] == \"INJECT_IMPORT_BUNDLE\") {\n try {\n await onInjectImportBundle(\n event.data[\"value\"],\n event.data[\"organizationId\"],\n event.data[\"userId\"],\n event.data[\"requestId\"]\n );\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_WALLET_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractWalletEncryptedBundle(event.data[\"requestId\"]);\n } catch (e) {\n TKHQ.sendMessageUp(\"ERROR\", e.toString(), event.data[\"requestId\"]);\n }\n }\n if (event.data && event.data[\"type\"] == \"EXTRACT_KEY_ENCRYPTED_BUNDLE\") {\n try {\n await onExtractKeyEncryptedBundle(\n event.data[\"keyFormat\"],\n event.data[\"requestId\"]\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};\n\n/**\n * Broadcast that the frame is ready and set up the message event listeners\n */\ndocument.addEventListener(\n \"DOMContentLoaded\",\n async function () {\n // Legacy embedded mode: @turnkey/iframe-stamper < 2.1.0 posts requests\n // straight to this window instead of establishing a MessageChannel.\n // We harden this path to mirror the export-and-sign pattern from PR #129:\n // 1. Only the direct parent window is accepted.\n // 2. Opaque and empty origins are rejected.\n // 3. The first accepted origin is bound; later messages from a different\n // origin are dropped.\n // 4. Outbound responses are restricted to the bound origin so they are\n // only readable by the legitimate parent.\n window.addEventListener(\n \"message\",\n async function (event) {\n if (!event.data || !event.data[\"type\"]) {\n return;\n }\n // Channel establishment is owned by the handshake listener below.\n if (event.data[\"type\"] === \"TURNKEY_INIT_MESSAGE_CHANNEL\") {\n return;\n }\n // Only the direct parent, with a real (non-opaque) origin, may drive\n // the legacy path.\n if (event.source !== window.parent) {\n return;\n }\n if (!event.origin || event.origin === \"null\") {\n return;\n }\n if (legacyParentOrigin === null) {\n legacyParentOrigin = event.origin;\n // From now on, responses posted to window.parent are only readable\n // by the bound origin.\n TKHQ.setParentFrameOrigin(event.origin);\n } else if (event.origin !== legacyParentOrigin) {\n return;\n }\n await messageEventListener(event);\n },\n {\n capture: false,\n signal: messageListenerController.signal,\n }\n );\n\n if (!messageListenerController.signal.aborted) {\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 // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\n\n const plaintextTextarea = document.getElementById(\"plaintext\");\n if (!plaintextTextarea) return;\n // Clear clipboard after paste to avoid sensitive data lingering in clipboard.\n\n plaintextTextarea.addEventListener(\"paste\", async () => {\n // Let the paste happen first\n try {\n // Check clipboard-write permission first. In new versions of iframe-stamper, we add this permission when creating the iframe. In older versions, this permission is not added.\n const permStatus = await navigator.permissions\n .query({ name: \"clipboard-write\" }) // This is required to avoid error on clipboard write\n .catch(() => null);\n\n // Proceed only if granted or promptable\n if (\n permStatus?.state === \"granted\" ||\n permStatus?.state === \"prompt\"\n ) {\n await navigator.clipboard.writeText(\"\");\n }\n } catch {\n // Silently ignore any errors — no warnings or console noise\n }\n });\n }\n },\n false\n);\n\nwindow.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.source === window.parent &&\n event.origin &&\n event.origin !== \"null\" &&\n event.ports?.length === 1\n ) {\n // Synchronously check-and-set the flag before any await. This prevents\n // a second concurrent invocation from racing through while the first is\n // suspended at an await, which would allow multiple origins to establish\n // a channel before turnkeyInitController.abort() is reached.\n if (channelEstablished) {\n return;\n }\n channelEstablished = true;\n\n // remove the message event listener that was added in the DOMContentLoaded event\n messageListenerController.abort();\n\n iframeMessagePort = event.ports[0];\n iframeMessagePort.onmessage = messageEventListener;\n\n TKHQ.setParentFrameMessageChannelPort(iframeMessagePort);\n\n // This is a workaround for how @turnkey/iframe-stamper is initialized. Currently,\n // init() waits for a public key to be initialized that can be used to send to the server\n // which will encrypt messages to this public key.\n // In the case of import, this public key is not used because the client encrypts messages\n // to the server's public key.\n TKHQ.sendMessageUp(\"PUBLIC_KEY_READY\", \"\");\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// make sure the mnemonic does not include our splitter (\\n--PASS--\\n) string or \\n characters\nfunction validateMnemonic(mnemonic) {\n if (mnemonic.includes(\"\\n--PASS--\\n\")) {\n throw new Error('mnemonic cannot include the string \"\\\\n--PASS--\\\\n\"');\n }\n if (mnemonic.includes(\"\\n\")) {\n throw new Error(\"mnemonic cannot include newline characters\");\n }\n}\n\n/**\n * Function triggered when INJECT_IMPORT_BUNDLE event is received.\n * Parses the `import_bundle` and stores the target public key as a JWK\n * in local storage. Sends true upon success.\n * @param {string} bundle\n * Example bundle: {\"targetPublic\":\"0491ccb68758b822a6549257f87769eeed37c6cb68a6c6255c5f238e2b6e6e61838c8ac857f2e305970a6435715f84e5a2e4b02a4d1e5289ba7ec7910e47d2d50f\",\"targetPublicSignature\":\"3045022100cefc333c330c9fa300d1aa10a439a76539b4d6967301638ab9edc9fd9468bfdb0220339bba7e2b00b45d52e941d068ecd3bfd16fd1926da69dd7769893268990d62f\",\"enclaveQuorumPublic\":\"04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569\"}\n * @param {string} organizationId\n * @param {string} userId\n * @param {string} requestId\n */\nasync function onInjectImportBundle(bundle, organizationId, userId, requestId) {\n let targetPublicBuf;\n let verified;\n\n // Parse the import bundle\n const bundleObj = JSON.parse(bundle);\n\n switch (bundleObj.version) {\n case \"v1.0.0\": {\n // Validate fields exist\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 // Verify enclave signature\n if (!TKHQ.verifyEnclaveSignature) {\n throw new Error(\"method not loaded\");\n }\n verified = await TKHQ.verifyEnclaveSignature(\n bundleObj.enclaveQuorumPublic,\n bundleObj.dataSignature,\n bundleObj.data\n );\n if (!verified) {\n throw new Error(`failed to verify enclave signature: ${bundle}`);\n }\n\n // Parse the signed data. The data is produced by JSON encoding followed by hex encoding. We reverse this here.\n const signedData = JSON.parse(\n new TextDecoder().decode(TKHQ.uint8arrayFromHexString(bundleObj.data))\n );\n\n // Validate fields match\n if (!organizationId) {\n throw new Error(\n 'missing \"organizationId\": @turnkey/iframe-stamper >= v2.0.0 is required 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 if (!userId) {\n throw new Error(\n 'missing \"userId\": @turnkey/iframe-stamper >= v2.0.0 is required to pass \"userId\" for security purposes.'\n );\n } else if (!signedData.userId || signedData.userId !== userId) {\n throw new Error(\n `user id does not match expected value. Expected: ${userId}. Found: ${signedData.userId}.`\n );\n }\n\n if (!signedData.targetPublic) {\n throw new Error('missing \"targetPublic\" in bundle signed data');\n }\n\n // Load target public key generated from enclave and set in local storage\n targetPublicBuf = TKHQ.uint8arrayFromHexString(signedData.targetPublic);\n break;\n }\n default:\n throw new Error(`unsupported version: ${bundleObj.version}`);\n }\n\n const targetPublicKeyJwk = await TKHQ.loadTargetKey(\n new Uint8Array(targetPublicBuf)\n );\n TKHQ.setTargetEmbeddedKey(targetPublicKeyJwk);\n\n // Send up BUNDLE_INJECTED message\n TKHQ.sendMessageUp(\"BUNDLE_INJECTED\", true, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_WALLET_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} requestId\n */\nasync function onExtractWalletEncryptedBundle(requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext wallet mnemonic\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no wallet mnemonic entered\");\n }\n\n const passphrase = document.getElementById(\"passphrase\").value;\n\n validateMnemonic(plaintext);\n\n const combined =\n passphrase === \"\" ? plaintext : `${plaintext}\\n--PASS--\\n${passphrase}`;\n const plaintextBuf = new TextEncoder().encode(combined);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, requestId);\n}\n\n/**\n * Function triggered when EXTRACT_KEY_ENCRYPTED_BUNDLE event is received.\n * Prerequisite: This function uses the target public key in local storage that is imported\n * from the INJECT_IMPORT_BUNDLE event.\n * Uses the target public key in local storage to encrypt the text entered in the\n * `plaintext` textarea element. Upon successful encryption, sends\n * an `encrypted_bundle` containing the ciphertext and encapped public key.\n * Example bundle: {\"encappedPublic\":\"0497f33f3306f67f4402d4824e15b63b04786b6558d417aac2fef69051e46fa7bfbe776b142e4ded4f02097617a7588e93c53b71f900a4a8831a31be6f95e5f60f\",\"ciphertext\":\"c17c3085505f3c094f0fa61791395b83ab1d8c90bdf9f12a64fc6e2e9cba266beb528f65c88bd933e36e6203752a9b63e6a92290a0ab6bf0ed591cf7bfa08006001e2cc63870165dc99ec61554ffdc14dea7d567e62cceed29314ae6c71a013843f5c06146dee5bf9c1d\"}\n * @param {string} keyFormat\n * @param {string} requestId\n */\nasync function onExtractKeyEncryptedBundle(keyFormat, requestId) {\n // Get target embedded key from previous step (onInjectImportBundle)\n const targetPublicKeyJwk = TKHQ.getTargetEmbeddedKey();\n if (targetPublicKeyJwk == null) {\n throw new Error(\"no target key found\");\n }\n\n // Get plaintext private key\n const plaintext = document.getElementById(\"plaintext\").value.trim();\n if (!plaintext) {\n throw new Error(\"no private key entered\");\n }\n const plaintextBuf = await TKHQ.decodeKey(plaintext, keyFormat);\n\n // Encrypt the bundle using the enclave target public key\n const encryptedBundle = await HpkeEncrypt({\n plaintextBuf,\n receiverPubJwk: targetPublicKeyJwk,\n });\n\n // Reset target embedded key after using for encryption\n TKHQ.resetTargetEmbeddedKey();\n\n // Send up ENCRYPTED_BUNDLE_EXTRACTED message\n TKHQ.sendMessageUp(\"ENCRYPTED_BUNDLE_EXTRACTED\", encryptedBundle, 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","// 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\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\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","// 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 \"\" + chunkId + \".bundle.\" + {\"291\":\"b62abe64ba4ebf68e89b\",\"825\":\"3a4aff0e743a7540fe25\"}[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__.p = \"/\";","// 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\t57: 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[\"webpackChunkimport\"] = self[\"webpackChunkimport\"] || [];\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,551], () => (__webpack_require__(954)))\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","_OverloadYield","k","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","window","TKHQ","iframeMessagePort","messageListenerController","AbortController","turnkeyInitController","channelEstablished","legacyParentOrigin","messageEventListener","_ref","_regeneratorRuntime","mark","_callee","event","wrap","_context","prev","next","data","onInjectImportBundle","t0","toString","onExtractWalletEncryptedBundle","t1","onExtractKeyEncryptedBundle","t2","onApplySettings","t3","stop","_x","validateMnemonic","mnemonic","includes","Error","_x4","_x5","_x6","_x7","_onInjectImportBundle","_callee6","bundle","organizationId","userId","requestId","targetPublicBuf","bundleObj","signedData","targetPublicKeyJwk","_context6","JSON","parse","version","dataSignature","enclaveQuorumPublic","sent","concat","TextDecoder","decode","targetPublic","abrupt","Uint8Array","_x8","_onExtractWalletEncryptedBundle","_callee7","plaintext","passphrase","combined","plaintextBuf","encryptedBundle","_context7","document","getElementById","trim","TextEncoder","encode","HpkeEncrypt","receiverPubJwk","_x9","_x10","_onExtractKeyEncryptedBundle","_callee8","keyFormat","_context8","_x11","_x12","_onApplySettings","_callee9","settings","validSettings","_context9","addEventListener","_callee4","styleSettings","plaintextTextarea","_context4","_ref3","_callee2","_context2","source","parent","origin","_x2","capture","signal","aborted","_callee3","permStatus","_context3","navigator","permissions","query","name","state","clipboard","writeText","_ref5","_callee5","_event$ports","_context5","ports","abort","onmessage","_x3","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","O","result","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","keys","every","key","splice","obj","mode","this","__esModule","ns","def","current","indexOf","getOwnPropertyNames","forEach","definition","get","chunkId","all","reduce","promises","miniCssF","g","globalThis","Function","prop","hasOwnProperty","url","push","script","needAttach","scripts","getElementsByTagName","s","getAttribute","createElement","charset","nc","setAttribute","src","onScriptComplete","onerror","onload","clearTimeout","timeout","doneFns","parentNode","removeChild","setTimeout","type","target","head","appendChild","installedChunks","installedChunkData","promise","reject","error","errorType","realSrc","message","request","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","id","chunkLoadingGlobal","self","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/import/dist/index.html b/import/dist/index.html index fca7b73e..679767c7 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 564da603..81f57edb 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/import/index.test.js b/import/index.test.js index 4cf73660..1832e972 100644 --- a/import/index.test.js +++ b/import/index.test.js @@ -608,6 +608,9 @@ describe("onInjectImportBundle org/user binding (import frame)", () => { /** * Dispatch an INJECT_IMPORT_BUNDLE message event and wait for the async * handler to settle. Returns sendMessageUp call args since this dispatch. + * + * The event is dispatched from window.parent with a real origin so that it + * passes the hardened legacy-listener gate added in the PR #130 fix. */ async function dispatchInjectBundle(bundle, organizationId, userId) { // Clear previous calls (e.g. PUBLIC_KEY_READY from DOMContentLoaded) @@ -621,7 +624,10 @@ describe("onInjectImportBundle org/user binding (import frame)", () => { userId, requestId: "req-test", }, + origin: "https://app.turnkey.com", }); + // Set source to window.parent so the hardened legacy-listener accepts it. + Object.defineProperty(event, "source", { value: window.parent }); window.dispatchEvent(event); await new Promise((resolve) => setTimeout(resolve, 0)); return TKHQModule.sendMessageUp.mock.calls; @@ -644,6 +650,9 @@ describe("onInjectImportBundle org/user binding (import frame)", () => { jest .spyOn(TKHQModule, "setParentFrameMessageChannelPort") .mockImplementation(() => {}); + jest + .spyOn(TKHQModule, "setParentFrameOrigin") + .mockImplementation(() => {}); // Mock verifyEnclaveSignature so ALL bundles pass the signature check. // This lets us test the org/user binding logic in isolation. @@ -775,3 +784,246 @@ describe("onInjectImportBundle org/user binding (import frame)", () => { expect(calls[0][1]).toBe(true); }); }); + +// --------------------------------------------------------------------------- +// Legacy listener cross-origin gate (PR #130 fix) +// +// These tests verify that the DOMContentLoaded legacy window message listener +// now enforces the hardening mirrored from export-and-sign (PR #129): +// • event.source === window.parent (direct parent only) +// • event.origin && event.origin !== "null" (no opaque origins) +// • first accepted origin is bound; later messages from a different origin +// are silently dropped +// • a valid message from the bound parent is accepted and processed +// +// Covered message types: INJECT_IMPORT_BUNDLE, EXTRACT_WALLET_ENCRYPTED_BUNDLE, +// EXTRACT_KEY_ENCRYPTED_BUNDLE, APPLY_SETTINGS. +// --------------------------------------------------------------------------- + +describe("Legacy listener cross-origin gate (import frame)", () => { + let TKHQModule; + let parentWindow; + + /** + * Build a minimal operational message event with configurable source/origin. + */ + function makeOpEvent( + type = "INJECT_IMPORT_BUNDLE", + origin = "https://app.turnkey.com", + source = null // set after construction via Object.defineProperty + ) { + const event = new window.MessageEvent("message", { + data: { type, value: "dummy", organizationId: "org-1", userId: "user-1" }, + origin, + }); + Object.defineProperty(event, "source", { + value: source !== null ? source : parentWindow, + }); + return event; + } + + beforeEach(async () => { + parentWindow = { postMessage: jest.fn() }; + Object.defineProperty(window, "parent", { + configurable: true, + value: parentWindow, + }); + + global.crypto = crypto.webcrypto; + + await new Promise((resolve) => { + jest.isolateModules(() => { + jest.mock("./src/styles.css", () => {}, { virtual: true }); + jest.mock("@shared/crypto-utils.js", () => ({ + HpkeEncrypt: jest.fn(), + })); + + TKHQModule = require("./src/turnkey-core.js"); + + jest.spyOn(TKHQModule, "sendMessageUp").mockImplementation(() => {}); + jest + .spyOn(TKHQModule, "setParentFrameMessageChannelPort") + .mockImplementation(() => {}); + jest + .spyOn(TKHQModule, "setParentFrameOrigin") + .mockImplementation(() => {}); + + // Mock verifyEnclaveSignature so bundles pass signature check + jest + .spyOn(TKHQModule, "verifyEnclaveSignature") + .mockResolvedValue(true); + jest + .spyOn(TKHQModule, "loadTargetKey") + .mockResolvedValue({ kty: "EC" }); + jest + .spyOn(TKHQModule, "setTargetEmbeddedKey") + .mockImplementation(() => {}); + + require("./src/index.js"); + document.dispatchEvent(new Event("DOMContentLoaded")); + + resolve(); + }); + }); + }); + + afterEach(() => { + jest.restoreAllMocks(); + Object.defineProperty(window, "parent", { + configurable: true, + value: window, + }); + }); + + // ── Rejection tests ────────────────────────────────────────────────────── + + it.each(["INJECT_IMPORT_BUNDLE", "APPLY_SETTINGS"])( + "rejects %s from a non-parent sender (source !== window.parent)", + async (type) => { + TKHQModule.sendMessageUp.mockClear(); + const event = makeOpEvent(type, "https://app.turnkey.com", {}); // not parentWindow + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + // sendMessageUp should NOT have been called for the operational message + // (PUBLIC_KEY_READY from DOMContentLoaded may have fired already but we cleared) + const opCalls = TKHQModule.sendMessageUp.mock.calls.filter( + (c) => c[0] !== "PUBLIC_KEY_READY" + ); + expect(opCalls).toHaveLength(0); + } + ); + + it.each(["EXTRACT_WALLET_ENCRYPTED_BUNDLE", "EXTRACT_KEY_ENCRYPTED_BUNDLE"])( + "rejects %s from a non-parent sender", + async (type) => { + TKHQModule.sendMessageUp.mockClear(); + const event = makeOpEvent(type, "https://app.turnkey.com", {}); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + const opCalls = TKHQModule.sendMessageUp.mock.calls.filter( + (c) => c[0] !== "PUBLIC_KEY_READY" + ); + expect(opCalls).toHaveLength(0); + } + ); + + it("rejects INJECT_IMPORT_BUNDLE from an opaque ('null') origin", async () => { + TKHQModule.sendMessageUp.mockClear(); + const event = makeOpEvent("INJECT_IMPORT_BUNDLE", "null"); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + const opCalls = TKHQModule.sendMessageUp.mock.calls.filter( + (c) => c[0] !== "PUBLIC_KEY_READY" + ); + expect(opCalls).toHaveLength(0); + }); + + it("rejects INJECT_IMPORT_BUNDLE from an empty string origin", async () => { + TKHQModule.sendMessageUp.mockClear(); + const event = makeOpEvent("INJECT_IMPORT_BUNDLE", ""); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + const opCalls = TKHQModule.sendMessageUp.mock.calls.filter( + (c) => c[0] !== "PUBLIC_KEY_READY" + ); + expect(opCalls).toHaveLength(0); + }); + + it("rejects a second origin after the first origin is bound", async () => { + // First message from the legitimate parent — binds legacyParentOrigin. + TKHQModule.sendMessageUp.mockClear(); + const first = makeOpEvent( + "INJECT_IMPORT_BUNDLE", + "https://app.turnkey.com" + ); + window.dispatchEvent(first); + await new Promise((resolve) => setTimeout(resolve, 0)); + // The first message triggers the handler (will throw on dummy bundle, but + // the important thing is it was not silently dropped by the gate). + const firstCalls = TKHQModule.sendMessageUp.mock.calls.filter( + (c) => c[0] !== "PUBLIC_KEY_READY" + ); + expect(firstCalls.length).toBeGreaterThan(0); // processed (even if errored) + + // Second message from a *different* origin — must be dropped. + TKHQModule.sendMessageUp.mockClear(); + const second = makeOpEvent( + "APPLY_SETTINGS", + "https://evil.example.com" // different origin + ); + window.dispatchEvent(second); + await new Promise((resolve) => setTimeout(resolve, 0)); + + const secondCalls = TKHQModule.sendMessageUp.mock.calls.filter( + (c) => c[0] !== "PUBLIC_KEY_READY" + ); + expect(secondCalls).toHaveLength(0); + }); + + it("binds the origin on first accepted message and calls setParentFrameOrigin", async () => { + const event = makeOpEvent( + "INJECT_IMPORT_BUNDLE", + "https://app.turnkey.com" + ); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(TKHQModule.setParentFrameOrigin).toHaveBeenCalledWith( + "https://app.turnkey.com" + ); + expect(TKHQModule.setParentFrameOrigin).toHaveBeenCalledTimes(1); + }); + + it("does not call setParentFrameOrigin a second time for the same origin", async () => { + // Send two valid messages from the same origin + const e1 = makeOpEvent("INJECT_IMPORT_BUNDLE", "https://app.turnkey.com"); + window.dispatchEvent(e1); + await new Promise((resolve) => setTimeout(resolve, 0)); + + const e2 = makeOpEvent("INJECT_IMPORT_BUNDLE", "https://app.turnkey.com"); + window.dispatchEvent(e2); + await new Promise((resolve) => setTimeout(resolve, 0)); + + // setParentFrameOrigin should only be called once (on first binding) + expect(TKHQModule.setParentFrameOrigin).toHaveBeenCalledTimes(1); + }); + + it("accepts INJECT_IMPORT_BUNDLE from the valid bound parent", async () => { + // Mock verifyEnclaveSignature and loadTargetKey are already set up in + // beforeEach. Send a well-formed bundle to get past the gate and see + // that the handler runs (will error on dummy data, which is fine). + TKHQModule.sendMessageUp.mockClear(); + const event = makeOpEvent( + "INJECT_IMPORT_BUNDLE", + "https://app.turnkey.com" + ); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + // The gate did NOT silently drop it — sendMessageUp was called + // (either BUNDLE_INJECTED or ERROR, depending on bundle validity). + const opCalls = TKHQModule.sendMessageUp.mock.calls.filter( + (c) => c[0] !== "PUBLIC_KEY_READY" + ); + expect(opCalls.length).toBeGreaterThan(0); + }); + + it("silently ignores TURNKEY_INIT_MESSAGE_CHANNEL via legacy listener (owned by handshake handler)", async () => { + TKHQModule.sendMessageUp.mockClear(); + const event = new window.MessageEvent("message", { + data: { type: "TURNKEY_INIT_MESSAGE_CHANNEL" }, + origin: "https://app.turnkey.com", + }); + Object.defineProperty(event, "source", { value: parentWindow }); + window.dispatchEvent(event); + await new Promise((resolve) => setTimeout(resolve, 0)); + + // The legacy listener must skip it — setParentFrameOrigin must not be + // called (origin would otherwise be bound by a non-operational message). + expect(TKHQModule.setParentFrameOrigin).not.toHaveBeenCalled(); + }); +}); diff --git a/import/jest.config.js b/import/jest.config.js index 8ed0ad26..cf303a05 100644 --- a/import/jest.config.js +++ b/import/jest.config.js @@ -9,4 +9,7 @@ module.exports = { moduleNameMapper: { "^@shared/(.*)$": path.resolve(__dirname, "../shared/$1"), }, + // Allow modules imported via @shared/* (which live outside ) to + // resolve their own dependencies (e.g. bech32) from import/node_modules. + modulePaths: [path.resolve(__dirname, "node_modules")], }; diff --git a/import/src/index.js b/import/src/index.js index e690c34b..eec67583 100644 --- a/import/src/index.js +++ b/import/src/index.js @@ -15,6 +15,11 @@ const turnkeyInitController = new AbortController(); // Guard to prevent concurrent channel establishment from multiple senders let channelEstablished = false; +// Origin of a legacy (@turnkey/iframe-stamper < 2.1.0) parent, bound on its +// first valid message. A document belongs to exactly one embedder for its +// lifetime, so every subsequent message must come from the same origin. +let legacyParentOrigin = null; + /** * Message Event Handlers to process messages from the parent frame */ @@ -63,10 +68,48 @@ var messageEventListener = async function (event) { document.addEventListener( "DOMContentLoaded", async function () { - window.addEventListener("message", messageEventListener, { - capture: false, - signal: messageListenerController.signal, - }); + // Legacy embedded mode: @turnkey/iframe-stamper < 2.1.0 posts requests + // straight to this window instead of establishing a MessageChannel. + // We harden this path to mirror the export-and-sign pattern from PR #129: + // 1. Only the direct parent window is accepted. + // 2. Opaque and empty origins are rejected. + // 3. The first accepted origin is bound; later messages from a different + // origin are dropped. + // 4. Outbound responses are restricted to the bound origin so they are + // only readable by the legitimate parent. + window.addEventListener( + "message", + async function (event) { + if (!event.data || !event.data["type"]) { + return; + } + // Channel establishment is owned by the handshake listener below. + if (event.data["type"] === "TURNKEY_INIT_MESSAGE_CHANNEL") { + return; + } + // Only the direct parent, with a real (non-opaque) origin, may drive + // the legacy path. + if (event.source !== window.parent) { + return; + } + if (!event.origin || event.origin === "null") { + return; + } + if (legacyParentOrigin === null) { + legacyParentOrigin = event.origin; + // From now on, responses posted to window.parent are only readable + // by the bound origin. + TKHQ.setParentFrameOrigin(event.origin); + } else if (event.origin !== legacyParentOrigin) { + return; + } + await messageEventListener(event); + }, + { + capture: false, + signal: messageListenerController.signal, + } + ); if (!messageListenerController.signal.aborted) { // If styles are saved in local storage, sanitize and apply them. diff --git a/import/src/turnkey-core.js b/import/src/turnkey-core.js index f142d734..886e7609 100644 --- a/import/src/turnkey-core.js +++ b/import/src/turnkey-core.js @@ -15,6 +15,7 @@ const { base58CheckDecode, decodeKey, setParentFrameMessageChannelPort, + setParentFrameOrigin, normalizePadding, fromDerSignature, additionalAssociatedData, @@ -122,6 +123,7 @@ export { base58CheckDecode, decodeKey, setParentFrameMessageChannelPort, + setParentFrameOrigin, normalizePadding, fromDerSignature, additionalAssociatedData,