@enbox/browser 0.3.32 → 0.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,10 @@
15
15
  ---
16
16
 
17
17
  - [Enbox Browser](#enbox-browser)
18
+ - [Install](#install)
19
+ - [Usage](#usage)
20
+ - [Bundlers and Service Workers](#bundlers-and-service-workers)
21
+ - [Storage Model](#storage-model)
18
22
  - [Activate Polyfills](#activate-polyfills)
19
23
  - [Project Resources](#project-resources)
20
24
 
@@ -24,6 +28,48 @@
24
28
 
25
29
  This package contains browser-specific helpers for building DWAs (Decentralized Web Apps) with the Enbox toolkit.
26
30
 
31
+ ## Install
32
+
33
+ ```bash
34
+ bun add @enbox/browser
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ Use the bare package entrypoint in browser apps. It re-exports the high-level
40
+ API from `@enbox/api`, auth/session helpers from `@enbox/auth`, and
41
+ browser-specific connect utilities.
42
+
43
+ ```ts
44
+ import { BrowserConnectHandler, Enbox, defineProtocol } from '@enbox/browser';
45
+
46
+ const { enbox } = await Enbox.connect({
47
+ connectHandler : BrowserConnectHandler({ appName: 'Notes' }),
48
+ createIdentity : true,
49
+ protocols : [NotesProtocol],
50
+ });
51
+ ```
52
+
53
+ ## Bundlers and Service Workers
54
+
55
+ `@enbox/browser` declares a browser-conditioned root export that resolves to the
56
+ prebuilt `dist/browser.mjs` bundle. Browser-aware bundlers, including secondary
57
+ Vite passes used for service workers, can import `@enbox/browser` without
58
+ adding Node global shims for `process`, `process.env`, `process.browser`,
59
+ `process.emitWarning`, `global`, or the Node `events` builtin.
60
+
61
+ `activatePolyfills()` is unrelated to Node-global shims. It installs browser
62
+ DWeb/DRL behavior such as service-worker handling for `dweb` URLs; it is not a
63
+ compatibility shim for the SDK package graph.
64
+
65
+ ## Storage Model
66
+
67
+ The default browser agent storage remains Level-backed. The `level` package
68
+ resolves to `browser-level`, which stores data in IndexedDB so tabs, workers,
69
+ and service workers on the same origin can safely write concurrently. SQLite
70
+ over OPFS is not a drop-in browser replacement for this usage because it does
71
+ not provide the same cross-context write behavior.
72
+
27
73
  ### Activate Polyfills
28
74
 
29
75
  This enables a service worker that can handle Enbox features in the browser such as resolving DRLs that look like: `http://dweb/did:dht:abc123/protocols/read/aHR0cHM6Ly9hcmV3ZXdlYjV5ZXQuY29tL3NjaGVtYXMvcHJvdG9jb2xz/avatar`
@@ -0,0 +1,308 @@
1
+ import{Enbox as Be,defineProtocol as Fe,repository as ze}from"@enbox/api";import{AuthManager as je,AuthSession as Ge,normalizeProtocolRequests as Ye,WalletConnect as Ve}from"@enbox/auth/browser";import{DidDht as ae,DidWeb as se,UniversalResolver as V}from"@enbox/dids";function D(e){let t=e.indexOf("://dweb/");if(t===-1)return null;let n=e.slice(0,t);if(n!=="http"&&n!=="https")return null;let o=e.slice(t+8);if(o.length===0)return null;let r=o.indexOf("/");return r===-1?[o,""]:r===0?null:[o.slice(0,r),o.slice(r+1)]}var _=new V({didResolvers:[ae,se]}),J=/^http:/,O=/\/$/,Z="drl";async function Q(e){let{didDocument:t}=await _.resolve(e),n=t?.service?.find(o=>o.type==="DecentralizedWebNode")?.serviceEndpoint;return n?(Array.isArray(n)?n:[n]).filter(o=>typeof o=="string"&&o.startsWith("http")):[]}async function X(){if(!(typeof caches>"u"))return caches.open(Z)}async function le(e,t,n,o){let r=e.request.url.replace(J,"https:").replace(O,""),i=await X(),s=await i?.match(r);if(s){if(!navigator.onLine)return s;let a=await o?.onCacheCheck?.(e,r);if(a){let c=s.headers.get("dwn-cache-time");if(c&&Date.now()<Number(c)+(Number(a.ttl)||0))return s}}try{if(n)return await ce(e,t,r,n,i,o);{let a=await _.resolve(t);return new Response(JSON.stringify(a),{status:200,headers:{"Content-Type":"application/json"}})}}catch(a){return a instanceof Response?a:(console.log(`Error in DID URL fetch: ${a}`),new Response("DID URL fetch error",{status:500}))}}async function ce(e,t,n,o,r,i){let s=await Q(t);if(!s?.length)throw new Response("DWeb Node resolution failed: no valid endpoints found.",{status:530});let a;for(let c of s)try{let l=`${c.replace(O,"")}/${t}/${o}`,m=await fetch(l,{headers:e.request.headers});if(m.ok)return await i?.onCacheCheck?.(e,n)&&r&&de(n,l,m,r),m;console.log(`DWN endpoint error: ${m.status}`),a=new Response("DWeb Node request failed",{status:m.status})}catch(l){console.log(`DWN endpoint error: ${l}`),a=new Response("DWeb Node request failed",{status:500})}return a}async function de(e,t,n,o){try{let r=n.clone(),i=new Headers(r.headers);i.append("dwn-cache-time",Date.now().toString()),i.append("dwn-composed-url",t);let s=new Response(r.body,{headers:i});await o.put(e,s)}catch(r){console.log(`Failed to cache DRL response: ${r}`)}}async function pe(e={}){try{if(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope){let t=self;t.skipWaiting(),t.addEventListener("activate",n=>{n.waitUntil(t.clients.claim())}),t.addEventListener("fetch",n=>{let o=D(n.request.url);o&&n.respondWith(le(n,o[0],o[1],e))})}else if(globalThis?.navigator?.serviceWorker){if(!await navigator.serviceWorker.getRegistration("/")){let n=e.path||document?.currentScript?.src||import.meta.url;n&&navigator.serviceWorker.register(n,{type:"module"}).catch(o=>{console.error("DWeb networking feature installation failed: ",o)})}}else throw new Error("DWeb networking features are not available for install in this environment")}catch(t){console.error("Error in installing networking features:",t)}}var ee=`
2
+ .drl-loading-overlay {
3
+ position: fixed;
4
+ inset: 0;
5
+ display: flex;
6
+ flex-wrap: wrap;
7
+ flex-direction: column;
8
+ align-items: center;
9
+ justify-content: center;
10
+ font-size: 22px;
11
+ color: #fff;
12
+ background: rgba(0, 0, 0, 0.75);
13
+ backdrop-filter: blur(15px);
14
+ -webkit-backdrop-filter: blur(15px);
15
+ z-index: 1000000;
16
+ }
17
+
18
+ .drl-loading-overlay > div {
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ }
23
+
24
+ .drl-loading-spinner {
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+ }
29
+
30
+ .drl-loading-spinner div {
31
+ position: relative;
32
+ width: 2em;
33
+ height: 2em;
34
+ margin: 0.1em 0.25em 0 0;
35
+ }
36
+ .drl-loading-spinner div::after,
37
+ .drl-loading-spinner div::before {
38
+ content: '';
39
+ box-sizing: border-box;
40
+ width: 100%;
41
+ height: 100%;
42
+ border-radius: 50%;
43
+ border: 0.1em solid #FFF;
44
+ position: absolute;
45
+ left: 0;
46
+ top: 0;
47
+ opacity: 0;
48
+ animation: drl-loading-spinner 2s linear infinite;
49
+ }
50
+ .drl-loading-spinner div::after {
51
+ animation-delay: 1s;
52
+ }
53
+
54
+ .drl-loading-overlay span {
55
+ --text-opacity: 2;
56
+ display: flex;
57
+ align-items: center;
58
+ margin: 2em auto 0;
59
+ padding: 0.2em 0.75em 0.25em;
60
+ text-align: center;
61
+ border-radius: 5em;
62
+ background: rgba(255 255 255 / 8%);
63
+ opacity: 0.8;
64
+ transition: opacity 0.3s ease;
65
+ cursor: pointer;
66
+ }
67
+
68
+ .drl-loading-overlay span:focus {
69
+ opacity: 1;
70
+ }
71
+
72
+ .drl-loading-overlay span:hover {
73
+ opacity: 1;
74
+ }
75
+
76
+ .drl-loading-overlay span::before {
77
+ content: '\u2715 ';
78
+ margin: 0 0.4em 0 0;
79
+ color: red;
80
+ font-size: 65%;
81
+ font-weight: bold;
82
+ }
83
+
84
+ .drl-loading-overlay span::after {
85
+ content: 'stop';
86
+ display: block;
87
+ font-size: 60%;
88
+ line-height: 0;
89
+ color: rgba(255 255 255 / 60%);
90
+ }
91
+
92
+ .drl-loading-overlay.new-tab-overlay span::after {
93
+ content: 'close';
94
+ }
95
+
96
+ @keyframes drl-loading-spinner {
97
+ 0% {
98
+ transform: scale(0);
99
+ opacity: 1;
100
+ }
101
+ 100% {
102
+ transform: scale(1);
103
+ opacity: 0;
104
+ }
105
+ }
106
+ `,ue=`
107
+ <!DOCTYPE html>
108
+ <html lang='en'>
109
+ <head>
110
+ <meta charset='UTF-8'>
111
+ <meta name='viewport' content='width=device-width, initial-scale=1.0'>
112
+ <title>Loading DRL...</title>
113
+ <style>
114
+ html, body {
115
+ background-color: #151518;
116
+ height: 100%;
117
+ margin: 0;
118
+ padding: 0;
119
+ font-family: Arial, sans-serif;
120
+ text-align: center;
121
+ }
122
+ ${ee}
123
+ </style>
124
+ </head>
125
+ <body>
126
+ <div class='drl-loading-overlay new-tab-overlay'>
127
+ <div class='drl-loading-spinner'>
128
+ <div></div>
129
+ Loading DRL
130
+ </div>
131
+ <span onclick='window.close()' tabindex='0'></span>
132
+ </div>
133
+ </body>
134
+ </html>
135
+ `,T=!1,v=null,L=null;function Y(){T||(L=document.createElement("style"),L.innerHTML=`
136
+ ${ee}
137
+
138
+ .drl-loading-overlay {
139
+ opacity: 0;
140
+ transition: opacity 0.3s ease;
141
+ pointer-events: none;
142
+ }
143
+
144
+ :root[drl-link-loading] .drl-loading-overlay {
145
+ opacity: 1;
146
+ pointer-events: all;
147
+ }
148
+ `,document.head.append(L),v=document.createElement("div"),v.classList.add("drl-loading-overlay"),v.innerHTML=`
149
+ <div class='drl-loading-spinner'>
150
+ <div></div>
151
+ Loading DRL
152
+ </div>
153
+ <span tabindex='0'></span>
154
+ `,v.lastElementChild.addEventListener("click",I),document.body.prepend(v),T=!0)}function me(){T&&(L?.remove(),L=null,v?.remove(),v=null,T=!1)}function I(){document.documentElement.removeAttribute("drl-link-loading"),K=null}var K=null,N=!1,W=null,A=null;function fe(){N||(W=async e=>{let t=e.target?.closest("a");if(t){let n=t.href,o=D(n);if(o){let r=o[0],i=o[1],s=t.target==="_blank";e.preventDefault();try{let a=null;s?(a=window.open("","_blank"),a&&a.document.write(ue)):(K=i,setTimeout(()=>document.documentElement.setAttribute("drl-link-loading",""),50));let c=await Q(r);if(!c.length)throw new Error("no valid DWN endpoints found");let l=`${c[0].replace(O,"")}/${r}/${i}`;s?a&&!a.closed&&(a.location.href=l):K===i&&(window.location.href=l)}catch{throw K===i&&I(),new Error(`DID endpoint resolution failed for the DRL: ${n}`)}}}},A=async e=>{let t=e.composedPath()[0];if(e.pointerType==="mouse"&&e.button===2||e.pointerType==="touch"&&e.isPrimary){if(C(),t?.src&&D(t.src)){x=t,t.__src__=t.src;let n=t.src.replace(J,"https:").replace(O,""),r=await(await X())?.match(n);if(r){let i=r.headers.get("dwn-composed-url");i&&(t.src=i)}t.addEventListener("pointerup",C,{once:!0})}}else t===x&&C()},document.addEventListener("click",W),document.addEventListener("pointercancel",C),document.addEventListener("pointerdown",A),N=!0)}function ge(){N&&(W&&(document.removeEventListener("click",W),W=null),A&&(document.removeEventListener("pointerdown",A),A=null),document.removeEventListener("pointercancel",C),C(),I(),N=!1)}var x=null;async function C(e){e?.type==="pointerup"&&await new Promise(t=>requestAnimationFrame(()=>t())),x&&(x.src=x.__src__,delete x.__src__,x=null)}function Le(e={}){e.didResolvers&&(_=new V({didResolvers:e.didResolvers})),e.serviceWorker!==!1&&pe(e),typeof window<"u"&&typeof window.document<"u"&&(e.injectStyles!==!1&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Y,{once:!0}):Y()),e.links!==!1&&fe())}function We(){typeof window<"u"&&typeof window.document<"u"&&(ge(),me())}async function Ae(){return typeof caches>"u"?!1:caches.delete(Z)}var te={name:"ECDH",namedCurve:"P-256"},ye={name:"AES-GCM",length:256},he=new TextEncoder().encode("dweb-connect-v1");async function z(){let e=await crypto.subtle.generateKey(te,!1,["deriveBits"]),t=await crypto.subtle.exportKey("raw",e.publicKey);return{keyPair:e,publicKeyBase64url:B(new Uint8Array(t))}}async function ne(e,t){let n=F(t),o=await crypto.subtle.importKey("raw",n,te,!1,[]),r=await crypto.subtle.deriveBits({name:"ECDH",public:o},e,256),i=await crypto.subtle.importKey("raw",r,"HKDF",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:he},i,ye,!1,["encrypt","decrypt"])}async function we(e,t,n,o){let r=await ne(t.privateKey,o),i=crypto.getRandomValues(new Uint8Array(12)),s=new TextEncoder().encode(JSON.stringify(e)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},r,s);return{ciphertext:B(new Uint8Array(a)),iv:B(i),walletPublicKey:n}}async function oe(e,t){let n=await ne(t.privateKey,e.walletPublicKey),o=F(e.iv),r=F(e.ciphertext),i=await crypto.subtle.decrypt({name:"AES-GCM",iv:o},n,r);return JSON.parse(new TextDecoder().decode(i))}function B(e){let t="";for(let o=0;o<e.length;o++)t+=String.fromCharCode(e[o]);let n=btoa(t).replace(/\+/g,"-").replace(/\//g,"_");for(;n.endsWith("=");)n=n.slice(0,-1);return n}function F(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=atob(t),o=new Uint8Array(n.length);for(let r=0;r<n.length;r++)o[r]=n.charCodeAt(r);return o}function be(){let e=Intl.DateTimeFormat().resolvedOptions(),t=Array.isArray(globalThis.navigator.languages)?globalThis.navigator.languages.filter(n=>typeof n=="string"&&n.length>0):void 0;return{origin:globalThis.location.origin,userAgent:globalThis.navigator.userAgent,platform:globalThis.navigator.platform,language:globalThis.navigator.language,...t&&t.length>0?{languages:t}:{},...e.timeZone?{timezone:e.timeZone}:{}}}async function ve(e){let{walletUrl:t,did:n,permissionRequests:o,timeout:r=3e5,appName:i,appIcon:s,portableIdentity:a}=e;if(typeof window>"u")throw new Error("[@enbox/browser] DWeb Connect is only available in browser environments.");let c=new URL("/dweb-connect",t).toString(),l=window.open(c,"enbox-dweb-connect","width=500,height=700,menubar=no,toolbar=no,location=no,status=no");if(!l)throw new Error("[@enbox/browser] Popup blocked. Allow popups for this site to connect to a wallet.");let m,h;try{let p=await z();m=p.keyPair,h=p.publicKeyBase64url}catch{throw l.close(),new Error("[@enbox/browser] DWeb Connect requires a secure context (HTTPS) for encrypted key exchange. crypto.subtle is not available in this environment.")}return new Promise((p,P)=>{let g=!1,E=()=>{g=!0,clearTimeout(M),window.removeEventListener("message",b)},M=setTimeout(()=>{if(!g){E();try{l.close()}catch{}P(new Error("[@enbox/browser] DWeb Connect timed out waiting for wallet response."))}},r),k=setInterval(()=>{l.closed&&!g&&(clearInterval(k),E(),p(void 0))},500),b=d=>{let y=new URL(t).origin;if(d.origin!==y)return;let{type:R}=d.data??{};if(R==="dweb-connect-loaded"){l.postMessage({type:"dweb-connect-authorization-request",did:n,permissions:o,ephemeralPublicKey:h,appName:i,appIcon:s,clientMetadata:be(),portableIdentity:a},y);return}if(R==="dweb-connect-authorization-response"){if(clearInterval(k),E(),d.data.error){p(void 0);return}let u=d.data.encryptedPayload;if(!u){p(void 0);return}oe(u,m).then(w=>{let f=w;if(!f.delegateDid||!f.grants){p(void 0);return}p({delegatePortableDid:f.delegateDid,delegateGrants:f.grants,connectedDid:f.connectedDid??n??f.delegateDid.uri,sessionRevocations:f.sessionRevocations??void 0})}).catch(()=>{p(void 0)})}};window.addEventListener("message",b)})}async function xe(e,t,n=5e3){return typeof window>"u"?!1:new Promise(o=>{let r=document.createElement("iframe");r.style.display="none",r.src=e;let i=!1,s=()=>{i=!0,window.removeEventListener("message",c);try{document.body.removeChild(r)}catch{}},a=setTimeout(()=>{i||(s(),o(!1))},n),c=l=>{let m=new URL(e).origin;if(l.origin!==m)return;let{type:h,supported:p}=l.data??{};h==="dweb-connect-support-response"&&(clearTimeout(a),s(),o(!!p))};window.addEventListener("message",c),r.addEventListener("load",()=>{let l=new URL(e).origin;r.contentWindow?.postMessage({type:"dweb-connect-support-request",did:t},l)}),document.body.appendChild(r)})}var q={initClient:ve,probeWalletSupport:xe};function G(e){if(typeof window>"u"||typeof document>"u")throw new Error("[@enbox/browser] Wallet selector is only available in browser environments.");return new Promise((t,n)=>{let o=document.createElement("div");o.id="enbox-wallet-selector";let r=o.attachShadow({mode:"open"}),i=()=>{try{document.body.removeChild(o)}catch{}},s=window.matchMedia?.("(prefers-color-scheme: dark)").matches,a=document.createElement("style");a.textContent=Ce(s),r.appendChild(a);let c=document.createElement("div");c.className="overlay";let l=document.createElement("div");l.className="modal";let m=document.createElement("div");m.className="header";let h=document.createElement("h2");h.textContent="Connect Wallet";let p=document.createElement("button");p.className="close-btn",p.innerHTML="&times;",p.addEventListener("click",()=>{i(),n(new Error("[@enbox/browser] Wallet selection cancelled."))}),m.appendChild(h),m.appendChild(p),l.appendChild(m);let P=document.createElement("div");P.className="wallet-list";for(let u of e){let w=document.createElement("button");w.className="wallet-item";let f=document.createElement("img");f.src=u.icon??Ee(u.url),f.alt=u.name,f.width=32,f.height=32,f.onerror=()=>{f.style.display="none"};let S=document.createElement("div");S.className="wallet-text";let U=document.createElement("span");if(U.className="wallet-name",U.textContent=u.name,S.appendChild(U),u.description){let H=document.createElement("span");H.className="wallet-description",H.textContent=u.description,S.appendChild(H)}let $=document.createElement("span");$.className="arrow",$.textContent="\u203A",w.appendChild(f),w.appendChild(S),w.appendChild($),w.addEventListener("click",()=>{i(),t(u.url)}),P.appendChild(w)}l.appendChild(P);let g=document.createElement("div");g.className="separator";let E=document.createElement("div");E.className="sep-line";let M=document.createElement("span");M.textContent="or";let k=document.createElement("div");k.className="sep-line",g.appendChild(E),g.appendChild(M),g.appendChild(k),l.appendChild(g);let b=document.createElement("div");b.className="input-group";let d=document.createElement("input");d.type="url",d.placeholder="Enter wallet URL...",d.className="url-input";let y=document.createElement("button");y.className="go-btn",y.textContent="Connect",y.disabled=!0,d.addEventListener("input",()=>{y.disabled=!j(d.value)}),d.addEventListener("keydown",u=>{u.key==="Enter"&&j(d.value)&&(i(),t(re(d.value)))}),y.addEventListener("click",()=>{j(d.value)&&(i(),t(re(d.value)))}),b.appendChild(d),b.appendChild(y),l.appendChild(b),c.addEventListener("click",u=>{u.target===c&&(i(),n(new Error("[@enbox/browser] Wallet selection cancelled.")))});let R=u=>{u.key==="Escape"&&(document.removeEventListener("keydown",R),i(),n(new Error("[@enbox/browser] Wallet selection cancelled.")))};document.addEventListener("keydown",R),c.appendChild(l),r.appendChild(c),document.body.appendChild(o),d.focus()})}function Ee(e){return`https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${e}&size=128`}function j(e){try{let t=new URL(e.includes("://")?e:`https://${e}`);return t.protocol==="https:"||t.protocol==="http:"}catch{return!1}}function re(e){return e.includes("://")||(e=`https://${e}`),new URL(e).origin}function Ce(e){let t=e?"#1a1a2e":"#ffffff",n=e?"#e0e0e0":"#1a1a2e",o=e?"#888":"#666",r=e?"#333":"#e0e0e0",i=e?"#16213e":"#f8f9fa",s=e?"#0f3460":"#e9ecef",a=e?"#4a9eff":"#0066cc";return`
155
+ * { box-sizing: border-box; margin: 0; padding: 0; }
156
+
157
+ .overlay {
158
+ position: fixed;
159
+ inset: 0;
160
+ z-index: 2147483647;
161
+ display: flex;
162
+ align-items: center;
163
+ justify-content: center;
164
+ background: rgba(0, 0, 0, 0.5);
165
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
166
+ animation: fadeIn 0.15s ease-out;
167
+ }
168
+
169
+ @keyframes fadeIn {
170
+ from { opacity: 0; }
171
+ to { opacity: 1; }
172
+ }
173
+
174
+ @keyframes slideUp {
175
+ from { transform: translateY(20px); opacity: 0; }
176
+ to { transform: translateY(0); opacity: 1; }
177
+ }
178
+
179
+ .modal {
180
+ background: ${t};
181
+ color: ${n};
182
+ border-radius: 16px;
183
+ width: 380px;
184
+ max-width: 90vw;
185
+ max-height: 80vh;
186
+ overflow-y: auto;
187
+ padding: 24px;
188
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
189
+ animation: slideUp 0.2s ease-out;
190
+ }
191
+
192
+ .header {
193
+ display: flex;
194
+ justify-content: space-between;
195
+ align-items: center;
196
+ margin-bottom: 20px;
197
+ }
198
+
199
+ h2 {
200
+ font-size: 18px;
201
+ font-weight: 600;
202
+ }
203
+
204
+ .close-btn {
205
+ background: none;
206
+ border: none;
207
+ font-size: 24px;
208
+ cursor: pointer;
209
+ color: ${o};
210
+ padding: 4px 8px;
211
+ border-radius: 8px;
212
+ line-height: 1;
213
+ }
214
+ .close-btn:hover { color: ${n}; background: ${i}; }
215
+
216
+ .wallet-list {
217
+ display: flex;
218
+ flex-direction: column;
219
+ gap: 8px;
220
+ }
221
+
222
+ .wallet-item {
223
+ display: flex;
224
+ align-items: center;
225
+ gap: 12px;
226
+ padding: 12px 16px;
227
+ background: ${i};
228
+ border: 1px solid ${r};
229
+ border-radius: 12px;
230
+ cursor: pointer;
231
+ font-size: 15px;
232
+ color: ${n};
233
+ transition: background 0.15s;
234
+ width: 100%;
235
+ text-align: left;
236
+ }
237
+ .wallet-item:hover { background: ${s}; }
238
+
239
+ .wallet-text {
240
+ flex: 1;
241
+ display: flex;
242
+ flex-direction: column;
243
+ gap: 2px;
244
+ min-width: 0;
245
+ }
246
+
247
+ .wallet-name { font-weight: 500; }
248
+
249
+ .wallet-description {
250
+ font-size: 12px;
251
+ color: ${o};
252
+ white-space: nowrap;
253
+ overflow: hidden;
254
+ text-overflow: ellipsis;
255
+ }
256
+
257
+ .arrow {
258
+ font-size: 20px;
259
+ color: ${o};
260
+ flex-shrink: 0;
261
+ }
262
+
263
+ .separator {
264
+ display: flex;
265
+ align-items: center;
266
+ gap: 12px;
267
+ margin: 20px 0;
268
+ color: ${o};
269
+ font-size: 13px;
270
+ }
271
+ .sep-line { flex: 1; height: 1px; background: ${r}; }
272
+
273
+ .input-group {
274
+ display: flex;
275
+ gap: 8px;
276
+ }
277
+
278
+ .url-input {
279
+ flex: 1;
280
+ padding: 10px 14px;
281
+ border: 1px solid ${r};
282
+ border-radius: 10px;
283
+ font-size: 14px;
284
+ background: ${i};
285
+ color: ${n};
286
+ outline: none;
287
+ }
288
+ .url-input:focus { border-color: ${a}; }
289
+ .url-input::placeholder { color: ${o}; }
290
+
291
+ .go-btn {
292
+ padding: 10px 18px;
293
+ border: none;
294
+ border-radius: 10px;
295
+ background: ${a};
296
+ color: #fff;
297
+ font-size: 14px;
298
+ font-weight: 500;
299
+ cursor: pointer;
300
+ white-space: nowrap;
301
+ }
302
+ .go-btn:disabled {
303
+ opacity: 0.4;
304
+ cursor: not-allowed;
305
+ }
306
+ .go-btn:not(:disabled):hover { filter: brightness(1.1); }
307
+ `}var ie=[{name:"Enbox Wallet",url:"https://enbox-wallet.pages.dev",description:"Your digital identity wallet"},{name:"Blue Enbox Wallet",url:"https://blue-enbox-wallet.pages.dev",description:"Your digital identity wallet"}];function Pe(e={}){let{wallets:t=ie,walletUrl:n,timeout:o,appName:r,appIcon:i}=e;return{async requestAccess(s){let a=n;return a||(a=await G(t)),q.initClient({walletUrl:a,permissionRequests:s.permissionRequests,timeout:o,appName:r,appIcon:i})}}}export{je as AuthManager,Ge as AuthSession,Pe as BrowserConnectHandler,ie as DEFAULT_WALLETS,q as DWebConnect,Be as Enbox,Ve as WalletConnect,Le as activatePolyfills,de as cacheResponse,Ae as clearDrlCache,We as deactivatePolyfills,Fe as defineProtocol,we as encryptPostMessagePayload,ce as fetchResource,z as generateEphemeralKeyPair,Q as getDwnEndpoints,le as handleEvent,Ye as normalizeProtocolRequests,D as parseDrlUrl,ze as repository,G as showWalletSelector};
308
+ //# sourceMappingURL=browser.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/web-features.ts", "../src/drl-url-parser.ts", "../src/dweb-connect-crypto.ts", "../src/dweb-connect-client.ts", "../src/ui/wallet-selector.ts", "../src/browser-connect-handler.ts"],
4
+ "sourcesContent": ["/**\n * @enbox/browser \u2014 The Enbox browser SDK.\n *\n * For browser-based dapps, this is the only package you need to import.\n * It re-exports the high-level API from `@enbox/api`, the authentication\n * layer from `@enbox/auth`, and provides browser-specific connect handlers.\n *\n * @example Single-import dapp setup\n * ```ts\n * import {\n * Enbox, BrowserConnectHandler,\n * defineProtocol, repository,\n * } from '@enbox/browser';\n *\n * const { enbox, session } = await Enbox.connect({\n * connectHandler: BrowserConnectHandler({ appName: 'My App' }),\n * protocols: [MyProtocol],\n * });\n * ```\n *\n * For non-browser environments (Node.js, CLI, desktop), import from\n * `@enbox/api` and `@enbox/auth` directly instead.\n *\n * @packageDocumentation\n */\n\n// \u2500\u2500\u2500 Re-exports from @enbox/api \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// The high-level Enbox API: DWN records, protocols, repositories.\n\nexport {\n Enbox,\n defineProtocol,\n repository,\n} from '@enbox/api';\n\nexport type {\n EnboxAnonymousOptions,\n EnboxConnectOptions,\n EnboxConnectResult,\n EnboxParams,\n EnboxSessionParams,\n} from '@enbox/api';\n\n// \u2500\u2500\u2500 Re-exports from @enbox/auth \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// Authentication lifecycle, session management, connect handlers.\n\nexport {\n AuthManager,\n AuthSession,\n normalizeProtocolRequests,\n WalletConnect,\n} from '@enbox/auth/browser';\n\nexport type {\n AuthEvent,\n AuthEventHandler,\n AuthManagerOptions,\n AuthState,\n ConnectHandler,\n ConnectOptions,\n ConnectResult,\n DisconnectOptions,\n HandlerConnectOptions,\n ImportFromPortableOptions,\n VaultConnectOptions,\n Permission,\n PortableIdentity,\n ProtocolRequest,\n RegistrationOptions,\n StorageAdapter,\n SyncOption,\n WalletConnectOptions,\n} from '@enbox/auth/browser';\n\n// \u2500\u2500\u2500 Browser-specific exports \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// DWeb Connect, wallet selector, DRL polyfills.\n\nexport * from './web-features.js';\nexport { BrowserConnectHandler, DEFAULT_WALLETS } from './browser-connect-handler.js';\nexport type { BrowserConnectHandlerOptions, WalletOption } from './browser-connect-handler.js';\nexport { DWebConnect } from './dweb-connect-client.js';\nexport type { DWebConnectClientOptions } from './dweb-connect-client.js';\nexport { showWalletSelector } from './ui/wallet-selector.js';\nexport { encryptPostMessagePayload, generateEphemeralKeyPair } from './dweb-connect-crypto.js';\nexport type { EncryptedPostMessagePayload } from './dweb-connect-crypto.js';\n", "/*\n This file is run in dual environments to make installation of the Service Worker code easier.\n Be mindful that code placed in any open excution space may be evaluated multiple times in different contexts,\n so take care to gate additions to only activate code in the right env, such as a Service Worker scope or page window.\n*/\n\nimport type { DidMethodResolver } from '@enbox/dids';\n\nimport { DidDht, DidWeb, UniversalResolver } from '@enbox/dids';\n\n/**\n * Result returned by the `onCacheCheck` callback.\n * When returned, it signals that the response for the given DRL should be cached.\n */\nexport type CacheCheckResult = {\n /** Time-to-live for the cached DRL response, in milliseconds. */\n ttl?: number;\n};\n\n/**\n * Callback invoked to determine whether a DRL response should be cached and for how long.\n * Returning a truthy `CacheCheckResult` opts in to caching; returning a falsy value skips it.\n */\nexport type CacheCheckCallback = (\n event: FetchEvent | Event,\n drl: string,\n) => CacheCheckResult | undefined | null | Promise<CacheCheckResult | undefined | null>;\n\n/**\n * Configuration options for {@link activatePolyfills}.\n */\nexport type ActivatePolyfillsOptions = {\n /**\n * Path to the script to register as a Service Worker.\n * Falls back to `document.currentScript.src` or `import.meta.url`.\n *\n * **Required in strict CSP environments** where `new Function()` is blocked and `import.meta`\n * cannot be evaluated dynamically.\n */\n path?: string;\n /** Set to `false` to skip Service Worker installation. Defaults to `true`. */\n serviceWorker?: boolean;\n /** Set to `false` to skip injection of DRL loading-overlay styles. Defaults to `true`. */\n injectStyles?: boolean;\n /** Set to `false` to skip activation of DRL anchor/link click handling. Defaults to `true`. */\n links?: boolean;\n /** Callback to control per-request caching behaviour. */\n onCacheCheck?: CacheCheckCallback;\n /**\n * DID method resolvers to use for DRL resolution. Defaults to `[DidDht, DidWeb]`.\n * Pass a custom array to add or replace DID methods (e.g., `[DidDht, DidWeb, DidJwk]`).\n */\n didResolvers?: DidMethodResolver[];\n};\n\n/**\n * An `HTMLElement` that has a `src` property (e.g., `<img>`, `<video>`, `<audio>`).\n * Extended with `__src__` to stash the original DRL src during context-menu swaps.\n */\ninterface DrlMediaElement extends HTMLElement {\n src: string;\n __src__?: string;\n}\n\nlet didResolver = new UniversalResolver({ didResolvers: [DidDht, DidWeb] });\n\nimport { parseDrlUrl } from './drl-url-parser.js';\nexport { parseDrlUrl } from './drl-url-parser.js';\n\nconst httpToHttpsRegex = /^http:/;\nconst trailingSlashRegex = /\\/$/;\nconst DRL_CACHE_NAME = 'drl';\n\n/** @internal Exported for testing. Resolves DWN service endpoints from a DID. */\nexport async function getDwnEndpoints(did: string): Promise<string[]> {\n const { didDocument } = await didResolver.resolve(did);\n const endpoints = didDocument?.service?.find(\n (service) => service.type === 'DecentralizedWebNode'\n )?.serviceEndpoint;\n if (!endpoints) {return [];}\n return (Array.isArray(endpoints) ? endpoints : [endpoints]).filter(\n (url) => typeof url === 'string' && url.startsWith('http')\n );\n}\n\n/** Returns an open DRL cache, or `undefined` if the Cache API is unavailable. */\nasync function openDrlCache(): Promise<Cache | undefined> {\n if (typeof caches === 'undefined') {return undefined;}\n return caches.open(DRL_CACHE_NAME);\n}\n\n/** @internal Exported for testing. Handles a DRL fetch event. */\nexport async function handleEvent(\n event: FetchEvent, did: string, path: string, options?: ActivatePolyfillsOptions\n): Promise<Response> {\n const drl = event.request.url\n .replace(httpToHttpsRegex, 'https:')\n .replace(trailingSlashRegex, '');\n const responseCache = await openDrlCache();\n const cachedResponse = await responseCache?.match(drl);\n if (cachedResponse) {\n if (!navigator.onLine) {return cachedResponse;}\n const match = await options?.onCacheCheck?.(event, drl);\n if (match) {\n const cacheTime = cachedResponse.headers.get('dwn-cache-time');\n if (\n cacheTime &&\n Date.now() < Number(cacheTime) + (Number(match.ttl) || 0)\n ) {\n return cachedResponse;\n }\n }\n }\n try {\n if (path) {\n return await fetchResource(event, did, drl, path, responseCache, options);\n } else {\n const response = await didResolver.resolve(did);\n return new Response(JSON.stringify(response), {\n status : 200,\n headers : {\n 'Content-Type': 'application/json',\n },\n });\n }\n } catch (error) {\n if (error instanceof Response) {\n return error;\n }\n console.log(`Error in DID URL fetch: ${error}`);\n return new Response('DID URL fetch error', { status: 500 });\n }\n}\n\n/** @internal Exported for testing. Fetches a resource from DWN endpoints. */\nexport async function fetchResource(\n event: FetchEvent, did: string, drl: string, path: string,\n responseCache: Cache | undefined, options?: ActivatePolyfillsOptions\n): Promise<Response> {\n const endpoints = await getDwnEndpoints(did);\n if (!endpoints?.length) {\n throw new Response(\n 'DWeb Node resolution failed: no valid endpoints found.',\n { status: 530 }\n );\n }\n let lastError: Response | undefined;\n for (const endpoint of endpoints) {\n try {\n const url = `${endpoint.replace(trailingSlashRegex, '')}/${did}/${path}`;\n const response = await fetch(url, { headers: event.request.headers });\n if (response.ok) {\n const match = await options?.onCacheCheck?.(event, drl);\n if (match && responseCache) {\n cacheResponse(drl, url, response, responseCache);\n }\n return response;\n }\n console.log(`DWN endpoint error: ${response.status}`);\n lastError = new Response('DWeb Node request failed', {\n status: response.status,\n });\n } catch (error) {\n console.log(`DWN endpoint error: ${error}`);\n lastError = new Response('DWeb Node request failed', {\n status: 500,\n });\n }\n }\n return lastError!;\n}\n\n/** @internal Exported for testing. Caches a DRL response with metadata headers. */\nexport async function cacheResponse(drl: string, url: string, response: Response, cache: Cache): Promise<void> {\n try {\n const clonedResponse = response.clone();\n const headers = new Headers(clonedResponse.headers);\n headers.append('dwn-cache-time', Date.now().toString());\n headers.append('dwn-composed-url', url);\n const modifiedResponse = new Response(clonedResponse.body, { headers });\n await cache.put(drl, modifiedResponse);\n } catch (error) {\n console.log(`Failed to cache DRL response: ${error}`);\n }\n}\n\n/* Service Worker-based features */\n\nasync function installWorker(options: ActivatePolyfillsOptions = {}): Promise<void> {\n try {\n // Check to see if we are in a Service Worker already, if so, proceed\n // You can call the activatePolyfills() function in your own worker, or standalone as a root worker\n if (\n typeof ServiceWorkerGlobalScope !== 'undefined' &&\n self instanceof ServiceWorkerGlobalScope\n ) {\n const workerSelf = self as unknown as ServiceWorkerGlobalScope;\n workerSelf.skipWaiting();\n workerSelf.addEventListener('activate', (event: ExtendableEvent) => {\n // Claim clients to make the service worker take control immediately\n event.waitUntil(workerSelf.clients.claim());\n });\n workerSelf.addEventListener('fetch', (event: FetchEvent) => {\n const parsed = parseDrlUrl(event.request.url);\n if (parsed) {\n event.respondWith(handleEvent(event, parsed[0], parsed[1], options));\n }\n });\n }\n // If the code gets here, it is not a SW env, it is likely DOM, but check to be sure\n else if (globalThis?.navigator?.serviceWorker) {\n const registration = await navigator.serviceWorker.getRegistration('/');\n // You can only have one worker per path, so check to see if one is already registered\n if (!registration) {\n const installUrl: string | undefined =\n options.path ||\n (document?.currentScript as HTMLScriptElement | null)?.src ||\n import.meta.url;\n if (installUrl)\n {navigator.serviceWorker\n .register(installUrl, { type: 'module' })\n .catch((error: unknown) => {\n console.error(\n 'DWeb networking feature installation failed: ',\n error\n );\n });}\n }\n } else {\n throw new Error(\n 'DWeb networking features are not available for install in this environment'\n );\n }\n } catch (error) {\n console.error('Error in installing networking features:', error);\n }\n}\n\n/* DOM Environment Features */\n\nconst loaderStyles = `\n .drl-loading-overlay {\n position: fixed;\n inset: 0;\n display: flex;\n flex-wrap: wrap;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: 22px;\n color: #fff;\n background: rgba(0, 0, 0, 0.75);\n backdrop-filter: blur(15px);\n -webkit-backdrop-filter: blur(15px);\n z-index: 1000000;\n }\n\n .drl-loading-overlay > div {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .drl-loading-spinner {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .drl-loading-spinner div {\n position: relative;\n width: 2em;\n height: 2em;\n margin: 0.1em 0.25em 0 0;\n }\n .drl-loading-spinner div::after,\n .drl-loading-spinner div::before {\n content: ''; \n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n border: 0.1em solid #FFF;\n position: absolute;\n left: 0;\n top: 0;\n opacity: 0;\n animation: drl-loading-spinner 2s linear infinite;\n }\n .drl-loading-spinner div::after {\n animation-delay: 1s;\n }\n\n .drl-loading-overlay span {\n --text-opacity: 2;\n display: flex;\n align-items: center;\n margin: 2em auto 0;\n padding: 0.2em 0.75em 0.25em;\n text-align: center;\n border-radius: 5em;\n background: rgba(255 255 255 / 8%);\n opacity: 0.8;\n transition: opacity 0.3s ease;\n cursor: pointer;\n }\n\n .drl-loading-overlay span:focus {\n opacity: 1;\n }\n\n .drl-loading-overlay span:hover {\n opacity: 1;\n }\n\n .drl-loading-overlay span::before {\n content: '\u2715 ';\n margin: 0 0.4em 0 0;\n color: red;\n font-size: 65%;\n font-weight: bold;\n }\n\n .drl-loading-overlay span::after {\n content: 'stop';\n display: block;\n font-size: 60%;\n line-height: 0;\n color: rgba(255 255 255 / 60%);\n }\n\n .drl-loading-overlay.new-tab-overlay span::after {\n content: 'close';\n }\n \n @keyframes drl-loading-spinner {\n 0% {\n transform: scale(0);\n opacity: 1;\n }\n 100% {\n transform: scale(1);\n opacity: 0;\n }\n }\n`;\nconst tabContent = `\n<!DOCTYPE html>\n<html lang='en'>\n<head>\n <meta charset='UTF-8'>\n <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n <title>Loading DRL...</title>\n <style>\n html, body {\n background-color: #151518;\n height: 100%;\n margin: 0;\n padding: 0;\n font-family: Arial, sans-serif;\n text-align: center;\n }\n ${loaderStyles}\n </style>\n</head>\n<body>\n <div class='drl-loading-overlay new-tab-overlay'>\n <div class='drl-loading-spinner'>\n <div></div>\n Loading DRL\n </div>\n <span onclick='window.close()' tabindex='0'></span>\n </div>\n</body>\n</html>\n`;\n\nlet elementsInjected = false;\nlet overlayElement: HTMLDivElement | null = null;\nlet styleElement: HTMLStyleElement | null = null;\n\nfunction injectElements(): void {\n if (elementsInjected) {return;}\n styleElement = document.createElement('style');\n styleElement.innerHTML = `\n ${loaderStyles}\n\n .drl-loading-overlay {\n opacity: 0;\n transition: opacity 0.3s ease;\n pointer-events: none;\n }\n\n :root[drl-link-loading] .drl-loading-overlay {\n opacity: 1;\n pointer-events: all;\n }\n `;\n document.head.append(styleElement);\n\n overlayElement = document.createElement('div');\n overlayElement.classList.add('drl-loading-overlay');\n overlayElement.innerHTML = `\n <div class='drl-loading-spinner'>\n <div></div>\n Loading DRL\n </div> \n <span tabindex='0'></span>\n `;\n overlayElement.lastElementChild!.addEventListener('click', cancelNavigation);\n document.body.prepend(overlayElement);\n elementsInjected = true;\n}\n\nfunction removeElements(): void {\n if (!elementsInjected) {return;}\n styleElement?.remove();\n styleElement = null;\n overlayElement?.remove();\n overlayElement = null;\n elementsInjected = false;\n}\n\nfunction cancelNavigation(): void {\n document.documentElement.removeAttribute('drl-link-loading');\n activeNavigation = null;\n}\n\nlet activeNavigation: string | null = null;\nlet linkFeaturesActive = false;\n\n// Stored references for listener cleanup in deactivatePolyfills()\nlet clickHandler: ((event: MouseEvent) => Promise<void>) | null = null;\nlet pointerdownHandler: ((event: PointerEvent) => Promise<void>) | null = null;\n\nfunction addLinkFeatures(): void {\n if (!linkFeaturesActive) {\n clickHandler = async (event: MouseEvent): Promise<void> => {\n const anchor = (event.target as Element)?.closest('a');\n if (anchor) {\n const href = anchor.href;\n const parsed = parseDrlUrl(href);\n if (parsed) {\n const did = parsed[0];\n const path = parsed[1];\n const openAsTab = anchor.target === '_blank';\n event.preventDefault();\n try {\n let tab: Window | null = null;\n if (openAsTab) {\n tab = window.open('', '_blank');\n if (tab) {tab.document.write(tabContent);}\n } else {\n activeNavigation = path;\n // this is to allow for cached DIDs to instantly load without any flash of loading UI\n setTimeout(\n () =>\n document.documentElement.setAttribute('drl-link-loading', ''),\n 50\n );\n }\n const endpoints = await getDwnEndpoints(did);\n if (!endpoints.length) {\n throw new Error('no valid DWN endpoints found');\n }\n const url = `${endpoints[0].replace(\n trailingSlashRegex,\n ''\n )}/${did}/${path}`;\n if (openAsTab) {\n if (tab && !tab.closed) {tab.location.href = url;}\n } else if (activeNavigation === path) {\n window.location.href = url;\n }\n } catch {\n if (activeNavigation === path) {\n cancelNavigation();\n }\n throw new Error(\n `DID endpoint resolution failed for the DRL: ${href}`\n );\n }\n }\n }\n };\n\n pointerdownHandler = async (event: PointerEvent): Promise<void> => {\n const target = event.composedPath()[0] as DrlMediaElement | undefined;\n if (\n (event.pointerType === 'mouse' && event.button === 2) ||\n (event.pointerType === 'touch' && event.isPrimary)\n ) {\n resetContextMenuTarget();\n if (target?.src && parseDrlUrl(target.src)) {\n contextMenuTarget = target;\n target.__src__ = target.src;\n const drl = target.src\n .replace(httpToHttpsRegex, 'https:')\n .replace(trailingSlashRegex, '');\n const responseCache = await openDrlCache();\n const response = await responseCache?.match(drl);\n if (response) {\n const url = response.headers.get('dwn-composed-url');\n if (url) {target.src = url;}\n }\n target.addEventListener('pointerup', resetContextMenuTarget, {\n once: true,\n });\n }\n } else if (target === contextMenuTarget) {\n resetContextMenuTarget();\n }\n };\n\n document.addEventListener('click', clickHandler);\n document.addEventListener('pointercancel', resetContextMenuTarget);\n document.addEventListener('pointerdown', pointerdownHandler);\n\n linkFeaturesActive = true;\n }\n}\n\nfunction removeLinkFeatures(): void {\n if (!linkFeaturesActive) {return;}\n if (clickHandler) {\n document.removeEventListener('click', clickHandler);\n clickHandler = null;\n }\n if (pointerdownHandler) {\n document.removeEventListener('pointerdown', pointerdownHandler);\n pointerdownHandler = null;\n }\n document.removeEventListener('pointercancel', resetContextMenuTarget);\n resetContextMenuTarget();\n cancelNavigation();\n linkFeaturesActive = false;\n}\n\nlet contextMenuTarget: DrlMediaElement | null = null;\nasync function resetContextMenuTarget(e?: Event): Promise<void> {\n if (e?.type === 'pointerup') {\n await new Promise<void>((r) => requestAnimationFrame(() => r()));\n }\n if (contextMenuTarget) {\n contextMenuTarget.src = contextMenuTarget.__src__!;\n delete contextMenuTarget.__src__;\n contextMenuTarget = null;\n }\n}\n\n/**\n * Activates various polyfills to enable Enbox features in Web environments.\n *\n * @param options - Configuration options to control the activation of polyfills.\n *\n * @example\n * // Activate all polyfills with default options, and cache every DRL for 1 minute\n * activatePolyfills({\n * onCacheCheck(event, route){\n * return {\n * ttl: 60_000\n * }\n * }\n * });\n *\n * @example\n * // Activate polyfills, but without Service Worker activation\n * activatePolyfills({ serviceWorker: false });\n *\n * @example\n * // Use custom DID resolvers\n * activatePolyfills({ didResolvers: [DidDht, DidWeb, DidJwk] });\n */\nexport function activatePolyfills(options: ActivatePolyfillsOptions = {}): void {\n if (options.didResolvers) {\n didResolver = new UniversalResolver({ didResolvers: options.didResolvers });\n }\n if (options.serviceWorker !== false) {\n installWorker(options);\n }\n if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {\n if (options.injectStyles !== false) {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', injectElements, {\n once: true,\n });\n } else {injectElements();}\n }\n if (options.links !== false) {addLinkFeatures();}\n }\n}\n\n/**\n * Removes all polyfill event listeners, injected DOM elements, and resets internal state.\n * Call this to fully clean up after {@link activatePolyfills}.\n *\n * Does **not** unregister an installed Service Worker \u2014 use\n * `navigator.serviceWorker.getRegistration('/').then(r => r?.unregister())` for that.\n */\nexport function deactivatePolyfills(): void {\n if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {\n removeLinkFeatures();\n removeElements();\n }\n}\n\n/**\n * Deletes the entire DRL response cache.\n * Useful for clearing stale cached DWN responses.\n *\n * @returns `true` if the cache existed and was deleted, `false` otherwise.\n * Returns `false` if the Cache API is unavailable.\n */\nexport async function clearDrlCache(): Promise<boolean> {\n if (typeof caches === 'undefined') {return false;}\n return caches.delete(DRL_CACHE_NAME);\n}\n", "/**\n * Parses a DRL URL (http(s)://dweb/{did}/{path}) without regex quantifiers.\n * Returns `[did, path]` or `null` if the URL does not match the DRL scheme.\n *\n * Extracted to a standalone module so it can be tested under Node.js (bun:test)\n * in addition to the browser-based vitest suite, ensuring SonarCloud's\n * merged coverage report includes these lines.\n */\nexport function parseDrlUrl(url: string): [string, string] | null {\n const idx = url.indexOf('://dweb/');\n if (idx === -1) { return null; }\n const prefix = url.slice(0, idx);\n if (prefix !== 'http' && prefix !== 'https') { return null; }\n const rest = url.slice(idx + 8); // '://dweb/'.length === 8\n if (rest.length === 0) { return null; }\n const slashIdx = rest.indexOf('/');\n if (slashIdx === -1) { return [rest, '']; }\n if (slashIdx === 0) { return null; } // DID segment must be non-empty\n return [rest.slice(0, slashIdx), rest.slice(slashIdx + 1)];\n}\n", "/**\n * ECDH + AES-256-GCM encryption for the DWeb Connect postMessage channel.\n *\n * Protects the authorization response (delegate private keys, decryption\n * keys, grants) from same-origin XSS interception. Both the dapp and\n * wallet generate ephemeral P-256 keypairs, exchange public keys during\n * the handshake, derive a shared AES-256-GCM key via ECDH + HKDF, and\n * encrypt/decrypt the payload.\n *\n * P-256 is used (instead of X25519) because `crypto.subtle.deriveKey`\n * with ECDH requires a NIST curve in all major browsers. The keys are\n * ephemeral \u2014 generated fresh for each connect session.\n *\n * @module\n */\n\n/** Exported public key as raw bytes (base64url-encoded for postMessage). */\nexport type ExportedPublicKey = string;\n\n/** Encrypted payload sent via postMessage. */\nexport interface EncryptedPostMessagePayload {\n /** The encrypted JSON payload as base64url. */\n ciphertext: string;\n /** AES-GCM initialization vector as base64url. */\n iv: string;\n /** The wallet's ephemeral P-256 public key as base64url raw bytes. */\n walletPublicKey: string;\n}\n\nconst ECDH_PARAMS: EcKeyGenParams = { name: 'ECDH', namedCurve: 'P-256' };\nconst AES_KEY_PARAMS: AesDerivedKeyParams = { name: 'AES-GCM', length: 256 };\nconst HKDF_INFO = new TextEncoder().encode('dweb-connect-v1');\n\n/**\n * Generate an ephemeral P-256 ECDH keypair for a single connect session.\n *\n * @returns The keypair and the public key as a base64url-encoded raw export.\n */\nexport async function generateEphemeralKeyPair(): Promise<{\n keyPair: CryptoKeyPair;\n publicKeyBase64url: ExportedPublicKey;\n}> {\n const keyPair = await crypto.subtle.generateKey(ECDH_PARAMS, false, ['deriveBits']);\n const rawPub = await crypto.subtle.exportKey('raw', keyPair.publicKey);\n return { keyPair, publicKeyBase64url: toBase64url(new Uint8Array(rawPub)) };\n}\n\n/**\n * Derive a shared AES-256-GCM key from a local ECDH private key and a\n * remote public key.\n */\nasync function deriveSharedKey(\n localPrivateKey: CryptoKey,\n remotePublicKeyBase64url: string,\n): Promise<CryptoKey> {\n const remotePubRaw = fromBase64url(remotePublicKeyBase64url);\n const remotePublicKey = await crypto.subtle.importKey(\n 'raw', remotePubRaw, ECDH_PARAMS, false, [],\n );\n\n // ECDH \u2192 raw shared secret, then HKDF \u2192 AES-256-GCM key.\n const sharedBits = await crypto.subtle.deriveBits(\n { name: 'ECDH', public: remotePublicKey } as EcdhKeyDeriveParams,\n localPrivateKey,\n 256,\n );\n\n const hkdfKey = await crypto.subtle.importKey(\n 'raw', sharedBits, 'HKDF', false, ['deriveKey'],\n );\n\n return crypto.subtle.deriveKey(\n { name: 'HKDF', hash: 'SHA-256', salt: new Uint8Array(32), info: HKDF_INFO },\n hkdfKey,\n AES_KEY_PARAMS,\n false,\n ['encrypt', 'decrypt'],\n );\n}\n\n/**\n * Encrypt a JSON-serializable payload for postMessage transport.\n *\n * Called by the **wallet** side. Uses the wallet's ephemeral private key\n * and the dapp's ephemeral public key to derive the shared AES key.\n *\n * @returns The encrypted payload plus the wallet's public key (for the dapp to derive the same shared key).\n */\nexport async function encryptPostMessagePayload(\n payload: Record<string, unknown>,\n walletKeyPair: CryptoKeyPair,\n walletPublicKeyBase64url: string,\n dappPublicKeyBase64url: string,\n): Promise<EncryptedPostMessagePayload> {\n const sharedKey = await deriveSharedKey(walletKeyPair.privateKey, dappPublicKeyBase64url);\n const iv = crypto.getRandomValues(new Uint8Array(12));\n const plaintext = new TextEncoder().encode(JSON.stringify(payload));\n\n const ciphertextBuf = await crypto.subtle.encrypt(\n { name: 'AES-GCM', iv } as AesGcmParams,\n sharedKey,\n plaintext,\n );\n\n return {\n ciphertext : toBase64url(new Uint8Array(ciphertextBuf)),\n iv : toBase64url(iv),\n walletPublicKey : walletPublicKeyBase64url,\n };\n}\n\n/**\n * Decrypt a postMessage payload received from the wallet.\n *\n * Called by the **dapp** side. Uses the dapp's ephemeral private key\n * and the wallet's ephemeral public key to derive the same shared key.\n */\nexport async function decryptPostMessagePayload(\n encrypted: EncryptedPostMessagePayload,\n dappKeyPair: CryptoKeyPair,\n): Promise<Record<string, unknown>> {\n const sharedKey = await deriveSharedKey(dappKeyPair.privateKey, encrypted.walletPublicKey);\n const iv = fromBase64url(encrypted.iv);\n const ciphertext = fromBase64url(encrypted.ciphertext);\n\n const plaintextBuf = await crypto.subtle.decrypt(\n { name: 'AES-GCM', iv } as AesGcmParams,\n sharedKey,\n ciphertext,\n );\n\n return JSON.parse(new TextDecoder().decode(plaintextBuf));\n}\n\n// \u2500\u2500 Base64url helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction toBase64url(bytes: Uint8Array): string {\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n let b64 = btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_');\n // Strip trailing padding without a backtracking-vulnerable regex.\n while (b64.endsWith('=')) { b64 = b64.slice(0, -1); }\n return b64;\n}\n\nfunction fromBase64url(str: string): Uint8Array {\n const padded = str.replace(/-/g, '+').replace(/_/g, '/');\n const binary = atob(padded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n", "/**\n * DWeb Connect client \u2014 initiates the popup/postMessage connect flow.\n *\n * This is the dapp-side counterpart to the wallet's `/dweb-connect` page.\n * The wallet is opened as a popup window, and communication happens via\n * `window.postMessage`. No relay server, QR codes, or PINs are needed.\n *\n * @module\n */\n\nimport type { PortableDid } from '@enbox/dids';\nimport type { ConnectClientMetadata, ConnectPermissionRequest, DwnDataEncodedRecordsWriteMessage } from '@enbox/agent';\nimport type { ConnectResult, PortableIdentity } from '@enbox/auth';\n\nimport type { EncryptedPostMessagePayload } from './dweb-connect-crypto.js';\nimport { decryptPostMessagePayload, generateEphemeralKeyPair } from './dweb-connect-crypto.js';\n\n/** Options for initiating a DWeb Connect flow via popup. */\nexport interface DWebConnectClientOptions {\n /** Base URL of the wallet app (e.g. \"https://enbox-wallet.pages.dev\"). */\n walletUrl: string;\n\n /** The DID to pre-select in the wallet's identity picker. */\n did?: string;\n\n /**\n * Protocol permission requests to send to the wallet.\n * Each entry contains a `protocolDefinition` and `permissionScopes`.\n */\n permissionRequests: ConnectPermissionRequest[];\n\n /**\n * Timeout in milliseconds. The popup is closed and an error thrown\n * if the wallet doesn't respond within this time.\n * @default 300_000 (5 minutes)\n */\n timeout?: number;\n\n /**\n * Display name of the requesting application.\n * Shown in the wallet's permission consent screen.\n */\n appName?: string;\n\n /**\n * Icon URL of the requesting application.\n * Shown alongside the app name in the wallet's consent screen.\n */\n appIcon?: string;\n\n /**\n * A portable identity to transfer to the wallet for import.\n *\n * When provided, the wallet imports this identity and creates\n * delegate grants for the dapp, allowing the dapp to transition\n * from local-DID mode to delegate mode while keeping the same DID.\n */\n portableIdentity?: PortableIdentity;\n}\n\nfunction collectBrowserClientMetadata(): ConnectClientMetadata {\n const resolvedOptions = Intl.DateTimeFormat().resolvedOptions();\n const languages = Array.isArray(globalThis.navigator.languages)\n ? globalThis.navigator.languages.filter((language) => typeof language === 'string' && language.length > 0)\n : undefined;\n\n return {\n origin : globalThis.location.origin,\n userAgent : globalThis.navigator.userAgent,\n platform : globalThis.navigator.platform,\n language : globalThis.navigator.language,\n ...(languages && languages.length > 0 ? { languages } : {}),\n ...(resolvedOptions.timeZone ? { timezone: resolvedOptions.timeZone } : {}),\n };\n}\n\n/**\n * Open a wallet popup and run the DWeb Connect postMessage flow.\n *\n * Protocol:\n * 1. Dapp opens `${walletUrl}/dweb-connect` as a popup.\n * 2. Wallet sends `{ type: 'dweb-connect-loaded' }` when ready.\n * 3. Dapp sends `{ type: 'dweb-connect-authorization-request', did, permissions,\n * appName?, appIcon?, portableIdentity? }`.\n * 4. Wallet shows consent UI, then sends back\n * `{ type: 'dweb-connect-authorization-response', delegateDid, grants }`.\n * 5. Popup closes.\n *\n * @returns The delegate credentials, or `undefined` if the user denied.\n * @throws If the popup is blocked, times out, or the wallet returns an error.\n */\nasync function initClient(options: DWebConnectClientOptions): Promise<ConnectResult | undefined> {\n const {\n walletUrl,\n did,\n permissionRequests,\n timeout = 300_000,\n appName,\n appIcon,\n portableIdentity,\n } = options;\n\n if (typeof window === 'undefined') {\n throw new Error(\n '[@enbox/browser] DWeb Connect is only available in browser environments.'\n );\n }\n\n // Open the wallet's DWeb Connect page as a popup.\n const popupUrl = new URL('/dweb-connect', walletUrl).toString();\n const popup = window.open(\n popupUrl,\n 'enbox-dweb-connect',\n 'width=500,height=700,menubar=no,toolbar=no,location=no,status=no',\n );\n\n if (!popup) {\n throw new Error(\n '[@enbox/browser] Popup blocked. Allow popups for this site to connect to a wallet.'\n );\n }\n\n // Generate an ephemeral ECDH keypair for this connect session.\n // The public key is sent to the wallet so it can encrypt the response\n // containing delegate private keys and decryption material.\n // Encryption is mandatory \u2014 if key generation fails (e.g. non-secure\n // context where crypto.subtle is unavailable), the connect flow aborts.\n let dappKeyPair: CryptoKeyPair;\n let dappPublicKeyBase64url: string;\n\n try {\n const ephemeral = await generateEphemeralKeyPair();\n dappKeyPair = ephemeral.keyPair;\n dappPublicKeyBase64url = ephemeral.publicKeyBase64url;\n } catch {\n popup.close();\n throw new Error(\n '[@enbox/browser] DWeb Connect requires a secure context (HTTPS) for encrypted key exchange. '\n + 'crypto.subtle is not available in this environment.'\n );\n }\n\n return new Promise<ConnectResult | undefined>((resolve, reject) => {\n let settled = false;\n\n const cleanup = (): void => {\n settled = true;\n clearTimeout(timeoutId);\n window.removeEventListener('message', onMessage);\n };\n\n // Set up timeout.\n const timeoutId = setTimeout(() => {\n if (!settled) {\n cleanup();\n try { popup.close(); } catch { /* best effort */ }\n reject(new Error(\n '[@enbox/browser] DWeb Connect timed out waiting for wallet response.'\n ));\n }\n }, timeout);\n\n // Monitor popup closed without response (user closed the window).\n const pollClosed = setInterval(() => {\n if (popup.closed && !settled) {\n clearInterval(pollClosed);\n cleanup();\n resolve(undefined);\n }\n }, 500);\n\n const onMessage = (event: MessageEvent): void => {\n // Validate origin matches the wallet URL.\n const walletOrigin = new URL(walletUrl).origin;\n if (event.origin !== walletOrigin) {return;}\n\n const { type } = event.data ?? {};\n\n if (type === 'dweb-connect-loaded') {\n // Wallet is ready \u2014 send the authorization request with\n // ephemeral public key and optional app metadata.\n popup.postMessage({\n type : 'dweb-connect-authorization-request',\n did,\n permissions : permissionRequests,\n ephemeralPublicKey : dappPublicKeyBase64url,\n appName,\n appIcon,\n clientMetadata : collectBrowserClientMetadata(),\n portableIdentity,\n }, walletOrigin);\n return;\n }\n\n if (type === 'dweb-connect-authorization-response') {\n clearInterval(pollClosed);\n cleanup();\n\n // If the wallet sent an explicit error, treat as denied.\n if (event.data.error) {\n resolve(undefined);\n return;\n }\n\n // Require an encrypted response. The dapp always sends an\n // ephemeralPublicKey, so a plaintext response means either the\n // wallet is outdated or something intercepted the flow.\n const encrypted = event.data.encryptedPayload as EncryptedPostMessagePayload | undefined;\n if (!encrypted) {\n resolve(undefined);\n return;\n }\n\n decryptPostMessagePayload(encrypted, dappKeyPair).then((payload: Record<string, unknown>) => {\n const p = payload as any;\n if (!p.delegateDid || !p.grants) {\n resolve(undefined);\n return;\n }\n resolve({\n delegatePortableDid : p.delegateDid as PortableDid,\n delegateGrants : p.grants as DwnDataEncodedRecordsWriteMessage[],\n connectedDid : p.connectedDid ?? did ?? (p.delegateDid as PortableDid).uri,\n sessionRevocations : p.sessionRevocations ?? undefined,\n });\n }).catch(() => {\n // Decryption failed \u2014 treat as denied.\n resolve(undefined);\n });\n }\n };\n\n window.addEventListener('message', onMessage);\n });\n}\n\n/**\n * Probe whether a wallet supports a specific DID via a hidden iframe.\n *\n * Sends a `dweb-connect-support-request` message to the wallet and\n * waits for a `dweb-connect-support-response`. Useful for checking\n * multiple wallet URLs to find the one that manages a given DID.\n *\n * @param walletUrl - Base URL of the wallet to probe.\n * @param did - The DID to check.\n * @param timeout - Probe timeout in ms. Default: 5_000 (5 seconds).\n * @returns `true` if the wallet manages the DID, `false` otherwise.\n */\nasync function probeWalletSupport(\n walletUrl: string,\n did: string,\n timeout = 5_000,\n): Promise<boolean> {\n if (typeof window === 'undefined') {return false;}\n\n return new Promise<boolean>((resolve) => {\n const iframe = document.createElement('iframe');\n iframe.style.display = 'none';\n iframe.src = walletUrl;\n\n let settled = false;\n\n const cleanup = (): void => {\n settled = true;\n window.removeEventListener('message', onMessage);\n try { document.body.removeChild(iframe); } catch { /* best effort */ }\n };\n\n const timeoutId = setTimeout(() => {\n if (!settled) {\n cleanup();\n resolve(false);\n }\n }, timeout);\n\n const onMessage = (event: MessageEvent): void => {\n const walletOrigin = new URL(walletUrl).origin;\n if (event.origin !== walletOrigin) { return; }\n\n const { type, supported } = event.data ?? {};\n if (type === 'dweb-connect-support-response') {\n clearTimeout(timeoutId);\n cleanup();\n resolve(!!supported);\n }\n };\n\n window.addEventListener('message', onMessage);\n\n iframe.addEventListener('load', () => {\n const walletOrigin = new URL(walletUrl).origin;\n iframe.contentWindow?.postMessage({\n type: 'dweb-connect-support-request',\n did,\n }, walletOrigin);\n });\n\n document.body.appendChild(iframe);\n });\n}\n\nexport const DWebConnect = { initClient, probeWalletSupport };\n", "/**\n * Wallet selector modal \u2014 a self-contained, framework-agnostic UI component.\n *\n * Injected into the DOM as a Shadow DOM element to prevent style conflicts.\n * Inspired by WalletConnect's Web3Modal pattern.\n *\n * @module\n */\n\nimport type { WalletOption } from '../browser-connect-handler.js';\n\n/** Shows the wallet selector modal and resolves with the chosen wallet URL. */\nexport function showWalletSelector(wallets: WalletOption[]): Promise<string> {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n throw new Error('[@enbox/browser] Wallet selector is only available in browser environments.');\n }\n\n return new Promise<string>((resolve, reject) => {\n // Create the host element with Shadow DOM isolation.\n const host = document.createElement('div');\n host.id = 'enbox-wallet-selector';\n const shadow = host.attachShadow({ mode: 'open' });\n\n const cleanup = (): void => {\n try { document.body.removeChild(host); } catch { /* best effort */ }\n };\n\n // Detect dark mode.\n const isDark = window.matchMedia?.('(prefers-color-scheme: dark)').matches;\n\n // Build styles.\n const style = document.createElement('style');\n style.textContent = buildStyles(isDark);\n shadow.appendChild(style);\n\n // Build modal DOM.\n const overlay = document.createElement('div');\n overlay.className = 'overlay';\n\n const modal = document.createElement('div');\n modal.className = 'modal';\n\n // Header\n const header = document.createElement('div');\n header.className = 'header';\n\n const title = document.createElement('h2');\n title.textContent = 'Connect Wallet';\n\n const closeBtn = document.createElement('button');\n closeBtn.className = 'close-btn';\n closeBtn.innerHTML = '&times;';\n closeBtn.addEventListener('click', () => {\n cleanup();\n reject(new Error('[@enbox/browser] Wallet selection cancelled.'));\n });\n\n header.appendChild(title);\n header.appendChild(closeBtn);\n modal.appendChild(header);\n\n // Wallet list\n const list = document.createElement('div');\n list.className = 'wallet-list';\n\n for (const wallet of wallets) {\n const item = document.createElement('button');\n item.className = 'wallet-item';\n\n const icon = document.createElement('img');\n icon.src = wallet.icon ?? faviconUrl(wallet.url);\n icon.alt = wallet.name;\n icon.width = 32;\n icon.height = 32;\n icon.onerror = (): void => { icon.style.display = 'none'; };\n\n const textGroup = document.createElement('div');\n textGroup.className = 'wallet-text';\n\n const name = document.createElement('span');\n name.className = 'wallet-name';\n name.textContent = wallet.name;\n\n textGroup.appendChild(name);\n\n if (wallet.description) {\n const desc = document.createElement('span');\n desc.className = 'wallet-description';\n desc.textContent = wallet.description;\n textGroup.appendChild(desc);\n }\n\n const arrow = document.createElement('span');\n arrow.className = 'arrow';\n arrow.textContent = '\\u203A'; // \u203A\n\n item.appendChild(icon);\n item.appendChild(textGroup);\n item.appendChild(arrow);\n\n item.addEventListener('click', () => {\n cleanup();\n resolve(wallet.url);\n });\n\n list.appendChild(item);\n }\n\n modal.appendChild(list);\n\n // Separator\n const sep = document.createElement('div');\n sep.className = 'separator';\n\n const sepLine1 = document.createElement('div');\n sepLine1.className = 'sep-line';\n const sepText = document.createElement('span');\n sepText.textContent = 'or';\n const sepLine2 = document.createElement('div');\n sepLine2.className = 'sep-line';\n\n sep.appendChild(sepLine1);\n sep.appendChild(sepText);\n sep.appendChild(sepLine2);\n modal.appendChild(sep);\n\n // Custom URL input\n const inputGroup = document.createElement('div');\n inputGroup.className = 'input-group';\n\n const input = document.createElement('input');\n input.type = 'url';\n input.placeholder = 'Enter wallet URL...';\n input.className = 'url-input';\n\n const goBtn = document.createElement('button');\n goBtn.className = 'go-btn';\n goBtn.textContent = 'Connect';\n goBtn.disabled = true;\n\n input.addEventListener('input', () => {\n goBtn.disabled = !isValidUrl(input.value);\n });\n\n input.addEventListener('keydown', (e) => {\n if (e.key === 'Enter' && isValidUrl(input.value)) {\n cleanup();\n resolve(normalizeUrl(input.value));\n }\n });\n\n goBtn.addEventListener('click', () => {\n if (isValidUrl(input.value)) {\n cleanup();\n resolve(normalizeUrl(input.value));\n }\n });\n\n inputGroup.appendChild(input);\n inputGroup.appendChild(goBtn);\n modal.appendChild(inputGroup);\n\n // Close on overlay click.\n overlay.addEventListener('click', (e) => {\n if (e.target === overlay) {\n cleanup();\n reject(new Error('[@enbox/browser] Wallet selection cancelled.'));\n }\n });\n\n // Close on Escape.\n const onKeydown = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') {\n document.removeEventListener('keydown', onKeydown);\n cleanup();\n reject(new Error('[@enbox/browser] Wallet selection cancelled.'));\n }\n };\n document.addEventListener('keydown', onKeydown);\n\n overlay.appendChild(modal);\n shadow.appendChild(overlay);\n document.body.appendChild(host);\n\n // Focus the input for keyboard-first users.\n input.focus();\n });\n}\n\n// \u2500\u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction faviconUrl(walletUrl: string): string {\n return `https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${walletUrl}&size=128`;\n}\n\nfunction isValidUrl(value: string): boolean {\n try {\n const url = new URL(value.includes('://') ? value : `https://${value}`);\n return url.protocol === 'https:' || url.protocol === 'http:';\n } catch {\n return false;\n }\n}\n\nfunction normalizeUrl(value: string): string {\n if (!value.includes('://')) {\n value = `https://${value}`;\n }\n const url = new URL(value);\n // Return origin only (strip path/trailing slash).\n return url.origin;\n}\n\nfunction buildStyles(isDark: boolean): string {\n const bg = isDark ? '#1a1a2e' : '#ffffff';\n const text = isDark ? '#e0e0e0' : '#1a1a2e';\n const muted = isDark ? '#888' : '#666';\n const border = isDark ? '#333' : '#e0e0e0';\n const itemBg = isDark ? '#16213e' : '#f8f9fa';\n const itemHover = isDark ? '#0f3460' : '#e9ecef';\n const accent = isDark ? '#4a9eff' : '#0066cc';\n const overlayBg = 'rgba(0, 0, 0, 0.5)';\n\n return `\n * { box-sizing: border-box; margin: 0; padding: 0; }\n\n .overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483647;\n display: flex;\n align-items: center;\n justify-content: center;\n background: ${overlayBg};\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n animation: fadeIn 0.15s ease-out;\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes slideUp {\n from { transform: translateY(20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n }\n\n .modal {\n background: ${bg};\n color: ${text};\n border-radius: 16px;\n width: 380px;\n max-width: 90vw;\n max-height: 80vh;\n overflow-y: auto;\n padding: 24px;\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);\n animation: slideUp 0.2s ease-out;\n }\n\n .header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 20px;\n }\n\n h2 {\n font-size: 18px;\n font-weight: 600;\n }\n\n .close-btn {\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: ${muted};\n padding: 4px 8px;\n border-radius: 8px;\n line-height: 1;\n }\n .close-btn:hover { color: ${text}; background: ${itemBg}; }\n\n .wallet-list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .wallet-item {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px 16px;\n background: ${itemBg};\n border: 1px solid ${border};\n border-radius: 12px;\n cursor: pointer;\n font-size: 15px;\n color: ${text};\n transition: background 0.15s;\n width: 100%;\n text-align: left;\n }\n .wallet-item:hover { background: ${itemHover}; }\n\n .wallet-text {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n }\n\n .wallet-name { font-weight: 500; }\n\n .wallet-description {\n font-size: 12px;\n color: ${muted};\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .arrow {\n font-size: 20px;\n color: ${muted};\n flex-shrink: 0;\n }\n\n .separator {\n display: flex;\n align-items: center;\n gap: 12px;\n margin: 20px 0;\n color: ${muted};\n font-size: 13px;\n }\n .sep-line { flex: 1; height: 1px; background: ${border}; }\n\n .input-group {\n display: flex;\n gap: 8px;\n }\n\n .url-input {\n flex: 1;\n padding: 10px 14px;\n border: 1px solid ${border};\n border-radius: 10px;\n font-size: 14px;\n background: ${itemBg};\n color: ${text};\n outline: none;\n }\n .url-input:focus { border-color: ${accent}; }\n .url-input::placeholder { color: ${muted}; }\n\n .go-btn {\n padding: 10px 18px;\n border: none;\n border-radius: 10px;\n background: ${accent};\n color: #fff;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n white-space: nowrap;\n }\n .go-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n }\n .go-btn:not(:disabled):hover { filter: brightness(1.1); }\n `;\n}\n", "/**\n * Browser connect handler for `@enbox/auth`.\n *\n * Implements the {@link ConnectHandler} interface using browser-native\n * DWeb Connect (popup + postMessage) with a wallet selector modal.\n *\n * @module\n */\n\nimport type { ConnectPermissionRequest } from '@enbox/agent';\nimport type { ConnectHandler, ConnectResult } from '@enbox/auth';\n\nimport { DWebConnect } from './dweb-connect-client.js';\nimport { showWalletSelector } from './ui/wallet-selector.js';\n\n/** A wallet entry shown in the wallet selector modal. */\nexport interface WalletOption {\n /** Display name (e.g. \"Enbox Wallet\"). */\n name: string;\n\n /** Base URL of the wallet app (e.g. \"https://enbox-wallet.pages.dev\"). */\n url: string;\n\n /** Optional icon URL. If omitted, the wallet's favicon is used. */\n icon?: string;\n\n /** Short description shown below the wallet name in the selector. */\n description?: string;\n}\n\n/** Default wallets shown in the selector when no overrides are provided. */\nexport const DEFAULT_WALLETS: WalletOption[] = [\n {\n name : 'Enbox Wallet',\n url : 'https://enbox-wallet.pages.dev',\n description : 'Your digital identity wallet',\n },\n {\n name : 'Blue Enbox Wallet',\n url : 'https://blue-enbox-wallet.pages.dev',\n description : 'Your digital identity wallet',\n },\n];\n\n/** Options for creating a BrowserConnectHandler. */\nexport interface BrowserConnectHandlerOptions {\n /**\n * Known wallets shown in the wallet selector modal.\n * If omitted, {@link DEFAULT_WALLETS} is used.\n */\n wallets?: WalletOption[];\n\n /**\n * Explicit wallet URL. If provided, the wallet selector is skipped\n * and this URL is used directly.\n */\n walletUrl?: string;\n\n /**\n * Timeout in milliseconds for the wallet popup flow.\n * @default 300_000 (5 minutes)\n */\n timeout?: number;\n\n /**\n * Display name of the requesting application.\n * Shown in the wallet's permission consent screen.\n */\n appName?: string;\n\n /**\n * Icon URL of the requesting application.\n * Shown alongside the app name in the wallet's consent screen.\n * Defaults to `${window.location.origin}/favicon.ico` if omitted.\n */\n appIcon?: string;\n\n}\n\n/**\n * Create a browser-native connect handler using DWeb Connect\n * (popup + postMessage).\n *\n * This handler:\n * 1. Shows a wallet selector modal (or uses a provided walletUrl).\n * 2. Opens the selected wallet as a popup window.\n * 3. Runs the DWeb Connect postMessage protocol.\n * 4. Returns the delegate credentials on success.\n *\n * @example\n * ```ts\n * import { AuthManager, BrowserConnectHandler } from '@enbox/browser';\n *\n * const auth = await AuthManager.create({\n * connectHandler: BrowserConnectHandler({\n * appName: 'My Dapp',\n * }),\n * });\n *\n * const session = await auth.connect({ protocols: [NotesProtocol] });\n * ```\n */\nexport function BrowserConnectHandler(\n options: BrowserConnectHandlerOptions = {},\n): ConnectHandler {\n const {\n wallets = DEFAULT_WALLETS,\n walletUrl: fixedWalletUrl,\n timeout,\n appName,\n appIcon,\n } = options;\n\n return {\n async requestAccess(params: {\n permissionRequests: ConnectPermissionRequest[];\n }): Promise<ConnectResult | undefined> {\n // 1. Determine wallet URL.\n let walletUrl = fixedWalletUrl;\n if (!walletUrl) {\n walletUrl = await showWalletSelector(wallets);\n }\n\n // 2. Run the DWeb Connect popup flow.\n return DWebConnect.initClient({\n walletUrl,\n permissionRequests: params.permissionRequests,\n timeout,\n appName,\n appIcon,\n });\n },\n };\n}\n"],
5
+ "mappings": "AA8BA,OACE,SAAAA,GACA,kBAAAC,GACA,cAAAC,OACK,aAcP,OACE,eAAAC,GACA,eAAAC,GACA,6BAAAC,GACA,iBAAAC,OACK,sBC7CP,OAAS,UAAAC,GAAQ,UAAAC,GAAQ,qBAAAC,MAAyB,cCA3C,SAASC,EAAYC,EAAsC,CAChE,IAAMC,EA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAQLA,CAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eASLA,CAAK;AAAA;AAAA;AAAA,oDAGgCC,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAUhCA,CAAM;AAAA;AAAA;AAAA,oBAGZC,CAAM;AAAA,eACXH,CAAI;AAAA;AAAA;AAAA,uCAGoBK,CAAM;AAAA,uCACNJ,CAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAMxBI,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAa1B,CC1VO,IAAMC,GAAkC,CAC7C,CACE,KAAc,eACd,IAAc,iCACd,YAAc,8BAChB,EACA,CACE,KAAc,oBACd,IAAc,sCACd,YAAc,8BAChB,CACF,EA4DO,SAASC,GACdC,EAAwC,CAAC,EACzB,CAChB,GAAM,CACJ,QAAAC,EAAUH,GACV,UAAWI,EACX,QAAAC,EACA,QAAAC,EACA,QAAAC,CACF,EAAIL,EAEJ,MAAO,CACL,MAAM,cAAcM,EAEmB,CAErC,IAAIC,EAAYL,EAChB,OAAKK,IACHA,EAAY,MAAMC,EAAmBP,CAAO,GAIvCQ,EAAY,WAAW,CAC5B,UAAAF,EACA,mBAAoBD,EAAO,mBAC3B,QAAAH,EACA,QAAAC,EACA,QAAAC,CACF,CAAC,CACH,CACF,CACF",
6
+ "names": ["Enbox", "defineProtocol", "repository", "AuthManager", "AuthSession", "normalizeProtocolRequests", "WalletConnect", "DidDht", "DidWeb", "UniversalResolver", "parseDrlUrl", "url", "idx", "prefix", "rest", "slashIdx", "didResolver", "UniversalResolver", "DidDht", "DidWeb", "httpToHttpsRegex", "trailingSlashRegex", "DRL_CACHE_NAME", "getDwnEndpoints", "did", "didDocument", "endpoints", "service", "url", "openDrlCache", "handleEvent", "event", "path", "options", "drl", "responseCache", "cachedResponse", "match", "cacheTime", "fetchResource", "response", "error", "lastError", "endpoint", "cacheResponse", "cache", "clonedResponse", "headers", "modifiedResponse", "installWorker", "workerSelf", "parsed", "parseDrlUrl", "installUrl", "loaderStyles", "tabContent", "elementsInjected", "overlayElement", "styleElement", "injectElements", "cancelNavigation", "removeElements", "activeNavigation", "linkFeaturesActive", "clickHandler", "pointerdownHandler", "addLinkFeatures", "anchor", "href", "openAsTab", "tab", "target", "resetContextMenuTarget", "contextMenuTarget", "removeLinkFeatures", "r", "activatePolyfills", "deactivatePolyfills", "clearDrlCache", "ECDH_PARAMS", "AES_KEY_PARAMS", "HKDF_INFO", "generateEphemeralKeyPair", "keyPair", "rawPub", "toBase64url", "deriveSharedKey", "localPrivateKey", "remotePublicKeyBase64url", "remotePubRaw", "fromBase64url", "remotePublicKey", "sharedBits", "hkdfKey", "encryptPostMessagePayload", "payload", "walletKeyPair", "walletPublicKeyBase64url", "dappPublicKeyBase64url", "sharedKey", "iv", "plaintext", "ciphertextBuf", "decryptPostMessagePayload", "encrypted", "dappKeyPair", "ciphertext", "plaintextBuf", "bytes", "binary", "i", "b64", "str", "padded", "collectBrowserClientMetadata", "resolvedOptions", "languages", "language", "initClient", "options", "walletUrl", "did", "permissionRequests", "timeout", "appName", "appIcon", "portableIdentity", "popupUrl", "popup", "dappKeyPair", "dappPublicKeyBase64url", "ephemeral", "generateEphemeralKeyPair", "resolve", "reject", "settled", "cleanup", "timeoutId", "onMessage", "pollClosed", "event", "walletOrigin", "type", "encrypted", "decryptPostMessagePayload", "payload", "p", "probeWalletSupport", "iframe", "supported", "DWebConnect", "showWalletSelector", "wallets", "resolve", "reject", "host", "shadow", "cleanup", "isDark", "style", "buildStyles", "overlay", "modal", "header", "title", "closeBtn", "list", "wallet", "item", "icon", "faviconUrl", "textGroup", "name", "desc", "arrow", "sep", "sepLine1", "sepText", "sepLine2", "inputGroup", "input", "goBtn", "isValidUrl", "e", "normalizeUrl", "onKeydown", "walletUrl", "value", "url", "bg", "text", "muted", "border", "itemBg", "itemHover", "accent", "DEFAULT_WALLETS", "BrowserConnectHandler", "options", "wallets", "fixedWalletUrl", "timeout", "appName", "appIcon", "params", "walletUrl", "showWalletSelector", "DWebConnect"]
7
+ }
@@ -134,7 +134,7 @@ function initClient(options) {
134
134
  return;
135
135
  }
136
136
  decryptPostMessagePayload(encrypted, dappKeyPair).then((payload) => {
137
- var _a, _b, _c, _d;
137
+ var _a, _b, _c;
138
138
  const p = payload;
139
139
  if (!p.delegateDid || !p.grants) {
140
140
  resolve(undefined);
@@ -144,8 +144,7 @@ function initClient(options) {
144
144
  delegatePortableDid: p.delegateDid,
145
145
  delegateGrants: p.grants,
146
146
  connectedDid: (_b = (_a = p.connectedDid) !== null && _a !== void 0 ? _a : did) !== null && _b !== void 0 ? _b : p.delegateDid.uri,
147
- delegateDecryptionKeys: (_c = p.delegateDecryptionKeys) !== null && _c !== void 0 ? _c : undefined,
148
- sessionRevocations: (_d = p.sessionRevocations) !== null && _d !== void 0 ? _d : undefined,
147
+ sessionRevocations: (_c = p.sessionRevocations) !== null && _c !== void 0 ? _c : undefined,
149
148
  });
150
149
  }).catch(() => {
151
150
  // Decryption failed — treat as denied.
@@ -1 +1 @@
1
- {"version":3,"file":"dweb-connect-client.js","sourceRoot":"","sources":["../../src/dweb-connect-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;;;;;;;;;AAOH,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AA6C/F,SAAS,4BAA4B;IACnC,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC;IAChE,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC;QAC7D,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,QAAQ,KA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,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;gBAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;oBAAC,OAAO;gBAAC,CAAC;gBAE9C,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAA,KAAK,CAAC,IAAI,mCAAI,EAAE,CAAC;gBAC7C,IAAI,IAAI,KAAK,+BAA+B,EAAE,CAAC;oBAC7C,YAAY,CAAC,SAAS,CAAC,CAAC;oBACxB,OAAO,EAAE,CAAC;oBACV,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,CAAC;YAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAE9C,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;;gBACnC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;gBAC/C,MAAA,MAAM,CAAC,aAAa,0CAAE,WAAW,CAAC;oBAChC,IAAI,EAAE,8BAA8B;oBACpC,GAAG;iBACJ,EAAE,YAAY,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;YAEH,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/esm/index.js CHANGED
@@ -30,7 +30,7 @@ export { Enbox, defineProtocol, repository, } from '@enbox/api';
30
30
  // ─── Re-exports from @enbox/auth ────────────────────────────────
31
31
  //
32
32
  // Authentication lifecycle, session management, connect handlers.
33
- export { AuthManager, AuthSession, normalizeProtocolRequests, WalletConnect, } from '@enbox/auth';
33
+ export { AuthManager, AuthSession, normalizeProtocolRequests, WalletConnect, } from '@enbox/auth/browser';
34
34
  // ─── Browser-specific exports ───────────────────────────────────
35
35
  //
36
36
  // DWeb Connect, wallet selector, DRL polyfills.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAElE,OAAO,EACL,KAAK,EACL,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC;AAUpB,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAElE,OAAO,EACL,WAAW,EACX,WAAW,EACX,yBAAyB,EACzB,aAAa,GACd,MAAM,aAAa,CAAC;AAuBrB,mEAAmE;AACnE,EAAE;AACF,gDAAgD;AAEhD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAElE,OAAO,EACL,KAAK,EACL,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC;AAUpB,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAElE,OAAO,EACL,WAAW,EACX,WAAW,EACX,yBAAyB,EACzB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAuB7B,mEAAmE;AACnE,EAAE;AACF,gDAAgD;AAEhD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"dweb-connect-client.d.ts","sourceRoot":"","sources":["../../src/dweb-connect-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAyB,wBAAwB,EAAqC,MAAM,cAAc,CAAC;AACvH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKnE,4DAA4D;AAC5D,MAAM,WAAW,wBAAwB;IACvC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAElB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;IAE/C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAkBD;;;;;;;;;;;;;;GAcG;AACH,iBAAe,UAAU,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAgJ/F;AAED;;;;;;;;;;;GAWG;AACH,iBAAe,kBAAkB,CAC/B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,OAAO,SAAQ,GACd,OAAO,CAAC,OAAO,CAAC,CA+ClB;AAED,eAAO,MAAM,WAAW;;;CAAqC,CAAC"}
1
+ {"version":3,"file":"dweb-connect-client.d.ts","sourceRoot":"","sources":["../../src/dweb-connect-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAyB,wBAAwB,EAAqC,MAAM,cAAc,CAAC;AACvH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKnE,4DAA4D;AAC5D,MAAM,WAAW,wBAAwB;IACvC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAElB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;IAE/C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAkBD;;;;;;;;;;;;;;GAcG;AACH,iBAAe,UAAU,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA+I/F;AAED;;;;;;;;;;;GAWG;AACH,iBAAe,kBAAkB,CAC/B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,OAAO,SAAQ,GACd,OAAO,CAAC,OAAO,CAAC,CA+ClB;AAED,eAAO,MAAM,WAAW;;;CAAqC,CAAC"}
@@ -25,8 +25,8 @@
25
25
  */
26
26
  export { Enbox, defineProtocol, repository, } from '@enbox/api';
27
27
  export type { EnboxAnonymousOptions, EnboxConnectOptions, EnboxConnectResult, EnboxParams, EnboxSessionParams, } from '@enbox/api';
28
- export { AuthManager, AuthSession, normalizeProtocolRequests, WalletConnect, } from '@enbox/auth';
29
- export type { AuthEvent, AuthEventHandler, AuthManagerOptions, AuthState, ConnectHandler, ConnectOptions, ConnectResult, DisconnectOptions, HandlerConnectOptions, ImportFromPortableOptions, VaultConnectOptions, Permission, PortableIdentity, ProtocolRequest, RegistrationOptions, StorageAdapter, SyncOption, WalletConnectOptions, } from '@enbox/auth';
28
+ export { AuthManager, AuthSession, normalizeProtocolRequests, WalletConnect, } from '@enbox/auth/browser';
29
+ export type { AuthEvent, AuthEventHandler, AuthManagerOptions, AuthState, ConnectHandler, ConnectOptions, ConnectResult, DisconnectOptions, HandlerConnectOptions, ImportFromPortableOptions, VaultConnectOptions, Permission, PortableIdentity, ProtocolRequest, RegistrationOptions, StorageAdapter, SyncOption, WalletConnectOptions, } from '@enbox/auth/browser';
30
30
  export * from './web-features.js';
31
31
  export { BrowserConnectHandler, DEFAULT_WALLETS } from './browser-connect-handler.js';
32
32
  export type { BrowserConnectHandlerOptions, WalletOption } from './browser-connect-handler.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH,OAAO,EACL,KAAK,EACL,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAMpB,OAAO,EACL,WAAW,EACX,WAAW,EACX,yBAAyB,EACzB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAMrB,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACtF,YAAY,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,0BA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AE,MAAM,0BAA0B,CAAC;AAC/F,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@enbox/browser",
3
- "version": "0.3.32",
3
+ "version": "0.3.34",
4
4
  "description": "Enbox tools and features to use in the browser",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
7
7
  "module": "./dist/esm/index.js",
8
+ "browser": "./dist/browser.mjs",
9
+ "sideEffects": false,
8
10
  "types": "./dist/types/index.d.ts",
9
11
  "scripts": {
10
12
  "clean": "rm -rf dist",
11
13
  "build:esm": "rm -rf dist/esm dist/types && bun tsc -p tsconfig.json",
12
- "build:browser": "bun run build:esm",
13
- "build": "bun run clean && bun run build:esm",
14
+ "build:browser": "rm -rf dist/browser.mjs && bun ../../build/browser-bundle.js --metafile --external @enbox/agent --external @enbox/api --external @enbox/auth --external @enbox/auth/browser --external @enbox/dids",
15
+ "build": "bun run clean && bun run build:esm && bun run build:browser",
14
16
  "lint": "eslint . --max-warnings 0",
15
17
  "lint:fix": "eslint . --fix",
16
- "test:node": "bun test tests/drl-url-parser.spec.ts",
17
- "test:node:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov --coverage-dir=coverage tests/drl-url-parser.spec.ts",
18
+ "test:node": "bun test tests/drl-url-parser.spec.ts tests/browser-artifacts.spec.ts",
19
+ "test:node:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov --coverage-dir=coverage tests/drl-url-parser.spec.ts tests/browser-artifacts.spec.ts",
18
20
  "test:browser": "bunx --bun vitest --config vitest.browser.config.ts --run",
19
21
  "test:browser:coverage": "bunx --bun vitest --config vitest.browser.config.ts --run --coverage --coverage.provider=istanbul"
20
22
  },
@@ -40,6 +42,13 @@
40
42
  "dist",
41
43
  "src"
42
44
  ],
45
+ "exports": {
46
+ ".": {
47
+ "types": "./dist/types/index.d.ts",
48
+ "browser": "./dist/browser.mjs",
49
+ "import": "./dist/esm/index.js"
50
+ }
51
+ },
43
52
  "keywords": [
44
53
  "decentralized",
45
54
  "decentralized-applications",
@@ -57,10 +66,10 @@
57
66
  "access": "public"
58
67
  },
59
68
  "dependencies": {
60
- "@enbox/agent": "0.8.8",
61
- "@enbox/api": "0.6.46",
62
- "@enbox/auth": "0.6.54",
63
- "@enbox/dids": "0.1.2"
69
+ "@enbox/agent": "0.8.10",
70
+ "@enbox/api": "0.6.48",
71
+ "@enbox/auth": "0.6.56",
72
+ "@enbox/dids": "0.1.3"
64
73
  },
65
74
  "devDependencies": {
66
75
  "@typescript-eslint/eslint-plugin": "8.32.1",
@@ -218,11 +218,10 @@ async function initClient(options: DWebConnectClientOptions): Promise<ConnectRes
218
218
  return;
219
219
  }
220
220
  resolve({
221
- delegatePortableDid : p.delegateDid as PortableDid,
222
- delegateGrants : p.grants as DwnDataEncodedRecordsWriteMessage[],
223
- connectedDid : p.connectedDid ?? did ?? (p.delegateDid as PortableDid).uri,
224
- delegateDecryptionKeys : p.delegateDecryptionKeys ?? undefined,
225
- sessionRevocations : p.sessionRevocations ?? undefined,
221
+ delegatePortableDid : p.delegateDid as PortableDid,
222
+ delegateGrants : p.grants as DwnDataEncodedRecordsWriteMessage[],
223
+ connectedDid : p.connectedDid ?? did ?? (p.delegateDid as PortableDid).uri,
224
+ sessionRevocations : p.sessionRevocations ?? undefined,
226
225
  });
227
226
  }).catch(() => {
228
227
  // Decryption failed — treat as denied.
package/src/index.ts CHANGED
@@ -51,7 +51,7 @@ export {
51
51
  AuthSession,
52
52
  normalizeProtocolRequests,
53
53
  WalletConnect,
54
- } from '@enbox/auth';
54
+ } from '@enbox/auth/browser';
55
55
 
56
56
  export type {
57
57
  AuthEvent,
@@ -72,7 +72,7 @@ export type {
72
72
  StorageAdapter,
73
73
  SyncOption,
74
74
  WalletConnectOptions,
75
- } from '@enbox/auth';
75
+ } from '@enbox/auth/browser';
76
76
 
77
77
  // ─── Browser-specific exports ───────────────────────────────────
78
78
  //