@solarpunkltd/swarm-id 0.9.0 → 0.10.1

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/dist/schemas.d.ts CHANGED
@@ -59,6 +59,34 @@ export declare const ChatBindingSchema: z.ZodObject<{
59
59
  message: z.ZodString;
60
60
  signature: z.ZodString;
61
61
  }, z.core.$strip>;
62
+ /**
63
+ * Longer than any wallet link message can be: five lines, 258 characters,
64
+ * around two addresses and a date. A bound on what is stored and carried, not
65
+ * a check of the format, which `verifyWalletLink` does.
66
+ */
67
+ export declare const WALLET_LINK_MAX_LENGTH = 320;
68
+ /**
69
+ * The account's and its wallet's statement that they belong together
70
+ * (`utils/wallet-link.ts`, docs/Wallet-Link.md). Kept in the account's synced
71
+ * settings while the person has "Show my ENS name on sites" on, and shared
72
+ * with sites in the connection identity.
73
+ */
74
+ export declare const WalletLinkSchema: z.ZodObject<{
75
+ message: z.ZodString;
76
+ walletSignature: z.ZodString;
77
+ accountSignature: z.ZodString;
78
+ }, z.core.$strip>;
79
+ /**
80
+ * The account's synced settings, one shape for the account record, the state
81
+ * snapshot and the device feed, so a setting one of them does not name is
82
+ * never stripped on the way to another device. The whole object is one
83
+ * last-writer-wins field (`settingsAt`). The wallet link is not in it: it
84
+ * has a clock of its own (`walletLinkAt`), so another device's settings edit
85
+ * can never bring back a link that was turned off.
86
+ */
87
+ export declare const AccountSettingsSchema: z.ZodObject<{
88
+ appSessionDuration: z.ZodOptional<z.ZodNumber>;
89
+ }, z.core.$strip>;
62
90
  /** The stamp choice of an app the person set to use no stamp at all */
63
91
  export declare const NO_POSTAGE_STAMP = "none";
64
92
  /**
@@ -236,9 +264,15 @@ export declare const SyncedAccountSchemaV1: z.ZodObject<{
236
264
  settings: z.ZodOptional<z.ZodObject<{
237
265
  appSessionDuration: z.ZodOptional<z.ZodNumber>;
238
266
  }, z.core.$strip>>;
267
+ walletLink: z.ZodOptional<z.ZodObject<{
268
+ message: z.ZodString;
269
+ walletSignature: z.ZodString;
270
+ accountSignature: z.ZodString;
271
+ }, z.core.$strip>>;
239
272
  accountNameAt: z.ZodOptional<z.ZodNumber>;
240
273
  defaultStampAt: z.ZodOptional<z.ZodNumber>;
241
274
  settingsAt: z.ZodOptional<z.ZodNumber>;
275
+ walletLinkAt: z.ZodOptional<z.ZodNumber>;
242
276
  lastModified: z.ZodOptional<z.ZodNumber>;
243
277
  partitionCount: z.ZodOptional<z.ZodNumber>;
244
278
  }, z.core.$strip>;
@@ -303,9 +337,15 @@ declare const SignedInAccountSchemaV1: z.ZodObject<{
303
337
  settings: z.ZodOptional<z.ZodObject<{
304
338
  appSessionDuration: z.ZodOptional<z.ZodNumber>;
305
339
  }, z.core.$strip>>;
340
+ walletLink: z.ZodOptional<z.ZodObject<{
341
+ message: z.ZodString;
342
+ walletSignature: z.ZodString;
343
+ accountSignature: z.ZodString;
344
+ }, z.core.$strip>>;
306
345
  accountNameAt: z.ZodOptional<z.ZodNumber>;
307
346
  defaultStampAt: z.ZodOptional<z.ZodNumber>;
308
347
  settingsAt: z.ZodOptional<z.ZodNumber>;
348
+ walletLinkAt: z.ZodOptional<z.ZodNumber>;
309
349
  lastModified: z.ZodOptional<z.ZodNumber>;
310
350
  partitionCount: z.ZodOptional<z.ZodNumber>;
311
351
  signedOutAt: z.ZodOptional<z.ZodUndefined>;
@@ -428,9 +468,15 @@ export declare const LocalAccountSchemaV1: z.ZodUnion<readonly [z.ZodObject<{
428
468
  settings: z.ZodOptional<z.ZodObject<{
429
469
  appSessionDuration: z.ZodOptional<z.ZodNumber>;
430
470
  }, z.core.$strip>>;
471
+ walletLink: z.ZodOptional<z.ZodObject<{
472
+ message: z.ZodString;
473
+ walletSignature: z.ZodString;
474
+ accountSignature: z.ZodString;
475
+ }, z.core.$strip>>;
431
476
  accountNameAt: z.ZodOptional<z.ZodNumber>;
432
477
  defaultStampAt: z.ZodOptional<z.ZodNumber>;
433
478
  settingsAt: z.ZodOptional<z.ZodNumber>;
479
+ walletLinkAt: z.ZodOptional<z.ZodNumber>;
434
480
  lastModified: z.ZodOptional<z.ZodNumber>;
435
481
  partitionCount: z.ZodOptional<z.ZodNumber>;
436
482
  signedOutAt: z.ZodOptional<z.ZodUndefined>;
@@ -477,9 +523,15 @@ export declare const AccountMetadataSchemaV1: z.ZodObject<{
477
523
  settings: z.ZodOptional<z.ZodObject<{
478
524
  appSessionDuration: z.ZodOptional<z.ZodNumber>;
479
525
  }, z.core.$strip>>;
526
+ walletLink: z.ZodOptional<z.ZodObject<{
527
+ message: z.ZodString;
528
+ walletSignature: z.ZodString;
529
+ accountSignature: z.ZodString;
530
+ }, z.core.$strip>>;
480
531
  accountNameAt: z.ZodOptional<z.ZodNumber>;
481
532
  defaultStampAt: z.ZodOptional<z.ZodNumber>;
482
533
  settingsAt: z.ZodOptional<z.ZodNumber>;
534
+ walletLinkAt: z.ZodOptional<z.ZodNumber>;
483
535
  createdAt: z.ZodNumber;
484
536
  lastModified: z.ZodNumber;
485
537
  devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -511,9 +563,15 @@ export declare const AccountStateSnapshotSchemaV1: z.ZodObject<{
511
563
  settings: z.ZodOptional<z.ZodObject<{
512
564
  appSessionDuration: z.ZodOptional<z.ZodNumber>;
513
565
  }, z.core.$strip>>;
566
+ walletLink: z.ZodOptional<z.ZodObject<{
567
+ message: z.ZodString;
568
+ walletSignature: z.ZodString;
569
+ accountSignature: z.ZodString;
570
+ }, z.core.$strip>>;
514
571
  accountNameAt: z.ZodOptional<z.ZodNumber>;
515
572
  defaultStampAt: z.ZodOptional<z.ZodNumber>;
516
573
  settingsAt: z.ZodOptional<z.ZodNumber>;
574
+ walletLinkAt: z.ZodOptional<z.ZodNumber>;
517
575
  createdAt: z.ZodNumber;
518
576
  lastModified: z.ZodNumber;
519
577
  devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -572,6 +630,7 @@ export type SignedOutAccount = z.infer<typeof SignedOutAccountSchemaV1>;
572
630
  /** The local (on-device) account record: `SignedInAccount | SignedOutAccount`. */
573
631
  export type Account = z.infer<typeof LocalAccountSchemaV1>;
574
632
  export type ConnectedApp = z.infer<typeof ConnectedAppSchemaV1>;
633
+ export type AccountSettings = z.infer<typeof AccountSettingsSchema>;
575
634
  export type PostageStamp = z.infer<typeof PostageStampSchemaV1>;
576
635
  export type AccountMetadata = z.infer<typeof AccountMetadataSchemaV1>;
577
636
  export type AccountStateSnapshot = z.infer<typeof AccountStateSnapshotSchemaV1>;
@@ -65,6 +65,12 @@ export declare class SwarmIdProxy {
65
65
  * first-class writer despite the partition (docs/Account-Bus.md, phase 3).
66
66
  */
67
67
  private partitionAccount;
68
+ /**
69
+ * Set while a restored session's saved wallet link is unconfirmed, and kept
70
+ * out of the identity until then (docs/Wallet-Link.md). Cleared by the
71
+ * account's published state, a peer's `account-delta` or a new handover.
72
+ */
73
+ private walletLinkUnconfirmed;
68
74
  /** Account-derived topic the attached bus transports share; undefined when
69
75
  * none are attached. */
70
76
  private busTopic;
@@ -395,7 +401,7 @@ export declare class SwarmIdProxy {
395
401
  * Re-persist the stored session's account view after a live fold moved it.
396
402
  *
397
403
  * Without this the record is frozen at the handover: a rotated signer key or
398
- * a moved default stamp arrives over the bus, updates `partitionAccount`, and
404
+ * a moved pick for this site arrives over the bus, updates `partitionAccount`, and
399
405
  * then a reload resurrects the pre-fold copy and uploads with it until the
400
406
  * next live overlap.
401
407
  *
@@ -684,6 +690,20 @@ export declare class SwarmIdProxy {
684
690
  * restored from shared storage does.
685
691
  */
686
692
  private restorePartitionSession;
693
+ /**
694
+ * Take the wallet link the account published when it is newer than the
695
+ * restored copy, and tell the site (docs/Wallet-Link.md).
696
+ *
697
+ * The bus carries a change of "Show my ENS name on sites" to a frame that is
698
+ * open, and keeps no mailbox. Turned off while no page of the site was open,
699
+ * the restored copy would go on handing the site the withdrawn wallet, so
700
+ * the published state decides on the link's own clock. Only the link: the
701
+ * rest of the published account still arrives over the bus.
702
+ *
703
+ * Nothing published, or nothing read, confirms nothing, so the restored link
704
+ * stays held back.
705
+ */
706
+ private foldPublishedWalletLink;
687
707
  /**
688
708
  * Ask the account's published state whether this restored session was ended
689
709
  * while no page of the site was open. Ended means what it means
@@ -754,10 +774,11 @@ export declare class SwarmIdProxy {
754
774
  * `buildAccountStateSnapshotForPublish` below — reusing that one would cost
755
775
  * two key derivations to send a bus message.
756
776
  *
757
- * `requireDefaultStamp` is the FEED path's precondition, not the snapshot's:
758
- * that write is paid for by the default stamp, while a bus message costs
759
- * nothing to send and `metadata.defaultPostageStampBatchID` is optional on
760
- * the wire. An account with no drives is a supported connected state, and
777
+ * `requireDefaultStamp` is the FEED path's precondition, not the snapshot's.
778
+ * That write is paid from the drive the person picked for this site, through
779
+ * the coordinator built on the site's resolved stamp, and not from the
780
+ * account default this flag checks. A bus message costs nothing to send and
781
+ * `metadata.defaultPostageStampBatchID` is optional on the wire. An account with no drives is a supported connected state, and
761
782
  * gating the delta on a stamp is how such an account's revokes never reach
762
783
  * its partitioned sessions at all.
763
784
  */
@@ -795,7 +816,9 @@ export declare class SwarmIdProxy {
795
816
  * and to the shared feed via the coordinator (same write lock + held
796
817
  * partition). The feed write needs a partition; the bus message does not, so
797
818
  * it goes out first and a read-only session still relays to peers that
798
- * cannot see storage at all. Single-device accounts' feeds are published by
819
+ * cannot see storage at all. The feed write is paid from the site's picked
820
+ * drive, through the coordinator, and a site with no pick has no coordinator
821
+ * and writes none. Single-device accounts' feeds are published by
799
822
  * the SwarmID UI. Re-arms if a publish is already in flight so the latest
800
823
  * state still lands.
801
824
  */
@@ -1,2 +1,2 @@
1
- import{A as e,S as t,I as i,P as a,a as d,u as c,T as u,b as h,g as y,E as f,c as w,B as g,d as R,i as I,w as x,e as z,f as b,h as T,j as F,M as K,N as P,R as U}from"./chunks/chat-binding-BirKsDU3.js";export{C as CHAT_BINDING_TITLE,D as DEFAULT_BEE_NODE_URL,o as acceptedChatBinding,p as buildChatBindingMessage,l as formatTTL,k as generatedAvatarSvg,q as isCleanSiteOrigin,n as jsonRpcBatch,m as jsonRpcCall,r as parseChatBindingMessage,s as saveMantarayTreeRecursively,v as verifyChatBinding}from"./chunks/chat-binding-BirKsDU3.js";function O(e){const t=e.webkitRelativePath;return t?t.replace(/^[^/]*\//,""):e.name}function S(e,n,i){return x(e,n,i).catch(e=>{throw e instanceof z?new t("init-failed",e.message,{cause:e}):e})}function M(e){if(void 0===e)return;const n=T.safeParse(e);if(n.success)return n.data;const i=n.error.issues[0];throw new t("invalid-request",`Invalid button config at ${["config",...i.path].join(".")}: ${i.message}`,{cause:n.error})}function A(e){if(b.safeParse(e).success)return e;throw new t("invalid-request",`Invalid button action: ${JSON.stringify(e)}`)}function B(e){if(!I(e))throw new t("invalid-request","Invalid beeApiUrl: must be an http(s) URL, optionally with a path, and no credentials, query or fragment");return e}class L{constructor(n){if(this.mountedButtons=new Map,this.ready=!1,this.pendingRequests=new Map,this.progressListeners=new Map,this.requestIdCounter=0,"undefined"==typeof window)throw new Error("@solarpunkltd/swarm-id runs in the browser only: construct SwarmIdClient in code that runs there (an effect, onMount, or behind `typeof window !== 'undefined'`), not in a server render");this.iframeOrigin=n.iframeOrigin,this.iframePath=n.iframePath||"/proxy",this.timeout=n.timeout??3e4,this.initializationTimeout=n.initializationTimeout??3e4,this.onConnectionChange=n.onConnectionChange,this.popupMode=n.popupMode||"window",this.metadata=n.metadata,this.subsidisedGatewayUrl=n.subsidisedGatewayUrl,void 0!==n.beeApiUrl&&(this.beeApiUrl=B(n.beeApiUrl));try{e.parse(this.metadata)}catch(e){throw new t("invalid-request",`Invalid app metadata: ${e}`,{cause:e})}this.setupMessageListener()}async initialize(){if(this.iframe)throw new t("invalid-state","SwarmIdClient already initialized");this.firstConnectionInfoPromise=S(new Promise((e,t)=>{this.firstConnectionInfoResolve=e,this.firstConnectionInfoReject=t}),this.initializationTimeout,`Proxy initialization timeout - proxy did not send initial connectionInfoChanged within ${this.initializationTimeout}ms`),this.firstConnectionInfoPromise.catch(()=>{}),this.proxyInitializedPromise=S(new Promise((e,t)=>{this.proxyInitializedResolve=e,this.proxyInitializedReject=t}),this.initializationTimeout,`Proxy initialization timeout - proxy did not signal readiness within ${this.initializationTimeout}ms`),this.proxyInitializedPromise.catch(()=>{}),this.readyPromise=S(new Promise((e,t)=>{this.readyResolve=e,this.readyReject=t}),this.initializationTimeout,`Proxy initialization timeout - proxy did not respond within ${this.initializationTimeout}ms`),this.readyPromise.catch(()=>{}),this.iframe=document.createElement("iframe"),this.iframe.src=`${this.iframeOrigin}${this.iframePath}`,this.iframe.style.display="none",await new Promise((e,n)=>{this.iframeLoadReject=n,this.iframe.onload=()=>e(),this.iframe.onerror=()=>n(new t("init-failed","Failed to load Swarm ID iframe")),document.body.appendChild(this.iframe)}),this.iframeLoadReject=void 0,await this.proxyInitializedPromise,this.sendMessage({type:"parentIdentify",requestId:this.generateRequestId(),metadata:this.metadata,subsidisedGatewayUrl:this.subsidisedGatewayUrl,beeApiUrl:this.beeApiUrl}),await this.readyPromise,await this.firstConnectionInfoPromise}setupMessageListener(){this.messageListener=e=>{if(!this.iframe||e.source!==this.iframe.contentWindow)return;if("proxyInitialized"===e.data?.type)return void(this.proxyInitializedResolve&&(this.proxyInitializedResolve(),this.proxyInitializedResolve=void 0));const t=new URL(this.iframeOrigin).origin;if(e.origin!==t)return void console.warn("[SwarmIdClient] Rejected message from unauthorized origin:",e.origin);let n;try{n=i.parse(e.data)}catch(t){return void console.warn("[SwarmIdClient] Invalid message format:",e.data,t)}this.handleIframeMessage(n)},window.addEventListener("message",this.messageListener)}handleIframeMessage(e){switch(e.type){case"proxyReady":this.ready=!0,this.storageShared=e.storageShared,this.readyResolve&&this.readyResolve();break;case"connectionInfoChanged":{const t={canUpload:e.canUpload,storagePartitioned:e.storagePartitioned,uploadMode:e.uploadMode,uploadUnavailableReason:e.uploadUnavailableReason,identity:e.identity,appKey:e.appKey,partition:e.partition,chatBinding:e.chatBinding,beeApiUrl:e.beeApiUrl,postageBatchId:e.postageBatchId};this.lastConnectionInfo=t,this.firstConnectionInfoResolve&&(this.firstConnectionInfoResolve(),this.firstConnectionInfoResolve=void 0),this.onConnectionChange&&this.onConnectionChange(t);break}case"initError":console.error("[SwarmIdClient] Proxy initialization error:",e.error),this.readyReject&&this.readyReject(new t("init-failed",e.error));break;case"disconnectResponse":if("requestId"in e){const t=this.pendingRequests.get(e.requestId);t&&(clearTimeout(t.timeoutId),this.pendingRequests.delete(e.requestId),t.resolve(e))}break;case"error":{const n=this.pendingRequests.get(e.requestId);n&&(clearTimeout(n.timeoutId),this.pendingRequests.delete(e.requestId),n.reject(t.fromWire(e)));break}case"uploadProgress":this.progressListeners.get(e.requestId)?.({total:e.total,processed:e.processed});break;default:if("requestId"in e){const t=this.pendingRequests.get(e.requestId);t&&(clearTimeout(t.timeoutId),this.pendingRequests.delete(e.requestId),t.resolve(e))}}}sendMessage(e){if(!this.iframe||!this.iframe.contentWindow)throw new t("invalid-state","Iframe not initialized");try{a.parse(e)}catch(e){throw new t("invalid-request",`Invalid message format: ${e}`,{cause:e})}this.iframe.contentWindow.postMessage(e,this.iframeOrigin)}async sendRequest(e){const n=this.roundTripTimeout(e.requestOptions?.timeout);return new Promise((i,s)=>{const r=setTimeout(()=>{this.pendingRequests.delete(e.requestId),s(new t("timeout",`Request timeout after ${n}ms`))},n);this.pendingRequests.set(e.requestId,{resolve:i,reject:s,timeoutId:r}),this.sendMessage(e)})}roundTripTimeout(e){return void 0===e||e<=0?this.timeout:Math.min(e,2147483647)}generateRequestId(){return`req-${++this.requestIdCounter}-${Date.now()}`}normalizeSocIdentifier(e){return e instanceof d?e.toHex():e instanceof Uint8Array?c(e):e}normalizeSocKey(e){return e instanceof Uint8Array?c(e):e}normalizeFeedTopic(e){return e instanceof u?c(e.toUint8Array()):e instanceof d?e.toHex():e instanceof Uint8Array?c(e):e}normalizeReference(e){return e instanceof Uint8Array?c(e):e}normalizeFeedTimestamp(e){return"bigint"==typeof e?e.toString():"number"==typeof e?BigInt(Math.floor(e)).toString():e}normalizeFeedIndex(e){return"bigint"==typeof e?e.toString():"number"==typeof e?BigInt(Math.floor(e)).toString():e}normalizePayload(e){return e instanceof Uint8Array?e:(new TextEncoder).encode(e)}socChunkFromResponse(e){return{data:e.data,identifier:e.identifier,signature:e.signature,span:e.span,payload:e.payload,address:e.address,owner:e.owner}}ensureReady(){if(!this.ready)throw new t("invalid-state","SwarmIdClient not initialized. Call initialize() first.")}async checkAuthStatus(){this.ensureReady();const e=this.generateRequestId(),t=await this.sendRequest({type:"checkAuth",requestId:e});return{authenticated:t.authenticated,origin:t.origin,beeApiUrl:t.beeApiUrl}}async setBeeApiUrl(e){const t=B(e);this.ensureReady(),await this.sendRequest({type:"setBeeApiUrl",requestId:this.generateRequestId(),beeApiUrl:t}),this.beeApiUrl=t}async getPostageBatch(){this.ensureReady();const e=this.generateRequestId();return(await this.sendRequest({type:"getPostageBatch",requestId:e})).postageBatch}async disconnect(){this.ensureReady();const e=this.generateRequestId();if(!(await this.sendRequest({type:"disconnect",requestId:e})).success)throw new t("internal","Failed to disconnect")}async connect(e={}){if(this.ensureReady(),!0!==this.storageShared)throw new t("button-required","Swarm ID's frame cannot read Swarm ID's storage here, so a window opened from this page cannot sign it in. Sign in through the button from client.mountButton().");if(!this.openAuthWindow(e))throw new t("popup-blocked","Failed to open authentication popup")}mountButton(e,n){this.ensureReady();const i=this.iframeOrigin,s=new URL(i).origin;let r=A(n.action),o=M(n.config),a=!1,d=!1,c=!1,u=!1;const h=document.createElement("iframe");let p,l;h.src=`${i}${this.iframePath.replace(/\/proxy$/,"")}/button`,h.title="Swarm ID",Object.assign(h.style,{border:"none",backgroundColor:"transparent",width:"100%",height:"100%",display:"block",borderRadius:o?.borderRadius??"0"});const y=S(new Promise((e,t)=>{p=e,l=t}),this.initializationTimeout,`Swarm ID button did not show within ${this.initializationTimeout}ms`);y.then(()=>d=!0,()=>d=!0);const f=e=>h.contentWindow?.postMessage(e,i),m=e=>{if(e.source!==h.contentWindow)return;if(e.data?.type===g)return a=!0,void f({type:"buttonIdentify",action:r,config:o,metadata:this.metadata,popupMode:this.popupMode});if(e.origin!==s)return;const i=R.safeParse(e.data);if(!i.success)return;const d=i.data;"buttonReady"===d.type?p():"buttonInitError"===d.type?l(new t("init-failed",d.error)):(c="open"===d.state,u?c||w():n.onWindowChange?.(d.state))},w=()=>{this.mountedButtons.delete(I),window.removeEventListener("message",m),h.remove(),d||l(new t("invalid-state","Swarm ID button unmounted"))};window.addEventListener("message",m),e.appendChild(h);const I={ready:y,update:e=>{u||(r=void 0===e.action?r:A(e.action),o=void 0===e.config?o:M(e.config),h.style.borderRadius=o?.borderRadius??"0",a&&f({type:"buttonUpdate",action:r,config:o}))},unmount:()=>{!u&&this.mountedButtons.has(I)&&(u=!0,c?h.style.display="none":w())}};return this.mountedButtons.set(I,w),I}openAuthWindow(e){const t=this.iframePath.replace(/\/proxy$/,""),n=h(this.iframeOrigin+t,window.location.origin,this.metadata),i="popup"===(e.popupMode??this.popupMode)?window.open(n,"_blank","width=500,height=600"):window.open(n,"_blank");return Boolean(i)}get connectionInfo(){if(this.ensureReady(),!this.lastConnectionInfo)throw new t("invalid-state","SwarmIdClient connectionInfo not yet available.");return this.lastConnectionInfo}async getAvatar(e={}){const{identity:t}=this.connectionInfo;if(t)return void 0!==e.size&&"generated"===t.avatar.source?y(t.id,e.size):t.avatar}async isBeeConnected(){try{this.ensureReady();const e=this.generateRequestId();return(await this.sendRequest({type:"isConnected",requestId:e})).connected}catch{return!1}}async getNodeInfo(){this.ensureReady();const e=this.generateRequestId(),t=await this.sendRequest({type:"getNodeInfo",requestId:e});return{beeMode:t.beeMode,chequebookEnabled:t.chequebookEnabled,swapEnabled:t.swapEnabled}}async uploadData(e,t,n){this.ensureReady();const i=this.generateRequestId(),{onProgress:s,useWebSocket:r,useWorkers:o,workerCount:a,concurrency:d,...c}=t??{},u=this.listenForProgress(i,s);try{const t=await this.sendRequest({type:"uploadData",requestId:i,data:new Uint8Array(e),options:c,requestOptions:n,enableProgress:!!s,useWebSocket:r,useWorkers:o,workerCount:a,concurrency:d});return{reference:t.reference,tagUid:t.tagUid}}finally{u()}}async downloadData(e,t,n){this.ensureReady();const i=this.generateRequestId();return(await this.sendRequest({type:"downloadData",requestId:i,reference:e,options:t,requestOptions:n})).data}async deriveAppSecret(e){this.ensureReady();const t=this.generateRequestId();return(await this.sendRequest({type:"deriveAppSecret",requestId:t,label:e})).secret}async getChatKey(){this.ensureReady();const e=this.generateRequestId();return(await this.sendRequest({type:"getChatKey",requestId:e})).chatKey}async stampChunk(e){this.ensureReady();const t=this.generateRequestId(),n="soc"===e.kind?{...e,identifier:this.normalizeSocIdentifier(e.identifier),signer:"app"===e.signer?e.signer:{...e.signer,privateKey:this.normalizeSocKey(e.signer.privateKey)}}:e,i=await this.sendRequest({type:"stampChunk",requestId:t,chunk:n});return{address:i.address,stamp:i.stamp,...void 0!==i.owner&&{owner:i.owner},...void 0!==i.signature&&{signature:i.signature}}}async uploadFile(e,t,n,i){this.ensureReady();const s=this.generateRequestId(),{onProgress:r,useWebSocket:o,useWorkers:a,workerCount:d,concurrency:c,...u}=n??{};let h,p=t;if(e instanceof File){const t=await e.arrayBuffer();h=new Uint8Array(t),p=p||e.name}else h=new Uint8Array(e.buffer.slice(0),e.byteOffset,e.byteLength);const l=this.listenForProgress(s,r);try{const e=await this.sendRequest({type:"uploadFile",requestId:s,data:h,name:p,options:u,requestOptions:i,enableProgress:!!r,useWebSocket:o,useWorkers:a,workerCount:d,concurrency:c});return{reference:e.reference,tagUid:e.tagUid}}finally{l()}}async downloadFile(e,t,n,i){this.ensureReady();const s=this.generateRequestId(),r=await this.sendRequest({type:"downloadFile",requestId:s,reference:e,path:t,options:n,requestOptions:i});return{name:r.name,data:new Uint8Array(r.data)}}async uploadFiles(e,t,n){this.ensureReady();const i=this.generateRequestId(),{onProgress:s,useWorkers:r,workerCount:o,...a}=t??{},d=await Promise.all(Array.from(e,async e=>{const{path:t,file:n}=e instanceof File?{path:O(e),file:e}:e;return{path:t,data:new Uint8Array(await n.arrayBuffer()),contentType:n.type||void 0}})),c=this.listenForProgress(i,s);try{const e=await this.sendRequest({type:"uploadFiles",requestId:i,files:d,options:a,requestOptions:n,enableProgress:!!s,useWorkers:r,workerCount:o});return{reference:e.reference,tagUid:e.tagUid}}finally{c()}}async listFiles(e,t){this.ensureReady();const n=this.generateRequestId();return(await this.sendRequest({type:"listFiles",requestId:n,reference:e,requestOptions:t})).entries}listenForProgress(e,t){return t?(this.progressListeners.set(e,t),()=>{this.progressListeners.delete(e)}):()=>{}}async uploadChunk(e,t,n){this.ensureReady();const i=this.generateRequestId(),{onProgress:s,...r}=t??{};return{reference:(await this.sendRequest({type:"uploadChunk",requestId:i,data:e,options:r,requestOptions:n})).reference}}async downloadChunk(e,t,n){this.ensureReady();const i=this.generateRequestId(),s=await this.sendRequest({type:"downloadChunk",requestId:i,reference:e,options:t,requestOptions:n});return new Uint8Array(s.data)}makeSOCReader(e,t){this.ensureReady();const n=new f(e).toHex(),i=async(e,i)=>{const s=this.generateRequestId(),r=await this.sendRequest({type:"socDownload",requestId:s,owner:n,identifier:this.normalizeSocIdentifier(e),encryptionKey:this.normalizeSocKey(i),requestOptions:t});return this.socChunkFromResponse(r)},s=async(e,i)=>{const s=this.generateRequestId(),r=await this.sendRequest({type:"socRawDownload",requestId:s,owner:n,identifier:this.normalizeSocIdentifier(e),encryptionKey:i?this.normalizeSocKey(i):void 0,requestOptions:t});return this.socChunkFromResponse(r)};return{getOwner:async()=>n,rawDownload:(e,t)=>s(e,t),download:(e,t)=>i(e,t)}}makeSOCWriter(e,t){this.ensureReady();const n=e?new w(e):void 0,i=n?n.toHex():void 0;let s=n?n.publicKey().address().toHex():void 0;const r=async(e,n)=>{const i=this.generateRequestId(),r=await this.sendRequest({type:"socDownload",requestId:i,owner:s,identifier:this.normalizeSocIdentifier(e),encryptionKey:this.normalizeSocKey(n),requestOptions:t});return this.socChunkFromResponse(r)},o=async(e,n)=>{const i=this.generateRequestId(),r=await this.sendRequest({type:"socRawDownload",requestId:i,owner:s,identifier:this.normalizeSocIdentifier(e),encryptionKey:n?this.normalizeSocKey(n):void 0,requestOptions:t});return this.socChunkFromResponse(r)},a=async(e,n,r)=>{const o=this.generateRequestId(),a=await this.sendRequest({type:"socUpload",requestId:o,identifier:this.normalizeSocIdentifier(e),data:new Uint8Array(n),signer:i,options:r,requestOptions:t});return s=a.owner,{reference:a.reference,tagUid:a.tagUid,encryptionKey:a.encryptionKey,owner:a.owner}},d=async(e,n,r)=>{const o=this.generateRequestId(),a=await this.sendRequest({type:"socRawUpload",requestId:o,identifier:this.normalizeSocIdentifier(e),data:new Uint8Array(n),signer:i,options:r,requestOptions:t});return s=a.owner,{reference:a.reference,tagUid:a.tagUid,encryptionKey:a.encryptionKey,owner:a.owner}};return{getOwner:async()=>{if(s)return s;const e=this.generateRequestId(),t=await this.sendRequest({type:"socGetOwner",requestId:e});return s=t.owner,s},rawDownload:(e,t)=>o(e,t),download:(e,t)=>r(e,t),upload:(e,t,n)=>a(e,t,n),rawUpload:(e,t,n)=>d(e,t,n)}}makeEpochFeedReader(e,t){this.ensureReady();const n=this.normalizeFeedTopic(e.topic);let i=e.owner?new f(e.owner).toHex():void 0;const s=async e=>{const s=void 0!==e?.at?e.at:BigInt(Math.floor(Date.now()/1e3)),r=this.generateRequestId(),o=(await this.sendRequest({type:"epochFeedDownloadReference",requestId:r,topic:n,owner:i,at:this.normalizeFeedTimestamp(s),after:void 0!==e?.after?this.normalizeFeedTimestamp(e.after):void 0,encryptionKey:void 0!==e?.encryptionKey?this.normalizeSocKey(e.encryptionKey):void 0,requestOptions:t})).reference,a=o&&o.startsWith("0x")?o.slice(2):o;return{reference:o,encryptionKey:a&&128===a.length?a.slice(64):void 0}},r=async e=>{const s=void 0!==e?.at?e.at:BigInt(Math.floor(Date.now()/1e3)),r=this.generateRequestId();return{reference:(await this.sendRequest({type:"epochFeedDownloadReference",requestId:r,topic:n,owner:i,at:this.normalizeFeedTimestamp(s),after:void 0!==e?.after?this.normalizeFeedTimestamp(e.after):void 0,encryptionKey:void 0,requestOptions:t})).reference,encryptionKey:void 0}};return{getOwner:async()=>{if(i)return i;const e=this.generateRequestId(),t=await this.sendRequest({type:"feedGetOwner",requestId:e});return i=t.owner,i},downloadReference:s,downloadPayload:async e=>{const n=await s(e);if(!n.reference)return{reference:void 0,payload:void 0,encryptionKey:void 0};const i=await this.downloadData(n.reference,void 0,t);return{reference:n.reference,payload:i,encryptionKey:n.encryptionKey}},downloadRawReference:r,downloadRawPayload:async e=>{const n=await r(e);if(!n.reference)return{reference:void 0,payload:void 0,encryptionKey:void 0};const i=await this.downloadData(n.reference,void 0,t);return{reference:n.reference,payload:i,encryptionKey:void 0}}}}makeEpochFeedWriter(e,t){this.ensureReady();const n=this.normalizeFeedTopic(e.topic),i=e.signer?new w(e.signer):void 0,s=i?i.toHex():void 0;let r=i?i.publicKey().address().toHex():void 0;const o=async e=>{const i=void 0!==e?.at?e.at:BigInt(Math.floor(Date.now()/1e3)),s=this.generateRequestId(),o=(await this.sendRequest({type:"epochFeedDownloadReference",requestId:s,topic:n,owner:r,at:this.normalizeFeedTimestamp(i),after:void 0!==e?.after?this.normalizeFeedTimestamp(e.after):void 0,encryptionKey:void 0!==e?.encryptionKey?this.normalizeSocKey(e.encryptionKey):void 0,requestOptions:t})).reference,a=o&&o.startsWith("0x")?o.slice(2):o;return{reference:o,encryptionKey:a&&128===a.length?a.slice(64):void 0}},a=async e=>{const i=void 0!==e?.at?e.at:BigInt(Math.floor(Date.now()/1e3)),s=this.generateRequestId();return{reference:(await this.sendRequest({type:"epochFeedDownloadReference",requestId:s,topic:n,owner:r,at:this.normalizeFeedTimestamp(i),after:void 0!==e?.after?this.normalizeFeedTimestamp(e.after):void 0,encryptionKey:void 0,requestOptions:t})).reference,encryptionKey:void 0}};return{getOwner:async()=>{if(r)return r;const e=this.generateRequestId(),t=await this.sendRequest({type:"feedGetOwner",requestId:e});return r=t.owner,r},downloadReference:o,downloadPayload:async e=>{const n=await o(e);if(!n.reference)return{reference:void 0,payload:void 0,encryptionKey:void 0};const i=await this.downloadData(n.reference,void 0,t);return{reference:n.reference,payload:i,encryptionKey:n.encryptionKey}},downloadRawReference:a,downloadRawPayload:async e=>{const n=await a(e);if(!n.reference)return{reference:void 0,payload:void 0,encryptionKey:void 0};const i=await this.downloadData(n.reference,void 0,t);return{reference:n.reference,payload:i,encryptionKey:void 0}},uploadReference:async(e,i)=>{const r=void 0!==i?.at?i.at:BigInt(Math.floor(Date.now()/1e3)),o=this.normalizeReference(e),a=o.startsWith("0x")?o.slice(2):o,d=128===a.length?a.slice(64):void 0,c=i?.encryptionKey??d,u=this.generateRequestId(),h=await this.sendRequest({type:"epochFeedUploadReference",requestId:u,topic:n,signer:s,at:this.normalizeFeedTimestamp(r),reference:o,encryptionKey:void 0!==c?this.normalizeSocKey(c):void 0,hints:i?.hints,requestOptions:t});return{socAddress:h.socAddress,reference:o,encryptionKey:d,epoch:h.epoch,timestamp:h.timestamp}},uploadPayload:async(e,i)=>{const r=void 0!==i?.at?i.at:BigInt(Math.floor(Date.now()/1e3)),o=!1!==i?.encrypt,a=await this.uploadData(this.normalizePayload(e),{...i?.uploadOptions,encrypt:o},t),d=a.reference.startsWith("0x")?a.reference.slice(2):a.reference,c=128===d.length?d.slice(64):void 0,u=i?.encryptionKey??c,h=this.generateRequestId(),p=await this.sendRequest({type:"epochFeedUploadReference",requestId:h,topic:n,signer:s,at:this.normalizeFeedTimestamp(r),reference:a.reference,encryptionKey:void 0!==u?this.normalizeSocKey(u):void 0,hints:i?.hints,requestOptions:t}),l=c;return{socAddress:p.socAddress,reference:a.reference,encryptionKey:l,epoch:p.epoch,timestamp:p.timestamp}},uploadRawReference:async(e,i)=>{const r=void 0!==i?.at?i.at:BigInt(Math.floor(Date.now()/1e3)),o=this.normalizeReference(e),a=this.generateRequestId(),d=await this.sendRequest({type:"epochFeedUploadReference",requestId:a,topic:n,signer:s,at:this.normalizeFeedTimestamp(r),reference:o,encryptionKey:void 0,hints:i?.hints,requestOptions:t});return{socAddress:d.socAddress,reference:o,encryptionKey:void 0,epoch:d.epoch,timestamp:d.timestamp}},uploadRawPayload:async(e,i)=>{const r=void 0!==i?.at?i.at:BigInt(Math.floor(Date.now()/1e3)),o=await this.uploadData(this.normalizePayload(e),{...i?.uploadOptions,encrypt:!1},t),a=this.generateRequestId(),d=await this.sendRequest({type:"epochFeedUploadReference",requestId:a,topic:n,signer:s,at:this.normalizeFeedTimestamp(r),reference:o.reference,encryptionKey:void 0,hints:i?.hints,requestOptions:t});return{socAddress:d.socAddress,reference:o.reference,encryptionKey:void 0,epoch:d.epoch,timestamp:d.timestamp}}}}makeSequentialFeedReader(e,t){this.ensureReady();const n=this.normalizeFeedTopic(e.topic);let i=e.owner?new f(e.owner).toHex():void 0;return{getOwner:async()=>{if(i)return i;const e=this.generateRequestId(),t=await this.sendRequest({type:"seqFeedGetOwner",requestId:e});return i=t.owner,i},downloadPayload:async(e,s)=>{const r=this.generateRequestId(),o=await this.sendRequest({type:"seqFeedDownloadPayload",requestId:r,topic:n,owner:i,index:void 0!==s?.index?this.normalizeFeedIndex(s.index):void 0,at:void 0!==s?.at?this.normalizeFeedTimestamp(s.at):void 0,hasTimestamp:s?.hasTimestamp,lookupTimeoutMs:s?.lookupTimeoutMs,encryptionKey:this.normalizeSocKey(e),requestOptions:t});return{payload:o.payload,timestamp:o.timestamp,feedIndex:o.feedIndex,feedIndexNext:o.feedIndexNext}},downloadRawPayload:async e=>{const s=this.generateRequestId(),r=await this.sendRequest({type:"seqFeedDownloadRawPayload",requestId:s,topic:n,owner:i,index:void 0!==e?.index?this.normalizeFeedIndex(e.index):void 0,at:void 0!==e?.at?this.normalizeFeedTimestamp(e.at):void 0,hasTimestamp:e?.hasTimestamp,lookupTimeoutMs:e?.lookupTimeoutMs,encryptionKey:e?.encryptionKey?this.normalizeSocKey(e.encryptionKey):void 0,requestOptions:t});return{payload:r.payload,timestamp:r.timestamp,feedIndex:r.feedIndex,feedIndexNext:r.feedIndexNext}},downloadReference:async(e,s)=>{const r=this.generateRequestId(),o=await this.sendRequest({type:"seqFeedDownloadReference",requestId:r,topic:n,owner:i,index:void 0!==s?.index?this.normalizeFeedIndex(s.index):void 0,at:void 0!==s?.at?this.normalizeFeedTimestamp(s.at):void 0,hasTimestamp:s?.hasTimestamp,lookupTimeoutMs:s?.lookupTimeoutMs,encryptionKey:this.normalizeSocKey(e),requestOptions:t});return{reference:o.reference,feedIndex:o.feedIndex,feedIndexNext:o.feedIndexNext}}}}makeSequentialFeedWriter(e,t){this.ensureReady();const n=this.normalizeFeedTopic(e.topic),i=e.signer?new w(e.signer):void 0,s=i?i.toHex():void 0;let r=i?i.publicKey().address().toHex():void 0;return{getOwner:async()=>{if(r)return r;const e=this.generateRequestId(),t=await this.sendRequest({type:"seqFeedGetOwner",requestId:e});return r=t.owner,r},downloadPayload:async(e,i)=>{const s=this.generateRequestId(),o=await this.sendRequest({type:"seqFeedDownloadPayload",requestId:s,topic:n,owner:r,index:void 0!==i?.index?this.normalizeFeedIndex(i.index):void 0,at:void 0!==i?.at?this.normalizeFeedTimestamp(i.at):void 0,hasTimestamp:i?.hasTimestamp,encryptionKey:this.normalizeSocKey(e),requestOptions:t});return{payload:o.payload,timestamp:o.timestamp,feedIndex:o.feedIndex,feedIndexNext:o.feedIndexNext}},downloadRawPayload:async e=>{const i=this.generateRequestId(),s=await this.sendRequest({type:"seqFeedDownloadRawPayload",requestId:i,topic:n,owner:r,index:void 0!==e?.index?this.normalizeFeedIndex(e.index):void 0,at:void 0!==e?.at?this.normalizeFeedTimestamp(e.at):void 0,hasTimestamp:e?.hasTimestamp,encryptionKey:e?.encryptionKey?this.normalizeSocKey(e.encryptionKey):void 0,requestOptions:t});return{payload:s.payload,timestamp:s.timestamp,feedIndex:s.feedIndex,feedIndexNext:s.feedIndexNext}},downloadReference:async(e,i)=>{const s=this.generateRequestId(),o=await this.sendRequest({type:"seqFeedDownloadReference",requestId:s,topic:n,owner:r,index:void 0!==i?.index?this.normalizeFeedIndex(i.index):void 0,at:void 0!==i?.at?this.normalizeFeedTimestamp(i.at):void 0,hasTimestamp:i?.hasTimestamp,encryptionKey:this.normalizeSocKey(e),requestOptions:t});return{reference:o.reference,feedIndex:o.feedIndex,feedIndexNext:o.feedIndexNext}},uploadPayload:async(e,i)=>{const o=this.generateRequestId(),a=await this.sendRequest({type:"seqFeedUploadPayload",requestId:o,topic:n,signer:s,data:this.normalizePayload(e),index:void 0!==i?.index?this.normalizeFeedIndex(i.index):void 0,at:void 0!==i?.at?this.normalizeFeedTimestamp(i.at):void 0,hasTimestamp:i?.hasTimestamp,lookupTimeoutMs:i?.lookupTimeoutMs,options:i,requestOptions:t});return r=a.owner,{reference:a.reference,feedIndex:a.feedIndex,owner:a.owner,encryptionKey:a.encryptionKey,tagUid:a.tagUid}},uploadRawPayload:async(e,i)=>{const o=this.generateRequestId(),a=await this.sendRequest({type:"seqFeedUploadRawPayload",requestId:o,topic:n,signer:s,data:this.normalizePayload(e),index:void 0!==i?.index?this.normalizeFeedIndex(i.index):void 0,at:void 0!==i?.at?this.normalizeFeedTimestamp(i.at):void 0,hasTimestamp:i?.hasTimestamp,lookupTimeoutMs:i?.lookupTimeoutMs,encryptionKey:i?.encryptionKey?this.normalizeSocKey(i.encryptionKey):void 0,options:i,requestOptions:t});return r=a.owner,{reference:a.reference,feedIndex:a.feedIndex,owner:a.owner,encryptionKey:a.encryptionKey,tagUid:a.tagUid}},uploadReference:async(e,i)=>{const o=this.generateRequestId(),a=await this.sendRequest({type:"seqFeedUploadReference",requestId:o,topic:n,signer:s,reference:this.normalizeReference(e),index:void 0!==i?.index?this.normalizeFeedIndex(i.index):void 0,at:void 0!==i?.at?this.normalizeFeedTimestamp(i.at):void 0,hasTimestamp:i?.hasTimestamp,lookupTimeoutMs:i?.lookupTimeoutMs,options:i,requestOptions:t});return r=a.owner,{reference:a.reference,feedIndex:a.feedIndex,owner:a.owner,encryptionKey:a.encryptionKey,tagUid:a.tagUid}}}}async createFeedManifest(e,t,n){this.ensureReady();const i=this.normalizeFeedTopic(e),s=this.generateRequestId();return(await this.sendRequest({type:"createFeedManifest",requestId:s,topic:i,owner:t?.owner,feedType:t?.feedType,uploadOptions:t?.uploadOptions,requestOptions:n})).reference}async gsocMine(e,t,n){this.ensureReady();const i=this.generateRequestId();return(await this.sendRequest({type:"gsocMine",requestId:i,targetOverlay:e,identifier:t,proximity:n})).signer}async gsocSend(e,t,n,i,s){this.ensureReady();const r=this.generateRequestId(),o=await this.sendRequest({type:"gsocSend",requestId:r,signer:e,identifier:t,data:new Uint8Array(n),options:i,requestOptions:s});return{reference:o.reference,tagUid:o.tagUid}}async actUploadData(e,t,n,i){this.ensureReady();const s=this.generateRequestId(),{onProgress:r,...o}=n??{},a=this.listenForProgress(s,r);try{const n=await this.sendRequest({type:"actUploadData",requestId:s,data:new Uint8Array(e),grantees:t,options:o,requestOptions:i,enableProgress:!!r});return{encryptedReference:n.encryptedReference,historyReference:n.historyReference,granteeListReference:n.granteeListReference,publisherPubKey:n.publisherPubKey,actReference:n.actReference,tagUid:n.tagUid}}finally{a()}}async actDownloadData(e,t,n,i,s){this.ensureReady();const r=this.generateRequestId();return(await this.sendRequest({type:"actDownloadData",requestId:r,encryptedReference:e,historyReference:t,publisherPubKey:n,timestamp:i,requestOptions:s})).data}async actAddGrantees(e,t,n){this.ensureReady();const i=this.generateRequestId(),s=await this.sendRequest({type:"actAddGrantees",requestId:i,historyReference:e,grantees:t,requestOptions:n});return{historyReference:s.historyReference,granteeListReference:s.granteeListReference,actReference:s.actReference}}async actRevokeGrantees(e,t,n,i){this.ensureReady();const s=this.generateRequestId(),r=await this.sendRequest({type:"actRevokeGrantees",requestId:s,historyReference:e,encryptedReference:t,revokeGrantees:n,requestOptions:i});return{encryptedReference:r.encryptedReference,historyReference:r.historyReference,granteeListReference:r.granteeListReference,actReference:r.actReference}}async actGetGrantees(e,t){this.ensureReady();const n=this.generateRequestId();return(await this.sendRequest({type:"actGetGrantees",requestId:n,historyReference:e,requestOptions:t})).grantees}destroy(){const e=()=>new t("invalid-state","Client destroyed");for(const e of[...this.mountedButtons.values()])e();this.pendingRequests.forEach(t=>{clearTimeout(t.timeoutId),t.reject(e())}),this.pendingRequests.clear(),this.progressListeners.clear(),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=void 0),this.iframe&&this.iframe.parentNode&&(this.iframe.parentNode.removeChild(this.iframe),this.iframe=void 0),this.iframeLoadReject?.(e()),this.proxyInitializedReject?.(e()),this.readyReject?.(e()),this.firstConnectionInfoReject?.(e()),this.iframeLoadReject=void 0,this.readyResolve=void 0,this.readyReject=void 0,this.proxyInitializedResolve=void 0,this.proxyInitializedReject=void 0,this.firstConnectionInfoResolve=void 0,this.firstConnectionInfoReject=void 0,this.readyPromise=void 0,this.proxyInitializedPromise=void 0,this.firstConnectionInfoPromise=void 0,this.ready=!1}}function E(e){const t=e instanceof Uint8Array?e:F(e);if(32!==t.length)throw new Error(`Invalid content reference length: ${t.length} (expected 32 bytes)`);const n=new K;return n.addFork("/",P,{"website-index-document":"index.bin"}),n.addFork("index.bin",t,{"Content-Type":"application/octet-stream",Filename:"index.bin"}),{manifestNode:n}}function j(e){let t=0;for(;e;)t+=1&e,e>>>=1;return t}function W(e){for(let t=0;t<e.length;t++)if(0!==e[t])return!1;return!0}function N(e){if(e.length<96)throw new Error(`Manifest too small: ${e.length} bytes (expected at least 96)`);const t=e.slice(64,96);if(W(t))throw new Error("Manifest entry is zero");return new U(t).toHex()}function $(e){if(e.length<192)throw new Error(`Manifest too small: ${e.length} bytes (expected at least 192)`);const t=e.slice(96,128),n=Math.floor(105/8);if(!(2&t[n]))throw new Error('Manifest does not contain "index.bin" fork');let i=0;for(let e=0;e<n;e++)i+=j(t[e]);for(let e=0;e<1;e++)t[n]&1<<e&&i++;let s=128;for(let t=0;t<i;t++){const t=e[s];if(s+=64,!!(16&t)){s+=2+(e[s]<<8|e[s+1])}}const r=e[s],o=e[s+1];if(105!==e[s+2])throw new Error(`Expected "index.bin" prefix, got byte 0x${e[s+2].toString(16)}`);if(o>=9){const t=e.slice(s+2,s+2+9),n=(new TextEncoder).encode("index.bin");t.every((e,t)=>e===n[t])||console.warn('[ManifestBuilder] Prefix does not fully match "index.bin"')}if(!!!(2&r))throw new Error('"index.bin" fork is not a VALUE type');const a=s+32,d=e.slice(a,a+32);if(W(d))throw new Error('Manifest "index.bin" fork has zero reference');return new U(d).toHex()}export{L as SwarmIdClient,t as SwarmIdError,z as TimeoutError,E as buildBzzManifestNode,O as collectionPath,$ as extractContentFromFlatManifest,N as extractEntryFromManifest,y as generatedAvatar,F as hexToUint8Array,c as uint8ArrayToHex,x as withTimeout};
1
+ export{E as ENS_NAME_CACHE_MS,p as ENS_NAME_FAILURE_CACHE_MS,S as SwarmIdClient,k as buildBzzManifestNode,o as collectionPath,m as extractContentFromFlatManifest,n as extractEntryFromManifest,r as resolveVerifiedEnsName}from"./chunks/index-BbRV2bja.js";export{F as CHAT_BINDING_TITLE,D as DEFAULT_BEE_NODE_URL,S as SwarmIdError,e as TimeoutError,W as WALLET_LINK_STATEMENT,Q as WALLET_LINK_TITLE,G as acceptedChatBinding,J as buildChatBindingMessage,U as buildWalletLinkMessage,x as formatTTL,g as generatedAvatar,r as generatedAvatarSvg,j as hexToUint8Array,K as isCleanSiteOrigin,z as jsonRpcBatch,y as jsonRpcCall,L as parseChatBindingMessage,V as parseWalletLinkMessage,v as saveMantarayTreeRecursively,u as uint8ArrayToHex,O as verifyChatBinding,X as verifyWalletLink,w as withTimeout}from"./chunks/chat-binding-gSvKTm5l.js";
2
2
  //# sourceMappingURL=swarm-id.esm.js.map