UNPKG

@reclaimprotocol/browser-extension-sdk

Version:

This guide will walk you through integrating the Reclaim Protocol Browser Extension SDK into your own browser extension or web application. It covers installation, manifest configuration, background initialization, content script setup, and how to trigg

3 lines 302 kB
var e={10:(e,t,r)=>{r.d(t,{a:()=>a});var n=r(385);function o(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",s=r.toStringTag||"@@toStringTag";function a(r,n,o,s){var a=n&&n.prototype instanceof u?n:u,l=Object.create(a.prototype);return i(l,"_invoke",function(r,n,o){var i,s,a,u=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,a=e,h.n=r,c}};function d(r,n){for(s=r,a=n,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(a=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return c;throw f=!0,n}return function(o,l,p){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,a=p;(t=s<2?e:a)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,a)):h.n=a:h.v=a);try{if(u=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?a:r.call(n,h))!==c)break}catch(t){i=e,s=1,a=t}finally{u=1}}return{value:t,done:f}}}(r,o,s),!0),l}var c={};function u(){}function l(){}function f(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(i(t={},n,function(){return this}),t),d=f.prototype=u.prototype=Object.create(h);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,i(e,s,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,i(d,"constructor",f),i(f,"constructor",l),l.displayName="GeneratorFunction",i(f,s,"GeneratorFunction"),i(d),i(d,s,"Generator"),i(d,n,function(){return this}),i(d,"toString",function(){return"[object Generator]"}),(o=function(){return{w:a,m:p}})()}function i(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}i=function(e,t,r,n){function s(t,r){i(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:(s("next",0),s("throw",1),s("return",2))},i(e,t,r,n)}function s(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function a(e,t,r,n){return c.apply(this,arguments)}function c(){var e;return e=o().m(function e(t,r,i,s){var a,c,u,l,f,h,d,p,y,g,m,b,E,v,w,S;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:a=r.action,c=r.source,u=r.target,l=r.data,e.p=1,w=a,e.n=w===t.MESSAGE_ACTIONS.CONTENT_SCRIPT_LOADED?2:w===t.MESSAGE_ACTIONS.REQUEST_PROVIDER_DATA?4:w===t.MESSAGE_ACTIONS.CHECK_IF_MANAGED_TAB?5:w===t.MESSAGE_ACTIONS.START_VERIFICATION?6:w===t.MESSAGE_ACTIONS.CANCEL_VERIFICATION?11:w===t.MESSAGE_ACTIONS.OFFSCREEN_DOCUMENT_READY?15:w===t.MESSAGE_ACTIONS.CLOSE_CURRENT_TAB?16:w===t.MESSAGE_ACTIONS.FILTERED_REQUEST_FOUND?17:w===t.MESSAGE_ACTIONS.GET_CURRENT_TAB_ID?23:24;break;case 2:if(c!==t.MESSAGE_SOURCES.CONTENT_SCRIPT||u!==t.MESSAGE_SOURCES.BACKGROUND){e.n=3;break}return h=(null===(f=i.tab)||void 0===f?void 0:f.id)&&t.managedTabs.has(i.tab.id),chrome.tabs.sendMessage(i.tab.id,{action:t.MESSAGE_ACTIONS.SHOULD_INITIALIZE,source:t.MESSAGE_SOURCES.BACKGROUND,target:t.MESSAGE_SOURCES.CONTENT_SCRIPT,data:{shouldInitialize:h}}).catch(function(e){return t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] Error sending initialization status:",e)}),h&&t.initPopupMessage&&t.initPopupMessage.has(i.tab.id)&&(d=t.initPopupMessage.get(i.tab.id),chrome.tabs.sendMessage(i.tab.id,d.message).then(function(){chrome.runtime.lastError&&t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] Error sending (pending) SHOW_PROVIDER_VERIFICATION_POPUP to tab ".concat(i.tab.id,":"),chrome.runtime.lastError.message)}).catch(function(e){return t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] Error sending (pending) SHOW_PROVIDER_VERIFICATION_POPUP to tab ".concat(i.tab.id," (promise catch):"),e)})),h&&t.providerDataMessage&&t.providerDataMessage.has(i.tab.id)&&(p=t.providerDataMessage.get(i.tab.id),chrome.tabs.sendMessage(i.tab.id,p.message).then(function(){chrome.runtime.lastError&&t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] Error sending (pending) PROVIDER_DATA_READY to tab ".concat(i.tab.id,":"),chrome.runtime.lastError.message)}).catch(function(e){return t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] Error sending (pending) PROVIDER_DATA_READY to tab ".concat(i.tab.id," (promise catch):"),e)}),t.providerDataMessage.delete(i.tab.id)),s({success:!0}),e.a(3,25);case 3:return e.a(3,25);case 4:return c===t.MESSAGE_SOURCES.CONTENT_SCRIPT&&u===t.MESSAGE_SOURCES.BACKGROUND&&(t.loggerService.log({message:"Content script requested provider data",type:t.LOG_TYPES.BACKGROUND,sessionId:t.sessionId||"unknown",providerId:t.httpProviderId||"unknown",appId:t.appId||"unknown"}),console.log({sender:i,ctx:t,REQUEST_PROVIDER_DATA:"REQUEST_PROVIDER_DATA"}),null!==(y=i.tab)&&void 0!==y&&y.id&&t.managedTabs.has(i.tab.id)&&t.providerData&&t.parameters&&t.sessionId&&void 0!==t.callbackUrl?(t.loggerService.log({message:"Sending the following provider data to content script: "+JSON.stringify(t.providerData),type:t.LOG_TYPES.BACKGROUND,sessionId:t.sessionId||"unknown",providerId:t.httpProviderId||"unknown",appId:t.appId||"unknown"}),s({success:!0,data:{providerData:t.providerData,parameters:t.parameters,sessionId:t.sessionId,callbackUrl:t.callbackUrl,httpProviderId:t.httpProviderId,appId:t.appId}})):s({success:!1,error:"Provider data not available or tab not managed"})),e.a(3,25);case 5:return c===t.MESSAGE_SOURCES.CONTENT_SCRIPT&&u===t.MESSAGE_SOURCES.BACKGROUND&&(m=(null===(g=i.tab)||void 0===g?void 0:g.id)&&t.managedTabs.has(i.tab.id),s({success:!0,isManaged:m})),e.a(3,25);case 6:if(c!==t.MESSAGE_SOURCES.CONTENT_SCRIPT||u!==t.MESSAGE_SOURCES.BACKGROUND){e.n=9;break}if(console.log("START VERIFICATION FROM BACKGROUND",{data:l}),t.loggerService.log({message:"Starting a new verification with data: "+JSON.stringify(l),type:t.LOG_TYPES.BACKGROUND,sessionId:l.sessionId||"unknown",providerId:l.providerId||"unknown",appId:l.applicationId||"unknown"}),t.loggerService.startFlushInterval(),!t.activeSessionId||t.activeSessionId===l.sessionId){e.n=7;break}return s({success:!1,error:"Another verification is in progress"}),e.a(3,25);case 7:return t.activeSessionId=l.sessionId||t.activeSessionId,i.tab&&i.tab.id&&(t.originalTabId=i.tab.id),e.n=8,n.startVerification(t,l);case 8:b=e.v,s({success:!0,result:b}),e.n=10;break;case 9:s({success:!1,error:"Action not supported"});case 10:return e.a(3,25);case 11:if(c!==t.MESSAGE_SOURCES.CONTENT_SCRIPT||u!==t.MESSAGE_SOURCES.BACKGROUND){e.n=13;break}return e.n=12,n.cancelSession(t,null==l?void 0:l.sessionId);case 12:s({success:!0}),e.n=14;break;case 13:s({success:!1,error:"Action not supported"});case 14:return e.a(3,25);case 15:return c===t.MESSAGE_SOURCES.OFFSCREEN&&u===t.MESSAGE_SOURCES.BACKGROUND?s({success:!0}):s({success:!1,error:"Action not supported"}),e.a(3,25);case 16:return c===t.MESSAGE_SOURCES.CONTENT_SCRIPT&&u===t.MESSAGE_SOURCES.BACKGROUND?i.tab&&i.tab.id?chrome.tabs.remove(i.tab.id,function(){chrome.runtime.lastError?(t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] Error closing tab:",chrome.runtime.lastError.message),s({success:!1,error:chrome.runtime.lastError.message})):(t.managedTabs.has(i.tab.id)&&t.managedTabs.delete(i.tab.id),s({success:!0}))}):(t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] CLOSE_CURRENT_TAB: No tab ID provided by sender."),s({success:!1,error:"No tab ID found to close."})):s({success:!1,error:"Action not supported"}),e.a(2,!0);case 17:if(c!==t.MESSAGE_SOURCES.CONTENT_SCRIPT||u!==t.MESSAGE_SOURCES.BACKGROUND){e.n=21;break}if(!t.filteredRequests.has(l.criteria.requestHash)){e.n=18;break}s({success:!0,result:t.filteredRequests.get(l.criteria.requestHash)}),e.n=20;break;case 18:return t.filteredRequests.set(l.criteria.requestHash,l.request),e.n=19,t.processFilteredRequest(l.request,l.criteria,l.sessionId,l.loginUrl);case 19:E=e.v,s({success:!0,result:E});case 20:e.n=22;break;case 21:s({success:!1,error:"Action not supported"});case 22:return e.a(3,25);case 23:return c===t.MESSAGE_SOURCES.CONTENT_SCRIPT&&u===t.MESSAGE_SOURCES.BACKGROUND?s({success:!0,tabId:null===(v=i.tab)||void 0===v?void 0:v.id}):s({success:!1,error:"Action not supported"}),e.a(3,25);case 24:s({success:!1,error:"Action not supported"});case 25:e.n=27;break;case 26:e.p=26,S=e.v,t.debugLogger.error(t.DebugLogType.BACKGROUND,"[BACKGROUND] Error handling ".concat(a,":"),S),s({success:!1,error:S.message});case 27:return e.a(2,!0)}},e,null,[[1,26]])}),c=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){s(i,n,o,a,c,"next",e)}function c(e){s(i,n,o,a,c,"throw",e)}a(void 0)})},c.apply(this,arguments)}},251:(e,t)=>{ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,c=(1<<a)-1,u=c>>1,l=-7,f=r?o-1:0,h=r?-1:1,d=e[t+f];for(f+=h,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+e[t+f],f+=h,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=h,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=u}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,c,u=8*i-o-1,l=(1<<u)-1,f=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+f>=1?h/c:h*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*c-1)*Math.pow(2,o),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;e[r+d]=255&s,d+=p,s/=256,u-=8);e[r+d-p]|=128*y}},254:(e,t,r)=>{r.d(t,{A:()=>ve});r(997);var n=r(952),o=r(856);function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,i){var a=n&&n.prototype instanceof u?n:u,l=Object.create(a.prototype);return s(l,"_invoke",function(r,n,o){var i,s,a,u=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,a=e,h.n=r,c}};function d(r,n){for(s=r,a=n,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(a=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return c;throw f=!0,n}return function(o,l,p){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,a=p;(t=s<2?e:a)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,a)):h.n=a:h.v=a);try{if(u=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?a:r.call(n,h))!==c)break}catch(t){i=e,s=1,a=t}finally{u=1}}return{value:t,done:f}}}(r,o,i),!0),l}var c={};function u(){}function l(){}function f(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(s(t={},n,function(){return this}),t),d=f.prototype=u.prototype=Object.create(h);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,s(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,s(d,"constructor",f),s(f,"constructor",l),l.displayName="GeneratorFunction",s(f,o,"GeneratorFunction"),s(d),s(d,o,"Generator"),s(d,n,function(){return this}),s(d,"toString",function(){return"[object Generator]"}),(i=function(){return{w:a,m:p}})()}function s(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}s=function(e,t,r,n){function i(t,r){s(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:(i("next",0),i("throw",1),i("return",2))},s(e,t,r,n)}function a(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function c(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function s(e){a(i,n,o,s,c,"next",e)}function c(e){a(i,n,o,s,c,"throw",e)}s(void 0)})}}var u=function(){var e=c(i().m(function e(t,r,s){var a,c,u;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,fetch("".concat(n.Sn.PROVIDER_URL(t)));case 1:if((a=e.v).ok){e.n=2;break}throw new Error("Failed to fetch provider data");case 2:return o.Ow.log({message:"Successfully fetched provider data from the backend: "+JSON.stringify(a),type:o.D_.FETCH_DATA,sessionId:r,providerId:t,appId:s}),e.n=3,a.json();case 3:return c=e.v,e.a(2,null==c?void 0:c.providers);case 4:throw e.p=4,u=e.v,o.Ow.logError({error:"Error fetching provider data: "+u.toString(),type:o.D_.FETCH_DATA,sessionId:r,providerId:t,appId:s}),o.w9.error(o.Ey.FETCH,"Error fetching provider data:",u),u;case 5:return e.a(2)}},e,null,[[0,4]])}));return function(t,r,n){return e.apply(this,arguments)}}(),l=function(){var e=c(i().m(function e(t,r,s,a){var c,u,l;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,console.log({sessionId:t,status:r,providerId:s,appId:a},"updateSessionStatus"),e.n=1,fetch("".concat(n.Sn.UPDATE_SESSION_STATUS()),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t,status:r})});case 1:if(c=e.v,console.log({response:c},"updateSessionStatus response"),c.ok){e.n=2;break}throw new Error("Failed to update session status");case 2:return o.Ow.log({message:"Successfully updated session status: "+r,type:o.D_.FETCH_DATA,sessionId:t,providerId:s,appId:a}),e.n=3,c.json();case 3:return u=e.v,console.log({res:u},"updateSessionStatus res"),e.a(2,u);case 4:throw e.p=4,l=e.v,console.log({error:l},"updateSessionStatus error"),o.Ow.logError({error:"Error updating session status: "+l.toString(),type:o.D_.FETCH_DATA,sessionId:t,providerId:s,appId:a}),l;case 5:return e.a(2)}},e,null,[[0,4]])}));return function(t,r,n,o){return e.apply(this,arguments)}}(),f=function(){var e=c(i().m(function e(t,r,s,a,c){var u,f,h,d,p;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,u=JSON.stringify(t),f=encodeURIComponent(u),e.n=1,fetch(r,{method:"POST",headers:{"Content-Type":"text/plain"},body:f});case 1:return h=e.v,e.n=2,h.text();case 2:if(d=e.v,h.ok){e.n=4;break}return e.n=3,l(s,n.Ew.PROOF_SUBMISSION_FAILED);case 3:throw new Error("Failed to submit proof to Callback and update session status");case 4:return o.Ow.log({message:"Successfully submitted proof to Callback and updated session status",type:o.D_.FETCH_DATA,sessionId:s,providerId:a,appId:c}),e.n=5,l(s,n.Ew.PROOF_SUBMITTED);case 5:return e.a(2,d);case 6:throw e.p=6,p=e.v,o.Ow.logError({error:"Error submitting proof to Callback: "+p.toString(),type:o.D_.FETCH_DATA,sessionId:s,providerId:a,appId:c}),o.w9.error(o.Ey.FETCH,"Error submitting proof to Callback:",p),p;case 7:return e.a(2)}},e,null,[[0,6]])}));return function(t,r,n,o,i){return e.apply(this,arguments)}}();function h(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof a?n:a,u=Object.create(c.prototype);return d(u,"_invoke",function(r,n,o){var i,a,c,u=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,a=0,c=e,h.n=r,s}};function d(r,n){for(a=r,c=n,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,a=0))}if(o||r>1)return s;throw f=!0,n}return function(o,l,p){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),a=l,c=p;(t=a<2?e:c)||!f;){i||(a?a<3?(a>1&&(h.n=-1),d(a,c)):h.n=c:h.v=c);try{if(u=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(f=h.n<0)?c:r.call(n,h))!==s)break}catch(t){i=e,a=1,c=t}finally{u=1}}return{value:t,done:f}}}(r,o,i),!0),u}var s={};function a(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(d(t={},n,function(){return this}),t),f=u.prototype=a.prototype=Object.create(l);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,d(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=u,d(f,"constructor",u),d(u,"constructor",c),c.displayName="GeneratorFunction",d(u,o,"GeneratorFunction"),d(f),d(f,o,"Generator"),d(f,n,function(){return this}),d(f,"toString",function(){return"[object Generator]"}),(h=function(){return{w:i,m:p}})()}function d(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}d=function(e,t,r,n){function i(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:(i("next",0),i("throw",1),i("return",2))},d(e,t,r,n)}function p(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function y(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function s(e){p(i,n,o,s,a,"next",e)}function a(e){p(i,n,o,s,a,"throw",e)}s(void 0)})}}var g=!1,m=null,b=null,E=function(e){(null==e?void 0:e.action)===n.wx.OFFSCREEN_DOCUMENT_READY&&(null==e?void 0:e.source)===n.J_.OFFSCREEN&&(null==e?void 0:e.target)===n.J_.BACKGROUND&&(o.w9.info(o.Ey.OFFSCREEN,"Received offscreen ready signal (global listener)."),g=!0,m&&(clearTimeout(m),m=null))},v=function(){"undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.onMessage&&chrome.runtime.onMessage.addListener&&chrome.runtime.onMessage.hasListener&&(chrome.runtime.onMessage.hasListener(E)?o.w9.info(o.Ey.OFFSCREEN,"Global listener already attached."):chrome.runtime.onMessage.addListener(E))},w=function(){"undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.onMessage&&chrome.runtime.onMessage.addListener&&chrome.runtime.onMessage.hasListener&&(chrome.runtime.onMessage.hasListener(E)?o.w9.info(o.Ey.OFFSCREEN,"Global listener already attached."):chrome.runtime.onMessage.addListener(E))};function S(){return I.apply(this,arguments)}function I(){return(I=y(h().m(function e(){var t,r;return h().w(function(e){for(;;)switch(e.p=e.n){case 0:return t=chrome.runtime.getURL("reclaim-browser-extension-sdk/offscreen/offscreen.html"),o.w9.info(o.Ey.OFFSCREEN,"Attempting to create offscreen document with URL:",t),e.p=1,e.n=2,chrome.offscreen.createDocument({url:t,reasons:["DOM_PARSER","IFRAME_SCRIPTING","BLOBS"],justification:"Manages DOM-dependent operations like crypto and ZK proof generation for the extension."});case 2:o.w9.info(o.Ey.OFFSCREEN,"Offscreen document creation initiated."),e.n=5;break;case 3:if(e.p=3,!(r=e.v).message||!r.message.includes("Only a single offscreen document may be created.")){e.n=4;break}o.w9.warn(o.Ey.OFFSCREEN,"Offscreen document already exists or creation was attempted by another part."),e.n=5;break;case 4:throw o.w9.error(o.Ey.OFFSCREEN,"Error creating offscreen document:",r),r;case 5:return e.a(2)}},e,null,[[1,3]])}))).apply(this,arguments)}function O(){return A.apply(this,arguments)}function A(){return A=y(h().m(function e(){var t,r=arguments;return h().w(function(e){for(;;)switch(e.n){case 0:if(t=r.length>0&&void 0!==r[0]?r[0]:15e3,console.log("waitForOffscreenReadyInternal",{offscreenReady:g}),!g){e.n=1;break}return o.w9.info(o.Ey.OFFSCREEN," Already ready (waitForOffscreenReadyInternal check)"),e.a(2,!0);case 1:o.w9.info(o.Ey.OFFSCREEN," Waiting for offscreen document to be ready (timeout:- ".concat(t,"ms)..."));try{console.log("Sending ping to offscreen document..."),chrome.runtime.sendMessage({action:n.wx.PING_OFFSCREEN,source:n.J_.BACKGROUND,target:n.J_.OFFSCREEN}),console.log("Ping sent to offscreen document")}catch(e){o.w9.warn(o.Ey.OFFSCREEN," Synchronous error sending ping:",e)}return e.a(2,new Promise(function(e){if(g)return o.w9.info(o.Ey.OFFSCREEN,"Became ready while setting up promise."),void e(!0);var r=function(t){t.action===n.wx.OFFSCREEN_DOCUMENT_READY&&t.source===n.J_.OFFSCREEN&&t.target===n.J_.BACKGROUND&&(g=!0,clearTimeout(i),chrome.runtime.onMessage.removeListener(r),m===i&&(m=null),e(!0))};chrome.runtime.onMessage.addListener(r),m&&clearTimeout(m);var i=setTimeout(function(){chrome.runtime.onMessage.removeListener(r),o.w9.error(o.Ey.OFFSCREEN," Timed out waiting for offscreen document after ".concat(t,"ms.")),m===i&&(m=null),e(!1)},t);m=i}))}},e)})),A.apply(this,arguments)}function T(){return R.apply(this,arguments)}function R(){return(R=y(h().m(function e(){return h().w(function(e){for(;;)switch(e.n){case 0:if(!g){e.n=1;break}return o.w9.info(o.Ey.OFFSCREEN,"Document already confirmed ready."),e.a(2,!0);case 1:if(!b){e.n=2;break}return o.w9.info(o.Ey.OFFSCREEN," Creation already in progress, awaiting..."),e.n=2,b;case 2:if(!chrome.runtime.getContexts){e.n=6;break}return e.n=3,chrome.runtime.getContexts({contextTypes:["OFFSCREEN_DOCUMENT"]});case 3:if(!(e.v.length>0)){e.n=6;break}if(o.w9.info(o.Ey.OFFSCREEN,"Offscreen document context found."),!g){e.n=4;break}return e.a(2,!0);case 4:return o.w9.info(o.Ey.OFFSCREEN,"Context exists, but not marked ready. Waiting for signal..."),e.n=5,O(5e3);case 5:return e.a(2,e.v);case 6:if(b){e.n=7;break}return o.w9.info(o.Ey.OFFSCREEN,"No existing context/promise, initiating creation."),b=S().finally(function(){console.log("OFFSCREEN CREATION PROMISE FINISHED",b),b=null}),e.n=7,b;case 7:return e.n=8,O(5e4);case 8:if(e.v){e.n=9;break}throw new Error("Failed to initialize or confirm offscreen document readiness.");case 9:return o.w9.info(o.Ey.OFFSCREEN,"Offscreen document ensured to be ready."),e.a(2,!0)}},e)}))).apply(this,arguments)}function P(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof a?n:a,u=Object.create(c.prototype);return N(u,"_invoke",function(r,n,o){var i,a,c,u=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,a=0,c=e,h.n=r,s}};function d(r,n){for(a=r,c=n,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,a=0))}if(o||r>1)return s;throw f=!0,n}return function(o,l,p){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),a=l,c=p;(t=a<2?e:c)||!f;){i||(a?a<3?(a>1&&(h.n=-1),d(a,c)):h.n=c:h.v=c);try{if(u=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(f=h.n<0)?c:r.call(n,h))!==s)break}catch(t){i=e,a=1,c=t}finally{u=1}}return{value:t,done:f}}}(r,o,i),!0),u}var s={};function a(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(N(t={},n,function(){return this}),t),f=u.prototype=a.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,N(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=u,N(f,"constructor",u),N(u,"constructor",c),c.displayName="GeneratorFunction",N(u,o,"GeneratorFunction"),N(f),N(f,o,"Generator"),N(f,n,function(){return this}),N(f,"toString",function(){return"[object Generator]"}),(P=function(){return{w:i,m:h}})()}function N(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}N=function(e,t,r,n){function i(t,r){N(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:(i("next",0),i("throw",1),i("return",2))},N(e,t,r,n)}function C(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}"undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.onMessage&&w(),w();var _=function(){var e,t=(e=P().m(function e(t){var r;return P().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,o.w9.info(o.Ey.PROOF,"[PROOF-GENERATOR] Starting proof generation with data:",t),t){e.n=1;break}throw new Error("No claim data provided for proof generation");case 1:return e.n=2,T();case 2:return e.a(2,new Promise(function(e,r){var i=setTimeout(function(){o.w9.error(o.Ey.PROOF,"[PROOF-GENERATOR] Timeout waiting for offscreen document to generate proof"),r({success:!1,error:"Timeout waiting for offscreen document to generate proof"})},6e4),s=function(t){if(t.action===n.wx.GENERATE_PROOF_RESPONSE&&t.source===n.J_.OFFSCREEN&&t.target===n.J_.BACKGROUND){if(clearTimeout(i),chrome.runtime.onMessage.removeListener(s),!t.success)return o.w9.error(o.Ey.PROOF,"[PROOF-GENERATOR] Proof generation failed:",t.error),void e({success:!1,error:t.error||"Unknown error in proof generation"});o.w9.info(o.Ey.PROOF,"[PROOF-GENERATOR] Proof generation successful"),e(t)}};chrome.runtime.onMessage.addListener(s),chrome.runtime.sendMessage({action:n.wx.GENERATE_PROOF,source:n.J_.BACKGROUND,target:n.J_.OFFSCREEN,data:t},function(){chrome.runtime.lastError&&(clearTimeout(i),chrome.runtime.onMessage.removeListener(s),o.w9.error(o.Ey.PROOF,"[PROOF-GENERATOR] Error sending message to offscreen document:",chrome.runtime.lastError),r({success:!1,error:chrome.runtime.lastError.message||"Error communicating with offscreen document"}))})}));case 3:return e.p=3,r=e.v,o.w9.error(o.Ey.PROOF,"[PROOF-GENERATOR] Error in proof generation process:",r),e.a(2,{success:!1,error:r.message||"Unknown error in proof generation process"})}},e,null,[[0,3]])}),function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function s(e){C(i,n,o,s,a,"next",e)}function a(e){C(i,n,o,s,a,"throw",e)}s(void 0)})});return function(e){return t.apply(this,arguments)}}(),L=r(573),k=function(e,t){try{if(!t.startsWith("$"))return null;for(var r=t.startsWith("$.")?t.substring(2):t.substring(1),n=[],i="",s=!1,a=0;a<r.length;a++){var c=r[a];if("["===c)i&&(n.push(i),i=""),s=!0;else if("]"===c){if(s&&i){var u=i.replace(/['"]/g,"");n.push(parseInt(u,10)),i=""}s=!1}else"."!==c||s?i+=c:i&&(n.push(i),i="")}i&&n.push(i);for(var l=e,f=0,h=n;f<h.length;f++){var d=h[f];if(null==l)return null;l=l[d]}return l}catch(e){return o.w9.error(o.Ey.CLAIM,"[PARAMS-EXTRACTOR-UTILS] Error extracting JSON value with path ".concat(t,":"),e),null}},U=function(e,t){try{var r=t.replace(/^\/\//,"").replace(/\/@/," ").split("/"),n=r[r.length-1],i=new RegExp("<".concat(n,"[^>]*>(.*?)</").concat(n,">"),"i"),s=e.match(i);return s?s[1]:null}catch(e){return o.w9.error(o.Ey.CLAIM,"[PARAMS-EXTRACTOR-UTILS] Error extracting HTML value with XPath ".concat(t,":"),e),null}};function x(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return F(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)?F(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function B(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.replace(/[[\]()*+?.,\\^$|#]/g,"\\$&"),o=function(e){for(var t,r=/{{(\w+)}}/g,n=[];null!==(t=r.exec(e));)n.push(t[1]);return n}(e),i=[],s=x(o);try{for(s.s();!(t=s.n()).done;){var a=t.value;if(r[a])n=n.replace("{{".concat(a,"}}"),r[a]);else{i.push(a);var c=a.endsWith("GRD")?"(.*)":"(.*?)";n=n.replace("{{".concat(a,"}}"),c)}}}catch(e){s.e(e)}finally{s.f()}return{pattern:n,allVars:o,unsubstitutedVars:i}}function D(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,i,s,a=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return G(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)?G(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 G(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function M(e){return M="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},M(e)}var j=function(e){return e?(e.match(/{{([^}]+)}}/g)||[]).map(function(e){return e.substring(2,e.length-2)}):[]},K=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||!t)return r;var n=j(e),o=B(e,n).pattern,i=t.match(o);if(i&&i.length>1)for(var s=0;s<n.length;s++)i[s+1]&&(r[n[s]]=i[s+1]);return r},V=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||!t)return r;var n=j(e),o=B(e,n).pattern,i=t.match(o);if(i&&i.length>1)for(var s=0;s<n.length;s++)i[s+1]&&(r[n[s]]=i[s+1]);return r},$=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!e)return n;try{var i=null,s=function(e){if(!e||"string"!=typeof e)return!1;var t=e.trim();return t.startsWith("{")||t.startsWith("[")}(e);if(s&&(i=function(e){try{return JSON.parse(e)}catch(e){return o.w9.warn(o.Ey.CLAIM,"[PARAMS-EXTRACTOR-UTILS] Response looks like JSON but couldn't be parsed"),null}}(e)),t&&t.length>0&&r&&r.length>0)for(var a=0;a<t.length;a++){var c=t[a],u=r[a];if(!c.value)return;var l=j(c.value);if(0===l.length)return;var f=u;if(f){var h=null;if(f.jsonPath&&i)h=k(i,f.jsonPath);else if(f.xPath&&!s)h=U(e,f.xPath);else if(f.regex){var d=e.match(new RegExp(f.regex));d&&d.length>1&&(h=d[1])}null!==h&&("object"===M(h)&&null!==h?n[l[0]]=JSON.stringify(h):n[l[0]]=String(h))}}}catch(e){o.w9.error(o.Ey.CLAIM,"[PARAM-EXTRACTOR] Error extracting params from response:",e)}return n},H=function(e){var t={},r={};return Object.entries(e||{}).forEach(function(e){var n=D(e,2),o=n[0],i=n[1];o.toLowerCase().includes("secret")?r[o]=i:t[o]=i}),{publicParams:t,secretParams:r}};function z(e){return z="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},z(e)}function q(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof a?n:a,u=Object.create(c.prototype);return W(u,"_invoke",function(r,n,o){var i,a,c,u=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,a=0,c=e,h.n=r,s}};function d(r,n){for(a=r,c=n,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,a=0))}if(o||r>1)return s;throw f=!0,n}return function(o,l,p){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),a=l,c=p;(t=a<2?e:c)||!f;){i||(a?a<3?(a>1&&(h.n=-1),d(a,c)):h.n=c:h.v=c);try{if(u=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(f=h.n<0)?c:r.call(n,h))!==s)break}catch(t){i=e,a=1,c=t}finally{u=1}}return{value:t,done:f}}}(r,o,i),!0),u}var s={};function a(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(W(t={},n,function(){return this}),t),f=u.prototype=a.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,W(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=u,W(f,"constructor",u),W(u,"constructor",c),c.displayName="GeneratorFunction",W(u,o,"GeneratorFunction"),W(f),W(f,o,"Generator"),W(f,n,function(){return this}),W(f,"toString",function(){return"[object Generator]"}),(q=function(){return{w:i,m:h}})()}function W(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}W=function(e,t,r,n){function i(t,r){W(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:(i("next",0),i("throw",1),i("return",2))},W(e,t,r,n)}function Y(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 J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(r),!0).forEach(function(t){Z(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Y(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Z(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=z(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=z(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==z(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Q(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,i,s,a=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return X(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)?X(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 X(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function ee(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}var te=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:135,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e<=0&&(e=135);var r="Chrome/".concat(e,".0.0.0"),n=t?" Mobile":"";return"Mozilla/5.0 ".concat("(Linux; Android 10; K)"," ").concat("AppleWebKit/537.36 (KHTML, like Gecko)"," ").concat(r).concat(n," ").concat("Safari/537.36")},re=function(){return new Promise(function(e,t){var r=setTimeout(function(){chrome.runtime.onMessage.removeListener(i),t(new Error("Timeout: No response from offscreen document for private key request."))},1e4),i=function(s,a){return s.action!==n.wx.GET_PRIVATE_KEY_RESPONSE||s.source!==n.J_.OFFSCREEN||s.target!==n.J_.BACKGROUND||(clearTimeout(r),chrome.runtime.onMessage.removeListener(i),s.success&&s.privateKey?(o.w9.info(o.Ey.CLAIM,"[CLAIM-CREATOR] Received private key from offscreen document"),e(s.privateKey)):(o.w9.error(o.Ey.CLAIM,"[CLAIM-CREATOR] Failed to get private key from offscreen:",s.error),t(new Error(s.error||"Unknown error getting private key from offscreen document."))),!1)};chrome.runtime.onMessage.addListener(i),o.w9.info(o.Ey.CLAIM,"[CLAIM-CREATOR] Requesting private key from offscreen document"),chrome.runtime.sendMessage({action:n.wx.GET_PRIVATE_KEY,source:n.J_.BACKGROUND,target:n.J_.OFFSCREEN},function(e){chrome.runtime.lastError&&(clearTimeout(r),chrome.runtime.onMessage.removeListener(i),o.w9.error(o.Ey.CLAIM,"[CLAIM-CREATOR] Error sending GET_PRIVATE_KEY message:",chrome.runtime.lastError.message),t(new Error("Error sending message to offscreen document: ".concat(chrome.runtime.lastError.message))))})})},ne=function(){var e,t=(e=q().m(function e(t,r,n,i){var s,a,c,u,l,f,h,d,p,y,g,m,b,E,v,w,S;return q().w(function(e){for(;;)switch(e.p=e.n){case 0:return o.w9.info(o.Ey.CLAIM,"[CLAIM-CREATOR] Creating claim object from request data"),e.p=1,o.w9.info(o.Ey.CLAIM,"[CLAIM-CREATOR] Ensuring offscreen document is ready..."),e.n=2,T();case 2:o.w9.info(o.Ey.CLAIM,"[CLAIM-CREATOR] Offscreen document is ready."),e.n=4;break;case 3:throw e.p=3,w=e.v,o.w9.error(o.Ey.CLAIM,"[CLAIM-CREATOR] Failed to ensure offscreen document:",w),new Error("Failed to initialize offscreen document: ".concat(w.message));case 4:return e.n=5,te();case 5:return c=e.v,u=["user-agent","accept","accept-language","accept-encoding","sec-fetch-mode","sec-fetch-site","sec-fetch-user","origin","x-requested-with","sec-ch-ua","sec-ch-ua-mobile"],f={},(l={}).url="TEMPLATE"===r.urlType?r.url:t.url,l.method=t.method||"GET",t.headers&&(o.w9.info(o.Ey.CLAIM,"[CLAIM-CREATOR] request.headers: ",t.headers),h={"Sec-Fetch-Mode":"same-origin","Sec-Fetch-Site":"same-origin","User-Agent":c},d={Referer:null!=i?i:""},Object.entries(t.headers).forEach(function(e){var t=Q(e,2),r=t[0],n=t[1],o=r.toLowerCase();u.includes(o)?h[r]=n:d[r]=n}),Object.keys(h).length>0&&(l.headers=h),Object.keys(d).length>0&&(f.headers=d)),null!=r&&null!==(s=r.bodySniff)&&void 0!==s&&s.enabled&&t.body&&(l.body=null==r||null===(p=r.bodySniff)||void 0===p?void 0:p.template),t.cookieStr&&(f.cookieStr=t.cookieStr),y={},"TEMPLATE"===r.urlType&&t.url&&(y=J(J({},y),K(r.url,t.url))),null!=r&&null!==(a=r.bodySniff)&&void 0!==a&&a.enabled&&t.body&&(y=J(J({},y),V(r.bodySniff.template,t.body))),t.responseText&&r.responseMatches&&(y=J(J({},y),$(t.responseText,r.responseMatches,r.responseRedactions||[]))),g=H(y),m=g.publicParams,b=g.secretParams,Object.keys(m).length>0&&(l.paramValues=m),Object.keys(b).length>0&&(f.paramValues=b),r.responseMatches&&(l.responseMatches=r.responseMatches.map(function(e){return{value:e.value,type:e.type||"contains",invert:e.invert||!1}})),r.responseRedactions&&(l.responseRedactions=r.responseRedactions.map(function(e){var t={};return Object.entries(e).forEach(function(e){var r=Q(e,2),n=r[0],o=r[1];"hash"!==n&&("jsonPath"!==n&&"xPath"!==n||o&&""!==o)&&(t[n]=o)}),t})),r.responseSelections&&(l.responseSelections=r.responseSelections.map(function(e){var t={};return"value"in e&&(t.value=e.value),"type"in e&&(t.type=e.type),"invert"in e&&(t.invert=e.invert),t})),r.additionalClientOptions&&(l.additionalClientOptions=r.additionalClientOptions),e.p=6,e.n=7,re();case 7:E=e.v,e.n=9;break;case 8:throw e.p=8,S=e.v,o.w9.error(o.Ey.CLAIM,"[CLAIM-CREATOR] Could not obtain private key:",S),new Error("Could not obtain owner private key: ".concat(S.message));case 9:return v={name:"http",sessionId:n,params:l,secretParams:f,ownerPrivateKey:E,client:{url:"wss://attestor.reclaimprotocol.org/ws"}},console.log("claimObject",v),o.w9.info(o.Ey.CLAIM,"[CLAIM-CREATOR] Claim object created successfully"),e.a(2,v)}},e,null,[[6,8],[1,3]])}),function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function s(e){ee(i,n,o,s,a,"next",e)}function a(e){ee(i,n,o,s,a,"throw",e)}s(void 0)})});return function(e,r,n,o){return t.apply(this,arguments)}}();function oe(e){return oe="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},oe(e)}function ie(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,se(n.key),n)}}function se(e){var t=function(e,t){if("object"!=oe(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==oe(t)?t:t+""}var ae=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.sessionTimer=null,this.sessionTimerDuration=3e4,this.sessionTimerPaused=!1,this.sessionTimerRemainingTime=0,this.sessionTimerStartTime=0,this.onSessionTimeout=null},(t=[{key:"setCallbacks",value:function(e){this.onSessionTimeout=e}},{key:"startSessionTimer",value:function(){var e=this;o.w9.info(o.Ey.SESSION_TIMER,"[SESSION TIMER] Starting session timer"),this.clearSessionTimer(),this.sessionTimerStartTime=Date.now(),this.sessionTimer=setTimeout(function(){null!==e.sessionTimer?(o.w9.error(o.Ey.SESSION_TIMER,"[SESSION TIMER] Session timer expired"),e.onSessionTimeout&&e.onSessionTimeout("Session timeout: No proofs generated within time limit")):o.w9.info(o.Ey.SESSION_TIMER,"[SESSION TIMER] Timer was already cleared, ignoring timeout")},this.sessionTimerDuration)}},{key:"resetSessionTimer",value:function(){o.w9.info(o.Ey.SESSION_TIMER,"[SESSION TIMER] Resetting session timer"),this.clearSessionTimer(),this.startSessionTimer()}},{key:"clearSessionTimer",value:function(){this.sessionTimer&&(clearTimeout(this.sessionTimer),this.sessionTimer=null)}},{key:"pauseSessionTimer",value:function(){if(this.sessionTimer&&!this.sessionTimerPaused){o.w9.info(o.Ey.SESSION_TIMER,"[SESSION TIMER] Pausing session timer");var e=Date.now()-this.sessionTimerStartTime;this.sessionTimerRemainingTime=Math.max(0,this.sessionTimerDuration-e),this.clearSessionTimer(),this.sessionTimerPaused=!0}}},{key:"resumeSessionTimer",value:function(){var e=this;this.sessionTimerPaused&&(o.w9.info(o.Ey.SESSION_TIMER,"[SESSION TIMER] Resuming session timer with remaining time:",this.sessionTimerRemainingTime),this.sessionTimer=setTimeout(function(){o.w9.error(o.Ey.SESSION_TIMER,"[SESSION TIMER] Session timer expired"),e.onSessionTimeout&&e.onSessionTimeout("Session timeout: No proofs generated within time limit")},this.sessionTimerRemainingTime),this.sessionTimerStartTime=Date.now()-(this.sessionTimerDuration-this.sessionTimerRemainingTime),this.sessionTimerPaused=!1)}},{key:"clearAllTimers",value:function(){o.w9.info(o.Ey.SESSION_TIMER,"[SESSION TIMER] Clearing all timers"),this.clearSessionTimer(),this.sessionTimerPaused=!1,this.sessionTimerRemainingTime=0,this.sessionTimerStartTime=0}},{key:"setTimerDuration",value:function(e){e&&"number"==typeof e&&(this.sessionTimerDuration=e)}}])&&ie(e.prototype,t),r&&ie(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}(),ce=r(10),ue=r(385);function le(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof a?n:a,u=Object.create(c.prototype);return fe(u,"_invoke",function(r,n,o){var i,a,c,u=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,a=0,c=e,h.n=r,s}};function d(r,n){for(a=r,c=n,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,a=0))}if(o||r>1)return s;throw f=!0,n}return function(o,l,p){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),a=l,c=p;(t=a<2?e:c)||!f;){i||(a?a<3?(a>1&&(h.n=-1),d(a,c)):h.n=c:h.v=c);try{if(u=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(f=h.n<0)?c:r.call(n,h))!==s)break}catch(t){i=e,a=1,c=t}finally{u=1}}return{value:t,done:f}}}(r,o,i),!0),u}var s={};function a(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(fe(t={},n,function(){return this}),t),f=u.prototype=a.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,fe(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=u,fe(f,"constructor",u),fe(u,"constructor",c),c.displayName="GeneratorFunction",fe(u,o,"GeneratorFunction"),fe(f),fe(f,o,"Generator"),fe(f,n,function(){return this}),fe(f,"toString",function(){return"[object Generator]"}),(le=function(){return{w:i,m:h}})()}function fe(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}fe=function(e,t,r,n){function i(t,r){fe(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:(i("next",0),i("throw",1),i("return",2))},fe(e,t,r,n)}function he(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function de(e,t,r){e.proofGenerationQueue.push({claimData:t,requestHash:r}),e.isProcessingQueue||(e.sessionTimerManager.pauseSessionTimer(),pe(e))}function pe(e){return ye.apply(this,arguments)}function ye(){var e;return e=le().m(function e(t){var r,n,i,s;return le().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!t.isProcessingQueue&&0!==t.proofGenerationQueue.length){e.n=3;break}if(0!==t.proofGenerationQueue.length){e.n=2;break}if(t.generatedProofs.size!==t.providerData.requestData.length){e.n=1;break}return t.sessionTimerManager.clearAllTimers(),setTimeout(function(){return t.submitProofs()},0),e.a(2);case 1:t.sessionTimerManager.resumeSessionTimer();case 2:return e.a(2);case 3:return t.isProcessingQueue=!0,r=t.proofGenerationQueue.shift(),e.p=4,chrome.tabs.sendMessage(t.activeTabId,{action:t.MESSAGE_ACTIONS.PROOF_GENERATION_STARTED,source:t.MESSAGE_SOURCES.BACKGROUND,target:t.MESSAGE_SOURCES.CONTENT_SCRIPT,data:{requestHash:r.requestHash}}),t.loggerService.log({message:"Queued proof generation request for request hash: ".concat(r.requestHash),type:t.LOG_TYPES.BACKGROUND,sessionId:t.sessionId||"unknown",providerId:t.httpProviderId||"unknown",appId:t.appId||"unknown"}),e.n=5,t.generateProof(r.claimData);case 5:if((n=e.v).success){e.n=6;break}return t.failSession("Proof generation failed: "+n.error,r.requestHash),e.a(2);case 6:(i=n.proof)&&(t.generatedProofs.has(r.requestHash)||t.generatedProofs.set(r.requestHash,i),t.loggerService.log({message:"Proof generation successful for request hash: ".concat(r.requestHash),type:t.LOG_TYPES.BACKGROUND,sessionId:t.sessionId||"unknown",providerId:t.httpProviderId||"unknown",appId:t.appId||"unknown"}),chrome.tabs.sendMessage(t.activeTabId,{action:t.MESSAGE_ACTIONS.PROOF_GENERATION_SUCCESS,source:t.MESSAGE_SOURCES.BACKGROUND,target:t.MESSAGE_SOURCES.CONTENT_SCRIPT,data:{requestHash:r.requestHash}}),t.sessionTimerManager.resetSessionTimer()),e.n=8;break;case 7:return e.p=7,s=e.v,o.w9.error(o.Ey.BACKGROUND,"Error processing proof generation queue item:",s),t.loggerService.logError({error:"Proof generation failed for request hash: ".concat(r.requestHash),type:t.LOG_TYPES.BACKGROUND,sessionId:t.sessionId||"unknown",providerId:t.httpProviderId||"unknown",appId:t.appId||"unknown"}),t.failSession("Proof generation failed: "+s.message,r.requestHash),e.a(2);case 8:return e.p=8,t.isProcessingQueue=!1,t.proofGenerationQueue.length>0?pe(t):t.generatedProofs.size===t.providerData.requestData.length?(t.sessionTimerManager.clearAllTimers(),setTimeout(function(){return t.submitProofs()},0)):t.sessionTimerManager.resumeSessionTimer(),e.f(8);case 9:return e.a(2)}},e,null,[[4,7,8,9]])}),ye=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function s(e){he(i,n,o,s,a,"next",e)}function a(e){he(i,n,o,s,a,"throw",e)}s(void 0)})},ye.apply(this,arguments)}var ge=r(887);function me(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packag