sealnet 2.0.4 → 3.0.0
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 +11 -8
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/index.cjs +1890 -1053
- package/dist/index.d.cts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +1890 -1053
- package/dist/seal.global.js +3 -3
- package/dist/seal.global.js.sha384 +1 -1
- package/dist/seal_crypto.wasm +0 -0
- package/dist/seal_crypto.wasm.sha384 +1 -1
- package/package.json +1 -1
package/dist/seal.global.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! sealnet
|
|
2
|
-
"use strict";var Seal=(()=>{var Ua=Object.create;var At=Object.defineProperty;var Fa=Object.getOwnPropertyDescriptor;var Ha=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,$a=Object.prototype.hasOwnProperty;var $n=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var za=(e,t)=>{for(var n in t)At(e,n,{get:t[n],enumerable:!0})},zn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ha(t))!$a.call(e,a)&&a!==n&&At(e,a,{get:()=>t[a],enumerable:!(r=Fa(t,a))||r.enumerable});return e};var Kn=(e,t,n)=>(n=e!=null?Ua(Wa(e)):{},zn(t||!e||!e.__esModule?At(n,"default",{value:e,enumerable:!0}):n,e)),Ka=e=>zn(At({},"__esModule",{value:!0}),e);var Ai={};za(Ai,{SealClient:()=>Mn,SealError:()=>K,VERSION:()=>Si});var be={url:"https://seal.net/sdk/v2.0.4/seal_crypto.wasm",integrity:"sha384-Ns+tIeOoczLFd8Cu9QLYM0jfXhqXKtwZ4DUGXDbpx4rvgBmPdduFWqlvTIZQz1Q7"};var Es={},Ya=Object.defineProperty,ja=(e,t)=>{for(var n in t)Ya(e,n,{get:t[n],enumerable:!0})},qn={};ja(qn,{WasmIdentity:()=>en,default:()=>ds,init:()=>Va,initSync:()=>cs,wasm_bundle_address:()=>qa,wasm_bundle_verify_for_address:()=>Xa,wasm_contract_message:()=>Za,wasm_ed25519_verify:()=>Ja,wasm_sealbox_unwrap:()=>Qa,wasm_sealbox_wrap:()=>es,wasm_unwrap_file_key:()=>ts,wasm_wrap_file_key:()=>ns});var en=class Tt{static __wrap(t){let n=Object.create(Tt.prototype);return n.__wbg_ptr=t,Gn.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Gn.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_wasmidentity_free(t,0)}address(){let t,n;try{let s=c.__wbindgen_add_to_stack_pointer(-16);c.wasmidentity_address(s,this.__wbg_ptr);var r=S().getInt32(s+0,!0),a=S().getInt32(s+4,!0);return t=r,n=a,Ue(r,a)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export2(t,n,1)}}bundle(){let t=c.wasmidentity_bundle(this.__wbg_ptr);return $(t)}static fromSeed32(t){try{let s=c.__wbindgen_add_to_stack_pointer(-16),o=ne(t,c.__wbindgen_export3),i=T;c.wasmidentity_fromSeed32(s,o,i);var n=S().getInt32(s+0,!0),r=S().getInt32(s+4,!0),a=S().getInt32(s+8,!0);if(a)throw $(r);return Tt.__wrap(n)}finally{c.__wbindgen_add_to_stack_pointer(16)}}static fromSeed64(t,n){try{let o=c.__wbindgen_add_to_stack_pointer(-16),i=ne(t,c.__wbindgen_export3),l=T;c.wasmidentity_fromSeed64(o,i,l,n);var r=S().getInt32(o+0,!0),a=S().getInt32(o+4,!0),s=S().getInt32(o+8,!0);if(s)throw $(a);return Tt.__wrap(r)}finally{c.__wbindgen_add_to_stack_pointer(16)}}inboxProof(t,n){try{let o=c.__wbindgen_add_to_stack_pointer(-16),i=ne(n,c.__wbindgen_export3),l=T;c.wasmidentity_inboxProof(o,this.__wbg_ptr,t,i,l);var r=S().getInt32(o+0,!0),a=S().getInt32(o+4,!0),s=S().getInt32(o+8,!0);if(s)throw $(a);return $(r)}finally{c.__wbindgen_add_to_stack_pointer(16)}}legacyAddress(){let t,n;try{let s=c.__wbindgen_add_to_stack_pointer(-16);c.wasmidentity_legacyAddress(s,this.__wbg_ptr);var r=S().getInt32(s+0,!0),a=S().getInt32(s+4,!0);return t=r,n=a,Ue(r,a)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export2(t,n,1)}}open(t,n,r){try{let i=c.__wbindgen_add_to_stack_pointer(-16),l=ne(t,c.__wbindgen_export3),d=T,p=oe(n,c.__wbindgen_export3,c.__wbindgen_export4),f=T,u=oe(r,c.__wbindgen_export3,c.__wbindgen_export4),_=T;c.wasmidentity_open(i,this.__wbg_ptr,l,d,p,f,u,_);var a=S().getInt32(i+0,!0),s=S().getInt32(i+4,!0),o=S().getInt32(i+8,!0);if(o)throw $(s);return $(a)}finally{c.__wbindgen_add_to_stack_pointer(16)}}signContract(t,n,r){try{let i=c.__wbindgen_add_to_stack_pointer(-16),l=oe(t,c.__wbindgen_export3,c.__wbindgen_export4),d=T,p=oe(n,c.__wbindgen_export3,c.__wbindgen_export4),f=T,u=oe(r,c.__wbindgen_export3,c.__wbindgen_export4),_=T;c.wasmidentity_signContract(i,this.__wbg_ptr,l,d,p,f,u,_);var a=S().getInt32(i+0,!0),s=S().getInt32(i+4,!0),o=S().getInt32(i+8,!0);if(o)throw $(s);return $(a)}finally{c.__wbindgen_add_to_stack_pointer(16)}}words(){let t,n;try{let s=c.__wbindgen_add_to_stack_pointer(-16);c.wasmidentity_words(s,this.__wbg_ptr);var r=S().getInt32(s+0,!0),a=S().getInt32(s+4,!0);return t=r,n=a,Ue(r,a)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export2(t,n,1)}}workloadProof(t,n){try{let o=c.__wbindgen_add_to_stack_pointer(-16),i=ne(t,c.__wbindgen_export3),l=T,d=ne(n,c.__wbindgen_export3),p=T;c.wasmidentity_workloadProof(o,this.__wbg_ptr,i,l,d,p);var r=S().getInt32(o+0,!0),a=S().getInt32(o+4,!0),s=S().getInt32(o+8,!0);if(s)throw $(a);return $(r)}finally{c.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(en.prototype[Symbol.dispose]=en.prototype.free);function Va(){c.init()}function qa(e){try{let a=c.__wbindgen_add_to_stack_pointer(-16),s=ne(e,c.__wbindgen_export3),o=T;c.wasm_bundle_address(a,s,o);var t=S().getInt32(a+0,!0),n=S().getInt32(a+4,!0),r=S().getInt32(a+8,!0);if(r)throw $(n);return $(t)}finally{c.__wbindgen_add_to_stack_pointer(16)}}function Xa(e,t){let n=ne(e,c.__wbindgen_export3),r=T,a=oe(t,c.__wbindgen_export3,c.__wbindgen_export4),s=T;return c.wasm_bundle_verify_for_address(n,r,a,s)!==0}function Za(e,t,n){let r,a;try{let f=c.__wbindgen_add_to_stack_pointer(-16),u=oe(e,c.__wbindgen_export3,c.__wbindgen_export4),_=T,h=oe(t,c.__wbindgen_export3,c.__wbindgen_export4),m=T,g=oe(n,c.__wbindgen_export3,c.__wbindgen_export4),M=T;c.wasm_contract_message(f,u,_,h,m,g,M);var s=S().getInt32(f+0,!0),o=S().getInt32(f+4,!0),i=S().getInt32(f+8,!0),l=S().getInt32(f+12,!0),d=s,p=o;if(l)throw d=0,p=0,$(i);return r=d,a=p,Ue(d,p)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export2(r,a,1)}}function Ja(e,t,n){let r=ne(e,c.__wbindgen_export3),a=T,s=ne(t,c.__wbindgen_export3),o=T,i=ne(n,c.__wbindgen_export3),l=T;return c.wasm_ed25519_verify(r,a,s,o,i,l)!==0}function Qa(e,t,n,r){try{let i=c.__wbindgen_add_to_stack_pointer(-16),l=ne(e,c.__wbindgen_export3),d=T,p=ne(t,c.__wbindgen_export3),f=T,u=oe(n,c.__wbindgen_export3,c.__wbindgen_export4),_=T,h=oe(r,c.__wbindgen_export3,c.__wbindgen_export4),m=T;c.wasm_sealbox_unwrap(i,l,d,p,f,u,_,h,m);var a=S().getInt32(i+0,!0),s=S().getInt32(i+4,!0),o=S().getInt32(i+8,!0);if(o)throw $(s);return $(a)}finally{c.__wbindgen_add_to_stack_pointer(16)}}function es(e,t,n,r){try{let i=c.__wbindgen_add_to_stack_pointer(-16),l=ne(e,c.__wbindgen_export3),d=T,p=ne(t,c.__wbindgen_export3),f=T,u=oe(n,c.__wbindgen_export3,c.__wbindgen_export4),_=T,h=oe(r,c.__wbindgen_export3,c.__wbindgen_export4),m=T;c.wasm_sealbox_wrap(i,l,d,p,f,u,_,h,m);var a=S().getInt32(i+0,!0),s=S().getInt32(i+4,!0),o=S().getInt32(i+8,!0);if(o)throw $(s);return $(a)}finally{c.__wbindgen_add_to_stack_pointer(16)}}function ts(e,t,n,r){try{let i=c.__wbindgen_add_to_stack_pointer(-16),l=ne(e,c.__wbindgen_export3),d=T,p=ne(t,c.__wbindgen_export3),f=T,u=oe(n,c.__wbindgen_export3,c.__wbindgen_export4),_=T,h=oe(r,c.__wbindgen_export3,c.__wbindgen_export4),m=T;c.wasm_unwrap_file_key(i,l,d,p,f,u,_,h,m);var a=S().getInt32(i+0,!0),s=S().getInt32(i+4,!0),o=S().getInt32(i+8,!0);if(o)throw $(s);return $(a)}finally{c.__wbindgen_add_to_stack_pointer(16)}}function ns(e,t,n,r){try{let i=c.__wbindgen_add_to_stack_pointer(-16),l=ne(e,c.__wbindgen_export3),d=T,p=ne(t,c.__wbindgen_export3),f=T,u=oe(n,c.__wbindgen_export3,c.__wbindgen_export4),_=T,h=oe(r,c.__wbindgen_export3,c.__wbindgen_export4),m=T;c.wasm_wrap_file_key(i,l,d,p,f,u,_,h,m);var a=S().getInt32(i+0,!0),s=S().getInt32(i+4,!0),o=S().getInt32(i+8,!0);if(o)throw $(s);return $(a)}finally{c.__wbindgen_add_to_stack_pointer(16)}}function Xn(){return{__proto__:null,"./seal_crypto_bg.js":{__proto__:null,__wbg___wbindgen_is_function_2f0fd7ceb86e64c5:function(t){return typeof W(t)=="function"},__wbg___wbindgen_is_object_5b22ff2418063a9c:function(t){let n=W(t);return typeof n=="object"&&n!==null},__wbg___wbindgen_is_string_eddc07a3efad52e6:function(t){return typeof W(t)=="string"},__wbg___wbindgen_is_undefined_244a92c34d3b6ec0:function(t){return W(t)===void 0},__wbg___wbindgen_throw_9c75d47bf9e7731e:function(t,n){throw new Error(Ue(t,n))},__wbg_call_a41d6421b30a32c5:function(){return st(function(t,n,r){let a=W(t).call(W(n),W(r));return J(a)},arguments)},__wbg_crypto_38df2bab126b63dc:function(t){let n=W(t).crypto;return J(n)},__wbg_error_a6fa202b58aa1cd3:function(t,n){let r,a;try{r=t,a=n,console.error(Ue(t,n))}finally{c.__wbindgen_export2(r,a,1)}},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return st(function(t,n){W(t).getRandomValues(W(n))},arguments)},__wbg_length_ba3c032602efe310:function(t){return W(t).length},__wbg_msCrypto_bd5a034af96bcba6:function(t){let n=W(t).msCrypto;return J(n)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return J(t)},__wbg_new_2fad8ca02fd00684:function(){let t=new Object;return J(t)},__wbg_new_from_slice_5a173c243af2e823:function(t,n){let r=new Uint8Array(Jt(t,n));return J(r)},__wbg_new_with_length_9011f5da794bf5d9:function(t){let n=new Uint8Array(t>>>0);return J(n)},__wbg_node_84ea875411254db1:function(t){let n=W(t).node;return J(n)},__wbg_process_44c7a14e11e9f69e:function(t){let n=W(t).process;return J(n)},__wbg_prototypesetcall_fd4050e806e1d519:function(t,n,r){Uint8Array.prototype.set.call(Jt(t,n),W(r))},__wbg_randomFillSync_6c25eac9869eb53c:function(){return st(function(t,n){W(t).randomFillSync($(n))},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return st(function(){let t=module.require;return J(t)},arguments)},__wbg_set_5337f8ac82364a3f:function(){return st(function(t,n,r){return Reflect.set(W(t),W(n),W(r))},arguments)},__wbg_stack_3b0d974bbf31e44f:function(t,n){let r=W(n).stack,a=oe(r,c.__wbindgen_export3,c.__wbindgen_export4),s=T;S().setInt32(t+4,s,!0),S().setInt32(t+0,a,!0)},__wbg_static_accessor_GLOBAL_THIS_1c7f1bd6c6941fdb:function(){let t=typeof globalThis>"u"?null:globalThis;return vt(t)?0:J(t)},__wbg_static_accessor_GLOBAL_e039bc914f83e74e:function(){let t=typeof global>"u"?null:global;return vt(t)?0:J(t)},__wbg_static_accessor_SELF_8bf8c48c28420ad5:function(){let t=typeof self>"u"?null:self;return vt(t)?0:J(t)},__wbg_static_accessor_WINDOW_6aeee9b51652ee0f:function(){let t=typeof window>"u"?null:window;return vt(t)?0:J(t)},__wbg_subarray_fbe3cef290e1fa43:function(t,n,r){let a=W(t).subarray(n>>>0,r>>>0);return J(a)},__wbg_versions_276b2795b1c6a219:function(t){let n=W(t).versions;return J(n)},__wbindgen_cast_0000000000000001:function(t,n){let r=Jt(t,n);return J(r)},__wbindgen_cast_0000000000000002:function(t,n){let r=Ue(t,n);return J(r)},__wbindgen_object_clone_ref:function(t){let n=W(t);return J(n)},__wbindgen_object_drop_ref:function(t){$(t)}}}}var Gn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>c.__wbg_wasmidentity_free(e,1));function J(e){it===ke.length&&ke.push(ke.length+1);let t=it;return it=ke[t],ke[t]=e,t}function rs(e){e<1028||(ke[e]=it,it=e)}function Jt(e,t){return e=e>>>0,Ye().subarray(e/1,e/1+t)}var Me=null;function S(){return(Me===null||Me.buffer.detached===!0||Me.buffer.detached===void 0&&Me.buffer!==c.memory.buffer)&&(Me=new DataView(c.memory.buffer)),Me}function Ue(e,t){return ss(e>>>0,t)}var ot=null;function Ye(){return(ot===null||ot.byteLength===0)&&(ot=new Uint8Array(c.memory.buffer)),ot}function W(e){return ke[e]}function st(e,t){try{return e.apply(this,t)}catch(n){c.__wbindgen_export(J(n))}}var ke=new Array(1024).fill(void 0);ke.push(void 0,null,!0,!1);var it=ke.length;function vt(e){return e==null}function ne(e,t){let n=t(e.length*1,1)>>>0;return Ye().set(e,n/1),T=e.length,n}function oe(e,t,n){if(n===void 0){let i=lt.encode(e),l=t(i.length,1)>>>0;return Ye().subarray(l,l+i.length).set(i),T=i.length,l}let r=e.length,a=t(r,1)>>>0,s=Ye(),o=0;for(;o<r;o++){let i=e.charCodeAt(o);if(i>127)break;s[a+o]=i}if(o!==r){o!==0&&(e=e.slice(o)),a=n(a,r,r=o+e.length*3,1)>>>0;let i=Ye().subarray(a+o,a+r),l=lt.encodeInto(e,i);o+=l.written,a=n(a,r,o,1)>>>0}return T=o,a}function $(e){let t=W(e);return rs(e),t}var xt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});xt.decode();var as=2146435072,Qt=0;function ss(e,t){return Qt+=t,Qt>=as&&(xt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),xt.decode(),Qt=t),xt.decode(Ye().subarray(e,e+t))}var lt=new TextEncoder;"encodeInto"in lt||(lt.encodeInto=function(e,t){let n=lt.encode(e);return t.set(n),{read:e.length,written:n.length}});var T=0,os,is,c;function Zn(e,t){return is=e,c=e.exports,os=t,Me=null,ot=null,c}async function ls(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(a){if(e.ok&&n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",a);else throw a}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}function cs(e){if(c!==void 0)return c;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=Xn();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let n=new WebAssembly.Instance(e,t);return Zn(n,e)}async function ds(e){if(c!==void 0)return c;if(e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0)throw new Error("SEAL crypto: the WASM source must be passed to the loader");let t=Xn();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await ls(await e,t);return Zn(n,r)}var us="seal_crypto.wasm",xe=null,kt=null,Ge=null;function Jn(e){if(kt||Ge)throw new Error("configureWasm: the WASM is already loaded or loading");xe=e}function fs(){return typeof globalThis.process?.versions?.node=="string"}async function Yn(e){let t="node:fs/promises",{readFile:n}=await import(t);return n(e)}async function hs(){if(xe&&"url"in xe)return fetch(xe.url,xe.integrity?{integrity:xe.integrity}:{});if(xe&&"path"in xe)return Yn(xe.path);if(fs())return Yn(new URL(us,Es.url));throw new Error("sealnet: no WASM source in this browser (a broken build — reinstall sealnet)")}async function Fe(){if(kt)return kt;if(Ge)return Ge;Ge=(async()=>{let e=qn;return await e.default({module_or_path:await hs()}),typeof e.init=="function"&&e.init(),kt=e,e})();try{return await Ge}catch(e){throw Ge=null,e}}async function ps(e){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),n=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(n)}async function je(e){let t=await ps(e);return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("")}var jn=32768,Vn=class extends Error{constructor(e,t){super(e),this.input=t,this.name="Base64DecodeError"}};function ys(e){let t="";for(let n=0;n<e.length;n+=jn){let r=e.subarray(n,Math.min(n+jn,e.length));t+=String.fromCharCode.apply(null,r)}return t}function _s(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function ws(e){let t=e.substring(0,20)+(e.length>20?"...":"");if(typeof atob<"u")try{return atob(e)}catch(n){throw new Vn(`Invalid base64 encoding: ${n.message}`,t)}try{return Buffer.from(e,"base64").toString("binary")}catch(n){throw new Vn(`Invalid base64 encoding: ${n.message}`,t)}}function gs(e){return typeof btoa<"u"?btoa(e):Buffer.from(e,"binary").toString("base64")}function bs(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4;return t+="=".repeat(n),t}function ms(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ie(e){return gs(ys(e))}function Q(e){return ms(Ie(e))}function It(e){return _s(ws(e))}function V(e){return It(bs(e))}function Ss(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rt(e,...t){if(!Ss(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function tn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Qn(e,t){Rt(e);let n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function ct(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Pt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function me(e,t){return e<<32-t|e>>>t}function As(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function nn(e){return typeof e=="string"&&(e=As(e)),Rt(e),e}var Ot=class{};function er(e){let t=r=>e().update(nn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function vs(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);let a=BigInt(32),s=BigInt(4294967295),o=Number(n>>a&s),i=Number(n&s),l=r?4:0,d=r?0:4;e.setUint32(t+l,o,r),e.setUint32(t+d,i,r)}function tr(e,t,n){return e&t^~e&n}function nr(e,t,n){return e&t^e&n^t&n}var Lt=class extends Ot{constructor(t,n,r,a){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=a,this.buffer=new Uint8Array(t),this.view=Pt(this.buffer)}update(t){tn(this),t=nn(t),Rt(t);let{view:n,buffer:r,blockLen:a}=this,s=t.length;for(let o=0;o<s;){let i=Math.min(a-this.pos,s-o);if(i===a){let l=Pt(t);for(;a<=s-o;o+=a)this.process(l,o);continue}r.set(t.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===a&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){tn(this),Qn(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:a,isLE:s}=this,{pos:o}=this;n[o++]=128,ct(this.buffer.subarray(o)),this.padOffset>a-o&&(this.process(r,0),o=0);for(let f=o;f<a;f++)n[f]=0;vs(r,a-8,BigInt(this.length*8),s),this.process(r,0);let i=Pt(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=l/4,p=this.get();if(d>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<d;f++)i.setUint32(4*f,p[f],s)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:r,length:a,finished:s,destroyed:o,pos:i}=this;return t.destroyed=o,t.finished=s,t.length=a,t.pos=i,a%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}},Oe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Ts=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Be=new Uint32Array(64),rn=class extends Lt{constructor(t=32){super(64,t,8,!1),this.A=Oe[0]|0,this.B=Oe[1]|0,this.C=Oe[2]|0,this.D=Oe[3]|0,this.E=Oe[4]|0,this.F=Oe[5]|0,this.G=Oe[6]|0,this.H=Oe[7]|0}get(){let{A:t,B:n,C:r,D:a,E:s,F:o,G:i,H:l}=this;return[t,n,r,a,s,o,i,l]}set(t,n,r,a,s,o,i,l){this.A=t|0,this.B=n|0,this.C=r|0,this.D=a|0,this.E=s|0,this.F=o|0,this.G=i|0,this.H=l|0}process(t,n){for(let f=0;f<16;f++,n+=4)Be[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){let u=Be[f-15],_=Be[f-2],h=me(u,7)^me(u,18)^u>>>3,m=me(_,17)^me(_,19)^_>>>10;Be[f]=m+Be[f-7]+h+Be[f-16]|0}let{A:r,B:a,C:s,D:o,E:i,F:l,G:d,H:p}=this;for(let f=0;f<64;f++){let u=me(i,6)^me(i,11)^me(i,25),_=p+u+tr(i,l,d)+Ts[f]+Be[f]|0,m=(me(r,2)^me(r,13)^me(r,22))+nr(r,a,s)|0;p=d,d=l,l=i,i=o+_|0,o=s,s=a,a=r,r=_+m|0}r=r+this.A|0,a=a+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,l=l+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(r,a,s,o,i,l,d,p)}roundClean(){ct(Be)}destroy(){this.set(0,0,0,0,0,0,0,0),ct(this.buffer)}};var Bt=er(()=>new rn);var he={version:2,name:"AEON",magic_bytes:[65,69,79,52],magic_length:4,header_length:24,header_layout:[{name:"magic",offset:0,length:4},{name:"segment_size_u32_le",offset:4,length:4},{name:"file_id",offset:8,length:16}],nonce_length:12,tag_length:16,segment_overhead:28,segment_size_bytes:1048576,min_segment_size_bytes:1048576,max_segment_size_bytes:67108864,aad_layout:[{name:"header",length:24},{name:"segment_index_u64_le",length:8},{name:"last_u8",length:1}],supported_format_versions:[3,4],current_format_version:4,v3_reader:{magic_bytes:[65,69,79,78],header_length:8}},hn=new Uint8Array(he.magic_bytes),Mt=he.magic_length,De=he.header_length,Ve=he.nonce_length,pn=he.tag_length,xr=he.segment_overhead,Kt=he.segment_size_bytes,rr=he.min_segment_size_bytes,ar=he.max_segment_size_bytes,ft=he.header_layout.find(e=>e.name==="file_id"),sr=he.aad_layout.reduce((e,t)=>e+t.length,0),kr=new Uint8Array(he.v3_reader.magic_bytes),Ir=he.v3_reader.header_length;function xs(e){return Ve+e+pn}function yn(e){let t=Math.max(1,Math.ceil(e/Kt));return De+t*xr+e}function ks(){let e=new Uint8Array(De);return e.set(hn,0),new DataView(e.buffer).setUint32(Mt,Kt,!0),e.set(crypto.getRandomValues(new Uint8Array(ft.length)),ft.offset),e}function Ut(e,t){return e.length>=t.length&&t.every((n,r)=>e[r]===n)}function Or(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(Mt,!0);if(t<rr||t>ar)throw new Error(`segment size ${t} is outside ${rr}\u2026${ar}`);return t}function Rr(e){if(e.length<De)throw new Error(`an AEON v4 header is ${De} bytes, got ${e.length}`);if(!Ut(e,hn))throw new Error("not an AEON v4 header");return{segmentSize:Or(e),fileId:e.slice(ft.offset,ft.offset+ft.length)}}function Is(e){if(e.length<Ir||!Ut(e,kr))throw new Error("not an AEON v3 header");return{segmentSize:Or(e)}}function Os(e){return Ut(e,hn)?"v4":Ut(e,kr)?"v3":null}function Pr(e,t,n){let r=new Uint8Array(sr);return r.set(e.subarray(0,De),0),new DataView(r.buffer).setBigUint64(De,BigInt(t),!0),r[sr-1]=n?1:0,r}function Rs(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Lr(e){return crypto.subtle.importKey("raw",Rs(e),{name:"AES-GCM"},!1,["encrypt","decrypt"])}async function Ps(e,t,n){let r=crypto.getRandomValues(new Uint8Array(Ve)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:r,tagLength:pn*8,additionalData:n},e,t),s=new Uint8Array(Ve+a.byteLength);return s.set(r,0),s.set(new Uint8Array(a),Ve),s}async function Ls(e,t,n){let r={name:"AES-GCM",iv:t.subarray(0,Ve),tagLength:pn*8};return n&&(r.additionalData=n),new Uint8Array(await crypto.subtle.decrypt(r,e,t.subarray(Ve)))}function Bs(){return Bt.create()}async function ht(){let e=globalThis.scheduler;return typeof e?.yield=="function"?e.yield():typeof MessageChannel<"u"?new Promise(t=>{let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(null)}):new Promise(t=>setTimeout(t,0))}function Ns(){return crypto.getRandomValues(new Uint8Array(32))}var ze={version:1,limits:{MAX_FILES_PER_SEAL:30,FREE_TIER_BYTES:1073741824,MAX_TOTAL_SIZE_BYTES:1073741824,MAX_FILE_SIZE_BYTES:10737418240,MAX_MULTIPART_FILE_SIZE_BYTES:10737418240,MAX_BLOB_SIZE:1048576,MAX_BLOB_BASE64_SIZE:1468006,MAX_MESSAGE_LENGTH:5e3,MAX_FILE_KEYS:1e4,MAX_ACTIVE_UPLOADS_PER_SEAL:10,MAX_OPENS_PER_SEAL_FREE:10,TIER_BYTES:{free:1073741824,"5gb":5368709120,"50gb":53687091200,"500gb":536870912e3},SEAL_TIERS:{"5gb":{bytes:5368709120,amount_cents:900,duration_days:90,name:"5 GB / 3 months",description:"One-time payment for 5 GB storage and 3 months TTL"},"50gb":{bytes:53687091200,amount_cents:2900,duration_days:180,name:"50 GB / 6 months",description:"One-time payment for 50 GB storage and 6 months TTL"},"500gb":{bytes:536870912e3,amount_cents:9900,duration_days:365,name:"500 GB / 12 months",description:"One-time payment for 500 GB storage and 12 months TTL"}},PRO_REGIONS:["eu-west","us-east","us-west","apac-southeast","apac-northeast"],ttl_options:["5m","30m","1h","1d","7d"],OTP_LENGTH:{min:6,max:10},USER_PASSWORD_MIN_LENGTH:8,INTAKE_TTL_DEFAULT_SECONDS:900,INTAKE_TTL_MAX_SECONDS:86400,INTAKE_WAIT_MAX_SECONDS:25,PAYMENT_WAIT_MAX_SECONDS:82800,ADDRESS_PROOF_TTL_SECONDS:300,INBOX_MAX_ITEMS:200,DRIVE_OPEN_TTL_SECONDS:300,DRIVE_PRESIGN_WINDOW_DEFAULT_BYTES:67108864,DRIVE_PRESIGN_WINDOW_MIN_BYTES:8388608,DRIVE_PRESIGN_UNBOUND_TTL_SECONDS:30,DRIVE_WRITE_LEASE_SECONDS:7200,DRIVE_WRITE_BACK_SECONDS:5,VERSION_RETENTION_DAYS_DEFAULT:30,VERSION_KEEP_MIN:10,GRANT_WORKLOAD_MAX_TTL_DAYS:90,SENSOR_OPENS_PER_MINUTE_DEFAULT:120,SENSOR_BYTES_PER_MINUTE_DEFAULT:2147483648,SENSOR_SECRETS_PER_MINUTE_DEFAULT:20,SENSOR_NOVELTY_WINDOW_DAYS:30,SENSOR_HOLD_TTL_SECONDS:86400,SENSOR_BASELINE_MIN_HOURS:72,SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT:107374182400}},Pe={version:2,$comment:"Address of a bundle: who a seal is for, without a URL (SPEC-AEON-V4 \xA75). Numbers live in limits.json, error codes in error_codes.json, the bundle and the wrap in crypto.json (keybundle, sealed_box_v2).",address:{of:"SHA-256 of the identity key (Ed25519) of the bundle v2, 32 bytes",text:"base64url without padding, 43 characters",words:"fingerprint_words.json over the first three bytes of the address: the words of SHA-256(identity key), named without hashing again",inbox:"the 32 bytes of the address are the key the server finds an inbox by"},box_origin:"https://box.seal.net",seed:{env:"SEAL_SEED",text:"base64url without padding of the 32-byte seed of an agent, a device or an inbox, 43 characters",derives:"the agreement key (X25519) is the seed itself; the identity key (Ed25519) and the ML-KEM-768 key are HKDF of the seed (crypto.json hkdf.identity_key_salt, info_prefixes workload_identity and kem_mlkem768) \u2014 together the bundle v2 the address names",same_as:["sealnet-mcp state.identity.x25519_secret_b64","seal identity.v1.json x25519_secret_b64url","sealnet (npm) KeyPair.secretKey","sealnet (PyPI) keygen().secret_key"]},bundles:{put:"PUT /intake/bundles {bundle}: bundle is base64url of the packed bundle (crypto.json keybundle.packed_length). The server verifies it with the core and files it under the address it computes; no authorization \u2014 the bundle proves itself \u2014 and a limit per IP",get:"GET /intake/bundles/{address} -> {bundle}; 404 intake.bundle_not_found",accept:"a sender takes a bundle only if SHA-256 of its identity key is the address and its signature verifies; a client puts its own bundle at its first start and again whenever it is gone"},scopes:{share_link:"seal_share",owner_copy:"seal_owner"},proof:{header_address:"X-Seal-Address",header_proof:"X-Seal-Proof",challenge:"POST /intake/proof {address} -> {ts, challenge}: challenge = base64url(HMAC(server key, address(32) || ts u64 BE)), 43 characters; the server keeps no state",message:'"seal:inbox-proof:v2" || address(32) || ts u64 BE || challenge(32), signed with the identity key of the address; the core builds it (Identity::inbox_proof)',proof_text:"<ts>.<challenge>.<signature>: ts the decimal Unix second of the challenge, challenge as received, signature base64url of 64 bytes",check:"the window, the HMAC, and the signature against the bundle of the address with a small-order key refused"},items:{delivery:{id:"s.<seal_id>.<share_code>",is:"a share link addressed to this address: path /s/<seal_id>/<share_code> without a fragment; fragment = its key wrapped to the address's bundle (sealed box v2, scope share_link)"},owner:{id:"o.<seal_id>",is:"the seal's owner-blob key wrapped to the address's bundle (sealed box v2, scope owner_copy); path /s/<seal_id> opens the seal page, the only place that manages a seal"},request:{id:"r.<intake_id>",is:"a request asked of this address; path /i/<intake_id>, no fragment; carries what, kind and recipient_bundle"},listing:"GET /intake?to= lists deliveries only, as before owner copies and cards existed; `all=1` adds owner and request items (a person's inbox). Agent clients never send it: those rows are a person's."},request:{recipient_bundle:"POST /intake carries recipient_bundle, base64url of the requester's packed bundle; the page verifies it and shows the three words of its address, the answer's key is wrapped to it (scope share_link) and comes back as the request's fragment, with share_path without a fragment"},owner_copy:{web_label:"seal.net",is:"The seal names the inbox that manages it: its row carries the owner-blob key wrapped to that address's bundle, one per seal, written with the owner blob (PATCH /seal/{id}/blob with to, fragment, label) before the first byte of the files. Best effort: an address without a bundle is the same PATCH without the address part, and the seal is made anyway."},request_kinds:["secret","file","any","pair","device"],pair_what:"inbox",payloads:{name_max:80,pair:{mime:"application/vnd.seal.pairing+json",json:`{"v":2,"bundle":"<the inbox's packed bundle, base64url, 1755>","name":"<inbox name, at most name_max>"}`},device:{mime:"application/vnd.seal.device+json",json:'{"v":2,"seed":"<inbox seed, 43>","name":"<inbox name>","agents":[{"address":"<43>","name":"<name>","paired_at":"<ISO 8601>"}]}'}},device_link:{code:"8 Crockford base32 characters from 5 random bytes",what:"base64url(HMAC-SHA256(key = the code in ASCII, message = the 32-byte address of the new device)), 43 characters: the what of the device request",link:"https://box.seal.net/#link=<address>.<code>"},bridge:{path:"/bridge",is:"A hidden iframe of box_origin on seal.net; postMessage only between the two origins. It never gives out the address or the name: it answers any script of seal.net.",hello:"box.hello {sealId?} -> {box: boolean, has: boolean}; box: this device has an inbox; has: this seal is already in Yours",owner_copy:"box.ownerCopy {sealId, ownerToken, linkKey} -> {ok: boolean}"},migrate:{until:"C1 + 7 days (C1 \xA76)",is:"Every inbox and agent changes its address once (\xA75.7). The X25519 key does not change \u2014 it is the seed \u2014 so the client moves the live rows of its old address once, under the proof of its new one: POST /intake/migrate {old_address} answers the old challenge, {old_address, old_proof} moves links, owner copies, cards and push subscriptions; the agreement key of the new address's bundle must equal the old address, and the senders of moved rows are cleared. Zero rows is a success.",old_address:"the X25519 public key of the seed, base64url without padding, 43 characters",challenge:"sealed box v1 of a 32-byte token to the old address with scope (address_proof, decimal ts): ephemeral_pub(32) || nonce(12) || ciphertext(48), base64url, 123 characters",old_proof:"<ts>.<token>: token base64url of the 32 bytes the challenge opens to",scope_address_proof:"seal_address_proof",vector:{comment:"every client that migrates must open it",secret:"BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc",address:"E75P6uryBMf9M1j8nAByGIHRdCeBKCJ-xnTzf3_pe20",ts:179e7,challenge:"4Oel-UMfgP_1dBhmf13yZiujhPDouCIQ6sSx1nY1qy-vyzFqDqb9jARbJ0e5A8vv4EDELDS5OPqBQMcsmDA-C_lXO95y_CVUyYtSu-1fltsy5ZihOFDp0T-C9Ro",token:"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8"}},vectors:[{address:"Afdcc-OkgjU572_xdbUHZSNPO6r6Up6ctP2pfF0PHJw",bundle:"4rFhOdoKNSNI9qMxGju3FssbOjE0YN8CnitU4OD4dW4Eun0cCRx-W2Ad-PsAyD8R9LVv_v5mxs08kUEG5VurbwtRz7BXT4NoZoZytUXshnRVuBnjT3nghVcGmLLCpUi4qVzBsZOkO3e7tBbmAHsnDDF1eEPkjS0zQ6s6mkmFbHQnANoFXUnSM6ESOpPMmi11pv4QE9XYRpj2C_5JzmFXWLiYTA3pucRjUgPZkSmgp38RGRWZbcpsexeMmmJCdEolY52MoQaJesxJYRPgzlMSa9YnEICxfr8Xuwkgpxw3ucOxMolUXQKUBToGfUUxtC7BHrq2W3wEcF4LJaFytD44qdW2Ze0LSf8IlsESZWj6YbLabL25FAwmGntZKHQ7LDK7C4ZXsNVioS9yDNh1ADaqdTqGZnPlDaI2HiDCGVMzVTOQRvt6BZWKSUNrudd7t-2JxyUCWFk5szNrcUVJwsBrNdIXm_04iuvbcW-4s-kmXmX6CStgPdZSVgFgcAOQwsOwU57zjoA0pehUqiLwaHbLu0Z5poD1agnppIXItFLhVkRDExOHF7KxUD70CEJjUrHxxf0ln4H1S1t3udfFTA11SjBYXsTxq0VIMDoTnXzYenHLWXpYwDlogzagyb1UXfprRkNgbssmd9xyw_aKz2AWjAdqpeAmIwVbnlfcxA-0MixZpVtkpSyZeXhwAPf8Q0raFNESLbJSBx1GStgiNzNkf553RC0JCLXITOw6YHuyQKF8y05gFwXTjJ0hBwUgTEQVJt71miJ8N7asYFDrAVSWm7t0qA55RobkTdnBliKCCjrnKxGET5M0sPrlyC3yTUu3fHrpEDRqiN8yFZRpD9QBXtaorIM8b6XcVAWJFKjauhn5tC4RAJDEi384o_NQAg0WowA3UuJ0LFg5ELRGQuZCrP_RVIHGAR5lcOeSY9SzW-dmp-MbsfSWf_iBEkYsc_iFTwkTf3M5Thd4TSJxwJ9odRS0LqRZgrgEWcYYl5PalYYrBHqhsMiAshpzibQLTPbQh1CUMTLMIrorvqVbhdZovQmSdShIWLTmkhWJGN_seAfnQNFhufXlg2dsNSGZCdcivn_VfKUHFpm8DOHRCqWcdwcrw7K3gtPgTC2GQvSJxAH6pq5hshTKCqF6mtFiA2-FbjYwDhRskt8Mf15IkQWDCI2LNDnJLg6qPMbaMxUEyWd7N1QWmHNgtU9syAMLhVHsHlohPq8ZdygIRIw6IjbFR0EDb8jYhY1DQUc3WWLQX_AsdMwHNgeRzhlcd2fohE5BzB_Lb3V1NpmsMPe2FhmGD8b3Pb-1ZR-MtJD6tgq1YSs7JOeWjKETlN2YqCaIFCeRWUIygkpbF158x4lVqqgQQZ70kzXsJTWJZbY5mvXHbAUsWLezERn4hWWKau_Mno78GTRKZfO5ymbWl4Hku8ECskl3dL8oy5hAOGhGcGOyhDLXISTTZL3JQ2Qwy0X7AfqDIQCTnuCLa3_AhIsjMXFzB-rCq8WjUsh4YsW1ENBJjV_2G6-HWRVDpo6nIDVnZRGxATTCvnLjXcn0USEXsBI6R6aAcgqGXzabd_QyLpK2EdUnaH3xIWjGYsdRjIuUWQM3odyjH7TFOurwlQV3hU2KMmAO13XqmD5fvhxVi5-kWTnN16EDDV0EXLky4Jug0SNgHchy3ymbXVBx8TfsJcCumYk9iuui2D-cDpa7KJEGwBVN-9lvLEidQddWX_CMfbmG_wdHaC4Hapi-U2OhsH-2AwEAAAA",challenge:"wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t8",comment:"generated once by shared/core (Identity::from_seed32, Identity::inbox_proof); every client must reproduce it",legacy_address:"BLp9HAkcfltgHfj7AMg_EfS1b_7-ZsbNPJFBBuVbq28",proof:"1790000000.wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t8.74s5T1rE2xRNbameeTbYUHVMN-ZzFu1JBPZJNtH8eYC1vV7-h2HE_hxgo4vUB0_sHFfdYRUf0bve4_KGe32ICg",seed:"Aw4ZJC86RVBbZnF8h5KdqLO-ydTf6vUACxYhLDdCTVg",signature:"74s5T1rE2xRNbameeTbYUHVMN-ZzFu1JBPZJNtH8eYC1vV7-h2HE_hxgo4vUB0_sHFfdYRUf0bve4_KGe32ICg",ts:179e7,words:"album wren hedge"}]},Ds="X-Seal-Client",P={version:1,upload:{DEFAULT_PART_SIZE_BYTES:16777216,S3_MIN_PART_SIZE_BYTES:5242880,MAX_PART_SIZE_BYTES:268435456,MULTIPART_THRESHOLD_BYTES:8388608,FINE_PART_SIZE_BYTES:8388608,FINE_PART_MAX_FILE_BYTES:536870912,INMEMORY_BLOB_LIMIT_BYTES:104857600,MULTIPART_UPLOAD_TTL_SECONDS:86400,PRESIGN_BATCH_SIZE:100,SMALL_FILE_POOL:4,PART_POOL_MIN:2,PART_POOL_START:2,PART_POOL_MAX:5,PART_POOL_GROW_RATIO:1.15,PART_POOL_SHRINK_RATIO:.7,PART_QUEUE_LIMIT:2,HEDGE_MIN_INFLIGHT_MS:3e3,HEDGE_LAG_FACTOR:3,HEDGE_POLL_MS:1e3,LIVENESS_SILENCE_MS:3e4,RETRY_BACKOFF_MS:[1e3,3e3,7e3,15e3,3e4],RETRY_JITTER_RATIO:.2,STALL_NOTICE_MS:3e4,MAX_STALL_MS:6e5,PUT_FLOOR_BYTES_PER_SECOND:20480,PUT_MIN_DEADLINE_MS:3e4,CONTROL_TIMEOUT_MS:3e4,COMPLETE_TIMEOUT_MS:12e4,VERIFY_POLL_BACKOFF_MS:[0,2e3,3e3,5e3,8e3],VERIFY_FALLBACK_WAIT_MS:6e4,NOT_READY_MAX_RETRIES:3,PROGRESS_SPEED_WINDOW_MS:2e4}},ln;function Br(e,t){ln=`${e}/${t}`}function Nr(){return ln===void 0?{}:{[Ds]:ln}}var ce=class extends Error{constructor(e,t,n,r={}){super(e),this.name="BackendError",this.code=t,this.status=n,this.body=r.body,this.detail=r.detail,this.appCode=r.appCode,this.retryAfter=r.retryAfter,this.update=r.update,this.minVersion=r.minVersion}};function Cs(e){return e===404?"not_found":e===410?"revoked":e===429?"rate_limited":e===401||e===403?"auth":e>=500&&e<600?"transient":"unknown"}async function Dr(e,t){let n=await e.text().catch(()=>""),r,a,s,o,i;if(n)try{let l=JSON.parse(n);typeof l?.detail=="string"&&(r=l.detail),typeof l?.code=="string"&&(a=l.code),typeof l?.retry_after=="number"&&(s=l.retry_after),typeof l?.update=="string"&&(o=l.update),typeof l?.min_version=="string"&&(i=l.min_version)}catch{}return new ce(r??t,Cs(e.status),e.status,{body:n||void 0,detail:r,appCode:a,retryAfter:s,update:o,minVersion:i})}function Ms(e){return{id:e.id,expiresAt:e.expires_at,revokedAt:e.revoked_at,ndaRequired:e.nda_required,otpRequired:e.otp_required,singleUse:e.single_use,maxOpens:e.max_opens??null,files:(e.files??[]).map(t=>({id:t.id,size:t.size,sha256_hex:t.sha256_hex,name_encrypted:t.name_encrypted,name_nonce:t.name_nonce,mime_encrypted:t.mime_encrypted,mime_nonce:t.mime_nonce}))}}function q(e){return encodeURIComponent(e)}var yt=class ye{constructor(t){if(this.baseUrl=t.baseUrl.replace(/\/+$/,""),typeof(t.fetch??globalThis.fetch)!="function")throw new Error("SealApi: no global fetch in this runtime \u2014 pass options.fetch or use Node >= 18");this.injectedFetch=t.fetch,this.credentials=t.credentials}fetchImpl(t,n){return(this.injectedFetch??globalThis.fetch).call(globalThis,t,n)}url(t){if(!t.startsWith("/"))throw new Error(`SealApi: path must start with '/', got: ${t}`);return`${this.baseUrl}${t}`}async request(t,n){let{what:r,...a}=n,s=await this.fetchImpl(this.url(t),{...a,headers:{...Nr(),...a.headers},credentials:a.credentials??this.credentials});if(!s.ok)throw await Dr(s,`${r} failed: ${s.status}`);return s}static ownerHeaders(t,n=!1){let r={"X-Owner-Token":t};return n&&(r["Content-Type"]="application/json"),r}async getMetadata(t,n={}){return await(await this.request(`/seal/${q(t)}`,{what:`GET /seal/${t}`,signal:n.signal})).json()}async getShareBlob(t,n,r={}){let a=`GET /seal/${t}/share/${n}`,s=await this.request(`/seal/${q(t)}/share/${q(n)}`,{what:a,signal:r.signal}),o=await s.json();return{blob:lr(o,a,s.status),wrap:typeof o.fragment=="string"&&o.fragment?o.fragment:null}}async verifyOtp(t,n,r={}){let a={code:n.code};n.fileId&&(a.file_id=n.fileId),n.shareCode&&(a.share_code=n.shareCode);let s=await this.request(`/seal/${q(t)}/otp`,{what:`POST /seal/${t}/otp`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:r.signal}),o=Hs(s,`otp_${t}`),i=await s.json().catch(()=>({}));return{status:typeof i.status=="string"?i.status:"ok",sessionCookie:o}}async acceptNda(t,n,r={}){let a={signature:n.signature,timestamp:n.timestamp,first_name:n.firstName,last_name:n.lastName};n.company&&(a.company=n.company),n.fileId&&(a.file_id=n.fileId),n.shareCode&&(a.share_code=n.shareCode),n.ndaText&&(a.nda_text=n.ndaText);let o=await(await this.request(`/seal/${q(t)}/nda`,{what:`POST /seal/${t}/nda`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:r.signal})).json().catch(()=>({}));return{status:typeof o.status=="string"?o.status:"ok"}}downloadUrl(t,n){return this.url(`/seal/${q(t)}/download?${or(n)}`)}async openDownload(t,n,r={}){let a=n.ownerToken?ye.ownerHeaders(n.ownerToken):{};n.sessionCookie&&(a.Cookie=n.sessionCookie);for(let s=0;;s++)try{return await this.request(`/seal/${q(t)}/download?${or(n)}`,{what:`GET /seal/${t}/download?file_id=${n.fileId}`,headers:a,signal:r.signal})}catch(o){if(!(o instanceof ce&&o.appCode==="file.not_ready"&&r.retryNotReady!==!1&&s<P.upload.NOT_READY_MAX_RETRIES))throw o;await Fs((o.retryAfter??Us)*1e3,r.signal)}}async getOwnerSeal(t,n,r={}){return await(await this.request(`/seal/${q(t)}/owner`,{what:`GET /seal/${t}/owner`,headers:ye.ownerHeaders(n),signal:r.signal})).json()}async readOwnerBlob(t,n={}){let r=await this.request(`/seal/${q(t)}/blob`,{what:`GET /seal/${t}/blob`,signal:n.signal}),a=r.headers.get("ETag");return{blob:lr(await r.json(),`GET /seal/${t}/blob`,r.status),etag:a}}async writeOwnerBlob(t,n,r,a={}){let s=ye.ownerHeaders(n,!0);a.ifMatch&&(s["If-Match"]=a.ifMatch);let o={encrypted_blob:r};return ir(a,o,s),{etag:(await this.request(`/seal/${q(t)}/blob`,{what:`PATCH /seal/${t}/blob`,method:"PATCH",headers:s,body:JSON.stringify(o),signal:a.signal})).headers.get("ETag")}}async createShareLink(t,n,r,a={}){let s=n===null?{"Content-Type":"application/json"}:ye.ownerHeaders(n,!0),o={encrypted_blob:r};a.fileIds&&(o.file_ids=a.fileIds),ir(a,o,s);let i=await this.request(`/seal/${q(t)}/share`,{what:`POST /seal/${t}/share`,method:"POST",headers:s,body:JSON.stringify(o),signal:a.signal}),l=await i.json();if(typeof l.share_code!="string"||!l.share_code)throw new ce(`POST /seal/${t}/share returned no share_code`,"unknown",i.status);return l.share_code}async revokeShareLink(t,n,r,a={}){await this.request(`/seal/${q(t)}/share/${q(n)}/revoke`,{what:`POST /seal/${t}/share/${n}/revoke`,method:"POST",headers:r===null?{}:ye.ownerHeaders(r),signal:a.signal})}async revoke(t,n,r={}){let a;try{a=await this.request(`/seal/${q(t)}/revoke`,{what:`POST /seal/${t}/revoke`,method:"POST",headers:ye.ownerHeaders(n),signal:r.signal})}catch(o){if(o instanceof ce&&(o.status===404||o.status===410))return{status:"revoked",revokedAt:null};throw o}let s=await a.json().catch(()=>({}));return{status:typeof s.status=="string"?s.status:"revoked",revokedAt:typeof s.revoked_at=="string"?s.revoked_at:null}}async revokeFile(t,n,r,a={}){await this.request(`/seal/${q(t)}/files/${q(n)}/revoke`,{what:`POST /seal/${t}/files/${n}/revoke`,method:"POST",headers:ye.ownerHeaders(r),signal:a.signal})}async getAudit(t,n,r={}){return await(await this.request(`/seal/${q(t)}/audit`,{what:`GET /seal/${t}/audit`,headers:ye.ownerHeaders(n),signal:r.signal})).json()}async openAuditDownload(t,n,r={}){return this.request(`/seal/${q(t)}/audit/download`,{what:`GET /seal/${t}/audit/download`,headers:ye.ownerHeaders(n),signal:r.signal})}async createSubscription(t,n,r={},a={}){let s=await this.request(`/seal/${q(t)}/subscriptions`,{what:`POST /seal/${t}/subscriptions`,method:"POST",headers:ye.ownerHeaders(n,!0),body:JSON.stringify(r.reference?{reference:r.reference}:{}),signal:a.signal}),o=await s.json();if(typeof o.id!="string"||typeof o.secret!="string")throw new ce(`POST /seal/${t}/subscriptions returned no subscription`,"unknown",s.status);return{id:o.id,secret:o.secret}}async createCheckout(t,n,r,a={}){let s=await this.request("/billing/checkout",{what:"POST /billing/checkout",method:"POST",headers:ye.ownerHeaders(n,!0),body:JSON.stringify({seal_id:t,tier:r}),signal:a.signal}),o=await s.json();if(typeof o.url!="string"||!o.url)throw new ce("POST /billing/checkout returned no url","unknown",s.status);return o.url}async createIntake(t,n={}){let r={recipient_bundle:t.recipientBundle,label:t.label,what:t.what,kind:t.kind??"any"};return t.whereUrl&&(r.where_url=t.whereUrl),t.ttlSeconds!==void 0&&(r.ttl_seconds=t.ttlSeconds),t.to&&(r.to=t.to),await(await this.request("/intake",{what:"POST /intake",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:n.signal})).json()}async getIntake(t,n={}){let r=n.waitSeconds?`?wait=${n.waitSeconds}`:"";return await(await this.request(`/intake/${q(t)}${r}`,{what:`GET /intake/${t}`,signal:n.signal})).json()}async fulfilIntake(t,n,r={}){return await(await this.request(`/intake/${q(t)}/fulfil`,{what:`POST /intake/${t}/fulfil`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seal_id:n.sealId,share_code:n.shareCode,fragment:n.fragment}),signal:r.signal})).json()}async putBundle(t,n={}){await this.request("/intake/bundles",{what:"PUT /intake/bundles",method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({bundle:Q(t)}),signal:n.signal})}async getBundle(t,n={}){try{let r=await this.request(`/intake/bundles/${q(t)}`,{what:`GET /intake/bundles/${t}`,signal:n.signal});return V((await r.json()).bundle)}catch(r){if(r instanceof ce&&r.status===404)return null;throw r}}async requestAddressProof(t,n={}){return await(await this.request("/intake/proof",{what:"POST /intake/proof",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:t}),signal:n.signal})).json()}async listInbox(t,n={}){let r=new URLSearchParams({to:t.address});return n.waitSeconds&&r.set("wait",String(Math.min(n.waitSeconds,ze.limits.INTAKE_WAIT_MAX_SECONDS))),n.seen&&r.set("seen",n.seen),n.all&&r.set("all","1"),await(await this.request(`/intake?${r.toString()}`,{what:"GET /intake",headers:ut(t),signal:n.signal})).json()}async dismissInboxItem(t,n,r={}){let a=new URLSearchParams({to:n.address,item:t});await this.request(`/intake?${a.toString()}`,{what:"DELETE /intake",method:"DELETE",headers:ut(n),signal:r.signal})}async migrateInbox(t,n,r={}){return await(await this.request("/intake/migrate",{what:"POST /intake/migrate",method:"POST",headers:{"Content-Type":"application/json",...ut(t)},body:JSON.stringify(n),signal:r.signal})).json()}async pushKey(t={}){return(await(await this.request("/intake/push-key",{what:"GET /intake/push-key",signal:t.signal})).json()).vapid_public}async setInboxPush(t,n,r,a={}){let s=n?"POST":"DELETE";await this.request("/intake/subscriptions",{what:`${s} /intake/subscriptions`,method:s,headers:{"Content-Type":"application/json",...ut(r)},body:JSON.stringify({to:r.address,endpoint:t}),signal:a.signal})}},Us=3;function ut(e){return{[Pe.proof.header_address]:e.address,[Pe.proof.header_proof]:e.proof}}function or(e){let t=new URLSearchParams({file_id:e.fileId});return e.shareCode&&t.set("share_code",e.shareCode),t.toString()}function ir(e,t,n){"to"in e&&(t.to=e.to,t.fragment=e.fragment,e.label&&(t.label=e.label),e.sender&&Object.assign(n,ut(e.sender)))}function Fs(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason);return}let a=()=>{clearTimeout(s),r(t?.reason)},s=setTimeout(()=>{t?.removeEventListener("abort",a),n()},e);t?.addEventListener("abort",a,{once:!0})})}function lr(e,t,n){if(typeof e.encrypted_blob!="string"||e.encrypted_blob.length===0)throw new ce(`${t} returned an empty blob`,"unknown",n);return V(e.encrypted_blob)}function Hs(e,t){let n=e.headers,r=typeof n.getSetCookie=="function"?n.getSetCookie():[],a=r.length>0?r:(()=>{let s=e.headers.get("set-cookie");return s?[s]:[]})();for(let s of a){let o=s.split(";",1)[0]?.trim()??"";if(o.startsWith(`${t}=`))return o}return null}var Ws=32,$s=32,Ft=ze.limits.MAX_BLOB_SIZE,zs=class extends Error{constructor(){super("Invalid encryption key"),this.name="BlobDecryptionError"}};function Cr(){return crypto.getRandomValues(new Uint8Array(Ws))}async function Mr(e){let t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}function _n(){return crypto.getRandomValues(new Uint8Array($s))}async function Ur(e,t,n,r,a){let s={owner_token:e,file_keys:Object.fromEntries(t),...r?{message:r}:{},...a?{nda_file:a}:{}};return Hr(s,n)}async function Fr(e,t,n,r,a){let s={file_keys:Object.fromEntries(e),...n?{message:n}:{},...r?{nda_file:r}:{},...a?{reply_to:Q(a)}:{}};return Hr(s,t)}async function Hr(e,t){let n=JSON.stringify(e);if(n.length>Ft)throw new Error(`Blob data size ${n.length} exceeds maximum of ${Ft}`);let r=new TextEncoder().encode(n),a=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:a,tagLength:128},s,r),i=new Uint8Array(12+o.byteLength);return i.set(a,0),i.set(new Uint8Array(o),12),i}function Ks(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.file_keys!="object"||t.file_keys===null)return!1;for(let[n,r]of Object.entries(t.file_keys))if(typeof n!="string"||typeof r!="string")return!1;return!(t.message!==void 0&&typeof t.message!="string"||t.reply_to!==void 0&&typeof t.reply_to!="string")}async function Gs(e,t){let n=await Ys(e,t);if(!Ks(n))throw new Error("Invalid share blob structure");return n}async function Ys(e,t){if(e.length>Ft)throw new Error(`Blob size ${e.length} exceeds maximum of ${Ft}`);if(e.length<28)throw new Error("Encrypted blob too short");let n=e.slice(0,12),r=e.slice(12),a=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),s;try{s=await crypto.subtle.decrypt({name:"AES-GCM",iv:n,tagLength:128},a,r)}catch{throw new zs}try{return JSON.parse(new TextDecoder().decode(s))}catch{throw new Error("Invalid JSON in decrypted blob")}}function js(){try{return typeof process<"u"&&!0}catch{return!1}}var Vs=(e,t,n,...r)=>{let a=`[${t}] ${n}`;switch(e){case"debug":js()||console.debug(a,...r);break;case"info":console.info(a,...r);break;case"warn":console.warn(a,...r);break;case"error":console.error(a,...r);break}},Nt=Vs;function _t(e){return{debug:(t,...n)=>Nt("debug",e,t,...n),info:(t,...n)=>Nt("info",e,t,...n),warn:(t,...n)=>Nt("warn",e,t,...n),error:(t,...n)=>Nt("error",e,t,...n)}}var ji=ze.limits.MAX_FILE_KEYS;var Ne=64,cr=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],qs=new Int32Array(64).map((e,t)=>Math.floor(Math.abs(Math.sin(t+1))*2**32)|0),Xs=new Uint8Array(new Uint32Array([1]).buffer)[0]===1;function dr(e,t,n){let r=e[0],a=e[1],s=e[2],o=e[3];for(let i=0;i<64;i++){let l,d;i<16?(l=a&s|~a&o,d=i):i<32?(l=o&a|~o&s,d=5*i+1&15):i<48?(l=a^s^o,d=3*i+5&15):(l=s^(a|~o),d=7*i&15);let p=r+l+qs[i]+t[n+d]|0;r=o,o=s,s=a,a=a+(p<<cr[i]|p>>>32-cr[i])|0}e[0]=e[0]+r|0,e[1]=e[1]+a|0,e[2]=e[2]+s|0,e[3]=e[3]+o|0}var wn=class{constructor(){this.state=new Int32Array([1732584193,-271733879,-1732584194,271733878]),this.pending=new Uint8Array(Ne),this.pendingLength=0,this.totalBytes=0,this.scratch=new Int32Array(16)}update(e){this.totalBytes+=e.length;let t=0;if(this.pendingLength>0){let r=Math.min(Ne-this.pendingLength,e.length);if(this.pending.set(e.subarray(0,r),this.pendingLength),this.pendingLength+=r,t=r,this.pendingLength<Ne)return this;this.compressBytes(this.pending,0,Ne),this.pendingLength=0}let n=e.length-(e.length-t)%Ne;return this.compressBytes(e,t,n),n<e.length&&(this.pending.set(e.subarray(n)),this.pendingLength=e.length-n),this}digest(){let e=new Uint8Array(this.pendingLength<56?Ne:2*Ne);e.set(this.pending.subarray(0,this.pendingLength)),e[this.pendingLength]=128;let t=new DataView(e.buffer);t.setUint32(e.length-8,this.totalBytes*8>>>0,!0),t.setUint32(e.length-4,Math.floor(this.totalBytes/2**29),!0),this.compressBytes(e,0,e.length);let n=new Uint8Array(16),r=new DataView(n.buffer);for(let a=0;a<4;a++)r.setInt32(a*4,this.state[a],!0);return n}compressBytes(e,t,n){if(t>=n)return;if(Xs&&(e.byteOffset+t)%4===0){let a=new Int32Array(e.buffer,e.byteOffset+t,(n-t)/4);for(let s=0;s<a.length;s+=16)dr(this.state,a,s);return}let r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=t;a<n;a+=Ne){for(let s=0;s<16;s++)this.scratch[s]=r.getInt32(a+s*4,!0);dr(this.state,this.scratch,0)}}};function Zs(e){return Ie(new wn().update(e).digest())}var an=4*1024*1024;async function Js(e){let t=new wn;for(let n=0;n<e.length;n+=an)t.update(e.subarray(n,Math.min(n+an,e.length))),n+an<e.length&&await ht();return Ie(t.digest())}var Wr=class{constructor(e){if(this.cryptoKey=null,e.key.length!==32)throw new Error("Key must be 32 bytes (AES-256)");this.segmentSize=Rr(e.header).segmentSize,this.header=e.header.subarray(0,De),this.key=e.key}async init(){this.cryptoKey=await Lr(this.key)}sha256Hex(){return je(this.header)}async encryptSegment(e,t,n){if(!this.cryptoKey)throw new Error("Encryptor.init() was not awaited");if(!(t?n.length<=this.segmentSize&&(n.length>0||e===0):n.length===this.segmentSize))throw new Error(`segment ${e}${t?" (last)":""} cannot carry ${n.length} bytes at segment size ${this.segmentSize}`);return Ps(this.cryptoKey,n,Pr(this.header,e,t))}};async function Qs(e,t,n,r){let a=new Uint8Array(t);try{let s=new Wr({key:a,header:n});await s.init();let o=new wn().update(s.header),i=[ur(s.header)],l=Math.max(1,Math.ceil(e.size/s.segmentSize));for(let d=0;d<l;d++){let p=Math.min((d+1)*s.segmentSize,e.size),f=new Uint8Array(await e.slice(d*s.segmentSize,p).arrayBuffer()),u=await s.encryptSegment(d,d===l-1,f);f.fill(0),o.update(u),i.push(ur(u)),r?.(p,e.size)}return{blob:new Blob(i),md5_b64:Ie(o.digest())}}finally{a.fill(0)}}function ur(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var Re=class extends Error{constructor(e,t,n){super(t),this.name="DecryptError",this.kind=e,this.cause=n}};function eo(e,t){e.chunks.push(t),e.bytes+=t.length}function Dt(e,t){let n=new Uint8Array(t),r=0;for(;r<t;){let a=e.chunks[0],s=t-r;a.length<=s?(n.set(a,r),r+=a.length,e.chunks.shift()):(n.set(a.subarray(0,s),r),r+=s,e.chunks[0]=a.subarray(s))}return e.bytes-=t,n}function to(e,t){let n=Dt(e,t);return e.chunks.unshift(n),e.bytes+=t,n}function no(e,t){let n=t.expectedSha256Hex.trim().toLowerCase();if(!/^[0-9a-f]{64}$/.test(n))throw new Re("integrity","the expected sha256_hex is not 64 hex characters");let r={chunks:[],bytes:0},a,s=null,o=null,i=0,l=0,d=null,p=async(u,_)=>{if(u.length<xr)throw new Re("integrity",`segment ${l} is ${u.length} bytes: the stream was cut`);try{return await Ls(a,u,o==="v4"?Pr(s,l,_):null)}catch(h){throw new Re("integrity",`segment ${l} does not decrypt as the ${_?"last":"next"} segment of this file: moved, cut, extended or changed`,h)}finally{l+=1}},f=async()=>{if(r.bytes<Mt)return!1;let u=Os(to(r,Mt));if(u===null)throw new Re("outdated","the file is in a format newer than this client: update it");let _=u==="v4"?De:Ir;if(r.bytes<_)return!1;if(u==="v3"){d=Bs();for(let g of r.chunks)d.update(g)}let h=Dt(r,_),m;try{m=u==="v4"?Rr(h).segmentSize:Is(h).segmentSize}catch(g){throw new Re("integrity",g instanceof Error?g.message:String(g),g)}if(u==="v4"&&await je(h)!==n)throw new Re("integrity","the file header is not the one registered for this file");return s=h,o=u,i=xs(m),!0};return new TransformStream({async start(){a=await Lr(e)},async transform(u,_){if(u.length!==0&&(eo(r,u),d&&d.update(u),!(o===null&&!await f())))for(;r.bytes>i;){let h=Dt(r,i),m=await p(h,!1);h.fill(0),t.onPlaintextBytes?.(m.length),_.enqueue(m)}},async flush(u){if(o===null)throw new Re("integrity",r.bytes===0?"the ciphertext stream is empty":"the ciphertext stream was cut inside its header");if(o==="v3"){if(Array.from(d.digest(),m=>m.toString(16).padStart(2,"0")).join("")!==n)throw new Re("integrity","the ciphertext is not the one registered for this file");if(r.bytes===0)return}let _=await p(Dt(r,r.bytes),!0);t.onPlaintextBytes?.(_.length),u.enqueue(_)}},{highWaterMark:1},{highWaterMark:1})}var Xi=_t("SwDownload");var Zi=P.upload.MULTIPART_THRESHOLD_BYTES,Ji=P.upload.MULTIPART_THRESHOLD_BYTES;var Qi=_t("FolderZip");var el=100*1024*1024,tl=4*1024*1024;var ro=_t("upload"),dt=4*1024*1024;function Ht(){return new DOMException("Upload aborted","AbortError")}async function ao(e){let{stream:t,totalBytes:n,key:r,header:a,partSize:s,signal:o,yieldToRenderer:i,onSegment:l}=e,d=Kt,p=Math.max(1,Math.ceil(n/d)),f=new Wr({key:r,header:a});await f.init();let u=!0,_=0,h=0,m=[],g=0,M=A=>{if(m.length>0&&m[0].length===A)return g-=A,m.shift();let E=new Uint8Array(A),D=0;for(;D<A;){let ie=m[0],G=A-D;ie.length<=G?(E.set(ie,D),D+=ie.length,m.shift()):(E.set(ie.subarray(0,G),D),m[0]=ie.subarray(G),D+=G)}return g-=A,E},N=[],x=0,L=async A=>{let E=new Uint8Array(A),D=0,ie=0;for(;D<A;){let G=N[0],Z=i?dt-ie:Number.MAX_SAFE_INTEGER,ee=Math.min(G.length,A-D,Z);E.set(G.subarray(0,ee),D),D+=ee,ie+=ee,ee===G.length?N.shift():N[0]=G.subarray(ee),i&&ie>=dt&&D<A&&(ie=0,await ht())}return x-=A,E},U=async A=>{if(h+=1,e.hashParts===!1)await e.onPart(h,A);else{let E=i?await Js(A):Zs(A);await e.onPart(h,A,E)}i&&await ht()},I=async A=>{if(!i){A.fill(0);return}for(let E=0;E<A.length;E+=dt)A.fill(0,E,Math.min(E+dt,A.length)),E+dt<A.length&&await ht()},b=async()=>{for(;x>=s;)await U(await L(s))},F=async(A,E)=>{if(o?.aborted)throw Ht();let D=_;_+=1;let ie=performance.now(),G=f.encryptSegment(D,E,A);await b();let Z=await G;await I(A),ro.debug(`encrypt segment=${_} bytes=${A.length} time=${Math.round(performance.now()-ie)}ms`);let ee;u?(ee=new Uint8Array(a.length+Z.length),ee.set(a,0),ee.set(Z,a.length),u=!1):ee=Z,l?.(_),N.push(ee),x+=ee.length},B=t.getReader();try{for(;;){if(o?.aborted)throw Ht();let{done:A,value:E}=await B.read();if(A)break;for(E&&E.length>0&&(m.push(E),g+=E.length);g>=d;)await F(M(d),_===p-1)}(g>0||_===0)&&await F(M(g),!0),await b(),x>0&&await U(await L(x))}finally{B.releaseLock()}}function so(e,t){let n=0;return new ReadableStream({async pull(r){if(n>=e.size){r.close();return}let a=Math.min(n+t,e.size);try{let s=await e.slice(n,a).arrayBuffer();r.enqueue(new Uint8Array(s)),n=a}catch(s){r.error(s)}}})}function oo(e,t,n){let{file:r,key:a,header:s,partSize:o,totalBytes:i,signal:l,initialCredits:d,onSegment:p,onPart:f}=n;return new Promise((u,_)=>{let h=!1,m=!1,g=0,M=Promise.resolve(),N=I=>{h||(h=!0,_(I))},x=()=>{!m||g>0||M.then(()=>{h||(h=!0,u())})};if(l){if(l.aborted){N(Ht());return}l.addEventListener("abort",()=>N(Ht()),{once:!0})}e.onerror=t.onerror=I=>{N(new Error(`crypto worker crashed: ${String(I?.message??I)}`))},e.onmessage=I=>{let b=I.data;if(b.type==="segment"){p?.(b.segmentNumber);return}if(b.type==="part"){g+=1,t.postMessage({type:"md5",partNumber:b.partNumber,buffer:b.buffer},[b.buffer]);return}if(b.type==="done"){m=!0,x();return}b.type==="error"&&N(new Error(b.message))},t.onmessage=I=>{let b=I.data;if(b.type!=="md5")return;g-=1;let F=new Uint8Array(b.buffer);M=M.then(async()=>{h||(await f(b.partNumber,F,b.md5),e.postMessage({type:"credit"}))}).catch(N),x()};let L=new ArrayBuffer(a.length);new Uint8Array(L).set(a);let U=s.slice().buffer;e.postMessage({type:"start",file:r,key:L,header:U,partSize:o,totalBytes:i,credits:d},[L,U])})}var io=null;function lo(){return io}var O=class extends Error{constructor(e,t,n,r,a=!1){super(e),this.code=t,this.httpStatus=n,this.partNumber=r,this.retryable=a,this.name="UploadError"}};function We(e,t){return e instanceof O?e:e instanceof DOMException&&e.name==="AbortError"?new O("Upload aborted","ABORTED"):new O(e instanceof Error?e.message:t,"UNKNOWN")}async function qe(e,t,n,r){let a=await Dr(e,String(e.status));return new O(`${t}: ${a.message}`,e.status===426?"CLIENT_OUTDATED":n,e.status,r)}var co=_t("upload"),uo={retryBackoffMs:P.upload.RETRY_BACKOFF_MS,retryJitterRatio:P.upload.RETRY_JITTER_RATIO,stallNoticeMs:P.upload.STALL_NOTICE_MS,maxStallMs:P.upload.MAX_STALL_MS,putFloorBytesPerSecond:P.upload.PUT_FLOOR_BYTES_PER_SECOND,putMinDeadlineMs:P.upload.PUT_MIN_DEADLINE_MS,controlTimeoutMs:P.upload.CONTROL_TIMEOUT_MS,completeTimeoutMs:P.upload.COMPLETE_TIMEOUT_MS,poolStart:P.upload.PART_POOL_START,poolMax:P.upload.PART_POOL_MAX,poolMin:P.upload.PART_POOL_MIN,poolGrowRatio:P.upload.PART_POOL_GROW_RATIO,poolShrinkRatio:P.upload.PART_POOL_SHRINK_RATIO,partQueueLimit:P.upload.PART_QUEUE_LIMIT,hedgeMinInflightMs:P.upload.HEDGE_MIN_INFLIGHT_MS,hedgeLagFactor:P.upload.HEDGE_LAG_FACTOR,hedgePollMs:P.upload.HEDGE_POLL_MS,livenessSilenceMs:P.upload.LIVENESS_SILENCE_MS,verifyPollBackoffMs:P.upload.VERIFY_POLL_BACKOFF_MS,verifyFallbackWaitMs:P.upload.VERIFY_FALLBACK_WAIT_MS,speedWindowMs:P.upload.PROGRESS_SPEED_WINDOW_MS};function $r(e){return{...uo,...e}}function cn(e,t){return Math.max(t.putMinDeadlineMs,Math.ceil(e/t.putFloorBytesPerSecond*1e3))}function zr(e,t){let n=globalThis.AbortSignal;if(typeof n?.timeout!="function")return e;let r=n.timeout(t);return e?typeof n.any!="function"?e:n.any([e,r]):r}async function pt(e,t,n,r){try{return await fetch(e,{...t,signal:zr(r,n)})}catch(a){throw r?.aborted?new O("Upload aborted","ABORTED"):new O(`Request failed: ${a instanceof Error?a.message:String(a)}`,"NETWORK",void 0,void 0,!0)}}function Kr(e){return e===408||e===429||e>=500?"retryable":"terminal"}function Gr(e){return e.code==="ABORTED"?"terminal":e.code==="BAD_DIGEST"||e.httpStatus===void 0?"retryable":e.httpStatus===403?"refresh_url":Kr(e.httpStatus)}function Yr(e){return e.code==="ABORTED"?"terminal":e.httpStatus===void 0?"retryable":Kr(e.httpStatus)}var jr=class{constructor(e,t,n=()=>performance.now()){this.policy=e,this.onState=t,this.now=n,this.failingSince=null,this.current="running",this.noticeTimer=null,this.retriesSinceDelivery=0}get state(){return this.current}connectionLost(){this.setState("stalled")}delivered(){this.failingSince=null,this.retriesSinceDelivery=0,this.clearNotice(),this.setState("running")}exhausted(){return this.failingSince!==null&&this.now()-this.failingSince>=this.policy.maxStallMs}failed(){this.retriesSinceDelivery+=1,this.failingSince??(this.failingSince=this.now());let e=this.policy.stallNoticeMs-(this.now()-this.failingSince);e<=0?this.setState("stalled"):this.noticeTimer===null&&this.current==="running"&&(this.noticeTimer=setTimeout(()=>{this.noticeTimer=null,this.setState("stalled")},e))}dispose(){this.clearNotice()}clearNotice(){this.noticeTimer!==null&&(clearTimeout(this.noticeTimer),this.noticeTimer=null)}setState(e){e!==this.current&&(this.current=e,this.onState?.(e))}};function gn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new O("Upload aborted","ABORTED"));return}let a=()=>{clearTimeout(s),r(new O("Upload aborted","ABORTED"))},s=setTimeout(()=>{t?.removeEventListener("abort",a),n()},e);t?.addEventListener("abort",a,{once:!0})})}async function Wt(e,t){let{clock:n,policy:r,signal:a,classify:s,what:o}=t,i,l=0;for(let d=0;;d++){if(a?.aborted)throw new O("Upload aborted","ABORTED");try{return await e({attempt:d,after:i})}catch(p){let f=We(p,`${o} failed`);if(f.code==="ABORTED")throw f;let u=s(f);if(u==="terminal")throw f;if(n.exhausted())throw new O(`${o}: no progress for ${Math.round(r.maxStallMs/1e3)} s \u2014 ${f.message}`,f.code,f.httpStatus,f.partNumber,!1);n.failed(),l=u==="refresh_url"?l+1:0;let _=u==="refresh_url"&&l===1,h=r.retryBackoffMs[Math.min(d,r.retryBackoffMs.length-1)]??0,m=1+(Math.random()*2-1)*r.retryJitterRatio,g=_?0:Math.round(h*m);co.debug(`retry ${o} attempt=${d+2} in ${g}ms after ${f.code}${f.httpStatus?" "+f.httpStatus:""} (${u})`),i=u,await gn(g,a)}}}var He=_t("upload"),fr="<Code>BadDigest</Code>",fo=2;function bn(e){let t=Nr();return e?e.type==="bearer"?{...t,Authorization:`Bearer ${e.value}`}:e.type==="ownerToken"?{...t,"X-Owner-Token":e.value}:{...t,"X-API-Key":e.value}:t}async function ho(e){return po({file:e.file,sealId:e.sealId,fileId:e.fileId,key:e.key,header:e.header,baseUrl:e.baseUrl,auth:e.auth,partSize:e.partSize,onProgress:e.onProgress,signal:e.signal,transport:e.transport,onStreamed:e.onStreamed,onConflict:e.onConflict})}async function po(e){let{file:t,partSize:n}=e;return yo({stream:so(t,Kt),totalBytes:t.size,sealId:e.sealId,fileId:e.fileId,key:e.key,header:e.header,baseUrl:e.baseUrl,auth:e.auth,partSize:n,onProgress:e.onProgress,signal:e.signal,sourceFile:t,transport:e.transport,onStreamed:e.onStreamed,onConflict:e.onConflict})}async function yo(e){let{stream:t,totalBytes:n,sealId:r,fileId:a,key:s,header:o,baseUrl:i,auth:l,partSize:d,contentType:p="application/octet-stream",onProgress:f,signal:u,sourceFile:_,onStreamed:h,onConflict:m}=e,g=$r(e.transport);if(s.length!==32)throw new O("Key must be 32 bytes","ENCRYPTION_FAILED");if(d<P.upload.S3_MIN_PART_SIZE_BYTES)throw new O(`Part size must be at least ${P.upload.S3_MIN_PART_SIZE_BYTES} bytes (S3 spec)`,"INVALID_STATUS");let M=new Uint8Array(s),N=bn(l),x=yn(n),L=Math.ceil(x/d),U=null,I=[],b=0,F=0,B="encrypting",A=[],E=null,D,ie=y=>{let w=performance.now();A.push({at:w,bytes:y});let v=Math.max(E??w,w-g.speedWindowMs);for(;A.length>0&&A[0].at<v;)A.shift();let R=w-v;R>0&&(D=Math.round(A.reduce((k,z)=>k+z.bytes,0)/R*1e3))},G=y=>{B=y;let w=x-b;f?.({phase:y,percent:y==="done"?100:Math.min(99,Math.floor(b/x*100)),deliveredBytes:b,preparedBytes:F,totalBytes:x,speedBps:D,etaMs:D&&D>0?Math.round(w/D*1e3):void 0,state:Z.state,attempt:Z.retriesSinceDelivery+1})},Z=new jr(g,()=>G(B)),ee=new AbortController,Xe=globalThis.AbortSignal?.any,Te=u&&typeof Xe=="function"?Xe([u,ee.signal]):u??ee.signal,Ze=(y,w)=>Wt(w,{clock:Z,policy:g,signal:Te,classify:Yr,what:y}),Je=async y=>{throw M.fill(0),new O("Upload aborted","ABORTED")},re=y=>{if(U)try{fetch(`${i}/upload/multipart/abort`,{method:"POST",headers:{"Content-Type":"application/json",...N},body:JSON.stringify(y?{upload_id:U,discard_file:!0}:{upload_id:U}),keepalive:!0}).catch(()=>{})}catch{}},te=new Map,Ae=null,ue=null,fe=[],_e=new Set,we=g.poolStart,gt=g.poolMax,bt=0,Ce=null,mt=0,Et=0,Qe=null,qt=[],Un=[],et=new Set,tt=performance.now(),Fn=!1,Xt=y=>{tt=performance.now();for(let w of[...et])w.reconnect(y)};function Ia(y,w){let v=y.ciphertext.length;if(v>=d&&w>0){let z=Math.min(y.flowsAtStart??1,_e.size);if(Un.push({rate:v/w,flows:z}),v/w*1e3<g.putFloorBytesPerSecond*2&&we>g.poolMin){we-=1,gt=we,Qe=null,bt+=1,Ce=performance.now(),mt=0,Et=0;return}}if(y.round!==bt||(mt+=v,Et+=1,Et<we||Ce===null))return;let R=performance.now()-Ce;if(R<=0)return;let k=mt/R;Qe===null||k>Qe*g.poolGrowRatio?we=Math.min(gt,we+1):k<Qe*g.poolShrinkRatio&&(we=Math.max(Math.min(g.poolStart,gt),we-1)),Qe=k,bt+=1,Ce=performance.now(),mt=0,Et=0}function Oa(y,w){let v=performance.now()-w;if(v<g.hedgeMinInflightMs)return!1;let R=_e.size,k=Un.filter(C=>C.flows>=R).map(C=>C.rate);if(k.length===0)return!1;k.sort((C,Y)=>C-Y);let z=k[Math.floor(k.length/2)];return y.ciphertext.length/v*g.hedgeLagFactor<z}async function Ra(y,w,v,R,k,z){if(typeof XMLHttpRequest<"u"&&typeof document<"u")return await new Promise((Y,ge)=>{let ae=new XMLHttpRequest,le=!1;Fn=!0,ae.upload.onprogress=pe=>{z.onSocketActivity(pe.loaded,pe.lengthComputable?pe.total:y.length),clearTimeout(j),j=Ke()};let Ke=()=>setTimeout(()=>{le||z.onDeadline()},cn(y.length,g)),j=Ke(),H=()=>{clearTimeout(j),k.removeEventListener("abort",se)},se=()=>{le||(le=!0,ae.abort(),H(),ge(new O("Upload aborted","ABORTED",void 0,v)))};if(ae.onload=()=>{if(le)return;le=!0;let pe={status:ae.status,etag:ae.getResponseHeader("ETag")?.replace(/"/g,"")??null,badDigest:ae.status===400&&String(ae.responseText??"").includes(fr)};H(),Y(pe)},ae.onerror=()=>{le||(le=!0,H(),ge(new O(`Failed to upload part ${v}: network error`,"NETWORK",void 0,v,!0)))},ae.onabort=()=>{le||(le=!0,H(),ge(new O("Upload aborted","ABORTED",void 0,v)))},k.aborted){H(),ge(new O("Upload aborted","ABORTED",void 0,v));return}k.addEventListener("abort",se,{once:!0}),ae.open("PUT",R),ae.setRequestHeader("Content-MD5",w),ae.send(y)});let C;try{C=await fetch(R,{method:"PUT",headers:{"Content-MD5":w},body:y,signal:zr(k,cn(y.length,g))})}catch(Y){throw u?.aborted||k.aborted?We(Y,"Upload aborted"):new O(`Part ${v}: transport failure (${Y instanceof Error?Y.message:String(Y)})`,"NETWORK",void 0,v,!0)}return{status:C.status,etag:C.headers.get("ETag")?.replace(/"/g,"")??null,badDigest:C.status===400&&(await C.text().catch(()=>"")).includes(fr)}}function Pa(y,w){if(w.badDigest)throw new O(`Part ${y} arrived corrupted (BadDigest)`,"BAD_DIGEST",w.status,y,!0);if(w.status<200||w.status>=300)throw new O(`Failed to upload part ${y}: ${w.status}`,w.status===404?"EXPIRED_UPLOAD_ID":"NETWORK",w.status,y,w.status!==404);if(!w.etag)throw new O(`No ETag returned for part ${y}`,"S3_ETAG_MISMATCH",void 0,y);return w.etag}async function La(y,w){let v=performance.now(),R=null,k=0,z=v,C=null,Y=()=>{},ge={reconnect:ae=>Y(ae,!1),hasUnsentBytes:()=>C?.unsent??!1};et.add(ge);try{let ae=await new Promise((Ke,j)=>{let H=!1,se=Le=>{H||(H=!0,Le())},pe=()=>{let Le=new AbortController,nt=()=>Le.abort();Te?.aborted?Le.abort():Te?.addEventListener("abort",nt,{once:!0});let ve={ctl:Le,unsent:!0,ended:Promise.resolve()};C=ve,z=performance.now(),tt=z,ve.ended=Ra(y.ciphertext,y.contentMd5,y.partNumber,w,Le.signal,{onSocketActivity:(rt,at)=>{tt=performance.now(),ve.unsent=rt<at},onDeadline:()=>Y("copy deadline",!1)}).then(rt=>{if(C===ve)try{let at=Pa(y.partNumber,rt);se(()=>Ke(at))}catch(at){se(()=>j(at))}},rt=>{C===ve&&se(()=>j(We(rt,`Failed to upload part ${y.partNumber}`)))}).finally(()=>{ve.unsent=!1,Te?.removeEventListener("abort",nt)})};Y=(Le,nt)=>{let ve=C;H||ve===null||u?.aborted||(C=null,k=nt?k+1:0,He.debug(`${nt?"replace":"reconnect"} part=${y.partNumber} (${Le})`),ve.ctl.abort(),ve.ended.then(()=>{H||(Te?.aborted?se(()=>j(new O("Upload aborted","ABORTED",void 0,y.partNumber))):pe())}))},pe(),R=setInterval(()=>{H||u?.aborted||C===null||k>=fo||Oa(y,z)&&Y(`slower than its peers after ${Math.round(performance.now()-v)}ms`,!0)},g.hedgePollMs)}),le=performance.now();I.push({part_number:y.partNumber,etag:ae}),b+=y.ciphertext.length,ie(y.ciphertext.length),Ia(y,le-v),Z.delivered(),tt=le,He.debug(`part=${y.partNumber}/${L} put=${Math.round(le-v)}ms size=${y.ciphertext.length}${k>0?` replaced\xD7${k}`:""}`),G("uploading")}finally{et.delete(ge),Y=()=>{},R!==null&&clearInterval(R),C?.ctl.abort()}}let St=(y,w,v)=>pt(y,w,v,Te);async function Ba(){try{let y=await St(`${i}/upload/multipart/status?upload_id=${encodeURIComponent(U??"")}`,{method:"GET",headers:N},g.controlTimeoutMs);if(!y.ok)return null;let w=await y.json();return typeof w.status=="string"?w.status:null}catch{return null}}async function Hn(y){let w=performance.now(),v=await Ze("presign batch",async()=>{let k=await St(`${i}/upload/multipart/parts`,{method:"POST",headers:{"Content-Type":"application/json",...N},body:JSON.stringify({upload_id:U,part_numbers:y})},g.controlTimeoutMs);if(!k.ok)throw await qe(k,"Failed to get presigned URLs",k.status===404?"EXPIRED_UPLOAD_ID":"NETWORK");let{urls:z}=await k.json();return z}),R=new Map;for(let[k,z]of Object.entries(v))R.set(Number(k),z);return He.debug(`batch presign ${y.length} urls in ${Math.round(performance.now()-w)}ms`),R}async function Na(y){let w=[];for(let R=y;R<=L&&w.length<P.upload.PRESIGN_BATCH_SIZE;R++)te.has(R)||w.push(R);if(w.length===0)return;let v=await Hn(w);for(let[R,k]of v)te.set(R,k)}function Wn(y){Ae||(Ae=Na(y).catch(()=>{}).finally(()=>{Ae=null}))}async function Da(y){await ht(),Ce??(Ce=performance.now()),E??(E=Ce),y.round=bt,y.flowsAtStart=_e.size;let w=te.get(y.partNumber);!w&&Ae&&(await Ae,w=te.get(y.partNumber)),te.delete(y.partNumber),Wn(y.partNumber+1),await Wt(async({after:v})=>{if((!w||v==="refresh_url")&&(w=(await Hn([y.partNumber])).get(y.partNumber),!w))throw new O(`No presigned URL for part ${y.partNumber}`,"NETWORK",void 0,y.partNumber,!0);await La(y,w)},{clock:Z,policy:g,signal:Te,classify:Gr,what:`part ${y.partNumber}`})}function Zt(){for(;!ue&&!u?.aborted&&_e.size<we&&fe.length>0;){let y=fe.shift(),w=Da(y).catch(v=>{ue??(ue=We(v,"Part upload failed"))}).finally(()=>{_e.delete(w);let v=qt;qt=[];for(let R of v)R();Zt()});_e.add(w)}}let Ca=()=>new Promise(y=>{qt.push(y)}),Ma=(()=>{let y=globalThis,w=globalThis.navigator?.connection,v=w?.type,R=()=>Xt("network is back"),k=()=>Z.connectionLost(),z=()=>{let Y=w?.type;Y!==v&&(v=Y,Xt("network changed"))};y.addEventListener?.("online",R),y.addEventListener?.("offline",k),w?.addEventListener?.("change",z);let C=setInterval(()=>{!Fn||et.size===0||performance.now()-tt<g.livenessSilenceMs||[...et].some(Y=>Y.hasUnsentBytes())&&(Z.connectionLost(),Xt("every socket silent"))},Math.max(10,g.livenessSilenceMs/4));return()=>{clearInterval(C),y.removeEventListener?.("online",R),y.removeEventListener?.("offline",k),w?.removeEventListener?.("change",z)}})();try{let y=performance.now();if(He.debug(`starting multipart: totalBytes=${n} parts=${L} partSize=${d} pool=${g.poolStart}..${g.poolMax}`),u?.aborted)throw new O("Upload aborted","ABORTED");G("encrypting"),U=await Ze("multipart init",async()=>{let j=await St(`${i}/upload/multipart/init`,{method:"POST",headers:{"Content-Type":"application/json",...N},body:JSON.stringify({seal_id:r,content_type:p,content_length:x,part_size:d,file_id:a})},g.controlTimeoutMs);if(!j.ok)throw await qe(j,"Failed to initialize multipart upload","NETWORK");return(await j.json()).upload_id}),Wn(1),G("encrypting");let w=!1,v=()=>{w=!0,G("encrypting")},R=async(j,H,se)=>{for(w=!0,F+=H.length,G("encrypting"),u?.aborted&&await Je(u?.aborted===!0),fe.push({partNumber:j,ciphertext:H,contentMd5:se}),Zt();fe.length>=g.partQueueLimit;)if(await Ca(),ue)throw ue;if(ue)throw ue},k=()=>ao({stream:t,totalBytes:n,key:M,header:o,partSize:d,signal:u,yieldToRenderer:typeof document<"u",onSegment:v,onPart:R}),z=lo(),C=null;if(_&&z&&typeof document<"u"){let j=null;try{j=z(),C=[j,z()]}catch{j?.terminate()}}if(C){let[j,H]=C;He.debug("crypto pipeline: worker");try{await oo(j,H,{file:_,key:M,header:o,partSize:d,totalBytes:n,signal:u,initialCredits:g.partQueueLimit,onSegment:v,onPart:R})}catch(se){let pe=We(se,"Crypto worker failed");if(pe.code==="ABORTED"||w)throw pe;He.debug(`crypto worker failed before output \u2014 inline fallback (${pe.message})`),await k()}finally{j.terminate(),H.terminate()}}else await k();for(;Zt(),!(ue||(u?.aborted&&await Je(!0),_e.size===0&&fe.length===0));)await Promise.race(_e);if(ue)throw ue;G("verifying"),u?.aborted&&await Je(u?.aborted===!0),h?.();let Y=!1,ge,ae=await Ze("complete",async()=>{let j=Y;Y=!0;let H=await St(`${i}/upload/multipart/complete`,{method:"POST",headers:{"Content-Type":"application/json",...N},body:JSON.stringify({upload_id:U,parts:I.map(se=>({part_number:se.part_number,etag:se.etag})),...m?{on_conflict:m}:{}})},g.completeTimeoutMs);if(H.ok){let se=await H.json().catch(()=>null);return typeof se?.conflict_with=="string"&&(ge=se.conflict_with),se?.status==="verified"}if(j&&H.status===400&&await Ba()==="completed")return!1;throw await qe(H,"Failed to complete multipart upload",H.status===404?"EXPIRED_UPLOAD_ID":"INVALID_STATUS")});Z.delivered(),G("done");let le=Math.round(performance.now()-y),Ke=n/(1024*1024)/(le/1e3);return He.debug(`DONE totalTime=${le}ms speed=${Ke.toFixed(2)}MB/s parts=${I.length}`),M.fill(0),{verified:ae,...ge?{conflictWith:ge}:{}}}catch(y){M.fill(0);let w=We(y,"Unknown upload error");throw re(w.code==="ABORTED"),w}finally{Ma(),Z.dispose(),ee.abort()}}var $t="Encrypted file",zt="application/octet-stream";function Vr(e){return new TextEncoder().encode(`field:${e}`)}async function sn(e,t,n){let r=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.importKey("raw",t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),{name:"AES-GCM"},!1,["encrypt"]),s={name:"AES-GCM",iv:r,tagLength:128};if(n){let i=Vr(n);s.additionalData=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}let o=await crypto.subtle.encrypt(s,a,new TextEncoder().encode(e));return{ciphertext:Ie(new Uint8Array(o)),nonce:Ie(r)}}function _o(e){return e?.name==="OperationError"}async function hr(e,t,n,r){let a=It(e),s=It(t),o=async i=>{let l={name:"AES-GCM",iv:s};i&&(l.additionalData=i);let d=await crypto.subtle.decrypt(l,n,a);return new TextDecoder().decode(d)};if(!r)return o(void 0);try{return await o(Vr(r))}catch(i){if(!_o(i))throw i;return o(void 0)}}async function wo(e,t){let n=e.name||$t,r=e.mime||zt;if(e.name_encrypted&&e.name_nonce&&e.name_nonce.length>0)try{n=await hr(e.name_encrypted,e.name_nonce,t,"name")}catch{n=$t}if(e.mime_encrypted&&e.mime_nonce&&e.mime_nonce.length>0)try{r=await hr(e.mime_encrypted,e.mime_nonce,t,"mime")}catch{r=zt}return{name:n,mime:r}}async function go(e){return crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!1,["decrypt"])}async function bo(e,t){try{let n=await go(t);return wo(e,n)}catch{return{name:e.name||$t,mime:e.mime||zt}}}var Gt={multipartThresholdBytes:P.upload.MULTIPART_THRESHOLD_BYTES,partSizeBytes:P.upload.DEFAULT_PART_SIZE_BYTES,zipSmallLimitBytes:P.upload.INMEMORY_BLOB_LIMIT_BYTES};function mo(e,t=Gt){return e<=P.upload.FINE_PART_MAX_FILE_BYTES?P.upload.FINE_PART_SIZE_BYTES:t.partSizeBytes}function Eo(e,t){return e>=t.multipartThresholdBytes}function So(e){if(!(e.kind==="none"||!e.value)){if(e.kind==="ownerToken")return{type:"ownerToken",value:e.value};if(e.kind==="bearer")return{type:"bearer",value:e.value}}}function qr(e){return e.ownerToken?{type:"ownerToken",value:e.ownerToken}:So(e.auth)}function Ao(e){return e.ownerToken?e.ownerToken:e.auth.kind==="ownerToken"?e.auth.value:void 0}var vo={encrypting:[0,30],uploading:[30,95],verifying:[95,99],done:[100,100]},pr=[2,12],To=[12,95],xo=[95,99];function yr(e,t){let n=0;return r=>{let a=Math.min(1,Math.max(0,r.fraction)),s;e==="single-put"?s=vo[r.phase]:r.phase==="done"?s=[100,100]:r.phase==="verifying"?s=xo:r.deliveredBytes===0?s=pr:s=To;let o=s===pr?Math.min(1,Math.max(0,r.preparedFraction??0)):a,i=s[0]+(s[1]-s[0])*o,l=r.phase==="done"?100:Math.min(99,Math.round(i));n=Math.max(n,l),t({phase:r.phase,percent:n,deliveredBytes:r.deliveredBytes,preparedBytes:r.preparedBytes,totalBytes:r.totalBytes,speedBps:r.speedBps,etaMs:r.etaMs,state:r.state,attempt:r.attempt})}}var mn=class{constructor(e,t){this.run=t,this.cancelled=!1,this.ctx=e.ctx,this.policy=e.policy,this.sealId=e.sealId,this.createdSeal=e.createdSeal,this.expiresAt=e.expiresAt,this.files=e.files}get pending(){return this.files.filter(e=>e.state==="pending")}get verification(){return this.files.every(e=>e.state==="verified")?"verified":"pending"}async resume(e={}){if(this.cancelled)throw new O("Upload session was cancelled","ABORTED");try{return await this.run(this,e)}catch(t){let n=We(t,"Upload failed");throw n.session=this,n}}async cancel(){this.cancelled=!0;let e=Ao(this.ctx);if(!e)return;let t=new yt({baseUrl:this.ctx.baseUrl,credentials:this.ctx.credentials??"include"});try{if(this.createdSeal){await t.revoke(this.sealId,e);return}for(let n of this.pending)await t.revokeFile(this.sealId,n.fileId,e)}catch{}}};function ko(e,t,n){let r=t.length;if(!e||e.length<r)throw new Error(`${n} returned ${e?.length??0} file record(s) for ${r} file(s) \u2014 cannot upload ciphertext`);let a=e.slice(e.length-r);return a.forEach((s,o)=>{if(!s?.id)throw new Error(`${n}: file record ${o} has no id \u2014 cannot upload ciphertext`);if(s.sha256_hex===void 0){if(r===1)return;throw new Error(`${n}: file record ${o} carries no sha256_hex \u2014 refusing to pair ${r} files by position alone`)}if(s.sha256_hex!==t[o])throw new Error(`${n}: file record ${o} has sha256=${s.sha256_hex.slice(0,16)}\u2026 but we sent ${t[o].slice(0,16)}\u2026 \u2014 response order corrupted, refusing to upload`)}),a}function Io(e){return e>=200&&e<300||e===204}async function Oo(e){let{ctx:t,sealId:n,fileId:r,ciphertext:a,authHeaders:s,onVerifying:o,label:i,signal:l,clock:d,transport:p}=e,f=` for ${i}`,u={"Content-Type":"application/json",...s},_=t.credentials??"include",h=(x,L)=>Wt(L,{clock:d,policy:p,signal:l,classify:Yr,what:x}),m=()=>h(`initiate${f}`,async()=>{let x=await pt(`${t.baseUrl}/upload/initiate`,{method:"POST",headers:u,credentials:_,body:JSON.stringify({seal_id:n,content_type:"application/octet-stream",content_length:a.blob.size,file_id:r})},p.controlTimeoutMs,l);if(x.status===409)return null;if(!x.ok)throw await qe(x,`Upload initiate failed${f}`,"NETWORK");let L=await x.json();return L.already_verified?null:L}),g=await m();if(g===null)return!1;let M=!1;if(await Wt(async({after:x})=>{if(x==="refresh_url"){let I=await m();if(I===null){M=!0;return}g=I}let{upload_url:L}=g,U=await pt(L,{method:"PUT",body:a.blob,headers:{"Content-Type":"application/octet-stream","Content-MD5":a.md5_b64}},cn(a.blob.size,p),l);if(U.status===400&&(await U.clone().text().catch(()=>"")).includes("<Code>BadDigest</Code>"))throw new O(`Upload arrived corrupted (BadDigest)${f}`,"BAD_DIGEST",400,void 0,!0);if(!Io(U.status))throw new O(`Upload PUT failed${f}: ${U.status}`,"NETWORK",U.status)},{clock:d,policy:p,signal:l,classify:Gr,what:`PUT${f}`}),M)return!1;d.delivered(),o();let N=await h(`confirm${f}`,async()=>{let x=await pt(`${t.baseUrl}/upload/confirm`,{method:"POST",headers:u,credentials:_,body:JSON.stringify({seal_id:n,file_id:r,...t.onConflict?{on_conflict:t.onConflict}:{}})},p.controlTimeoutMs,l);if(!x.ok)throw await qe(x,`Upload confirm failed${f}`,"NETWORK");let L=await x.json().catch(()=>null);return typeof L?.conflict_with=="string"&&e.onConflictWith(L.conflict_with),L?.status==="verified"});return d.delivered(),N}async function Xr(e,t,n,r,a,s){try{let o=await pt(`${e.baseUrl}/upload/status/${encodeURIComponent(t)}/${n}`,{method:"GET",headers:r,credentials:e.credentials??"include"},a.controlTimeoutMs,s);if(!o.ok)return null;let i=await o.json();return typeof i.status=="string"?i.status:null}catch(o){if(o instanceof O&&o.code==="ABORTED")throw o;return null}}var Ro=new Set(["failed","size_mismatch","verification_error"]);async function Po(e){let{ctx:t,sealId:n,digest:r,authHeaders:a,transport:s,signal:o,label:i}=e,l=s.verifyFallbackWaitMs,d=performance.now(),p=s.verifyPollBackoffMs;for(let f=0;;f++){let u=p[Math.min(f,p.length-1)]??0;if(performance.now()-d+u>l)return"pending";u>0&&await gn(u,o);let _=await Xr(t,n,r,a,s,o);if(_==="verified")return"verified";if(_!==null&&Ro.has(_))throw new O(`The server rejected ${i} after upload (${_}). It has to be sent again.`,"VERIFICATION_REJECTED");if(_===null&&f===0)return"pending"}}async function Lo(e,t,n={}){let{ctx:r,policy:a,sealId:s}=e,{file:o,key:i,fileId:l}=t,{onProgress:d,signal:p}=n;if(t.state!=="pending")return;if(p?.aborted)throw new O("Upload aborted","ABORTED");let f=qr(r),u=bn(f),_=$r(a.transport),h=async I=>{if(t.state=I?"verified":"uploaded",!I)try{await Po({ctx:r,sealId:s,digest:t.sha256_hex,authHeaders:u,transport:_,signal:p,label:o.name})==="verified"&&(t.state="verified")}catch(b){throw b instanceof O&&b.code==="VERIFICATION_REJECTED"&&(t.state="pending",t.prepared=void 0,t.streamed=void 0),b}};if(Eo(o.size,a)){if(t.streamed){let E=await Xr(r,s,t.sha256_hex,u,_,p);if(E!==null&&E!=="pending"){await h(E==="verified");return}}let I=yr("multipart",E=>d?.(E)),b=null,F=await ho({file:o,sealId:s,fileId:l,key:i,header:t.header,baseUrl:r.baseUrl,auth:f,partSize:mo(o.size,a),onProgress:E=>{b=E;let D=E.phase==="done";I({...E,phase:D?"verifying":E.phase,fraction:D?0:E.deliveredBytes/E.totalBytes,preparedFraction:E.totalBytes>0?(E.preparedBytes??0)/E.totalBytes:0,preparedBytes:E.preparedBytes})},signal:p,transport:a.transport,onStreamed:()=>{t.streamed=!0},onConflict:r.onConflict});t.streamed=void 0,t.conflictWith=F.conflictWith,await h(F.verified);let B=t.encryptedSize;I({...b??{phase:"done",percent:100,deliveredBytes:B,totalBytes:B,state:"running",attempt:1},phase:"done",fraction:1});return}let m=yr("single-put",I=>d?.(I)),g=t.encryptedSize,M={phase:"encrypting",fraction:0,delivered:!1},N=(I,b,F=M.delivered)=>{M={phase:I,fraction:b,delivered:F},m({phase:I,fraction:b,deliveredBytes:F?g:0,totalBytes:g,state:x.state,attempt:x.retriesSinceDelivery+1})},x=new jr(_,()=>N(M.phase,M.fraction));t.prepared||(N("encrypting",0),t.prepared=await Qs(o,i,t.header,I=>N("encrypting",o.size>0?I/o.size:1)));let L=t.prepared;N("uploading",0);let U;try{U=await Oo({ctx:r,sealId:s,fileId:l,ciphertext:L,authHeaders:u,onVerifying:()=>N("verifying",0,!0),label:o.name,signal:p,clock:x,transport:_,onConflictWith:I=>{t.conflictWith=I}})}finally{x.dispose()}N("verifying",.5,!0),await h(U),t.prepared=void 0,N("done",1,!0)}function Bo(e){if(!e.roomId){if(!e.ownerTokenHash)throw new Error("ownerTokenHash is required for seal creation (SHORT LINKS)");if(e.ownerTokenHash.length!==64||!/^[a-f0-9]{64}$/i.test(e.ownerTokenHash))throw new Error("ownerTokenHash must be 64 hex characters (SHA256)")}}function No(e,t){t.ttl&&(e.ttl=t.ttl),t.roomId&&(e.room_id=t.roomId),t.otp&&(e.otp=t.otp),t.nda&&(e.nda=!0),t.ownerEmail&&(e.owner_email=t.ownerEmail),t.singleUse&&(e.single_use=!0),t.geo&&t.geo.length>0&&(e.geo=t.geo),typeof t.maxOpens=="number"&&t.maxOpens>0&&(e.max_opens=t.maxOpens),t.tier&&(e.tier=t.tier)}async function Do(e,t,n,r,a={}){let s=await sn(e.name,t,"name"),o=await sn(e.type||"application/octet-stream",t,"mime"),i={size:n,sha256_hex:r,name_encrypted:s.ciphertext,name_nonce:s.nonce,mime_encrypted:o.ciphertext,mime_nonce:o.nonce,encryption_version:he.current_format_version};if(a.relativePath!==void 0){let l=await sn(a.relativePath,t,"path");i.path_encrypted=l.ciphertext,i.path_nonce=l.nonce}return a.parentFolderId&&(i.parent_folder_id=a.parentFolderId),a.supersedes&&(i.supersedes=a.supersedes,i.layout="whole"),i}async function Co(e,t,n){if(n?.aborted)throw new O("Upload aborted","ABORTED");try{return await fetch(e,{...t,signal:n})}catch(r){throw n?.aborted?new O("Upload aborted","ABORTED"):r}}async function Mo(e,t,n){let r={files_meta:t};e.ownerTokenHash&&(r.owner_token_hash=e.ownerTokenHash),No(r,e);let a=await Co(`${e.baseUrl}/seal`,{method:"POST",headers:{"Content-Type":"application/json",...bn(qr(e))},credentials:e.credentials??"include",body:JSON.stringify(r)},n);if(!a.ok)throw await qe(a,"Create seal failed","UNKNOWN");return await a.json()}async function Uo(e,t){let n=ks();return{file:e,key:t,header:n,sha256_hex:await je(n)}}async function Fo(e,t,n,r){await e.onRegistered?.(t,n.map((a,s)=>({fileId:r[s].id,sha256_hex:a.sha256_hex,key:a.key})))}function Ho(e,t){return e.map((n,r)=>({index:r,fileId:t[r].id,file:n.file,key:n.key,header:n.header,sha256_hex:n.sha256_hex,encryptedSize:yn(n.file.size),state:"pending"}))}async function Zr(e,t,n=Gt,r={}){Bo(e);let a=await Uo(t,Ns()),s=await Mo(e,[await Do(t,a.key,yn(t.size),a.sha256_hex)],r.signal),o=ko(s.files,[a.sha256_hex],`Create seal ${s.id}`);return await Fo(r,s.id,[a],o),new mn({ctx:e,policy:n,sealId:s.id,createdSeal:!0,expiresAt:s.expires_at,files:Ho([a],o)},async(l,d)=>{let p=l.files[0];return await Lo(l,p,{onProgress:f=>d.onProgress?.(f),signal:d.signal}),{sealId:l.sealId,fileId:p.fileId,encryptionKey:p.key,sha256_hex:p.sha256_hex,expiresAt:l.expiresAt,verification:l.verification}}).resume(r)}var _r=[2e3,4e3,8e3,15e3],on=ze.limits.TIER_BYTES,rl=Object.keys(on).filter(e=>e!=="free").sort((e,t)=>on[e]-on[t]);function Jr(e){return e instanceof O&&e.httpStatus===402&&e.session?e.session:null}function Qr(e,t=Date.now()){let n=t+ze.limits.PAYMENT_WAIT_MAX_SECONDS*1e3,r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)?Math.min(n,r):n}async function ea(e,t,n,r){for(let a=0;;a++){try{let o=await e.getOwnerSeal(t,n,{signal:r.signal});if(r.tier?o.tier===r.tier:o.tier&&o.tier!=="free")return o}catch(o){if(r.signal?.aborted||o instanceof ce&&o.code!=="transient"&&o.code!=="rate_limited")throw o}let s=_r[Math.min(a,_r.length-1)];if(Date.now()+s>r.deadline)return null;await gn(s,r.signal)}}var al=ze.limits.ttl_options;var ta={version:2,name:"SEAL_SHARE_URL",description:"URL fragment scheme for SEAL share links (SPEC-AEON-V4 \xA76, law \u041B2): the fragment of any link carries one symmetric key or nothing. A link addressed to someone carries no fragment: its key, wrapped to the recipient's bundle (sealed box v2, crypto.json sealed_box_v2), lives in the share link's row on the server and comes back as `fragment` of GET /seal/{id}/share/{code}. Backends never see fragments (URL fragments are not sent over HTTP per RFC 3986 \xA73.5). Consumers: the web, the CLI, the MCP server, the SDK, sealnet and the bots. The wrap and its opening live in shared/core (targeted.rs over sealed_box.rs, Identity::open).",url_template:"https://<host>/s/<seal_id>/<share_code>[#<link_key>]",fragment_variants:{key:{format:"<link_key_urlsafe_b64_no_pad>",detection:"exactly 43 urlsafe-b64-no-pad characters, 32 bytes: the AES-256-GCM key of the share blob (seal_blob.v1.json)",field_layout:[{name:"link_key",offset:0,length:32,encoding:"urlsafe-b64-no-pad in URL"}]},none:{format:"",detection:"no fragment: an addressed link. The key, wrapped to the recipient's bundle with scope ('seal_share', seal_id from the path), is the `fragment` field of the share blob response (1575 base64url characters, first byte 0x02); only the recipient's seed opens it."},targeted_x25519_v1:{status:"read only until the removal (C1 \xA76): links made before C1 with the sealed box v1 in the fragment",format:"x25519:<packed_b64>",prefix:"x25519:",packed_binary_length_bytes:92,packed_layout:[{name:"ephemeral_public",offset:0,length:32,encoding:"raw bytes; X25519 ephemeral pubkey from sender"},{name:"nonce",offset:32,length:12,encoding:"raw bytes; AES-256-GCM nonce"},{name:"wrapped_link_key",offset:44,length:48,encoding:"raw bytes; 32 B ciphertext of the link key || 16 B GCM tag"}],implicit_fields_not_in_packed:{recipient_public:"the X25519 key of the recipient's seed (the seed itself is the X25519 secret)",scope_type:"'seal_share'",scope_id:"seal_id from the URL path /s/<seal_id>/<code>",grant_version:"1"},kdf_info_layout:'seal_crypto::hkdf::derive_wrap_key: b"WRAP" || 0x01 || len(scope_type) || scope_type || len(scope_id) || scope_id, salt crypto.json hkdf.wrap_key_salt',aad_layout:"recipient_public (32 B) || 0x01"}},version_detection_rule:"(1) no fragment \u2192 none: the wrap comes from the server; (2) starts with 'x25519:' \u2192 targeted_x25519_v1, read only until the removal; (3) exactly 43 urlsafe-b64-no-pad characters \u2192 key; (4) anything else \u2192 'update the client' (SPEC-AEON-V4 \xA77.4), never decoded as a key.",current_format_version:2,supported_format_versions:[2],implementations:{rust:"shared/core/src/targeted.rs (wrap_link_key / open_wrap; the x25519: opening until the removal); the CLI calls it as seal_crypto::targeted",ts:"shared/packages/protocol/src/identity.ts (wrapTo / openWrap) over the core's WASM; the whole link is parsed by protocol/src/url.ts::parseShareUrl",python:"sealnet calls the Rust core in its wheel (sealnet.seal_crypto); no Python implementation"},test_vectors:{description:"Frozen outputs of the read-only v1 variant, until the removal: every reader MUST recover link_key from fragment with recipient_secret (the seed) and seal_id, and MUST fail with any other seal_id.",targeted_x25519_v1:[{recipient_secret_b64url:"BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc",recipient_public_b64url:"E75P6uryBMf9M1j8nAByGIHRdCeBKCJ-xnTzf3_pe20",seal_id:"AbCd1234",fragment:"x25519:GkbbXddA43eoSgY1ZAAnPTCDmJIoGM3ZrY2_wctdKX2ivODHag_TCSjQql3PMu22xzsxJsYKHnIhHjXhvuJfe468pvsvvzuEZiaVzoPu2PTqlRin8xiDsopyrGQ",link_key_b64url:"q6urq6urq6urq6urq6urq6urq6urq6urq6urq6urq6s"}]},security_properties:{key:"Anyone with the URL can open. link_key is the entire capability \u2014 treat the URL itself as a bearer credential.",none:"The URL alone opens nothing: the key is sealed to the recipient's bundle (X25519 + ML-KEM-768) and only the seed on the recipient's device opens it. Each wrap has a fresh ephemeral key and encapsulation."}},Wo=ta.fragment_variants.targeted_x25519_v1.prefix,En=8,Sn=43,dn=4,Yt=/^[A-Za-z0-9_-]+$/;function $o(e,t){if(!Yt.test(e))return!1;try{let n=e.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return atob(n).length===t}catch{return!1}}function An(e){return e.length===En&&Yt.test(e)}function vn(e){return e.length===Sn&&$o(e,32)}function na(e,t){if(!An(e))throw new Error(`Invalid sealId: must be ${En} base64url characters`);if(!vn(t))throw new Error(`Invalid linkKey: must be ${Sn} base64url characters (32 bytes)`);return`/s/${e}#${t}`}function ra(e,t,n){if(!An(e))throw new Error(`Invalid sealId: must be ${En} base64url characters`);if(t.length!==dn||!Yt.test(t))throw new Error(`Invalid shareCode: must be ${dn} base64url characters`);if(!vn(n))throw new Error(`Invalid linkKey: must be ${Sn} base64url characters (32 bytes)`);return`/s/${e}/${t}#${n}`}var Ct=class extends Error{constructor(e,t){super(t),this.name="ShareUrlError",this.code=e}};function zo(e){let t;try{t=new URL(e)}catch{throw new Ct("url_invalid",`not a valid URL: ${e}`)}let n;try{n=Ko(t.pathname.replace(/\/+$/,""))}catch{throw new Ct("url_invalid",`expected /s/<seal_id>[/<share_code>] path, got: ${t.pathname}`)}let r=t.hash.replace(/^#/,"").trim(),a=n.shareCode??null;if(!r)return{sealId:n.sealId,shareCode:a,fragmentVariant:"none",fragment:r};if(r.startsWith(Wo))return{sealId:n.sealId,shareCode:a,fragmentVariant:"targeted_x25519_v1",fragment:r};if(!vn(r))throw new Ct("url_invalid",`the fragment is not one 43-character key (got ${r.length} characters): a mangled link, or one from a newer client \u2014 update it`);return{sealId:n.sealId,shareCode:a,fragmentVariant:"key",fragment:r}}function Ko(e){let t=e.match(/^\/s\/([A-Za-z0-9_-]{8})(?:\/([A-Za-z0-9_-]{4}))?$/);if(!t)throw new Error("Invalid seal URL format");let n=t[1],r=t[2];if(!An(n))throw new Error("Invalid sealId in URL");if(r&&(r.length!==dn||!Yt.test(r)))throw new Error("Invalid shareCode in URL");return{sealId:n,shareCode:r}}var Tn={version:1,default_aead:"aes_256_gcm",aes_gcm:{key_length_bytes:32,nonce_length_bytes:12,tag_length_bytes:16},sha256:{output_length_bytes:32,hex_string_length:64},owner_token_bytes:32,link_key_bytes:32,metadata_aad_prefix:"field:",keybundle:{signature_prefix:"seal:keybundle:",signed_bundle_version:2,v2_fields:["identity_ed25519_pub","agreement_x25519_pub","kem_mlkem768_pub"],packed_length:1316,address:{of:"sha256(identity_ed25519_pub), 32 bytes",text:"base64url without padding, 43 characters",words:"fingerprint_words.json over its first three bytes"}},hkdf:{wrap_key_salt:"seal:wrapkey:v1",wrap_key_salt_v2:"seal:wrapkey:v2",identity_key_salt:"seal:key-derivation:v1",file_envelope_salt:"seal:file-envelope:v1",info_prefixes:{wrap:"WRAP",agreement:"AGRE",identity:"IDEN",workload_identity:"seal:workload-identity:v1",kem_mlkem768:"seal:kem-mlkem768:v1"}},xwing:{label_hex:"5c2e2f2f5e5c"},sealed_box_v2:{version_byte:2,packed_layout:[{name:"version",offset:0,length:1},{name:"eph_pub",offset:1,length:32},{name:"kem_ct",offset:33,length:1088},{name:"nonce",offset:1121,length:12},{name:"ct",offset:1133,length:48}],packed_length:1181,packed_b64_length:1575},secret_scope_aad:"secret:{secret_id}",sign:{message_prefix:"aeon:sign:v1",message_format:"aeon:sign:v1|org:{org_id}|req:{request_id}|doc_hash:{doc_hash_hex}"},recovery_phrase:{seed:`BIP39: PBKDF2-HMAC-SHA512 of the phrase after trim, lower case and NFKD, salt "mnemonic", 2048 iterations, 64 bytes; the web's recoveryPhrase.ts phraseToMasterSeed and the core's hkdf::master_seed_from_phrase (\u04145 \xA73.2)`,vector:{phrase:"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art",typed:` Abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon ART
|
|
3
|
-
`,seed_hex:"408b285c123836004f4b8842c89324c1f01382450c0d439af345ba7fc49acf705489c6fc77dbd4e3dc1dd8cc6bc9f043db8ada1e243c4a0eafb290d399480840"}},device_link:{record:"a person's seed64, base64url, sealed by the browser to the one-time bundle of sealfs login: sealReply(seed64, bundle, scope, code) of the protocol's identity module \u2014 box (sealed_box_v2) \u2016 nonce(12) \u2016 AES-256-GCM of the record under the box's key; the daemon opens it with its one-time identity (\u04145 \xA73.2 \u043F. 2, D119)",scope:"device",vector:{daemon_seed32_hex:"0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20",code:"K7M2Q9XA",seed64_hex:"030a11181f262d343b424950575e656c737a81888f969da4abb2b9c0c7ced5dce3eaf1f8ff060d141b222930373e454c535a61686f767d848b9299a0a7aeb5bc",record:"AiLUcCQ-y_sD9lk4-SfbqB2ye0O1kPNp9WXB17aooqw6e0T2cUNCgVtTT-6G85cWqJYck6oV0yjTt2pk299lJ-mU4sJOwTcYqD_AmSzQEGalLYBfMWQUaDNbiN0izBY-gUwMMBYfhu5Dg8iunGtRq_NqmR_RVD90XKZcLGeDYlIP-Y9PZgpjhLgzYyygYVk_frpnezADgvVJZPX9aJZWBvYnluYJ7cziq0I1gNOd4YsxD9s5_YILQUPv5FZSD4pO6VteIa8frg_emCIbbZqOlfVAH4BJ9kc082OLPthe_c1-kk0r6a7aYCWMrQzDhiQaGtORWSc1zp6g4CS0EZgOH5hwi4-bTEiwA-DHNJAwheel8vOdAf9jj94e_3z-r0-VJqGvdZY1dojaxsH9ncnYtmPJHnK4NSA0HN8WUCTE9GPSGXdy-v5TPGl1lbx_CorhVS0skxnufB7Xbr0BdHH5RgwFogxCWHiltENydvBSLTdI1_R-N7ZI7qng0_4nOekZsQdIoVlgfzepatTtPHOvfVYEmvQ-VIurJWuIQTM2fcvqZNcjBtAMNmwMSfWuJZVL02ydFQTH8a9ZcNQI56lCOHkJvm5zakpx0E2RJr2vgDwNzrb_1AnQ7_3K0IK9Zv0sA-hCxOH8qQx6an-tAX_Nu-ImW-YKu-nZgCeG3eMmnhKHpMu3-quGhWhAI2ECrwCLUxycONPzbKpScXNn5KnBmAfJNvHdxJOzAIzoxPiDcbme1eud10pgxILimVXZ0aRwhvqxxr9qOrmDobsJfcLx8NKFgQ4NZad81j23CtoeadX03lPHJYngvsTJdhjgR4NUMLYzO-Y5D7dagDVI5I80oqhBtelMXqizH10b7LIIWPtFBBNmfeUjuOZau5CJuDGbiof53irMi3vugv1HggNQq0SS5E0_Lu6muVz4YR_O9E_caXosymEU4tcLsxxAolxNJO_nYorWgL-o_KrePQo81L-IAlpSf-wgjNQGm1CScnCZGAEY3ZYOHeB5bSdeNgzX4VWENZ5arfLk02ENk82Gfx8pdFgOFHhSXz574sGdnvIeTHiW0mQglVYSOodSLICAKvpwME3LtSytFl6zb5gpj_52mkFVXrPXV8ja2LK4ssCxtFXYzCYYgKSa7ZEKtx34xtj6U9yUI-TqWnSvukfOo2eTAEmxYf7DTyMq6Uj1EfNC7Zy77wBSXvPeca3M-1_aRuoaH3BKtveqkqAhIcacDbUW4ysg_F09ZFMAJZxJ7sXFAVI_jS-PDNvOn5Q5lkg07zAjZ64a9maZPXReNX-XNqBOde3GZ179HxmWPC0AEgKtyH7zjV9SSRs3tvTopyZuFd8tcZ17r2OaeR8UQWys6NKlK0dFqquQAeNlB4PyNIl3wKHxoIItVEiN4dT9UC_rZuYf-fsjRsZ9yvcOW6iCnZOSWoggV_sBl-7bvKhnkBwSreKFggXTnjEsAK0L-INniS3aYwrRAv9ZjYee0jUOV0DwbPskckVzjyiquja1-7_rt6XGmSqRkFDkBxvvLgEFFJjE22ySdyT2gRVuxLg8ayA0d3Mn-qqpGRMrThqnxaUv7Pp7KzcFQ97Eb0zxWroa3DdSPhPmutepx8P4cxtVhVP5R_aUHY0l26SwS2SwL-1yIicca4_PgSYlQX4gOKa87JPgr1BhO9HuDTXzu16hlDQ99-ioq0n0pXyDaUp4bVx9GL72hosl6U_vDNhMniI"}}},xn=Pe.scopes.share_link,aa=Pe.scopes.owner_copy;var wr=Tn.sealed_box_v2.version_byte,gr=Tn.sealed_box_v2.packed_length,$e=ta.fragment_variants.targeted_x25519_v1,Go=Pe.migrate.scope_address_proof,Se=32,br=32;var kn=/^[A-Za-z0-9_-]+$/;function sa(){return crypto.getRandomValues(new Uint8Array(Se))}async function In(e,t=1){let n=await Fe();if(e.length===Se)return n.WasmIdentity.fromSeed32(e);if(e.length===2*Se)return n.WasmIdentity.fromSeed64(e,t);throw new Error(`a seed is ${Se} or ${2*Se} bytes, got ${e.length}`)}async function jt(e,t=1){let n=await In(e,t);try{return{bundle:n.bundle(),address:n.address(),words:n.words(),legacyAddress:n.legacyAddress()}}finally{n.free()}}function oa(e){let t=e.trim().replace(/=+$/,"");if(t.length!==43)throw new Error(`an address is 43 urlsafe-base64-no-pad characters, got ${t.length}`);if(!kn.test(t))throw new Error("not valid urlsafe-base64-no-pad: contains characters outside [A-Za-z0-9_-] (standard-base64 input is rejected \u2014 copy the exact address from `seal keygen` or `sealnet-mcp pubkey`)");return t}async function ia(e,t){return(await Fe()).wasm_bundle_verify_for_address(e,t)}async function On(e){return(await Fe()).wasm_bundle_address(e)}async function Rn(e,t,n,r){if(e.length!==br)throw new Error(`a wrapped key is ${br} bytes, got ${e.length}`);if(r.length===0)throw new Error("the scope id must not be empty: the wrap binds to it");return Q((await Fe()).wasm_sealbox_wrap(e,t,n,r))}var Ee=class extends Error{constructor(e,t,n){super(t),this.name="WrapError",this.kind=e,this.cause=n}};async function Yo(e,t,n,r,a=1){if(r.length===0)throw new Ee("parse","the scope id must not be empty: the wrap binds to it");if(e.startsWith($e.prefix))return jo(e.slice($e.prefix.length),t,n,r);if(!kn.test(e))throw new Ee("parse","the wrap is not urlsafe-base64-no-pad");let s=V(e);if(s[0]!==wr)throw new Ee("parse",`the wrap is not a sealed box v${wr}: a newer client made it \u2014 update this one`);if(s.length!==gr)throw new Ee("parse",`the wrap is ${s.length} bytes, expected ${gr}`);if(t.length!==Se&&t.length!==2*Se)throw new Ee("parse",`a seed is ${Se} or ${2*Se} bytes, got ${t.length}`);let o=await In(t,a);try{return o.open(s,n,r)}catch(i){throw new Ee("aead","the wrap does not open: it is not for this seed, or its scope, id or bytes were changed",i)}finally{o.free()}}async function jo(e,t,n,r){if(!kn.test(e))throw new Ee("parse",`the ${$e.prefix} wrap is not urlsafe-base64-no-pad`);let a=V(e);if(a.length!==$e.packed_binary_length_bytes)throw new Ee("parse",`the ${$e.prefix} wrap is ${a.length} bytes, expected ${$e.packed_binary_length_bytes}`);if(t.length!==Se)throw new Ee("parse",`an ${$e.prefix} wrap opens with a ${Se}-byte seed`);let s=await Fe();try{return s.wasm_sealbox_unwrap(a,t,n,r)}catch(o){throw new Ee("aead","the wrap does not open: it is not for this seed, or its scope, id or bytes were changed",o)}}async function Vo(e,t){let n=await In(e);try{let r=n.inboxProof(BigInt(t.ts),V(t.challenge));return`${t.ts}.${t.challenge}.${Q(r)}`}finally{n.free()}}async function qo(e,t,n){let a=(await Fe()).wasm_sealbox_unwrap(V(t),e,Go,String(n));return`${n}.${Q(a)}`}var un={version:1,name:"FINGERPRINT_WORDS",description:"Three words that name the identity key of a bundle to a person (SPEC-AEON-V4 \xA75.3): word i (i = 0, 1, 2) is words[byte i of SHA-256(identity public key)] \u2014 the first three bytes of the same SHA-256 that is the address, so a client names an address by its own first bytes without hashing again \u2014 24 bits in all, written in lower case with one space between them. The agent shows them in its chat, box.seal.net and seal.net/i/{id} show them on the page, so a person sees at a glance whether both sides hold the same key. One list for every language and client: 256 English nouns of 3 to 7 letters, no two sharing their first three letters, in alphabetical order.",digest:"sha256",count:3,separator:" ",words:["acorn","album","amber","anchor","apple","arrow","atlas","bamboo","banjo","basket","beach","bell","bench","berry","birch","bison","bloom","boat","bolt","bottle","brick","broom","butter","cabin","cactus","camel","candle","cargo","castle","cedar","cherry","clock","coast","comet","copper","coral","cotton","crab","crown","daisy","dawn","deer","delta","desert","diamond","dolphin","dove","dragon","drum","duck","dune","eagle","earth","echo","egg","elk","ember","emerald","engine","falcon","farm","feather","fence","fern","fig","finch","fish","flag","flute","fog","forest","fossil","fox","frog","garden","gate","gazelle","gecko","geyser","ginger","giraffe","glacier","globe","goat","gold","goose","grape","guitar","hammer","harbor","hawk","hazel","hedge","heron","hill","hippo","hive","honey","horse","igloo","iguana","iris","iron","island","ivory","jacket","jaguar","jasmine","jelly","jewel","juice","jungle","kayak","kelp","kettle","kite","kiwi","koala","ladder","lagoon","lamp","lantern","lava","leaf","lemon","leopard","lily","lime","lion","lizard","llama","lobster","lotus","lynx","magnet","mango","maple","marble","meadow","melon","meteor","mint","mirror","monkey","moon","mosaic","muffin","nail","nectar","needle","nest","oasis","ocean","olive","opal","orange","orbit","orchid","otter","owl","palm","panda","paper","parrot","peach","pebble","pelican","pencil","pepper","piano","pine","pizza","planet","plum","pony","poppy","prism","pumpkin","quartz","queen","quill","rabbit","radio","raft","raven","reed","rhino","ribbon","ridge","river","robin","rocket","rose","ruby","sail","salmon","sand","saturn","scroll","shark","shell","ship","silk","sled","sloth","snail","snow","spider","spruce","star","stone","sugar","summit","swan","table","teapot","thunder","tiger","tile","timber","toast","tomato","topaz","torch","tower","trout","truck","tulip","turtle","unicorn","valley","vanilla","vase","velvet","violin","volcano","wagon","walnut","wave","whale","wheat","whistle","willow","window","wizard","wolf","wombat","wren","yacht","yarn","yeti","yucca","zebra","zenith","zinc","zipper"],vector:{public_key_b64url:"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",sha256_prefix_hex:"66687a",words:"iron ivory lava"}},Xo=un.words,Zo=/^[A-Za-z0-9_-]{43}$/;function la(e){if(!Zo.test(e))throw new Error(`an address is 43 base64url characters, got ${e.length}`);let t=V(e);return Array.from(t.subarray(0,un.count),n=>Xo[n]).join(un.separator)}var ca=Pe.payloads.pair.mime,ol=Pe.payloads.device.mime,da=Pe.pair_what,mr=Pe.payloads.name_max,Er=Tn.keybundle.packed_length,Sr=2;var Jo=/^[A-Za-z0-9_-]+$/;function ua(e){let t=Qo(e,"pairing");if(typeof t.bundle!="string"||!Jo.test(t.bundle))throw new Error("pairing bundle is not base64url");return{bundle:ei(V(t.bundle)),name:ti(t.name)}}function Qo(e,t){let n;try{n=JSON.parse(new TextDecoder().decode(e))}catch{throw new Error(`${t} payload is not JSON`)}if(typeof n!="object"||n===null||n.v!==Sr)throw new Error(`${t} payload is not version ${Sr}`);return n}function ei(e){if(e.length!==Er)throw new Error(`a bundle is ${Er} bytes, got ${e.length}`);return e}function ti(e){if(typeof e!="string"||e.length===0||e.length>mr)throw new Error(`name must be 1 to ${mr} characters`);return e}var ni={version:1,name:"SECRETS",description:"How a secret travels (SPEC-AGENTS \xA74.3, \xA76.1). `mime` is the marker a sender pins on a file that is a secret (`seal send --kind secret`, the intake page, the local dialog); it rides encrypted in the file metadata, so a receiving agent saves it to disk and never reads it into a conversation (`seal_open inline` refuses it). `sources`: where well-known keys are created, service name \u2192 the host of its key page. A request's `where_url` whose host is in this list is shown as that service; any other https host is shown with the note that the address came from the agent and should be checked. Data, not code: a service is added with one line.",mime:"application/vnd.seal.secret",sources:{Anthropic:"console.anthropic.com",AWS:"console.aws.amazon.com","Brave Search":"api.search.brave.com",Cloudflare:"dash.cloudflare.com",DigitalOcean:"cloud.digitalocean.com",Discord:"discord.com",GitHub:"github.com","Google AI Studio":"aistudio.google.com","Google Cloud":"console.cloud.google.com",Groq:"console.groq.com","Hugging Face":"huggingface.co",Mistral:"console.mistral.ai",npm:"www.npmjs.com",OpenAI:"platform.openai.com",OpenRouter:"openrouter.ai",PyPI:"pypi.org",Slack:"api.slack.com",Stripe:"dashboard.stripe.com",Supabase:"supabase.com","Telegram BotFather":"t.me",Twilio:"console.twilio.com",Vercel:"vercel.com"},patterns_note:"What a key looks like, for every reader: `seal doctor --transcripts`, the scanner of the Pro web page and the `sealfs` detector (C1 \u042039). `pattern` is an expression in the subset all three run alike \u2014 JS, Python `re`, Rust `regex`: no lookaround, no backreference, no inline flag; a boundary is `\\b` inside the expression. The flags are shared: case-insensitive and multiline. A match that contains a string of the entry's `allowlist` (case-insensitive) is no finding. A match of an entry with `checksum` is a finding only when it passes that sum: `luhn` \u2014 the Luhn sum of its digits is 0 modulo 10; `iban` \u2014 its characters but spaces, upper-cased, the first four moved to the end, each letter read as a number (A = 10 \u2026 Z = 35), are 1 modulo 97. A finding is shown masked: its first four characters, `\u2026`, its last two. `vectors.hit` holds a finding of the entry, `vectors.clean` none; every reader passes them. The scanner page does not take a file larger than `max_file_bytes`; `seal doctor` reads agent transcripts of any size, a line at a time \u2014 skipping a long transcript would hide its leak. Data, not code: a service is added with one entry.",max_file_bytes:10485760,patterns:[{name:"openai_api_key",pattern:"\\bsk-proj-[A-Za-z0-9_-]{40,}",severity:"critical",description:"OpenAI API Key",keywords:["openai","sk-proj-"],vectors:{hit:"OPENAI_API_KEY=sk-proj-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdEf",clean:"OPENAI_API_KEY=sk-proj-AbCdEfGhIj"}},{name:"anthropic_api_key",pattern:"\\bsk-ant-[A-Za-z0-9_-]{40,}",severity:"critical",description:"Anthropic API Key",keywords:["anthropic","sk-ant-"],vectors:{hit:"sk-ant-api03-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789AbCd",clean:"sk-ant-api03-short"}},{name:"github_token",pattern:"\\b(?:gh[pousr]|github_pat)_[A-Za-z0-9_]{30,}",severity:"critical",description:"GitHub Token",keywords:["github","token","ghp_","github_pat_"],vectors:{hit:"token: ghp_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",clean:"token: xghp_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789"}},{name:"gitlab_token",pattern:"glpat-[A-Za-z0-9\\-]{20,}",severity:"critical",description:"GitLab Personal Access Token",keywords:["gitlab","token"],vectors:{hit:"glpat-AbCdEfGhIjKlMnOpQrSt",clean:"glpat-short"}},{name:"aws_access_key_id",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",severity:"critical",description:"AWS Access Key ID",keywords:["aws","amazon","access_key","accesskey"],vectors:{hit:"AKIAIOSFODNN7EXAMPLE",clean:"AKIAIOSFODNN7EXAMPLEX"}},{name:"aws_secret_access_key",pattern:`aws[_\\-\\.]?secret[_\\-\\.]?access[_\\-\\.]?key['\\"]?\\s*[:=]\\s*['\\"]?([A-Za-z0-9/+=]{40})['\\"]?`,severity:"critical",description:"AWS Secret Access Key",keywords:["aws","secret","access_key"],vectors:{hit:'aws_secret_access_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"',clean:'aws_secret_access_key = "short"'}},{name:"stripe_live_key",pattern:"\\b[sr]k_live_[A-Za-z0-9]{20,}",severity:"critical",description:"Stripe Live Secret Key",keywords:["stripe","live","secret"],vectors:{hit:"sk_live_AbCdEfGhIjKlMnOpQrStUvWx",clean:"sk_live_AbCd"}},{name:"stripe_test_key",pattern:"\\b[sr]k_test_[A-Za-z0-9]{20,}",severity:"medium",description:"Stripe Test Secret Key",keywords:["stripe","test"],vectors:{hit:"rk_test_AbCdEfGhIjKlMnOpQrStUvWx",clean:"rk_test_AbCd"}},{name:"stripe_publishable_live",pattern:"pk_live_[A-Za-z0-9]{24,}",severity:"low",description:"Stripe Live Publishable Key",keywords:["stripe","publishable"],vectors:{hit:"pk_live_AbCdEfGhIjKlMnOpQrStUvWx",clean:"pk_live_AbCd"}},{name:"slack_token",pattern:"\\bxox[abprs]-[A-Za-z0-9-]{20,}",severity:"critical",description:"Slack Token",keywords:["slack","token","xox"],vectors:{hit:"xoxb-1234567890-1234567890123-AbCdEfGhIjKl",clean:"xoxb-12345"}},{name:"slack_webhook",pattern:"https://hooks\\.slack\\.com/services/T[A-Z0-9]+/B[A-Z0-9]+/[A-Za-z0-9]+",severity:"high",description:"Slack Webhook URL",keywords:["slack","webhook","hooks.slack.com"],vectors:{hit:"https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",clean:"https://hooks.slack.com/services/"}},{name:"google_api_key",pattern:"\\bAIza[0-9A-Za-z\\-_]{35}",severity:"high",description:"Google API Key",keywords:["google","api","AIza"],vectors:{hit:"AIzaSyAbCdEfGhIjKlMnOpQrStUvWxYz0123456",clean:"AIzaSyShort"}},{name:"google_oauth_client_secret",pattern:`client[_\\-]?secret['\\"]?\\s*[:=]\\s*['\\"]?([A-Za-z0-9\\-_]{24})['\\"]?`,severity:"high",description:"Google OAuth Client Secret",keywords:["google","oauth","client_secret"],vectors:{hit:'client_secret: "AbCdEfGhIjKlMnOpQrStUvWx"',clean:'client_secret: "short"'}},{name:"private_key",pattern:"-----BEGIN (?:RSA |EC |DSA |OPENSSH |ENCRYPTED |PGP )?PRIVATE KEY(?:\\s+BLOCK)?-----",severity:"critical",description:"Private Key",keywords:["private","key","-----BEGIN"],vectors:{hit:"-----BEGIN OPENSSH PRIVATE KEY-----",clean:"-----BEGIN PUBLIC KEY-----"}},{name:"jwt_token",pattern:"eyJ[A-Za-z0-9_-]*\\.eyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*",severity:"high",description:"JSON Web Token (JWT)",keywords:["jwt","token","eyJ"],vectors:{hit:"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.c2lnbmF0dXJl",clean:"eyJhbGciOiJIUzI1NiJ9"}},{name:"basic_auth",pattern:"(?:basic\\s+)[A-Za-z0-9+/=]{20,}",severity:"high",description:"Basic Authentication Header",keywords:["basic","auth","authorization"],vectors:{hit:"Authorization: Basic dXNlcjpwYXNzd29yZDEyMzQ1Ng==",clean:"Basic auth is disabled"}},{name:"bearer_token",pattern:"bearer\\s+[A-Za-z0-9_\\-\\.]{20,}",severity:"high",description:"Bearer Token",keywords:["bearer","token","authorization"],vectors:{hit:"Authorization: Bearer AbCdEfGhIjKlMnOpQrStUvWx",clean:"Bearer token expired"}},{name:"postgres_uri",pattern:"postgres(?:ql)?://[^:]+:[^@]+@[^/]+/[^\\s]+",severity:"critical",description:"PostgreSQL Connection String",keywords:["postgres","postgresql","database"],vectors:{hit:"postgresql://app:hunter2secret@db.internal:5432/app",clean:"postgresql://db.internal/app"}},{name:"mysql_uri",pattern:"mysql://[^:]+:[^@]+@[^/]+/[^\\s]+",severity:"critical",description:"MySQL Connection String",keywords:["mysql","database"],vectors:{hit:"mysql://app:hunter2secret@db.internal/app",clean:"mysql://db.internal/app"}},{name:"mongodb_uri",pattern:"mongodb(?:\\+srv)?://[^:]+:[^@]+@[^\\s]+",severity:"critical",description:"MongoDB Connection String",keywords:["mongodb","mongo","database"],vectors:{hit:"mongodb+srv://app:hunter2secret@cluster0.example.net",clean:"mongodb://localhost"}},{name:"redis_uri",pattern:"redis://[^:]*:[^@]+@[^\\s]+",severity:"high",description:"Redis Connection String",keywords:["redis","cache"],vectors:{hit:"redis://:hunter2secret@cache.internal:6379",clean:"redis://cache.internal:6379"}},{name:"azure_storage_key",pattern:`(?:account[_\\-]?key|storage[_\\-]?key)['\\"]?\\s*[:=]\\s*['\\"]?([A-Za-z0-9+/=]{88})['\\"]?`,severity:"critical",description:"Azure Storage Account Key",keywords:["azure","storage","account_key"],vectors:{hit:"AccountKey=AbCdEfGhIjKlMnOpQrStUvWxYz0123456789+/AbCdEfGhIjKlMnOpQrStUvWxYz0123456789+/AbCdEfGhIjKl",clean:"AccountKey=short"}},{name:"gcp_service_account",pattern:'"type"\\s*:\\s*"service_account"',severity:"critical",description:"GCP Service Account JSON",keywords:["gcp","google","service_account"],vectors:{hit:'{"type": "service_account", "project_id": "demo"}',clean:'{"type": "user"}'}},{name:"sendgrid_api_key",pattern:"SG\\.[A-Za-z0-9_-]{22}\\.[A-Za-z0-9_-]{43}",severity:"high",description:"SendGrid API Key",keywords:["sendgrid","email","SG."],vectors:{hit:"SG.AbCdEfGhIjKlMnOpQrStUv.AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdE",clean:"SG.short.key"}},{name:"twilio_api_key",pattern:"SK[a-f0-9]{32}",severity:"high",description:"Twilio API Key",keywords:["twilio","sms"],vectors:{hit:"SK0123456789abcdef0123456789abcdef",clean:"SK0123456789abcdef"}},{name:"npm_token",pattern:"npm_[A-Za-z0-9]{36}",severity:"high",description:"NPM Access Token",keywords:["npm","token"],vectors:{hit:"npm_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",clean:"npm_short"}},{name:"pypi_token",pattern:"pypi-[A-Za-z0-9_-]{100,}",severity:"high",description:"PyPI API Token",keywords:["pypi","token","python"],vectors:{hit:"pypi-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdEfGhIjKlMnOpQrStUvWx",clean:"pypi-short"}},{name:"generic_password",pattern:`(?:password|passwd|pwd|secret)['\\"]?\\s*[:=]\\s*['\\"]([^'\\"]{8,})['\\"]`,severity:"medium",description:"Generic Password Assignment",keywords:["password","passwd","secret"],allowlist:["password123","changeme","example","placeholder","xxxxxxxx"],vectors:{hit:'password = "s3cr3t-Value!"',clean:'password = "changeme-now"'}},{name:"generic_api_key",pattern:`(?:api[_\\-]?key|apikey)['\\"]?\\s*[:=]\\s*['\\"]([A-Za-z0-9_\\-]{20,})['\\"]`,severity:"medium",description:"Generic API Key Assignment",keywords:["api_key","apikey"],vectors:{hit:'api_key = "AbCdEfGhIjKlMnOpQrStUvWx"',clean:'api_key = "short"'}},{name:"seal_link",pattern:"https://seal\\.net/(?:pro/)?s/[A-Za-z0-9_/-]{8,}#[A-Za-z0-9_-]{43}",severity:"critical",description:"SEAL link (it opens its seal)",keywords:["seal","seal.net/s/"],vectors:{hit:"https://seal.net/s/AbCd1234/Xy7Q#AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCde",clean:"https://seal.net/s/AbCd1234/Xy7Q"}},{name:"payment_card",pattern:"\\b(?:\\d[ -]?){12,18}\\d\\b",checksum:"luhn",severity:"high",description:"Payment Card Number",keywords:["card","visa","mastercard"],vectors:{hit:"card: 4111 1111 1111 1111",clean:"card: 4111 1111 1111 1112"}},{name:"iban",pattern:"\\b[A-Z]{2}\\d{2}(?: ?[A-Z0-9]{4}){2,7}(?: ?[A-Z0-9]{1,3})?\\b",checksum:"iban",severity:"high",description:"IBAN",keywords:["iban","bank","account"],vectors:{hit:"IBAN DE89 3704 0044 0532 0130 00, please",clean:"IBAN DE89 3704 0044 0532 0130 01, please"}},{name:"passport_number",pattern:"\\bpassport(?:\\s*(?:no|number|#))?\\.?\\s*[:=#]?\\s*[A-Z]{0,2}[0-9]{6,9}\\b",severity:"high",description:"Passport Number",keywords:["passport"],vectors:{hit:"Passport No: X1234567",clean:"Passport photos: 2 copies"}}]},ri=ni.mime,X=class extends Error{constructor(e,t,n){super(t),this.name="OpenError",this.code=e,this.cause=n}},ai=32;async function Pn(e,t,n={}){let r;try{r=zo(t)}catch(h){throw h instanceof Ct?new X(h.code,h.message,h):h}if(r.shareCode===null)throw new X("url_invalid","share code missing from the URL path (/s/<seal_id>/<share_code>#<key>)");let{sealId:a,shareCode:s}=r;if(r.fragmentVariant!=="key"&&!n.seed)throw new X("targeted_fragment_invalid","this link is addressed to someone: pass their seed to open it");let o=n.seed,i=r.fragmentVariant==="targeted_x25519_v1"?r.fragment:n.wrap??null,l=r.fragmentVariant==="key"?V(r.fragment):i!==null&&o?await Ar(i,o,a):null,d=n.signal?{signal:n.signal}:{},p;try{p=Ms(await e.getMetadata(r.sealId,d))}catch(h){throw h instanceof ce&&(h.code==="not_found"||h.code==="revoked")?new X(h.code==="revoked"?"seal_revoked":"seal_not_found",`seal ${r.sealId} ${h.code==="revoked"?"has been revoked":"was not found or has expired"}`,h):new X("metadata_failed",`reading seal ${r.sealId} failed: ${fn(h)}`,h)}if(p.revokedAt!==null)throw new X("seal_revoked",`seal ${r.sealId} has been revoked`);if(p.files.length===0)throw new X("seal_not_ready",`seal ${r.sealId} has no files available yet: the server verifies an upload before offering it. Retry in a few seconds.`);let f;try{let h=await e.getShareBlob(a,s,d);if(f=h.blob,l===null){if(h.wrap===null||!o)throw new X("url_no_fragment","the link carries no key and the server holds no wrap of it for this link");l=await Ar(h.wrap,o,a)}}catch(h){throw h instanceof X?h:h instanceof ce&&(h.code==="not_found"||h.code==="revoked")?new X(h.code==="revoked"?"share_link_revoked":"share_link_not_found",`share link ${a}/${s} ${h.code==="revoked"?"has been revoked":"was not found"}`,h):new X("share_blob_fetch_failed",`share blob fetch failed: ${fn(h)}`,h)}let u;try{u=(await Gs(f,l)).file_keys}catch(h){throw new X("share_blob_decrypt_failed","the share blob does not open with this link \u2014 mistyped URL, or the link was revoked and minted again",h)}let _=await Promise.all(p.files.map(h=>li(h,u)));return{sealId:a,expiresAt:p.expiresAt,singleUse:p.singleUse,maxOpens:p.maxOpens,otpRequired:p.otpRequired,ndaRequired:p.ndaRequired,files:_}}async function Ar(e,t,n){try{return await Yo(e,t,xn,n)}catch(r){let a=r instanceof Ee&&r.kind==="aead";throw new X(a?"targeted_decrypt_failed":"targeted_fragment_invalid",fn(r),r)}}async function fa(e,t,n={}){for(;;){let r;try{r=await e.getIntake(t,{...n,waitSeconds:ze.limits.INTAKE_WAIT_MAX_SECONDS})}catch(a){throw a instanceof ce&&a.code==="not_found"?new X("request_expired","the request expired before anybody answered",a):a}if(r.status==="expired")throw new X("request_expired","nobody answered before the request expired");if(r.status==="fulfilled"&&r.share_path&&r.fragment)return{sharePath:r.share_path,wrap:r.fragment}}}var si=64*1024;async function ha(e,t,n,r){let a=await Pn(e,t,r),[s,...o]=a.files;if(!s?.key||!s.sha256Hex||o.length>0||_a(s.mime)!==n||s.size>si)throw new X("share_blob_corrupt",`the answer is not one ${n} file`);let i=await e.openDownload(a.sealId,{fileId:s.id},r.signal?{signal:r.signal}:{});if(!i.body)throw new X("share_blob_corrupt","the answer came without a body");let l=Bn(i.body,s.key,s.sha256Hex).stream.getReader(),d=[];for(let u=await l.read();!u.done;u=await l.read())d.push(u.value);let p=new Uint8Array(d.reduce((u,_)=>u+_.length,0)),f=0;for(let u of d)p.set(u,f),f+=u.length;return p}var oi=3e4,vr=new Map;async function ii(e,t,n){let r=await e.getBundle(t.address,n);r!==null&&ui(r,t.bundle)||await e.putBundle(t.bundle,n)}async function Tr(e,t,n={}){let r=await jt(t),a=`${e.baseUrl} ${r.address}`,s=vr.get(a);if(!n.fresh&&s&&s.until>Date.now())return s.proof;await ii(e,r,n);let o=await e.requestAddressProof(r.address,n),i={address:r.address,proof:await Vo(t,o)};return vr.set(a,{proof:i,until:Date.parse(o.expires_at)-oi}),i}async function wt(e,t,n,r){let a=n?{signal:n}:{};try{return await r(await Tr(e,t,a))}catch(s){if(!(s instanceof ce&&s.appCode==="intake.proof_required"))throw s;return r(await Tr(e,t,{...a,fresh:!0}))}}async function pa(e,t,n={}){let{legacyAddress:r}=await jt(t);return wt(e,t,n.signal,async a=>{let s=await e.migrateInbox(a,{old_address:r},n),o=await qo(t,s.challenge,s.ts);return(await e.migrateInbox(a,{old_address:r,old_proof:o},n)).moved})}async function Ln(e,t,n={}){let r=n;return wt(e,t,n.signal,a=>e.listInbox(a,r))}async function ya(e,t,n,r={}){return wt(e,t,r.signal,a=>e.dismissInboxItem(n,a,r))}async function li(e,t){let n=e.sha256_hex?t[e.sha256_hex]:void 0,r={id:e.id,size:e.size,sha256Hex:e.sha256_hex};if(n===void 0)return{...r,name:$t,mime:zt,secret:!1,key:null};let a;try{a=V(n)}catch(i){throw new X("share_blob_corrupt",`share blob carries a non-base64url key for ${e.sha256_hex}`,i)}if(a.length!==ai)throw new X("share_blob_corrupt",`share blob key for ${e.sha256_hex} is ${a.length} bytes`);let{name:s,mime:o}=await bo(e,a);return{...r,name:s,mime:o,secret:_a(o)===ri,key:a}}function _a(e){return(e.split(";")[0]??e).trim().toLowerCase()}function Bn(e,t,n,r=()=>{}){let a=new Uint8Array(t),s=Bt.create(),o=0,i,l=new Promise((u,_)=>{i={resolve:u,reject:_}});l.catch(()=>{});let d=new TransformStream({transform(u,_){r(u.length),_.enqueue(u)}}),p=new TransformStream({transform(u,_){s.update(u),o+=u.length,_.enqueue(u)},flush(){a.fill(0),i.resolve({sizeBytes:o,sha256:di(s.digest())})}}),f=e.pipeThrough(d).pipeThrough(no(a,{expectedSha256Hex:n})).pipeThrough(p);return{stream:fi(f,i.reject,a),done:l}}function ci(e){return e instanceof Re?new X(e.kind==="outdated"?"client_outdated":"integrity_check_failed",e.message,e):e}function di(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function ui(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function fi(e,t,n){let r=e.getReader();return new ReadableStream({async pull(a){try{let{value:s,done:o}=await r.read();o?a.close():a.enqueue(s)}catch(s){let o=ci(s);n.fill(0),t(o),a.error(o)}},cancel(a){return n.fill(0),t(a),r.cancel(a)}})}function fn(e){return e instanceof Error?e.message:String(e)}var hi="_",pi=200,yi=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]);function _i(){if(typeof process<"u"&&process.platform)switch(process.platform){case"win32":return"windows";case"darwin":return"macos";case"linux":return"linux";case"android":return"android";default:return"unknown"}if(typeof navigator<"u"&&navigator.userAgent){let e=navigator.userAgent.toLowerCase();if(e.includes("win"))return"windows";if(e.includes("android"))return"android";if(e.includes("iphone")||e.includes("ipad")||e.includes("ipod"))return"ios";if(e.includes("mac"))return"macos";if(e.includes("linux"))return"linux"}return"unknown"}function wi(e,t){let n=e.charCodeAt(0);if(n<32||n===127)return!1;switch(t){case"windows":return!/[<>:"/\\|?*]/.test(e);case"macos":case"ios":return!/[/:]/.test(e);case"linux":case"android":return e!=="/";default:return!/[<>:"/\\|?*]/.test(e)}}function gi(e){let t=e.split(".")[0].toUpperCase();return yi.has(t)}function wa(e,t={}){let{platform:n=_i(),replacement:r=hi,maxLength:a=pi,fallback:s="file"}=t;if(!e||!e.trim())return s;let o=e.normalize("NFC");o=o.trim(),o=o.replace(/^\.+|\.+$/g,""),o=[...o].map(d=>wi(d,n)?d:r).join("");let l=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(o=o.replace(new RegExp(`${l}+`,"g"),r),o=o.replace(new RegExp(`^(?:\\.|${l})+|${l}+$`,"g"),""),(n==="windows"||n==="unknown")&&gi(o)&&(o=`${r}${o}`),o.length>a){let d=o.lastIndexOf(".");if(d>0&&d>o.length-10){let p=o.slice(d);o=o.slice(0,a-p.length)+p}else o=o.slice(0,a)}return!o||o===r?s:o}var ga={version:1,limits:{MAX_FILES_PER_SEAL:30,FREE_TIER_BYTES:1073741824,MAX_TOTAL_SIZE_BYTES:1073741824,MAX_FILE_SIZE_BYTES:10737418240,MAX_MULTIPART_FILE_SIZE_BYTES:10737418240,MAX_BLOB_SIZE:1048576,MAX_BLOB_BASE64_SIZE:1468006,MAX_MESSAGE_LENGTH:5e3,MAX_FILE_KEYS:1e4,MAX_ACTIVE_UPLOADS_PER_SEAL:10,MAX_OPENS_PER_SEAL_FREE:10,TIER_BYTES:{free:1073741824,"5gb":5368709120,"50gb":53687091200,"500gb":536870912e3},SEAL_TIERS:{"5gb":{bytes:5368709120,amount_cents:900,duration_days:90,name:"5 GB / 3 months",description:"One-time payment for 5 GB storage and 3 months TTL"},"50gb":{bytes:53687091200,amount_cents:2900,duration_days:180,name:"50 GB / 6 months",description:"One-time payment for 50 GB storage and 6 months TTL"},"500gb":{bytes:536870912e3,amount_cents:9900,duration_days:365,name:"500 GB / 12 months",description:"One-time payment for 500 GB storage and 12 months TTL"}},PRO_REGIONS:["eu-west","us-east","us-west","apac-southeast","apac-northeast"],ttl_options:["5m","30m","1h","1d","7d"],OTP_LENGTH:{min:6,max:10},USER_PASSWORD_MIN_LENGTH:8,INTAKE_TTL_DEFAULT_SECONDS:900,INTAKE_TTL_MAX_SECONDS:86400,INTAKE_WAIT_MAX_SECONDS:25,PAYMENT_WAIT_MAX_SECONDS:82800,ADDRESS_PROOF_TTL_SECONDS:300,INBOX_MAX_ITEMS:200,DRIVE_OPEN_TTL_SECONDS:300,DRIVE_PRESIGN_WINDOW_DEFAULT_BYTES:67108864,DRIVE_PRESIGN_WINDOW_MIN_BYTES:8388608,DRIVE_PRESIGN_UNBOUND_TTL_SECONDS:30,DRIVE_WRITE_LEASE_SECONDS:7200,DRIVE_WRITE_BACK_SECONDS:5,VERSION_RETENTION_DAYS_DEFAULT:30,VERSION_KEEP_MIN:10,GRANT_WORKLOAD_MAX_TTL_DAYS:90,SENSOR_OPENS_PER_MINUTE_DEFAULT:120,SENSOR_BYTES_PER_MINUTE_DEFAULT:2147483648,SENSOR_SECRETS_PER_MINUTE_DEFAULT:20,SENSOR_NOVELTY_WINDOW_DAYS:30,SENSOR_HOLD_TTL_SECONDS:86400,SENSOR_BASELINE_MIN_HOURS:72,SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT:107374182400}};var K=class e extends Error{code;status;details;constructor(t,n,r,a=null,s){super(t,s),this.name="SealError",this.code=n,this.status=r,this.details=a,Error.captureStackTrace&&Error.captureStackTrace(this,e)}toJSON(){return{name:this.name,message:this.message,code:this.code,status:this.status,details:this.details}}},mi={url_invalid:"VALIDATION_ERROR",url_no_fragment:"VALIDATION_ERROR",targeted_fragment_invalid:"INVALID_KEY",targeted_decrypt_failed:"INVALID_KEY",seal_not_found:"RESOURCE_NOT_FOUND",seal_revoked:"RESOURCE_NOT_FOUND",share_link_not_found:"RESOURCE_NOT_FOUND",share_link_revoked:"RESOURCE_NOT_FOUND",request_expired:"RESOURCE_NOT_FOUND",seal_not_ready:"SERVICE_UNAVAILABLE",metadata_failed:"SERVICE_UNAVAILABLE",share_blob_fetch_failed:"SERVICE_UNAVAILABLE",share_blob_decrypt_failed:"DECRYPTION_ERROR",share_blob_corrupt:"DECRYPTION_ERROR",integrity_check_failed:"DECRYPTION_ERROR",client_outdated:"CLIENT_OUTDATED"};function de(e,t,n=null){if(e instanceof K)return e;if(e instanceof X){let r=e.cause instanceof ce?e.cause.status:400;return new K(e.message,mi[e.code],r,{...n,reason:e.code},{cause:e})}if(e instanceof ce){let r=e.appCode==="client.outdated"?"CLIENT_OUTDATED":e.appCode==="intake.proof_required"?"AUTH_INVALID_KEY":e.code==="not_found"||e.code==="revoked"?"RESOURCE_NOT_FOUND":e.code==="auth"?"AUTH_INSUFFICIENT_SCOPE":e.code==="rate_limited"?"RATE_LIMITED":e.code==="transient"?"SERVICE_UNAVAILABLE":"INTERNAL_ERROR";return new K(e.detail??t,r,e.status,n,{cause:e})}return new K(e instanceof Error?e.message:t,"INTERNAL_ERROR",500,n,{cause:e})}var Ol=ga.limits.ttl_options,Vt=class{api;baseUrl;shareUrlBase;credentials;constructor(t){this.baseUrl=(t?.apiUrl||"").replace(/\/$/,""),this.shareUrlBase=(t?.shareUrl||"https://seal.net").replace(/\/$/,"").replace(/\/s$/,""),this.credentials=t?.credentials,this.api=new yt({baseUrl:this.baseUrl,...this.credentials!==void 0?{credentials:this.credentials}:{}})}async create(t){if(t.nda&&!t.ownerEmail)throw new K("ownerEmail is required when nda=true","VALIDATION_ERROR",400);if(t.tier&&!t.onPaymentRequired)throw new K("onPaymentRequired is required with tier","VALIDATION_ERROR",400);let n=(b,F)=>{if(F!==void 0)try{return oa(F)}catch(B){throw new K(`${b}: ${B instanceof Error?B.message:String(B)}`,"VALIDATION_ERROR",400)}},r=n("to",t.to),a=n("owner",t.owner),s=t.signal?{signal:t.signal}:{},o=async b=>{let F=await this.api.getBundle(b,s);return F&&await ia(F,b)?F:null},i=null;if(r){try{i=await o(r)}catch(b){throw de(b,"Failed to read the recipient key")}if(!i)throw new K(`to: ${r} has no published key: ask the recipient for their address again`,"RESOURCE_NOT_FOUND",404)}let l=a?await o(a).catch(()=>null):null,d=t.keyPair?V(t.keyPair.secretKey):null,p=b=>d?wt(this.api,d,t.signal,b):b(),f=t.mimeType||t.file instanceof File&&t.file.type||"application/octet-stream",u;if(t.file instanceof File&&t.file.name===t.filename&&t.file.type===f)u=t.file;else if(t.file instanceof Blob)u=new File([t.file],t.filename,{type:f});else if(t.file instanceof Uint8Array){let b=t.file.buffer.slice(t.file.byteOffset,t.file.byteOffset+t.file.byteLength);u=new File([b],t.filename,{type:f})}else u=new File([t.file],t.filename,{type:f});let _=Cr(),h=Q(_),m=await Mr(_),g=_n(),M=Q(g),N={baseUrl:this.baseUrl,auth:{kind:"none"},ttl:t.ttl,ownerTokenHash:m,ownerToken:h,...this.credentials!==void 0?{credentials:this.credentials}:{},...t.otp!==void 0?{otp:t.otp}:{},...t.nda!==void 0?{nda:t.nda}:{},...t.nda&&t.ownerEmail!==void 0?{ownerEmail:t.ownerEmail}:{},...t.singleUse!==void 0?{singleUse:t.singleUse}:{},...t.geoAllowlist!==void 0?{geo:t.geoAllowlist}:{},...t.maxOpens!==void 0?{maxOpens:t.maxOpens}:{},...t.tier!==void 0?{tier:t.tier}:{}},x=null,L=b=>({sealId:b,ownerToken:h,ownerLinkKey:M}),U=t.message?.trim()?t.message:void 0,I=!1;try{let b=t.onProgress,F={...b?{onProgress:re=>b({phase:re.phase,percent:re.percent})}:{},...t.signal?{signal:t.signal}:{},onRegistered:async(re,te)=>{x=re;let Ae=new Map(te.map(fe=>[fe.sha256_hex,Q(fe.key)])),ue=Q(await Ur(h,Ae,g,U));if(a&&l){let fe=await Rn(g,l,aa,re);I=await p(_e=>this.api.writeOwnerBlob(re,h,ue,{...s,to:a,fragment:fe,label:"sealnet",..._e?{sender:_e}:{}})).then(()=>!0,()=>!1)}try{I||await this.api.writeOwnerBlob(re,h,ue,s)}catch(fe){throw de(fe,"Failed to store encrypted blob",L(re))}}},B,A;try{B=await Zr(N,u,Gt,F),A=B.expiresAt}catch(re){let te=Jr(re);if(!te||!t.tier||!t.onPaymentRequired)throw re;let Ae=t.signal?{signal:t.signal}:{};await t.onPaymentRequired(await this.api.createCheckout(te.sealId,h,t.tier,Ae));let ue=Qr(te instanceof mn?te.expiresAt:void 0),fe=await ea(this.api,te.sealId,h,{deadline:ue,...Ae});if(!fe)throw await this.api.revoke(te.sealId,h).catch(()=>{}),new K("The seal was not paid in time and was revoked","PAYMENT_REQUIRED",402,L(te.sealId));B=await te.resume(F),A=fe.expires_at}if(!A)throw new K(`Seal ${B.sealId}: the server sent no expiry`,"INTERNAL_ERROR",500,L(B.sealId));let E=new Map;E.set(B.sha256_hex,Q(B.encryptionKey));let D=_n(),ie=Q(D),G=await Fr(E,D,U),Z=r&&i?await Rn(D,i,xn,B.sealId):null,ee;try{let re=Q(G);ee=r&&Z?await p(te=>this.api.createShareLink(B.sealId,h,re,{...s,to:r,fragment:Z,label:"sealnet",...te?{sender:te}:{}})):await this.api.createShareLink(B.sealId,h,re,s)}catch(re){throw de(re,"Seal created but share link mint failed",L(B.sealId))}let Xe=ra(B.sealId,ee,ie),Te=`${this.shareUrlBase}${Z?Xe.split("#")[0]:Xe}`,Ze=`${this.shareUrlBase}${na(B.sealId,M)}`,Je=Ie(B.encryptionKey);return{sealId:B.sealId,shareUrl:Te,ownerUrl:Ze,ownerToken:h,expiresAt:A,encryptionKey:Je,fileId:B.fileId,delivered:Z!==null,ownerCopy:I}}catch(b){if(b instanceof K)throw b;if(x){let F=b instanceof Error?b.message:String(b);throw new K(`Seal ${x} was created but the create flow was interrupted: ${F}`,"INTERNAL_ERROR",500,L(x),{cause:b})}throw b}}async revoke(t,n,r={}){try{return await this.api.revoke(t,n,r.signal?{signal:r.signal}:{})}catch(a){throw de(a,"Failed to revoke seal")}}};async function ba(e,t,n){let r=await import("fs/promises"),a=await import("path");await r.mkdir(t,{recursive:!0});let s=Array.from(crypto.getRandomValues(new Uint8Array(6)),d=>d.toString(16).padStart(2,"0")).join(""),o=a.join(t,`.seal-partial-${s}`),i=await r.open(o,"wx",384),l=!1;try{await e.stream.pipeTo(new WritableStream({async write(_){await i.write(_)}}));let{sizeBytes:d,sha256:p}=await e.done;await i.sync(),await i.close();let f=a.extname(n),u=n.slice(0,n.length-f.length);for(let _=0;_<1e3;_++){let h=a.join(t,_===0?n:`${u} (${_})${f}`);try{await r.link(o,h)}catch(m){if(m.code==="EEXIST")continue;throw m}return await r.unlink(o),l=!0,{path:h,sizeBytes:d,sha256:p}}throw new Error(`no free name for ${n} in ${t}`)}finally{l||(await i.close().catch(()=>{}),await r.unlink(o).catch(()=>{}))}}async function ma(e,t,n,r){let a=n.signal?{signal:n.signal}:{},s=await Pn(e,t,{...n.keyPair?{seed:V(n.keyPair.secretKey)}:{},...r?{wrap:r}:{},...a});if(s.ndaRequired)throw new K("This seal asks for an NDA signature: open it in a browser","AUTH_INSUFFICIENT_SCOPE",403);let o=null;if(s.otpRequired){if(!n.password)throw new K("This seal is password-protected: pass `password`","AUTH_INVALID_KEY",401);o=(await e.verifyOtp(s.sealId,{code:n.password},a)).sessionCookie}let i=s.files.filter(f=>f.key!==null&&f.sha256Hex!==null),l=i.reduce((f,u)=>f+u.size,0),d=0;return{seal:s,covered:i,read:async f=>{let u=await e.openDownload(s.sealId,{fileId:f.id,...o?{sessionCookie:o}:{}},a);if(!u.body)throw new K(`Download of ${f.name} returned no body`,"INTERNAL_ERROR",u.status);return Bn(u.body,f.key,f.sha256Hex,_=>{d+=_,n.onProgress?.(d,l)})}}}async function Nn(e,t,n={},r=null){try{let{seal:a,covered:s,read:o}=await ma(e,t,n,r);return{sealId:a.sealId,expiresAt:a.expiresAt,files:s.map(i=>({name:i.name,mime:i.mime,size:i.size,secret:i.secret,read:()=>o(i).catch(l=>Promise.reject(de(l,"Download failed")))}))}}catch(a){throw de(a,"Failed to open the link")}}async function Dn(e,t,n,r={},a=null){try{let{seal:s,covered:o,read:i}=await ma(e,t,r,a),l=[];for(let d of o){let p=await ba(await i(d),n,wa(d.name));l.push({name:d.name,mime:d.mime,secret:d.secret,...p})}return{sealId:s.sealId,expiresAt:s.expiresAt,files:l}}catch(s){throw de(s,"Failed to open the link")}}async function Ea(e,t,n){try{let r=await e.createIntake({recipientBundle:n.recipientBundle,label:n.label??"sealnet",what:n.what,...n.whereUrl?{whereUrl:n.whereUrl}:{},...n.kind?{kind:n.kind}:{},...n.ttl!==void 0?{ttlSeconds:n.ttl}:{},...n.to!==void 0?{to:n.to}:{}},n.signal?{signal:n.signal}:{});return{intakeId:r.id,url:`${t}/i/${r.id}`,words:(await On(V(n.recipientBundle))).words,expiresAt:r.expires_at}}catch(r){throw de(r,"Failed to create the request")}}async function Cn(e,t,n){try{return await fa(e,t,n?{signal:n}:{})}catch(r){throw de(r,"Failed to wait for the request")}}async function Sa(e,t,n){let r;try{r=await e.createIntake({recipientBundle:n.keyPair.bundle,label:(n.name??"sealnet").slice(0,80),what:da,kind:"pair"},n.signal?{signal:n.signal}:{})}catch(s){throw de(s,"Failed to create the pairing request")}let a=async()=>{let{sharePath:s,wrap:o}=await Cn(e,r.id,n.signal);try{let i=await ha(e,`${t}${s}`,ca,{seed:V(n.keyPair.secretKey),wrap:o,...n.signal?{signal:n.signal}:{}}),{bundle:l,name:d}=ua(i);return{address:(await On(l)).address,name:d}}catch(i){throw de(i,"The answer of the inbox did not open")}};return{url:`${t}/i/${r.id}`,words:n.keyPair.words,expiresAt:r.expires_at,wait:a}}async function Aa(){let e=sa(),{address:t,bundle:n,words:r}=await jt(e);return{secretKey:Q(e),address:t,bundle:Q(n),words:r}}async function va(e,t){let n=V(t.keyPair.secretKey),r=Date.now()+(t.wait??0)*1e3;try{for(await pa(e,n,t.signal?{signal:t.signal}:{}).catch(()=>0);;){let a=Math.ceil((r-Date.now())/1e3),s=await Ln(e,n,{...a>0?{waitSeconds:a}:{},...t.seen!==void 0?{seen:t.seen}:{},...t.signal?{signal:t.signal}:{}});if((t.seen!==void 0?s.version!==t.seen:s.items.length>0)||Date.now()>=r)return{version:s.version,items:s.items.map(i=>({id:i.id,fromWords:i.sender===null?null:la(i.sender),label:i.label,receivedAt:i.at,expiresAt:i.expires_at}))}}}catch(a){throw de(a,"Failed to read the inbox")}}async function Ta(e,t,n,r){let a;try{a=(await Ln(e,V(r.keyPair.secretKey),r.signal?{signal:r.signal}:{})).items}catch(o){throw de(o,"Failed to read the inbox")}let s=a.find(o=>o.id===n.id);if(!s)throw new K(`${n.id} is not in the inbox: it was revoked, expired or removed`,"RESOURCE_NOT_FOUND",404);return{url:`${t}${s.path}`,wrap:s.fragment}}async function xa(e,t,n){try{await ya(e,V(n.keyPair.secretKey),t.id,n.signal?{signal:n.signal}:{})}catch(r){throw de(r,"Failed to remove the item")}}var[Ei="",ka=""]="sdk-web/2.0.4".split("/");typeof globalThis.process?.versions?.node!="string"&&Jn(be);var Mn=class{seals;api;site;constructor(t={}){Br(Ei,ka);let n=t.apiUrl??"https://api.seal.net";this.site=(t.shareUrl??"https://seal.net").replace(/\/$/,"").replace(/\/s$/,""),this.seals=new Vt({apiUrl:n,shareUrl:this.site,credentials:"omit"}),this.api=new yt({baseUrl:n,credentials:"omit"})}async send(t){return this.seals.create(t)}async open(t,n={}){let{to:r,...a}=n,s;if(typeof t=="string")s={url:t,wrap:null};else if(a.keyPair)s=await Ta(this.api,this.site,t,{keyPair:a.keyPair,...a.signal?{signal:a.signal}:{}});else throw new K("An inbox item opens with the seed it was sent to: pass `keyPair`","VALIDATION_ERROR",400);return r!==void 0?Dn(this.api,s.url,r,a,s.wrap):Nn(this.api,s.url,a,s.wrap)}async inbox(t){return va(this.api,t)}async dismiss(t,n){return xa(this.api,t,n)}async request(t){return Ea(this.api,this.site,t)}async waitFor(t,n){let{sharePath:r,wrap:a}=await Cn(this.api,t,n.signal),{to:s,...o}=n,i=`${this.site}${r}`;return s!==void 0?Dn(this.api,i,s,o,a):Nn(this.api,i,o,a)}async pair(t){return Sa(this.api,this.site,t)}async keygen(){return Aa()}async revoke(t,n,r={}){return this.seals.revoke(t,n,r)}},Si=ka;return Ka(Ai);})();
|
|
1
|
+
/*! sealnet v3.0.0 | Proprietary — see LICENSE | bundles MIT-licensed @noble/hashes (Copyright (c) 2022 Paul Miller (https://paulmillr.com)), fflate (Copyright (c) 2023 Arjun Barrett) | full texts: THIRD-PARTY-NOTICES.txt */
|
|
2
|
+
"use strict";var Seal=(()=>{var es=Object.create;var xt=Object.defineProperty;var ts=Object.getOwnPropertyDescriptor;var ns=Object.getOwnPropertyNames;var rs=Object.getPrototypeOf,as=Object.prototype.hasOwnProperty;var Zn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ss=(e,t)=>{for(var n in t)xt(e,n,{get:t[n],enumerable:!0})},Jn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ns(t))!as.call(e,a)&&a!==n&&xt(e,a,{get:()=>t[a],enumerable:!(r=ts(t,a))||r.enumerable});return e};var Qn=(e,t,n)=>(n=e!=null?es(rs(e)):{},Jn(t||!e||!e.__esModule?xt(n,"default",{value:e,enumerable:!0}):n,e)),os=e=>Jn(xt({},"__esModule",{value:!0}),e);var sl={};ss(sl,{SealClient:()=>Gn,SealError:()=>j,VERSION:()=>al});var Se={url:"https://seal.net/sdk/v3.0.0/seal_crypto.wasm",integrity:"sha384-1YRbwC1HEXYdDK3uZhUll78kTSwBJsxo0u34UsveDvpdd5We2JKnqAWOsru5GK3R"};var Ws={},ls=Object.defineProperty,cs=(e,t)=>{for(var n in t)ls(e,n,{get:t[n],enumerable:!0})},sr={};cs(sr,{ContractTermsBuilder:()=>an,WasmIdentity:()=>sn,default:()=>Os,init:()=>ds,initSync:()=>Is,wasm_approval_message:()=>us,wasm_bundle_address:()=>hs,wasm_bundle_verify_for_address:()=>fs,wasm_contract_message:()=>ps,wasm_contract_message_v2:()=>_s,wasm_ed25519_verify:()=>ws,wasm_sealbox_unwrap:()=>gs,wasm_sealbox_wrap:()=>ys,wasm_summary_message:()=>bs,wasm_unwrap_file_key:()=>ms,wasm_wrap_file_key:()=>Es});var an=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,er.unregister(this),e}free(){let e=this.__destroy_into_raw();l.__wbg_contracttermsbuilder_free(e,0)}digest(){let e,t;try{let a=this.__destroy_into_raw(),s=l.__wbindgen_add_to_stack_pointer(-16);l.contracttermsbuilder_digest(s,a);var n=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0);return e=n,t=r,Ae(n,r)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(e,t,1)}}field(e,t,n,r,a,s,o,i,c,d){try{let u=l.__wbindgen_add_to_stack_pointer(-16),p=x(e,l.__wbindgen_export3,l.__wbindgen_export4),g=E,_=x(t,l.__wbindgen_export3,l.__wbindgen_export4),b=E,v=x(i,l.__wbindgen_export3,l.__wbindgen_export4),D=E,k=x(c,l.__wbindgen_export3,l.__wbindgen_export4),R=E;l.contracttermsbuilder_field(u,this.__wbg_ptr,p,g,_,b,n,r,a,s,o,v,D,k,R,d);var f=y().getInt32(u+0,!0),h=y().getInt32(u+4,!0);if(h)throw P(f)}finally{l.__wbindgen_add_to_stack_pointer(16)}}filled(e,t){try{let a=l.__wbindgen_add_to_stack_pointer(-16),s=x(e,l.__wbindgen_export3,l.__wbindgen_export4),o=E,i=x(t,l.__wbindgen_export3,l.__wbindgen_export4),c=E;l.contracttermsbuilder_filled(a,this.__wbg_ptr,s,o,i,c);var n=y().getInt32(a+0,!0),r=y().getInt32(a+4,!0);if(r)throw P(n)}finally{l.__wbindgen_add_to_stack_pointer(16)}}constructor(e){var t=it(e)?0:x(e,l.__wbindgen_export3,l.__wbindgen_export4),n=E;let r=l.contracttermsbuilder_new(t,n);return this.__wbg_ptr=r,er.register(this,this.__wbg_ptr,this),this}};Symbol.dispose&&(an.prototype[Symbol.dispose]=an.prototype.free);var sn=class kt{static __wrap(t){let n=Object.create(kt.prototype);return n.__wbg_ptr=t,tr.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,tr.unregister(this),t}free(){let t=this.__destroy_into_raw();l.__wbg_wasmidentity_free(t,0)}address(){let t,n;try{let s=l.__wbindgen_add_to_stack_pointer(-16);l.wasmidentity_address(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),a=y().getInt32(s+4,!0);return t=r,n=a,Ae(r,a)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(t,n,1)}}bundle(){let t=l.wasmidentity_bundle(this.__wbg_ptr);return P(t)}static fromSeed32(t){try{let s=l.__wbindgen_add_to_stack_pointer(-16),o=J(t,l.__wbindgen_export3),i=E;l.wasmidentity_fromSeed32(s,o,i);var n=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),a=y().getInt32(s+8,!0);if(a)throw P(r);return kt.__wrap(n)}finally{l.__wbindgen_add_to_stack_pointer(16)}}static fromSeed64(t,n){try{let o=l.__wbindgen_add_to_stack_pointer(-16),i=J(t,l.__wbindgen_export3),c=E;l.wasmidentity_fromSeed64(o,i,c,n);var r=y().getInt32(o+0,!0),a=y().getInt32(o+4,!0),s=y().getInt32(o+8,!0);if(s)throw P(a);return kt.__wrap(r)}finally{l.__wbindgen_add_to_stack_pointer(16)}}inboxProof(t,n){try{let o=l.__wbindgen_add_to_stack_pointer(-16),i=J(n,l.__wbindgen_export3),c=E;l.wasmidentity_inboxProof(o,this.__wbg_ptr,t,i,c);var r=y().getInt32(o+0,!0),a=y().getInt32(o+4,!0),s=y().getInt32(o+8,!0);if(s)throw P(a);return P(r)}finally{l.__wbindgen_add_to_stack_pointer(16)}}legacyAddress(){let t,n;try{let s=l.__wbindgen_add_to_stack_pointer(-16);l.wasmidentity_legacyAddress(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),a=y().getInt32(s+4,!0);return t=r,n=a,Ae(r,a)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(t,n,1)}}open(t,n,r){try{let i=l.__wbindgen_add_to_stack_pointer(-16),c=J(t,l.__wbindgen_export3),d=E,f=x(n,l.__wbindgen_export3,l.__wbindgen_export4),h=E,u=x(r,l.__wbindgen_export3,l.__wbindgen_export4),p=E;l.wasmidentity_open(i,this.__wbg_ptr,c,d,f,h,u,p);var a=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0),o=y().getInt32(i+8,!0);if(o)throw P(s);return P(a)}finally{l.__wbindgen_add_to_stack_pointer(16)}}signApproval(t,n,r){try{let i=l.__wbindgen_add_to_stack_pointer(-16),c=x(t,l.__wbindgen_export3,l.__wbindgen_export4),d=E,f=x(n,l.__wbindgen_export3,l.__wbindgen_export4),h=E,u=x(r,l.__wbindgen_export3,l.__wbindgen_export4),p=E;l.wasmidentity_signApproval(i,this.__wbg_ptr,c,d,f,h,u,p);var a=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0),o=y().getInt32(i+8,!0);if(o)throw P(s);return P(a)}finally{l.__wbindgen_add_to_stack_pointer(16)}}signContract(t,n,r){try{let i=l.__wbindgen_add_to_stack_pointer(-16),c=x(t,l.__wbindgen_export3,l.__wbindgen_export4),d=E,f=x(n,l.__wbindgen_export3,l.__wbindgen_export4),h=E,u=x(r,l.__wbindgen_export3,l.__wbindgen_export4),p=E;l.wasmidentity_signContract(i,this.__wbg_ptr,c,d,f,h,u,p);var a=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0),o=y().getInt32(i+8,!0);if(o)throw P(s);return P(a)}finally{l.__wbindgen_add_to_stack_pointer(16)}}signContractV2(t,n,r,a){try{let c=l.__wbindgen_add_to_stack_pointer(-16),d=x(t,l.__wbindgen_export3,l.__wbindgen_export4),f=E,h=x(n,l.__wbindgen_export3,l.__wbindgen_export4),u=E,p=x(r,l.__wbindgen_export3,l.__wbindgen_export4),g=E,_=x(a,l.__wbindgen_export3,l.__wbindgen_export4),b=E;l.wasmidentity_signContractV2(c,this.__wbg_ptr,d,f,h,u,p,g,_,b);var s=y().getInt32(c+0,!0),o=y().getInt32(c+4,!0),i=y().getInt32(c+8,!0);if(i)throw P(o);return P(s)}finally{l.__wbindgen_add_to_stack_pointer(16)}}signSummary(t,n,r,a){try{let c=l.__wbindgen_add_to_stack_pointer(-16),d=x(t,l.__wbindgen_export3,l.__wbindgen_export4),f=E,h=x(n,l.__wbindgen_export3,l.__wbindgen_export4),u=E,p=x(r,l.__wbindgen_export3,l.__wbindgen_export4),g=E;l.wasmidentity_signSummary(c,this.__wbg_ptr,d,f,h,u,p,g,a);var s=y().getInt32(c+0,!0),o=y().getInt32(c+4,!0),i=y().getInt32(c+8,!0);if(i)throw P(o);return P(s)}finally{l.__wbindgen_add_to_stack_pointer(16)}}userProof(t,n){try{let o=l.__wbindgen_add_to_stack_pointer(-16),i=J(t,l.__wbindgen_export3),c=E,d=J(n,l.__wbindgen_export3),f=E;l.wasmidentity_userProof(o,this.__wbg_ptr,i,c,d,f);var r=y().getInt32(o+0,!0),a=y().getInt32(o+4,!0),s=y().getInt32(o+8,!0);if(s)throw P(a);return P(r)}finally{l.__wbindgen_add_to_stack_pointer(16)}}words(){let t,n;try{let s=l.__wbindgen_add_to_stack_pointer(-16);l.wasmidentity_words(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),a=y().getInt32(s+4,!0);return t=r,n=a,Ae(r,a)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(t,n,1)}}workloadProof(t,n){try{let o=l.__wbindgen_add_to_stack_pointer(-16),i=J(t,l.__wbindgen_export3),c=E,d=J(n,l.__wbindgen_export3),f=E;l.wasmidentity_workloadProof(o,this.__wbg_ptr,i,c,d,f);var r=y().getInt32(o+0,!0),a=y().getInt32(o+4,!0),s=y().getInt32(o+8,!0);if(s)throw P(a);return P(r)}finally{l.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(sn.prototype[Symbol.dispose]=sn.prototype.free);function ds(){l.init()}function us(e,t,n){let r,a;try{let h=l.__wbindgen_add_to_stack_pointer(-16),u=x(e,l.__wbindgen_export3,l.__wbindgen_export4),p=E,g=x(t,l.__wbindgen_export3,l.__wbindgen_export4),_=E,b=x(n,l.__wbindgen_export3,l.__wbindgen_export4),v=E;l.wasm_approval_message(h,u,p,g,_,b,v);var s=y().getInt32(h+0,!0),o=y().getInt32(h+4,!0),i=y().getInt32(h+8,!0),c=y().getInt32(h+12,!0),d=s,f=o;if(c)throw d=0,f=0,P(i);return r=d,a=f,Ae(d,f)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(r,a,1)}}function hs(e){try{let a=l.__wbindgen_add_to_stack_pointer(-16),s=J(e,l.__wbindgen_export3),o=E;l.wasm_bundle_address(a,s,o);var t=y().getInt32(a+0,!0),n=y().getInt32(a+4,!0),r=y().getInt32(a+8,!0);if(r)throw P(n);return P(t)}finally{l.__wbindgen_add_to_stack_pointer(16)}}function fs(e,t){let n=J(e,l.__wbindgen_export3),r=E,a=x(t,l.__wbindgen_export3,l.__wbindgen_export4),s=E;return l.wasm_bundle_verify_for_address(n,r,a,s)!==0}function ps(e,t,n){let r,a;try{let h=l.__wbindgen_add_to_stack_pointer(-16),u=x(e,l.__wbindgen_export3,l.__wbindgen_export4),p=E,g=x(t,l.__wbindgen_export3,l.__wbindgen_export4),_=E,b=x(n,l.__wbindgen_export3,l.__wbindgen_export4),v=E;l.wasm_contract_message(h,u,p,g,_,b,v);var s=y().getInt32(h+0,!0),o=y().getInt32(h+4,!0),i=y().getInt32(h+8,!0),c=y().getInt32(h+12,!0),d=s,f=o;if(c)throw d=0,f=0,P(i);return r=d,a=f,Ae(d,f)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(r,a,1)}}function _s(e,t,n,r){let a,s;try{let u=l.__wbindgen_add_to_stack_pointer(-16),p=x(e,l.__wbindgen_export3,l.__wbindgen_export4),g=E,_=x(t,l.__wbindgen_export3,l.__wbindgen_export4),b=E,v=x(n,l.__wbindgen_export3,l.__wbindgen_export4),D=E,k=x(r,l.__wbindgen_export3,l.__wbindgen_export4),R=E;l.wasm_contract_message_v2(u,p,g,_,b,v,D,k,R);var o=y().getInt32(u+0,!0),i=y().getInt32(u+4,!0),c=y().getInt32(u+8,!0),d=y().getInt32(u+12,!0),f=o,h=i;if(d)throw f=0,h=0,P(c);return a=f,s=h,Ae(f,h)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(a,s,1)}}function ws(e,t,n){let r=J(e,l.__wbindgen_export3),a=E,s=J(t,l.__wbindgen_export3),o=E,i=J(n,l.__wbindgen_export3),c=E;return l.wasm_ed25519_verify(r,a,s,o,i,c)!==0}function gs(e,t,n,r){try{let i=l.__wbindgen_add_to_stack_pointer(-16),c=J(e,l.__wbindgen_export3),d=E,f=J(t,l.__wbindgen_export3),h=E,u=x(n,l.__wbindgen_export3,l.__wbindgen_export4),p=E,g=x(r,l.__wbindgen_export3,l.__wbindgen_export4),_=E;l.wasm_sealbox_unwrap(i,c,d,f,h,u,p,g,_);var a=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0),o=y().getInt32(i+8,!0);if(o)throw P(s);return P(a)}finally{l.__wbindgen_add_to_stack_pointer(16)}}function ys(e,t,n,r){try{let i=l.__wbindgen_add_to_stack_pointer(-16),c=J(e,l.__wbindgen_export3),d=E,f=J(t,l.__wbindgen_export3),h=E,u=x(n,l.__wbindgen_export3,l.__wbindgen_export4),p=E,g=x(r,l.__wbindgen_export3,l.__wbindgen_export4),_=E;l.wasm_sealbox_wrap(i,c,d,f,h,u,p,g,_);var a=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0),o=y().getInt32(i+8,!0);if(o)throw P(s);return P(a)}finally{l.__wbindgen_add_to_stack_pointer(16)}}function bs(e,t,n,r){let a,s;try{let u=l.__wbindgen_add_to_stack_pointer(-16),p=x(e,l.__wbindgen_export3,l.__wbindgen_export4),g=E,_=x(t,l.__wbindgen_export3,l.__wbindgen_export4),b=E,v=x(n,l.__wbindgen_export3,l.__wbindgen_export4),D=E;l.wasm_summary_message(u,p,g,_,b,v,D,r);var o=y().getInt32(u+0,!0),i=y().getInt32(u+4,!0),c=y().getInt32(u+8,!0),d=y().getInt32(u+12,!0),f=o,h=i;if(d)throw f=0,h=0,P(c);return a=f,s=h,Ae(f,h)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export2(a,s,1)}}function ms(e,t,n,r){try{let i=l.__wbindgen_add_to_stack_pointer(-16),c=J(e,l.__wbindgen_export3),d=E,f=J(t,l.__wbindgen_export3),h=E,u=x(n,l.__wbindgen_export3,l.__wbindgen_export4),p=E,g=x(r,l.__wbindgen_export3,l.__wbindgen_export4),_=E;l.wasm_unwrap_file_key(i,c,d,f,h,u,p,g,_);var a=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0),o=y().getInt32(i+8,!0);if(o)throw P(s);return P(a)}finally{l.__wbindgen_add_to_stack_pointer(16)}}function Es(e,t,n,r){try{let i=l.__wbindgen_add_to_stack_pointer(-16),c=J(e,l.__wbindgen_export3),d=E,f=J(t,l.__wbindgen_export3),h=E,u=x(n,l.__wbindgen_export3,l.__wbindgen_export4),p=E,g=x(r,l.__wbindgen_export3,l.__wbindgen_export4),_=E;l.wasm_wrap_file_key(i,c,d,f,h,u,p,g,_);var a=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0),o=y().getInt32(i+8,!0);if(o)throw P(s);return P(a)}finally{l.__wbindgen_add_to_stack_pointer(16)}}function or(){return{__proto__:null,"./seal_crypto_bg.js":{__proto__:null,__wbg___wbindgen_is_function_2f0fd7ceb86e64c5:function(t){return typeof K(t)=="function"},__wbg___wbindgen_is_object_5b22ff2418063a9c:function(t){let n=K(t);return typeof n=="object"&&n!==null},__wbg___wbindgen_is_string_eddc07a3efad52e6:function(t){return typeof K(t)=="string"},__wbg___wbindgen_is_undefined_244a92c34d3b6ec0:function(t){return K(t)===void 0},__wbg___wbindgen_throw_9c75d47bf9e7731e:function(t,n){throw new Error(Ae(t,n))},__wbg_call_a41d6421b30a32c5:function(){return st(function(t,n,r){let a=K(t).call(K(n),K(r));return te(a)},arguments)},__wbg_crypto_38df2bab126b63dc:function(t){let n=K(t).crypto;return te(n)},__wbg_error_a6fa202b58aa1cd3:function(t,n){let r,a;try{r=t,a=n,console.error(Ae(t,n))}finally{l.__wbindgen_export2(r,a,1)}},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return st(function(t,n){K(t).getRandomValues(K(n))},arguments)},__wbg_length_ba3c032602efe310:function(t){return K(t).length},__wbg_msCrypto_bd5a034af96bcba6:function(t){let n=K(t).msCrypto;return te(n)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return te(t)},__wbg_new_2fad8ca02fd00684:function(){let t=new Object;return te(t)},__wbg_new_from_slice_5a173c243af2e823:function(t,n){let r=new Uint8Array(nn(t,n));return te(r)},__wbg_new_with_length_9011f5da794bf5d9:function(t){let n=new Uint8Array(t>>>0);return te(n)},__wbg_node_84ea875411254db1:function(t){let n=K(t).node;return te(n)},__wbg_process_44c7a14e11e9f69e:function(t){let n=K(t).process;return te(n)},__wbg_prototypesetcall_fd4050e806e1d519:function(t,n,r){Uint8Array.prototype.set.call(nn(t,n),K(r))},__wbg_randomFillSync_6c25eac9869eb53c:function(){return st(function(t,n){K(t).randomFillSync(P(n))},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return st(function(){let t=module.require;return te(t)},arguments)},__wbg_set_5337f8ac82364a3f:function(){return st(function(t,n,r){return Reflect.set(K(t),K(n),K(r))},arguments)},__wbg_stack_3b0d974bbf31e44f:function(t,n){let r=K(n).stack,a=x(r,l.__wbindgen_export3,l.__wbindgen_export4),s=E;y().setInt32(t+4,s,!0),y().setInt32(t+0,a,!0)},__wbg_static_accessor_GLOBAL_THIS_1c7f1bd6c6941fdb:function(){let t=typeof globalThis>"u"?null:globalThis;return it(t)?0:te(t)},__wbg_static_accessor_GLOBAL_e039bc914f83e74e:function(){let t=typeof global>"u"?null:global;return it(t)?0:te(t)},__wbg_static_accessor_SELF_8bf8c48c28420ad5:function(){let t=typeof self>"u"?null:self;return it(t)?0:te(t)},__wbg_static_accessor_WINDOW_6aeee9b51652ee0f:function(){let t=typeof window>"u"?null:window;return it(t)?0:te(t)},__wbg_subarray_fbe3cef290e1fa43:function(t,n,r){let a=K(t).subarray(n>>>0,r>>>0);return te(a)},__wbg_versions_276b2795b1c6a219:function(t){let n=K(t).versions;return te(n)},__wbindgen_cast_0000000000000001:function(t,n){let r=nn(t,n);return te(r)},__wbindgen_cast_0000000000000002:function(t,n){let r=Ae(t,n);return te(r)},__wbindgen_object_clone_ref:function(t){let n=K(t);return te(n)},__wbindgen_object_drop_ref:function(t){P(t)}}}}var er=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>l.__wbg_contracttermsbuilder_free(e,1)),tr=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>l.__wbg_wasmidentity_free(e,1));function te(e){lt===Re.length&&Re.push(Re.length+1);let t=lt;return lt=Re[t],Re[t]=e,t}function Ss(e){e<1028||(Re[e]=lt,lt=e)}function nn(e,t){return e=e>>>0,je().subarray(e/1,e/1+t)}var He=null;function y(){return(He===null||He.buffer.detached===!0||He.buffer.detached===void 0&&He.buffer!==l.memory.buffer)&&(He=new DataView(l.memory.buffer)),He}function Ae(e,t){return vs(e>>>0,t)}var ot=null;function je(){return(ot===null||ot.byteLength===0)&&(ot=new Uint8Array(l.memory.buffer)),ot}function K(e){return Re[e]}function st(e,t){try{return e.apply(this,t)}catch(n){l.__wbindgen_export(te(n))}}var Re=new Array(1024).fill(void 0);Re.push(void 0,null,!0,!1);var lt=Re.length;function it(e){return e==null}function J(e,t){let n=t(e.length*1,1)>>>0;return je().set(e,n/1),E=e.length,n}function x(e,t,n){if(n===void 0){let i=ct.encode(e),c=t(i.length,1)>>>0;return je().subarray(c,c+i.length).set(i),E=i.length,c}let r=e.length,a=t(r,1)>>>0,s=je(),o=0;for(;o<r;o++){let i=e.charCodeAt(o);if(i>127)break;s[a+o]=i}if(o!==r){o!==0&&(e=e.slice(o)),a=n(a,r,r=o+e.length*3,1)>>>0;let i=je().subarray(a+o,a+r),c=ct.encodeInto(e,i);o+=c.written,a=n(a,r,o,1)>>>0}return E=o,a}function P(e){let t=K(e);return Ss(e),t}var Tt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Tt.decode();var As=2146435072,rn=0;function vs(e,t){return rn+=t,rn>=As&&(Tt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Tt.decode(),rn=t),Tt.decode(je().subarray(e,e+t))}var ct=new TextEncoder;"encodeInto"in ct||(ct.encodeInto=function(e,t){let n=ct.encode(e);return t.set(n),{read:e.length,written:n.length}});var E=0,xs,ks,l;function ir(e,t){return ks=e,l=e.exports,xs=t,He=null,ot=null,l}async function Ts(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(a){if(e.ok&&n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",a);else throw a}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}function Is(e){if(l!==void 0)return l;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=or();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let n=new WebAssembly.Instance(e,t);return ir(n,e)}async function Os(e){if(l!==void 0)return l;if(e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0)throw new Error("SEAL crypto: the WASM source must be passed to the loader");let t=or();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Ts(await e,t);return ir(n,r)}var Rs="seal_crypto.wasm",me=null,It=null,Ge=null;function lr(e){if(It||Ge)throw new Error("configureWasm: the WASM is already loaded or loading");me=e}function cr(){return globalThis.navigator?.userAgent==="Cloudflare-Workers"}function Ps(){return typeof globalThis.process?.versions?.node=="string"&&!cr()}async function nr(e){let t="node:fs/promises",{readFile:n}=await import(t);return n(e)}async function Ls(){if(me&&"module"in me)return me.module;if(me&&"url"in me)return fetch(me.url,me.integrity?{integrity:me.integrity}:{});if(me&&"path"in me)return nr(me.path);if(Ps())return nr(new URL(Rs,Ws.url));throw new Error(cr()?"seal crypto core: a Worker compiles no WASM from bytes \u2014 call configureWasm({ module }) with the imported .wasm":"sealnet: no WASM source in this browser (a broken build — reinstall sealnet)")}async function dt(){if(It)return It;if(Ge)return Ge;Ge=(async()=>{let e=sr;return await e.default({module_or_path:await Ls()}),typeof e.init=="function"&&e.init(),It=e,e})();try{return await Ge}catch(e){throw Ge=null,e}}var rr=32768,ar=class extends Error{constructor(e,t){super(e),this.input=t,this.name="Base64DecodeError"}};function Ds(e){let t="";for(let n=0;n<e.length;n+=rr){let r=e.subarray(n,Math.min(n+rr,e.length));t+=String.fromCharCode.apply(null,r)}return t}function Ns(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function Bs(e){let t=`${e.length} characters`;if(typeof atob<"u")try{return atob(e)}catch(n){throw new ar(`Invalid base64 encoding: ${n.message}`,t)}try{return Buffer.from(e,"base64").toString("binary")}catch(n){throw new ar(`Invalid base64 encoding: ${n.message}`,t)}}function Cs(e){return typeof btoa<"u"?btoa(e):Buffer.from(e,"binary").toString("base64")}function Ms(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4;return t+="=".repeat(n),t}function Us(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Pe(e){return Cs(Ds(e))}function ne(e){return Us(Pe(e))}function Ot(e){return Ns(Bs(e))}function de(e){return Ot(Ms(e))}async function Fs(e){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),n=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(n)}async function Ye(e){let t=await Fs(e);return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("")}function Hs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Pt(e,...t){if(!Hs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function on(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function dr(e,t){Pt(e);let n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Lt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ve(e,t){return e<<32-t|e>>>t}function $s(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ln(e){return typeof e=="string"&&(e=$s(e)),Pt(e),e}var Rt=class{};function ur(e){let t=r=>e().update(ln(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ks(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);let a=BigInt(32),s=BigInt(4294967295),o=Number(n>>a&s),i=Number(n&s),c=r?4:0,d=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+d,i,r)}function hr(e,t,n){return e&t^~e&n}function fr(e,t,n){return e&t^e&n^t&n}var Dt=class extends Rt{constructor(t,n,r,a){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=a,this.buffer=new Uint8Array(t),this.view=Lt(this.buffer)}update(t){on(this),t=ln(t),Pt(t);let{view:n,buffer:r,blockLen:a}=this,s=t.length;for(let o=0;o<s;){let i=Math.min(a-this.pos,s-o);if(i===a){let c=Lt(t);for(;a<=s-o;o+=a)this.process(c,o);continue}r.set(t.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===a&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){on(this),dr(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:a,isLE:s}=this,{pos:o}=this;n[o++]=128,ut(this.buffer.subarray(o)),this.padOffset>a-o&&(this.process(r,0),o=0);for(let h=o;h<a;h++)n[h]=0;Ks(r,a-8,BigInt(this.length*8),s),this.process(r,0);let i=Lt(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<d;h++)i.setUint32(4*h,f[h],s)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:r,length:a,finished:s,destroyed:o,pos:i}=this;return t.destroyed=o,t.finished=s,t.length=a,t.pos=i,a%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}},Le=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var zs=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Me=new Uint32Array(64),cn=class extends Dt{constructor(t=32){super(64,t,8,!1),this.A=Le[0]|0,this.B=Le[1]|0,this.C=Le[2]|0,this.D=Le[3]|0,this.E=Le[4]|0,this.F=Le[5]|0,this.G=Le[6]|0,this.H=Le[7]|0}get(){let{A:t,B:n,C:r,D:a,E:s,F:o,G:i,H:c}=this;return[t,n,r,a,s,o,i,c]}set(t,n,r,a,s,o,i,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=a|0,this.E=s|0,this.F=o|0,this.G=i|0,this.H=c|0}process(t,n){for(let h=0;h<16;h++,n+=4)Me[h]=t.getUint32(n,!1);for(let h=16;h<64;h++){let u=Me[h-15],p=Me[h-2],g=ve(u,7)^ve(u,18)^u>>>3,_=ve(p,17)^ve(p,19)^p>>>10;Me[h]=_+Me[h-7]+g+Me[h-16]|0}let{A:r,B:a,C:s,D:o,E:i,F:c,G:d,H:f}=this;for(let h=0;h<64;h++){let u=ve(i,6)^ve(i,11)^ve(i,25),p=f+u+hr(i,c,d)+zs[h]+Me[h]|0,_=(ve(r,2)^ve(r,13)^ve(r,22))+fr(r,a,s)|0;f=d,d=c,c=i,i=o+p|0,o=s,s=a,a=r,r=p+_|0}r=r+this.A|0,a=a+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,a,s,o,i,c,d,f)}roundClean(){ut(Me)}destroy(){this.set(0,0,0,0,0,0,0,0),ut(this.buffer)}};var Nt=ur(()=>new cn);var pe={version:2,name:"AEON",magic_bytes:[65,69,79,52],magic_length:4,header_length:24,header_layout:[{name:"magic",offset:0,length:4},{name:"segment_size_u32_le",offset:4,length:4},{name:"file_id",offset:8,length:16}],nonce_length:12,tag_length:16,segment_overhead:28,segment_size_bytes:1048576,min_segment_size_bytes:1048576,max_segment_size_bytes:67108864,aad_layout:[{name:"header",length:24},{name:"segment_index_u64_le",length:8},{name:"last_u8",length:1}],supported_format_versions:[3,4],current_format_version:4,v3_reader:{magic_bytes:[65,69,79,78],header_length:8}},bn=new Uint8Array(pe.magic_bytes),Wt=pe.magic_length,Fe=pe.header_length,Ve=pe.nonce_length,mn=pe.tag_length,Hr=pe.segment_overhead,$r=pe.segment_size_bytes,pr=pe.min_segment_size_bytes,_r=pe.max_segment_size_bytes,ft=pe.header_layout.find(e=>e.name==="file_id"),wr=pe.aad_layout.reduce((e,t)=>e+t.length,0),Kr=new Uint8Array(pe.v3_reader.magic_bytes),zr=pe.v3_reader.header_length;function Gs(e){return Ve+e+mn}function En(e){let t=Math.max(1,Math.ceil(e/$r));return Fe+t*Hr+e}function js(){let e=new Uint8Array(Fe);return e.set(bn,0),new DataView(e.buffer).setUint32(Wt,$r,!0),e.set(crypto.getRandomValues(new Uint8Array(ft.length)),ft.offset),e}function Ht(e,t){return e.length>=t.length&&t.every((n,r)=>e[r]===n)}function Gr(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(Wt,!0);if(t<pr||t>_r)throw new Error(`segment size ${t} is outside ${pr}\u2026${_r}`);return t}function Sn(e){if(e.length<Fe)throw new Error(`an AEON v4 header is ${Fe} bytes, got ${e.length}`);if(!Ht(e,bn))throw new Error("not an AEON v4 header");return{segmentSize:Gr(e),fileId:e.slice(ft.offset,ft.offset+ft.length)}}function Ys(e){if(e.length<zr||!Ht(e,Kr))throw new Error("not an AEON v3 header");return{segmentSize:Gr(e)}}function Vs(e){return Ht(e,bn)?"v4":Ht(e,Kr)?"v3":null}function jr(e,t,n){let r=new Uint8Array(wr);return r.set(e.subarray(0,Fe),0),new DataView(r.buffer).setBigUint64(Fe,BigInt(t),!0),r[wr-1]=n?1:0,r}function qs(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Yr(e){let t=qs(e);try{return crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt","decrypt"])}finally{new Uint8Array(t).fill(0)}}async function Xs(e,t,n){let r=crypto.getRandomValues(new Uint8Array(Ve)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:r,tagLength:mn*8,additionalData:n},e,t),s=new Uint8Array(Ve+a.byteLength);return s.set(r,0),s.set(new Uint8Array(a),Ve),s}async function Zs(e,t,n){let r={name:"AES-GCM",iv:t.subarray(0,Ve),tagLength:mn*8};return n&&(r.additionalData=n),new Uint8Array(await crypto.subtle.decrypt(r,e,t.subarray(Ve)))}function Js(){return Nt.create()}async function pt(){let e=globalThis.scheduler;return typeof e?.yield=="function"?e.yield():typeof MessageChannel<"u"?new Promise(t=>{let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(null)}):new Promise(t=>setTimeout(t,0))}function Qs(){return crypto.getRandomValues(new Uint8Array(32))}var _e={version:1,limits:{MAX_FILES_PER_SEAL:30,FREE_TIER_BYTES:1073741824,MAX_TOTAL_SIZE_BYTES:1073741824,MAX_FILE_SIZE_BYTES:10737418240,MAX_MULTIPART_FILE_SIZE_BYTES:10737418240,MAX_BLOB_SIZE:1048576,MAX_BLOB_BASE64_SIZE:1468006,MAX_MESSAGE_LENGTH:5e3,MAX_FILE_KEYS:1e4,MAX_ACTIVE_UPLOADS_PER_SEAL:10,MAX_OPENS_PER_SEAL_FREE:10,TIER_BYTES:{free:1073741824,"5gb":5368709120,"50gb":53687091200,"500gb":536870912e3},SEAL_TIERS:{"5gb":{bytes:5368709120,amount_cents:900,duration_days:90,name:"5 GB / 3 months",description:"One-time payment for 5 GB storage and 3 months TTL"},"50gb":{bytes:53687091200,amount_cents:2900,duration_days:180,name:"50 GB / 6 months",description:"One-time payment for 50 GB storage and 6 months TTL"},"500gb":{bytes:536870912e3,amount_cents:9900,duration_days:365,name:"500 GB / 12 months",description:"One-time payment for 500 GB storage and 12 months TTL"}},PRO_REGIONS:["eu-west","eu-central","us-east","us-west","apac-southeast","apac-northeast"],ttl_options:["5m","30m","1h","1d","7d"],OTP_LENGTH:{min:6,max:10},USER_PASSWORD_MIN_LENGTH:8,INTAKE_TTL_DEFAULT_SECONDS:900,INTAKE_TTL_MAX_SECONDS:86400,INTAKE_WAIT_MAX_SECONDS:25,PAYMENT_WAIT_MAX_SECONDS:82800,ADDRESS_PROOF_TTL_SECONDS:300,INBOX_MAX_ITEMS:200,LEASE_DEFAULT_DAYS:7,LEASE_MAX_DAYS:90,LEASE_STATUS_BATCH_MAX:500,LEASE_POLL_SECONDS:600,LEASE_KEEP_DAYS:30,APPROVE_WAIT_SECONDS:120,APPROVE_BODY_SHOWN_BYTES:2048,DRIVE_OPEN_TTL_SECONDS:300,DRIVE_PRESIGN_WINDOW_DEFAULT_BYTES:67108864,DRIVE_PRESIGN_WINDOW_MIN_BYTES:8388608,DRIVE_PRESIGN_UNBOUND_TTL_SECONDS:30,DRIVE_WRITE_LEASE_SECONDS:7200,DRIVE_WRITE_BACK_SECONDS:5,VERSION_RETENTION_DAYS_DEFAULT:30,VERSION_KEEP_MIN:10,GRANT_WORKLOAD_MAX_TTL_DAYS:90,SENSOR_OPENS_PER_MINUTE_DEFAULT:120,SENSOR_BYTES_PER_MINUTE_DEFAULT:2147483648,SENSOR_SECRETS_PER_MINUTE_DEFAULT:20,SENSOR_NOVELTY_WINDOW_DAYS:30,SENSOR_HOLD_TTL_SECONDS:86400,SENSOR_BASELINE_MIN_HOURS:72,SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT:107374182400}},Xe={version:1,default_aead:"aes_256_gcm",aes_gcm:{key_length_bytes:32,nonce_length_bytes:12,tag_length_bytes:16},sha256:{output_length_bytes:32,hex_string_length:64},owner_token_bytes:32,link_key_bytes:32,metadata_aad_prefix:"field:",keybundle:{signature_prefix:"seal:keybundle:",signed_bundle_version:2,v2_fields:["identity_ed25519_pub","agreement_x25519_pub","kem_mlkem768_pub"],packed_length:1316,address:{of:"sha256(identity_ed25519_pub), 32 bytes",text:"base64url without padding, 43 characters",words:"fingerprint_words.json over its first eight bytes"}},hkdf:{wrap_key_salt:"seal:wrapkey:v1",wrap_key_salt_v2:"seal:wrapkey:v2",identity_key_salt:"seal:key-derivation:v1",file_envelope_salt:"seal:file-envelope:v1",info_prefixes:{wrap:"WRAP",agreement:"AGRE",identity:"IDEN",workload_identity:"seal:workload-identity:v1",share_proof:"seal:share-proof:v1",kem_mlkem768:"seal:kem-mlkem768:v1"}},share_link:{proof_of:"the proof of a share link's key (AUDIT K237): HKDF-SHA256(ikm = the link's 32-byte key, salt = hkdf.identity_key_salt, info = hkdf.info_prefixes.share_proof, 32 bytes), base64url; its maker gives the server proof_hash = SHA-256 hex of those bytes, an opener sends the proof in proof_header",proof_header:"X-Share-Proof",proof_vector:{link_key:"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8",proof:"xYwpyfG6o6iW43T5O7W9Av5bVZJc5MpUhcmPa6SxQy8",proof_hash:"75d668b6b3295aad0b8e3f83eb9d03181a9c81f92836105077023bf3bea0aa4a"}},xwing:{label_hex:"5c2e2f2f5e5c"},sealed_box_v2:{version_byte:2,packed_layout:[{name:"version",offset:0,length:1},{name:"eph_pub",offset:1,length:32},{name:"kem_ct",offset:33,length:1088},{name:"nonce",offset:1121,length:12},{name:"ct",offset:1133,length:48}],packed_length:1181,packed_b64_length:1575},secret_scope_aad:"secret:{secret_id}",scope_metadata_aad:{is:"What a sealed text of a scope's metadata is bound to: the AAD of its AES-256-GCM (SEAL Pro, AUDIT K140, SPEC-NAMES-BOUND). A room's name and description are bound to the room. A text under the organization's key and the name of a seal's folder are bound to their own object: its id stands in the AAD, so two of them cannot be swapped unnoticed. The binding before that named the kind and the organization (the seal) only; a row says which one its text has by `encryption_version`, a seal's folder has no such mark and is read bound first, then as before.",room:"room:{room_id}:{field}",org_object:{bound:"{kind}:{org_id}:{object_id}:{field}",before:"{kind}:{org_id}:{field}",kinds:["secret","sign-policy","sign-template","sign-template-body","sign-template-meta","sign-folder","sign-request-meta","sign-field-value"],field:"name",object:"the row the text belongs to: the secret, the policy, the template (its name, text and terms alike), the contract folder, the sign request, the signature field of a drawing"},folder:{bound:"seal:{seal_id}:{folder_id}:name",before:"seal:{seal_id}:name"},versions:{before:3,bound:5,note:"4 is a file's format version (seal_files) and names no metadata"},vectors:{key_hex:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",nonce_b64:"ZGVmZ2hpamtsbW5v",org_object:{kind:"secret",org_id:"0b9f4c1e-6f0a-4c56-9d0e-2f1c3a4b5d6e",object_id:"7a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d",other_object_id:"11111111-2222-4333-8444-555555555555",text:"prod-db",bound_aad:"secret:0b9f4c1e-6f0a-4c56-9d0e-2f1c3a4b5d6e:7a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d:name",bound_b64:"OGmxAlSNNC/EcAW6hlU6eU73XrC7Vaw=",before_aad:"secret:0b9f4c1e-6f0a-4c56-9d0e-2f1c3a4b5d6e:name",before_b64:"OGmxAlSNNBiKlnxW4fkbPMjFoZGJJDY="},folder:{seal_id:"AbCd1234",folder_id:"c0ffee00-1234-4abc-8def-0123456789ab",other_folder_id:"11111111-2222-4333-8444-555555555555",text:"\u0414\u043E\u0433\u043E\u0432\u043E\u0440\u044B 2026",bound_aad:"seal:AbCd1234:c0ffee00-1234-4abc-8def-0123456789ab:name",bound_b64:"mI8O2KlahiDu0I9WC+W7dmLwNji94CvUmMxJnLVFN5EChD6uMg==",before_aad:"seal:AbCd1234:name",before_b64:"mI8O2KlahiDu0I9WC+W7dmLwNji9ni0vIvgReyNDk0uY98XR7Q=="}}},sign:{message_prefix:"aeon:sign:v1",message_format:"aeon:sign:v1|org:{org_id}|req:{request_id}|doc_hash:{doc_hash_hex}",message_prefix_v2:"aeon:sign:v2",message_format_v2:"aeon:sign:v2|org:{org_id}|req:{request_id}|doc_hash:{doc_hash_hex}|terms:{terms_hex}",terms_label:"aeon:terms:v1",terms_of:"what the signer was shown (AUDIT K204): SHA-256 hex of the lines the core builds (shared/core/src/contract_terms.rs) \u2014 for a member of the organization or its agent from the metadata ciphertext and the whole field layout, for an outside signer from their own fields alone and no metadata \u2014 and the signer's own filled fields",terms_vector:{org_id:"0d0f2a1e-5b7c-4c1d-9e3a-2f6b8c4d1a70",request_id:"7a1c3e5b-9d2f-4b6a-8c0e-1f3a5b7d9c2e",doc_hash:"cb99e3fc33b873e56252762ef641f21153fb14f66fb1d8bbf82d2033dcb31d33",meta:"bWV0YS1jaXBoZXJ0ZXh0",fields:[{id:"b2f1c3d4-0000-4000-8000-000000000002",type:"signature",page:2,x:.615,y:.8125,w:.3,h:.075,assignee_type:"email",assignee:"ann|example@example.com",required:!0},{id:"a1e0b2c3-0000-4000-8000-000000000001",type:"signature",page:1,x:.1,y:.7,w:.3,h:.075,assignee_type:"user",assignee:"5c9e7a3b-1d2f-4a6b-8c0d-2e4f6a8b0c1d",required:!0}],filled:[{field_id:"a1e0b2c3-0000-4000-8000-000000000001",sha256:"bde5c9647a96e96c78ea116eaa7a653b2347cd83855d223b30984f235151f813"}],terms:"a38d4d567232eb54cb8c2276988b1a4d0b31dc763b6dadcc6b33909d1b844f30",message:"aeon:sign:v2|org:0d0f2a1e-5b7c-4c1d-9e3a-2f6b8c4d1a70|req:7a1c3e5b-9d2f-4b6a-8c0e-1f3a5b7d9c2e|doc_hash:cb99e3fc33b873e56252762ef641f21153fb14f66fb1d8bbf82d2033dcb31d33|terms:a38d4d567232eb54cb8c2276988b1a4d0b31dc763b6dadcc6b33909d1b844f30"}},sign_doc_hash_of:"sha256(plaintext) of the exact seal_files row in doc_ref",recovery_phrase:{seed:`BIP39: PBKDF2-HMAC-SHA512 of the phrase after trim, lower case and NFKD, salt "mnemonic", 2048 iterations, 64 bytes; the web's recoveryPhrase.ts phraseToMasterSeed and the core's hkdf::master_seed_from_phrase (\u04145 \xA73.2)`,vector:{phrase:"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art",typed:` Abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon ART
|
|
3
|
+
`,seed_hex:"408b285c123836004f4b8842c89324c1f01382450c0d439af345ba7fc49acf705489c6fc77dbd4e3dc1dd8cc6bc9f043db8ada1e243c4a0eafb290d399480840"}},device_link:{record:"a person's seed64, base64url, sealed by the browser to the one-time bundle of sealfs login: sealReply(seed64, bundle, scope, code) of the protocol's identity module \u2014 box (sealed_box_v2) \u2016 nonce(12) \u2016 AES-256-GCM of the record under the box's key; the daemon opens it with its one-time identity (\u04145 \xA73.2 \u043F. 2, D119)",scope:"device",vector:{daemon_seed64_hex:"01080f161d242b323940474e555c636a71787f868d949ba2a9b0b7bec5ccd3dae1e8eff6fd040b121920272e353c434a51585f666d747b828990979ea5acb3ba",code:"K7M2Q9XA",seed64_hex:"030a11181f262d343b424950575e656c737a81888f969da4abb2b9c0c7ced5dce3eaf1f8ff060d141b222930373e454c535a61686f767d848b9299a0a7aeb5bc",record:"AlbSFUYf2V9yux_9DyViIEw_gXJcdITRt0kFjJC9XAJTOCRSKh3_hDCGxBSS5idHldzc_qQOtd43_GYaZQm9_VH90eY2JDP_A2T4I8W_qPPfS4MlLGtBp0kkShY_PnspF6bELAbft3XNkEuwQpfynXH2OFFvAPwJFKceua18YAywNbq84plsv8n3C5lRmeITyeFwKlxDW3-6q-2NHlAgkSrScie1B63CQu3D0U3SRWcOHMvwnl9Topwe1J2iu4EpOUlJRZQsgfBR4LhyywAWam0R3VHa_pXjCtN4Of-JRyO3Jub-6MgDXpoGsQuD9V1XszngRZkwz0R_4xqSlabtA-GMiCJyhff7HBp3t0XHeaS04cNdtATfwce_FUL3IL-z0YAQh-JSzKz_VeVq8iFSZcbHnx2Eab3ND4YuwvJxfJJ8jGquahnhndiI6qxZtK7OmQsy8ZBQ_p4Gi8v1ziN74OMdQG9UtqR9igeJohiMos5tHpveIXQ9luWiQ9gk22p53yGzP8hH_mv508tb4KsveNjssXS0hVmLl4c7fqQbrBjKvNauuEbzNd1gimV4I_f-N0FN2c7Pe7sTZevR5dnIGrAF_31cxFTOWVjZdKsyEWUiwSHrG2dQBccO2AB6TurTsqr4hBP64c3WkUW1vJVXKEOCKxBIwMa7XyyLw4La5tZue0Ls2cHzfy2Kd5jKCo3UIQrjvNWOvXFDRlkTx10UMFpZNvmnITHVh6rHkr5_tGFVMwqU2arRmwQBWCBYsDhN1NVJ8cEwEb0lNHfuotqf54IZUP25JwqpqSkSadjHdVHZdJ50MQUiNiumm0e-kbLDfWHds9dkGhwVgqha3s-svngKweowybgYAnRIDYeHHkSN-9Bm2jNmidilQhTiY6eLmnxg81sdESUNrjk1nhNJdiTaDAeX-CL5DJxPVirKFWYgrBpvJ7ocpxg9Idqsdm8fIzZi-MAQyq_I1y2RcsUqZEwFFeHqwPZdUce1PxVBjFn27cfKzyifotbTBumodLXMRnrrhfQ2i6cHAt9utI2X_WJuGxDRfYICuKdQHt3NPswIwLxSxgNUvpani5DzhYA5FnC-zfh_LWXyJnyfJx1Yr-07_ICpIP85fwzO7FAVZxpdpsL8wk19HhW63LAOVcQxANLcIue7hp1vU6QU1Co0H4yGJgmehDEBYWFJCpaDk8_srkw42Y9eZn6SNoIekuz-BNgjnnB0WB2mh-k3vux92C-_2o8GsSeENNvOOTRwLOLAB4PCi-Uf__oonrLR0kBdE2gbrVjb6sttEx8Df_S7YuTCytpw13ABaXCcJRsPfR6os2KuM1Rv53CH5SZ2NpKgdFlBmva9gIsMSJxAh08UtLGNhKrli3uUW1KER7Ng92RDDV-HHUqNyOhkPPD4KteeZHX0m9h8POVCjXr0TNHSisQK_CPFMMOhUc2DmEHDOZO9piI5uMAznMdzrR-qFbhPNN9ugUUSIdDnVS9Mc2INiUIKjnLWB37_wYTSpXRCS5bSfohMPyNu0dTuAJuHLNfK1hA9XOGhvZLFW9rgXN8bYdAmUL0TrJJ4DYBWrpzXuzaiXEf2peRi0z6LYiXWyjvmIaQfvttTgWSymbREbJmanBDfTUPR5XPFQHZ-n_876ODCoJAXnqOkSSWEHKf885bOre3IkJIS_2jH9_MJzG0Fsmnvj8VYHECIrZlRFdsqzMQ9MIIIIWg0bfHvAn5R06o"}}},fe={version:2,$comment:"Address of a bundle: who a seal is for, without a URL (SPEC-AEON-V4 \xA75). Numbers live in limits.json, error codes in error_codes.json, the bundle and the wrap in crypto.json (keybundle, sealed_box_v2).",address:{of:"SHA-256 of the identity key (Ed25519) of the bundle v2, 32 bytes",text:"base64url without padding, 43 characters",words:"fingerprint_words.json over the first eight bytes of the address: the words of SHA-256(identity key), named without hashing again",inbox:"the 32 bytes of the address are the key the server finds an inbox by"},box_origin:"https://box.seal.net",seed:{env:"SEAL_SEED",text:"base64url without padding of the 64-byte seed of an agent, a device or an inbox, 86 characters",derives:"all three keys of the bundle v2 the address names are HKDF-SHA256 of the seed under crypto.json hkdf.identity_key_salt, each under its own info: hkdf.info_prefixes identity (Ed25519), agreement (X25519) and kem_mlkem768 (d \u2016 z of ML-KEM-768), followed by key_version as four bytes, little-endian \u2014 the core's Identity::from_seed. No public key of the bundle is the seed",key_version:1,same_as:["sealnet-mcp state.identity.seed_b64","seal identity.v1.json seed_b64url","sealnet (npm) KeyPair.secretKey","sealnet (PyPI) keygen().secret_key"],root:"SPEC-SEED-ROOT: the one kind of seed. A seed of 32 bytes (43 characters) is a key of the kind before: a holder that keeps its seed itself reads it as its previous key (below) until that expires, and nothing makes it or takes it as a seed \u2014 SEAL_SEED, an inbox key file, a device transfer and an SDK key of that length are refused in words that say how to make a new one.",vector:{comment:"the seed of the vector `sealed-box-v2-person` of xwing_test_vectors.json (seed64_hex; its bundle, address and words are there) signs the challenge of ts into this proof \u2014 Identity::from_seed, Identity::inbox_proof; Ed25519 is deterministic, every client reproduces it",of:"sealed-box-v2-person",ts:179e7,challenge:"wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t8",proof:"1790000000.wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t8.1VKxaNHrNu5Is9gYxMur7mAABL8Pn0Lcz6vpw5JDmUI65epcxGCMUOGcJK-lneqALDx0EHlBHbhmUIHWPCCDCQ"},previous:"the seed a holder had before it replaced its key, 32 or 64 bytes, kept beside the current one where the holder keeps its seed itself (an inbox, a device's identity file, the MCP server's state): it opens what the server still holds at the old address and is erased when the last of that has expired \u2014 seven days from the replacement (limits.json ttl_options, the longest free seal), longer while the inbox shows a live row at the old address"},bundles:{put:"PUT /intake/bundles {bundle}: bundle is base64url of the packed bundle (crypto.json keybundle.packed_length). The server verifies it with the core and files it under the address it computes; no authorization \u2014 the bundle proves itself \u2014 and a limit per IP",get:"GET /intake/bundles/{address} -> {bundle}; 404 intake.bundle_not_found",accept:"a sender takes a bundle only if SHA-256 of its identity key is the address and its signature verifies; a client puts its own bundle at its first start and again whenever it is gone"},scopes:{share_link:"seal_share",owner_copy:"seal_owner"},proof:{header_address:"X-Seal-Address",header_proof:"X-Seal-Proof",challenge:"POST /intake/proof {address} -> {ts, challenge}: challenge = base64url(HMAC(server key, address(32) || ts u64 BE)), 43 characters; the server keeps no state",message:'"seal:inbox-proof:v2" || address(32) || ts u64 BE || challenge(32), signed with the identity key of the address; the core builds it (Identity::inbox_proof)',proof_text:"<ts>.<challenge>.<signature>: ts the decimal Unix second of the challenge, challenge as received, signature base64url of 64 bytes",check:"the window, the HMAC, and the signature against the bundle of the address with a small-order key refused"},items:{delivery:{id:"s.<seal_id>.<share_code>",is:"a share link addressed to this address: path /s/<seal_id>/<share_code> without a fragment; fragment = its key wrapped to the address's bundle (sealed box v2, scope share_link)"},owner:{id:"o.<seal_id>",is:"the seal's owner-blob key wrapped to the address's bundle (sealed box v2, scope owner_copy); path /s/<seal_id> opens the seal page, the only place that manages a seal"},request:{id:"r.<intake_id>",is:"a request asked of this address; path /i/<intake_id>, no fragment; carries what, kind and recipient_bundle"},listing:"GET /intake?to= lists deliveries only, as before owner copies and cards existed; `all=1` adds owner and request items (a person's inbox). Agent clients never send it: those rows are a person's."},request:{recipient_bundle:"POST /intake carries recipient_bundle, base64url of the requester's packed bundle; the page verifies it and shows the eight words of its address, the answer's key is wrapped to it (scope share_link) and comes back as the request's fragment, with share_path without a fragment"},owner_copy:{web_label:"seal.net",is:"The seal names the inbox that manages it: its row carries the owner-blob key wrapped to that address's bundle, one per seal, written with the owner blob (PATCH /seal/{id}/blob with to, fragment, label) before the first byte of the files. Best effort: an address without a bundle is the same PATCH without the address part, and the seal is made anyway."},request_kinds:["secret","file","any","pair","device","guard"],pair_what:"inbox",guard:{kind:"guard",is:"a pair request whose requester is this machine's guard (SPEC agent egress \xA73.1): the same answer as `pair` (the pairing file), and the inbox marks the agent as a guard. A request for a secret whose recipient_bundle is a guard's is shown by the inbox as sealed to that guard; one whose bundle is no known guard's is answered only after the person types its eight words (\xA76.1, T2\u0430).",gateway:"SPEC agent egress \xA77.2, level \u0412: `seal guard expose --listen <address:port> [--as <host:port>]` makes a guard the owner's gateway \u2014 `POST https://<host:port>/v1/forward` over mTLS, both certificates made from the guards' Ed25519 identity keys and checked against the published bundles of their addresses (the client names its address in `x-seal-address`, the server is the `gateway.guard` of the binding). `seal guard lend <key> --to <address>` lends a key as use: the borrower's guard receives a handle under a binding with `gateway: {at, guard}` (owner_blob_payload.v1.json bindings) and sends the request with `x-seal-method` and `x-seal-url` (the host's URL) to the gateway, which puts the value in and answers with the host's answer. The gateway not reachable: 502 `{error: seal_guard.gateway, reason: gateway_offline}`.",bind:"POST /intake may carry `bind`: what the agent proposes the key be bound to \u2014 {hosts: [<host>], place?: <place>, class?: outbound|inprocess} (secrets.json guard_note). `bind` is sent only when the recipient_bundle is a guard's, hosts proposed or not: its presence is what lets the page bind the key and lend it under a lease; without it the page says the value goes to the agent as it is. The page shows the proposal as the binding when no entry of secrets.json knows the key's form; the person confirms, narrows or removes it. At most 16 hosts of 253 characters, each a name of two labels or more (`*.` with two labels under it, three under secrets.json wildcard_public_second_level); the server checks the shape and keeps it as given."},payloads:{name_max:80,pair:{mime:"application/vnd.seal.pairing+json",json:`{"v":2,"bundle":"<the inbox's packed bundle, base64url, 1755>","name":"<inbox name, at most name_max>"}`},device:{mime:"application/vnd.seal.device+json",json:'{"v":2,"seed":"<inbox seed, 86>","name":"<inbox name>","agents":[{"address":"<43>","name":"<name>","paired_at":"<ISO 8601>","kind":"guard"?}]}',kind:"`guard` for an agent that is a machine's guard (request kind `guard`): it stays a guard on every device of the inbox and through a rename; a reader drops a kind it does not know (SPEC-APP r5 \u041425)"},approve:{mime:"application/vnd.seal.approve+json",json:'{"v":2,"ask":"<16 random bytes, base64url>","secret_id":"<k_\u2026>","secret":"<STRIPE_KEY>","guard":"<eight words of the guard>","host":"api.stripe.com","method":"POST","path":"/v1/refunds?expand=charge","at":"<ISO 8601>","until":"<ISO 8601>","body_bytes":24,"body":"charge=ch_1&amount=50000"?,"body_sha256":"<SHA-256 hex of the whole body>"?,"body_more":true?}',body:"What the call carries (AUDIT K152): `path` is the path with its query; `body_bytes` the bytes of the body the guard read; `body` its first `limits.json::APPROVE_BODY_SHOWN_BYTES` bytes when they are text, cut where a character ends, absent for an empty or a binary body; `body_sha256` the digest of the whole body, absent for an empty one and for one that streams on past what the guard reads whole, which `body_more` says. An agent's request holds surrogates, never a value. A reader takes a question without these fields (a guard before them) and shows what it has.",is:"A guard's question to a key's owner (SPEC agent egress \xA77.3, \u04214): a call the binding marks `approve: owner` waits for this answer. Sent as a seal addressed to the owner (30 minutes, one open), its share blob marked `payload: approve`; the inbox shows it as a card with Allow and Deny and pushes. Unanswered within `limits.json::APPROVE_WAIT_SECONDS` the call is refused (403 `approve`)."},approve_answer:{mime:"application/vnd.seal.approve-answer+json",json:`{"v":2,"ask":"<the ask>","decision":"allow"|"deny","at":"<ISO 8601>","signature":"<Ed25519 by the inbox's identity key over the core's approval message, base64url, 86>"}`,is:"The owner's answer (\xA77.3): a seal from the inbox to the guard's address (30 minutes, one open), blob `payload: approve_answer`; the guard checks the signature against the owner's bundle (the `owner` of the binding). `allow` is for the one call the question was about (AUDIT K152): the same call again is another question."},summary:{mime:"application/vnd.seal.summary+json",json:`{"v":2,"secret_id":"<k_\u2026>","secret":"<STRIPE_KEY>","day":"<YYYY-MM-DD, UTC>","counts":[{"method":"GET","path":"/v1/charges/*","status":200,"n":40}],"approved":2,"refused":1,"root":"<SHA-256 hex, the chain's last link>","n":43,"signature":"<Ed25519 by the guard's identity key over the core's summary message, base64url, 86>"}`,is:"A guard's daily summary of one lent key to its owner (\xA77.4, \u04213): once a day by UTC and on a revoke, a seal addressed to the owner (7 days, one open), blob `payload: summary`. The inbox checks the signature against the guard's bundle (the item's sender), keeps the summary in its own storage (the carrier expires) and shows the journal under the lease. Attested by the guard that wrote the receipts: honest of an honest guard."},blob_payload:"A seal a machine makes for another machine or for an inbox carries the kind of its file in the share blob's `payload` (`approve`, `approve_answer`, `summary`, `delivery`), under the link key: the inbox reads the blob of every delivery and downloads only the files of these kinds; the server sees one more addressed seal. Readers tolerate a blob without the field.",delivery:{mime:"application/vnd.seal.delivery+json",json:`{"v":2,"name":"<the binding's name, STRIPE_KEY>","level":"A"|"B"|"0","at":"<ISO 8601>"}`,is:"The receipt of a lent key's arrival (SPEC agent egress \xA76.2, T17): whoever opens a secret whose binding names an `owner` sends this file, as a seal addressed to that owner (7d, one open), the moment the secret is opened. `A` or `B`: the opener's guard holds the key and the agent got a surrogate \u2014 the level is the one that guard names in its `status` (SPEC-APP r4 \u042038: `A` its key in a file of the user, `B` in the protected keychain of the SEAL app); `0`: the opener holds the value itself, the second level. The level travels inside the ciphertext; the server sees one more addressed seal. No receipt when the binding has no owner, or the owner is the opener itself."}},device_link:{code:"16 Crockford base32 characters from 10 random bytes (80 bits): the server sees the what beside the device's address, so the code must not be searchable from them (SPEC-r4 \u041A-4, AUDIT wpkg03.3)",what:"base64url(HMAC-SHA256(key = the code in ASCII, message = the 32-byte address of the new device)), 43 characters: the what of the device request",link:"https://box.seal.net/#link=<address>.<code>"},bridge:{path:"/bridge",is:"A hidden iframe of box_origin on seal.net; postMessage only between the two origins. It never gives out the address or the name for the asking: it answers any script of seal.net. The address goes back only with a lease the inbox kept (box.lease), to be sealed into the key's binding as its owner.",hello:"box.hello {sealId?} -> {box: boolean, has: boolean}; box: this device has an inbox; has: this seal is already in Yours",owner_copy:"box.ownerCopy {sealId, ownerToken, linkKey} -> {ok: boolean}",lease:"box.lease {lease: {id, token, name, hosts, words, expires_at}} -> {ok: boolean, address?: string}; ok: the lease and its revoke token are in Sent; address: the inbox's address, the owner of the lent key (SPEC agent egress \xA77.3\u20137.5: the guard asks it for its word and sends it the daily summary)"},migrate:{until:"C1 + 7 days (C1 \xA76)",is:"Every inbox and agent changes its address once (\xA75.7). The X25519 key does not change \u2014 it is the seed \u2014 so the client moves the live rows of its old address once, under the proof of its new one: POST /intake/migrate {old_address} answers the old challenge, {old_address, old_proof} moves links, owner copies, cards and push subscriptions; the agreement key of the new address's bundle must equal the old address, and the senders of moved rows are cleared. Zero rows is a success.",old_address:"the X25519 public key of the seed, base64url without padding, 43 characters",challenge:"sealed box v1 of a 32-byte token to the old address with scope (address_proof, decimal ts): ephemeral_pub(32) || nonce(12) || ciphertext(48), base64url, 123 characters",old_proof:"<ts>.<token>: token base64url of the 32 bytes the challenge opens to",scope_address_proof:"seal_address_proof",vector:{comment:"every client that migrates must open it",secret:"BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc",address:"E75P6uryBMf9M1j8nAByGIHRdCeBKCJ-xnTzf3_pe20",ts:179e7,challenge:"4Oel-UMfgP_1dBhmf13yZiujhPDouCIQ6sSx1nY1qy-vyzFqDqb9jARbJ0e5A8vv4EDELDS5OPqBQMcsmDA-C_lXO95y_CVUyYtSu-1fltsy5ZihOFDp0T-C9Ro",token:"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8"}},vectors:[{address:"Afdcc-OkgjU572_xdbUHZSNPO6r6Up6ctP2pfF0PHJw",bundle:"4rFhOdoKNSNI9qMxGju3FssbOjE0YN8CnitU4OD4dW4Eun0cCRx-W2Ad-PsAyD8R9LVv_v5mxs08kUEG5VurbwtRz7BXT4NoZoZytUXshnRVuBnjT3nghVcGmLLCpUi4qVzBsZOkO3e7tBbmAHsnDDF1eEPkjS0zQ6s6mkmFbHQnANoFXUnSM6ESOpPMmi11pv4QE9XYRpj2C_5JzmFXWLiYTA3pucRjUgPZkSmgp38RGRWZbcpsexeMmmJCdEolY52MoQaJesxJYRPgzlMSa9YnEICxfr8Xuwkgpxw3ucOxMolUXQKUBToGfUUxtC7BHrq2W3wEcF4LJaFytD44qdW2Ze0LSf8IlsESZWj6YbLabL25FAwmGntZKHQ7LDK7C4ZXsNVioS9yDNh1ADaqdTqGZnPlDaI2HiDCGVMzVTOQRvt6BZWKSUNrudd7t-2JxyUCWFk5szNrcUVJwsBrNdIXm_04iuvbcW-4s-kmXmX6CStgPdZSVgFgcAOQwsOwU57zjoA0pehUqiLwaHbLu0Z5poD1agnppIXItFLhVkRDExOHF7KxUD70CEJjUrHxxf0ln4H1S1t3udfFTA11SjBYXsTxq0VIMDoTnXzYenHLWXpYwDlogzagyb1UXfprRkNgbssmd9xyw_aKz2AWjAdqpeAmIwVbnlfcxA-0MixZpVtkpSyZeXhwAPf8Q0raFNESLbJSBx1GStgiNzNkf553RC0JCLXITOw6YHuyQKF8y05gFwXTjJ0hBwUgTEQVJt71miJ8N7asYFDrAVSWm7t0qA55RobkTdnBliKCCjrnKxGET5M0sPrlyC3yTUu3fHrpEDRqiN8yFZRpD9QBXtaorIM8b6XcVAWJFKjauhn5tC4RAJDEi384o_NQAg0WowA3UuJ0LFg5ELRGQuZCrP_RVIHGAR5lcOeSY9SzW-dmp-MbsfSWf_iBEkYsc_iFTwkTf3M5Thd4TSJxwJ9odRS0LqRZgrgEWcYYl5PalYYrBHqhsMiAshpzibQLTPbQh1CUMTLMIrorvqVbhdZovQmSdShIWLTmkhWJGN_seAfnQNFhufXlg2dsNSGZCdcivn_VfKUHFpm8DOHRCqWcdwcrw7K3gtPgTC2GQvSJxAH6pq5hshTKCqF6mtFiA2-FbjYwDhRskt8Mf15IkQWDCI2LNDnJLg6qPMbaMxUEyWd7N1QWmHNgtU9syAMLhVHsHlohPq8ZdygIRIw6IjbFR0EDb8jYhY1DQUc3WWLQX_AsdMwHNgeRzhlcd2fohE5BzB_Lb3V1NpmsMPe2FhmGD8b3Pb-1ZR-MtJD6tgq1YSs7JOeWjKETlN2YqCaIFCeRWUIygkpbF158x4lVqqgQQZ70kzXsJTWJZbY5mvXHbAUsWLezERn4hWWKau_Mno78GTRKZfO5ymbWl4Hku8ECskl3dL8oy5hAOGhGcGOyhDLXISTTZL3JQ2Qwy0X7AfqDIQCTnuCLa3_AhIsjMXFzB-rCq8WjUsh4YsW1ENBJjV_2G6-HWRVDpo6nIDVnZRGxATTCvnLjXcn0USEXsBI6R6aAcgqGXzabd_QyLpK2EdUnaH3xIWjGYsdRjIuUWQM3odyjH7TFOurwlQV3hU2KMmAO13XqmD5fvhxVi5-kWTnN16EDDV0EXLky4Jug0SNgHchy3ymbXVBx8TfsJcCumYk9iuui2D-cDpa7KJEGwBVN-9lvLEidQddWX_CMfbmG_wdHaC4Hapi-U2OhsH-2AwEAAAA",challenge:"wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t8",comment:"generated once by shared/core (Identity::from_seed32, Identity::inbox_proof); every client must reproduce it",legacy_address:"BLp9HAkcfltgHfj7AMg_EfS1b_7-ZsbNPJFBBuVbq28",proof:"1790000000.wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t8.74s5T1rE2xRNbameeTbYUHVMN-ZzFu1JBPZJNtH8eYC1vV7-h2HE_hxgo4vUB0_sHFfdYRUf0bve4_KGe32ICg",seed:"Aw4ZJC86RVBbZnF8h5KdqLO-ydTf6vUACxYhLDdCTVg",signature:"74s5T1rE2xRNbameeTbYUHVMN-ZzFu1JBPZJNtH8eYC1vV7-h2HE_hxgo4vUB0_sHFfdYRUf0bve4_KGe32ICg",ts:179e7,words:"album wren hedge kite tulip peach llama echo"}]},eo="X-Seal-Client",B={version:1,upload:{DEFAULT_PART_SIZE_BYTES:16777216,S3_MIN_PART_SIZE_BYTES:5242880,MAX_PART_SIZE_BYTES:268435456,MULTIPART_THRESHOLD_BYTES:8388608,FINE_PART_SIZE_BYTES:8388608,FINE_PART_MAX_FILE_BYTES:536870912,INMEMORY_BLOB_LIMIT_BYTES:104857600,MULTIPART_UPLOAD_TTL_SECONDS:86400,PRESIGN_BATCH_SIZE:100,SMALL_FILE_POOL:4,PART_POOL_MIN:2,PART_POOL_START:2,PART_POOL_MAX:5,PART_POOL_GROW_RATIO:1.15,PART_POOL_SHRINK_RATIO:.7,PART_QUEUE_LIMIT:2,HEDGE_MIN_INFLIGHT_MS:3e3,HEDGE_LAG_FACTOR:3,HEDGE_POLL_MS:1e3,LIVENESS_SILENCE_MS:3e4,RETRY_BACKOFF_MS:[1e3,3e3,7e3,15e3,3e4],RETRY_JITTER_RATIO:.2,STALL_NOTICE_MS:3e4,MAX_STALL_MS:6e5,PUT_FLOOR_BYTES_PER_SECOND:20480,PUT_MIN_DEADLINE_MS:3e4,CONTROL_TIMEOUT_MS:3e4,COMPLETE_TIMEOUT_MS:12e4,VERIFY_POLL_BACKOFF_MS:[0,2e3,3e3,5e3,8e3],VERIFY_FALLBACK_WAIT_MS:6e4,NOT_READY_MAX_RETRIES:3,PROGRESS_SPEED_WINDOW_MS:2e4}},Vr;function Ze(e,t){return(Vr??globalThis.fetch).call(globalThis,e,t)}function to(){return Vr!==void 0}var Il=2*1024*1024,no=(_e.limits.INTAKE_WAIT_MAX_SECONDS+15)*1e3,Ol=fe.proof.header_address,Rl=fe.proof.header_proof;function ro(){try{return typeof process<"u"&&!0}catch{return!1}}var ao=(e,t,n,...r)=>{let a=`[${t}] ${n}`;switch(e){case"debug":ro()||console.debug(a,...r);break;case"info":console.info(a,...r);break;case"warn":console.warn(a,...r);break;case"error":console.error(a,...r);break}},Bt=ao;function gt(e){return{debug:(t,...n)=>Bt("debug",e,t,...n),info:(t,...n)=>Bt("info",e,t,...n),warn:(t,...n)=>Bt("warn",e,t,...n),error:(t,...n)=>Bt("error",e,t,...n)}}var O=class extends Error{constructor(e,t,n,r,a=!1){super(e),this.code=t,this.httpStatus=n,this.partNumber=r,this.retryable=a,this.name="UploadError"}};function so(e,t){return Object.defineProperty(e,"session",{value:t,enumerable:!1,configurable:!0,writable:!0}),e}function ze(e,t){return e instanceof O?e:e instanceof DOMException&&e.name==="AbortError"?new O("Upload aborted","ABORTED"):new O(e instanceof Error?e.message:t,"UNKNOWN")}async function qe(e,t,n,r){let a=await Ct(e,String(e.status));return new O(`${t}: ${a.message}`,e.status===426?"CLIENT_OUTDATED":n,e.status,r)}var oo=gt("upload"),io={now:()=>performance.now(),after:(e,t)=>{let n=setTimeout(t,e);return()=>clearTimeout(n)},every:(e,t)=>{let n=setInterval(t,e);return()=>clearInterval(n)}},lo={retryBackoffMs:B.upload.RETRY_BACKOFF_MS,retryJitterRatio:B.upload.RETRY_JITTER_RATIO,stallNoticeMs:B.upload.STALL_NOTICE_MS,maxStallMs:B.upload.MAX_STALL_MS,putFloorBytesPerSecond:B.upload.PUT_FLOOR_BYTES_PER_SECOND,putMinDeadlineMs:B.upload.PUT_MIN_DEADLINE_MS,controlTimeoutMs:B.upload.CONTROL_TIMEOUT_MS,completeTimeoutMs:B.upload.COMPLETE_TIMEOUT_MS,poolStart:B.upload.PART_POOL_START,poolMax:B.upload.PART_POOL_MAX,poolMin:B.upload.PART_POOL_MIN,poolGrowRatio:B.upload.PART_POOL_GROW_RATIO,poolShrinkRatio:B.upload.PART_POOL_SHRINK_RATIO,partQueueLimit:B.upload.PART_QUEUE_LIMIT,hedgeMinInflightMs:B.upload.HEDGE_MIN_INFLIGHT_MS,hedgeLagFactor:B.upload.HEDGE_LAG_FACTOR,hedgePollMs:B.upload.HEDGE_POLL_MS,livenessSilenceMs:B.upload.LIVENESS_SILENCE_MS,verifyPollBackoffMs:B.upload.VERIFY_POLL_BACKOFF_MS,verifyFallbackWaitMs:B.upload.VERIFY_FALLBACK_WAIT_MS,speedWindowMs:B.upload.PROGRESS_SPEED_WINDOW_MS,clock:io};function An(e){return{...lo,...e}}function hn(e,t){return Math.max(t.putMinDeadlineMs,Math.ceil(e/t.putFloorBytesPerSecond*1e3))}var qr=()=>globalThis.AbortSignal;function vn(e){let t=qr()?.any;if(typeof t=="function")return t.call(AbortSignal,e);let n=new AbortController,r=e.find(a=>a.aborted);if(r)return n.abort(r.reason),n.signal;for(let a of e)a.addEventListener("abort",()=>n.abort(a.reason),{once:!0,signal:n.signal});return n.signal}function co(e){let t=qr()?.timeout;if(typeof t=="function")return t.call(AbortSignal,e);let n=new AbortController;return setTimeout(()=>n.abort(new DOMException("The operation timed out.","TimeoutError")),e),n.signal}function Xr(e,t){let n=co(t);return e?vn([e,n]):n}async function _t(e,t,n,r){try{return await Ze(e,{...t,signal:Xr(r,n)})}catch(a){throw r?.aborted?new O("Upload aborted","ABORTED"):new O(`Request failed: ${a instanceof Error?a.message:String(a)}`,"NETWORK",void 0,void 0,!0)}}function Zr(e){return e===408||e===429||e>=500?"retryable":"terminal"}function Jr(e){return e.code==="ABORTED"?"terminal":e.code==="BAD_DIGEST"||e.httpStatus===void 0?"retryable":e.httpStatus===403?"refresh_url":Zr(e.httpStatus)}function Qr(e){return e.code==="ABORTED"?"terminal":e.httpStatus===void 0?"retryable":Zr(e.httpStatus)}var ea=class{constructor(e,t,n=()=>performance.now()){this.policy=e,this.onState=t,this.now=n,this.failingSince=null,this.current="running",this.noticeTimer=null,this.retriesSinceDelivery=0}get state(){return this.current}connectionLost(){this.setState("stalled")}delivered(){this.failingSince=null,this.retriesSinceDelivery=0,this.clearNotice(),this.setState("running")}exhausted(){return this.failingSince!==null&&this.now()-this.failingSince>=this.policy.maxStallMs}failed(){this.retriesSinceDelivery+=1,this.failingSince??(this.failingSince=this.now());let e=this.policy.stallNoticeMs-(this.now()-this.failingSince);e<=0?this.setState("stalled"):this.noticeTimer===null&&this.current==="running"&&(this.noticeTimer=setTimeout(()=>{this.noticeTimer=null,this.setState("stalled")},e))}dispose(){this.clearNotice()}clearNotice(){this.noticeTimer!==null&&(clearTimeout(this.noticeTimer),this.noticeTimer=null)}setState(e){e!==this.current&&(this.current=e,this.onState?.(e))}};function xn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new O("Upload aborted","ABORTED"));return}let a=()=>{clearTimeout(s),r(new O("Upload aborted","ABORTED"))},s=setTimeout(()=>{t?.removeEventListener("abort",a),n()},e);t?.addEventListener("abort",a,{once:!0})})}async function $t(e,t){let{clock:n,policy:r,signal:a,classify:s,what:o}=t,i,c=0;for(let d=0;;d++){if(a?.aborted)throw new O("Upload aborted","ABORTED");try{return await e({attempt:d,after:i})}catch(f){let h=ze(f,`${o} failed`);if(h.code==="ABORTED")throw h;let u=s(h);if(u==="terminal")throw h;if(n.exhausted())throw new O(`${o}: no progress for ${Math.round(r.maxStallMs/1e3)} s \u2014 ${h.message}`,h.code,h.httpStatus,h.partNumber,!1);n.failed(),c=u==="refresh_url"?c+1:0;let p=u==="refresh_url"&&c===1,g=r.retryBackoffMs[Math.min(d,r.retryBackoffMs.length-1)]??0,_=1+(Math.random()*2-1)*r.retryJitterRatio,b=p?0:Math.round(g*_);oo.debug(`retry ${o} attempt=${d+2} in ${b}ms after ${h.code}${h.httpStatus?" "+h.httpStatus:""} (${u})`),i=u,await xn(b,a)}}}var fn;function ta(e,t){fn=`${e}/${t}`}function pn(){return fn===void 0?{}:{[eo]:fn}}var ie=class extends Error{constructor(e,t,n,r={}){super(e),this.name="BackendError",this.code=t,this.status=n,this.body=r.body,this.detail=r.detail,this.appCode=r.appCode,this.retryAfter=r.retryAfter,this.update=r.update,this.minVersion=r.minVersion}};function uo(e){return e===404?"not_found":e===410?"revoked":e===451?"blocked":e===429?"rate_limited":e===401||e===403?"auth":e>=500&&e<600?"transient":"unknown"}async function Ct(e,t){let n=await e.text().catch(()=>""),r,a,s,o,i;if(n)try{let c=JSON.parse(n);typeof c?.detail=="string"&&(r=c.detail),typeof c?.code=="string"&&(a=c.code),typeof c?.retry_after=="number"&&(s=c.retry_after),typeof c?.update=="string"&&(o=c.update),typeof c?.min_version=="string"&&(i=c.min_version)}catch{}return new ie(r??t,uo(e.status),e.status,{body:n||void 0,detail:r,appCode:a,retryAfter:s,update:o,minVersion:i})}function ho(e){return{id:e.id,expiresAt:e.expires_at,revokedAt:e.revoked_at,ndaRequired:e.nda_required,otpRequired:e.otp_required,singleUse:e.single_use,maxOpens:e.max_opens??null,files:(e.files??[]).map(t=>({id:t.id,size:t.size,sha256_hex:t.sha256_hex,name_encrypted:t.name_encrypted,name_nonce:t.name_nonce,mime_encrypted:t.mime_encrypted,mime_nonce:t.mime_nonce}))}}function z(e){return encodeURIComponent(e)}var fo=Xe.share_link.proof_header,na=new Map;async function ra(e){let t=new TextEncoder,n=await crypto.subtle.importKey("raw",e,"HKDF",!1,["deriveBits"]),r=await crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:t.encode(Xe.hkdf.identity_key_salt),info:t.encode(Xe.hkdf.info_prefixes.share_proof)},n,256),a=new Uint8Array(r),s=new Uint8Array(await crypto.subtle.digest("SHA-256",a));return{proof:ne(a),hash:Array.from(s,o=>o.toString(16).padStart(2,"0")).join("")}}async function gr(e,t){na.set(e,(await ra(t)).proof)}function po(e){let t=/^\/seal\/([^/?]+)/.exec(e)?.[1],n=t?na.get(decodeURIComponent(t)):void 0;return n?{[fo]:n}:{}}var yt=class ge{constructor(t){if(this.baseUrl=t.baseUrl.replace(/\/+$/,""),typeof(t.fetch??globalThis.fetch)!="function")throw new Error("SealApi: no global fetch in this runtime \u2014 pass options.fetch or use Node >= 18");this.injectedFetch=t.fetch,this.credentials=t.credentials,this.answerTimeoutMs=t.answerTimeoutMs??no}fetchImpl(t,n){return this.injectedFetch?this.injectedFetch.call(globalThis,t,n):Ze(t,n)}url(t){if(!t.startsWith("/"))throw new Error(`SealApi: path must start with '/', got: ${t}`);return`${this.baseUrl}${t}`}async request(t,n){let{what:r,...a}=n,s=new AbortController,o=setTimeout(()=>s.abort(new DOMException(`${r}: no answer in time`,"TimeoutError")),this.answerTimeoutMs),i;try{i=await this.fetchImpl(this.url(t),{...a,headers:{...pn(),...po(t),...a.headers},credentials:a.credentials??this.credentials,signal:a.signal?vn([a.signal,s.signal]):s.signal})}finally{clearTimeout(o)}if(!i.ok)throw await Ct(i,`${r} failed: ${i.status}`);return i}static ownerHeaders(t,n=!1){let r={"X-Owner-Token":t};return n&&(r["Content-Type"]="application/json"),r}async getMetadata(t,n={}){let r=n.shareCode?`?share_code=${z(n.shareCode)}`:"";return await(await this.request(`/seal/${z(t)}${r}`,{what:`GET /seal/${t}`,signal:n.signal})).json()}async getShareBlob(t,n,r={}){let a=`GET /seal/${t}/share/${n}`,s=await this.request(`/seal/${z(t)}/share/${z(n)}`,{what:a,signal:r.signal}),o=await s.json();return{blob:mr(o,a,s.status),wrap:typeof o.fragment=="string"&&o.fragment?o.fragment:null}}async verifyOtp(t,n,r={}){let a={code:n.code};n.fileId&&(a.file_id=n.fileId),n.shareCode&&(a.share_code=n.shareCode);let s=await this.request(`/seal/${z(t)}/otp`,{what:`POST /seal/${t}/otp`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:r.signal}),o=go(s,`otp_${t}`),i=await s.json().catch(()=>({}));return{status:typeof i.status=="string"?i.status:"ok",sessionCookie:o}}async acceptNda(t,n,r={}){let a={signature:n.signature,timestamp:n.timestamp,first_name:n.firstName,last_name:n.lastName};n.company&&(a.company=n.company),n.fileId&&(a.file_id=n.fileId),n.shareCode&&(a.share_code=n.shareCode),n.ndaText&&(a.nda_text=n.ndaText);let o=await(await this.request(`/seal/${z(t)}/nda`,{what:`POST /seal/${t}/nda`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:r.signal})).json().catch(()=>({}));return{status:typeof o.status=="string"?o.status:"ok"}}downloadUrl(t,n){return this.url(`/seal/${z(t)}/download?${yr(n)}`)}async openDownload(t,n,r={}){let a=n.ownerToken?ge.ownerHeaders(n.ownerToken):{};n.sessionCookie&&(a.Cookie=n.sessionCookie);for(let s=0;;s++)try{return await this.request(`/seal/${z(t)}/download?${yr(n)}`,{what:`GET /seal/${t}/download?file_id=${n.fileId}`,headers:a,signal:r.signal})}catch(o){if(!(o instanceof ie&&o.appCode==="file.not_ready"&&r.retryNotReady!==!1&&s<B.upload.NOT_READY_MAX_RETRIES))throw o;await wo((o.retryAfter??_o)*1e3,r.signal)}}async downloadCiphertext(t,n,r={}){let a=await this.openDownload(t,n,r);if(a.headers.get("X-Download-Mode")!=="presigned")return a;let{url:s}=await a.json();if(typeof s!="string"||!s)throw new ie(`GET /seal/${t}/download answered no storage URL`,"transient",502);let o=await this.fetchImpl(s,{signal:r.signal});if(!o.ok)throw await Ct(o,`storage download failed: ${o.status}`);return o}async getOwnerSeal(t,n,r={}){return await(await this.request(`/seal/${z(t)}/owner`,{what:`GET /seal/${t}/owner`,headers:ge.ownerHeaders(n),signal:r.signal})).json()}async readOwnerBlob(t,n={}){let r=await this.request(`/seal/${z(t)}/blob`,{what:`GET /seal/${t}/blob`,signal:n.signal}),a=r.headers.get("ETag");return{blob:mr(await r.json(),`GET /seal/${t}/blob`,r.status),etag:a}}async writeOwnerBlob(t,n,r,a={}){let s=ge.ownerHeaders(n,!0);a.ifMatch&&(s["If-Match"]=a.ifMatch);let o={encrypted_blob:r};return br(a,o,s),{etag:(await this.request(`/seal/${z(t)}/blob`,{what:`PATCH /seal/${t}/blob`,method:"PATCH",headers:s,body:JSON.stringify(o),signal:a.signal})).headers.get("ETag")}}async createShareLink(t,n,r,a,s={}){let o=n===null?{"Content-Type":"application/json"}:ge.ownerHeaders(n,!0),i={encrypted_blob:r,proof_hash:(await ra(a)).hash};s.fileIds&&(i.file_ids=s.fileIds),br(s,i,o);let c=await this.request(`/seal/${z(t)}/share`,{what:`POST /seal/${t}/share`,method:"POST",headers:o,body:JSON.stringify(i),signal:s.signal}),d=await c.json();if(typeof d.share_code!="string"||!d.share_code)throw new ie(`POST /seal/${t}/share returned no share_code`,"unknown",c.status);return d.share_code}async revokeShareLink(t,n,r,a={}){await this.request(`/seal/${z(t)}/share/${z(n)}/revoke`,{what:`POST /seal/${t}/share/${n}/revoke`,method:"POST",headers:r===null?{}:ge.ownerHeaders(r),signal:a.signal})}async revoke(t,n,r={}){let a;try{a=await this.request(`/seal/${z(t)}/revoke`,{what:`POST /seal/${t}/revoke`,method:"POST",headers:ge.ownerHeaders(n),signal:r.signal})}catch(o){if(o instanceof ie&&(o.status===404&&o.appCode==="seal.not_found"||o.status===410))return{status:"revoked",revokedAt:null};throw o}let s=await a.json().catch(()=>({}));return{status:typeof s.status=="string"?s.status:"revoked",revokedAt:typeof s.revoked_at=="string"?s.revoked_at:null}}async revokeFile(t,n,r,a={}){await this.request(`/seal/${z(t)}/files/${z(n)}/revoke`,{what:`POST /seal/${t}/files/${n}/revoke`,method:"POST",headers:ge.ownerHeaders(r),signal:a.signal})}async getAudit(t,n,r={}){return await(await this.request(`/seal/${z(t)}/audit`,{what:`GET /seal/${t}/audit`,headers:ge.ownerHeaders(n),signal:r.signal})).json()}async openAuditDownload(t,n,r={}){return this.request(`/seal/${z(t)}/audit/download`,{what:`GET /seal/${t}/audit/download`,headers:ge.ownerHeaders(n),signal:r.signal})}async createSubscription(t,n,r={},a={}){let s=await this.request(`/seal/${z(t)}/subscriptions`,{what:`POST /seal/${t}/subscriptions`,method:"POST",headers:ge.ownerHeaders(n,!0),body:JSON.stringify(r.reference?{reference:r.reference}:{}),signal:a.signal}),o=await s.json();if(typeof o.id!="string"||typeof o.secret!="string")throw new ie(`POST /seal/${t}/subscriptions returned no subscription`,"unknown",s.status);return{id:o.id,secret:o.secret}}async createCheckout(t,n,r,a={}){let s=await this.request("/billing/checkout",{what:"POST /billing/checkout",method:"POST",headers:ge.ownerHeaders(n,!0),body:JSON.stringify({seal_id:t,tier:r}),signal:a.signal}),o=await s.json();if(typeof o.url!="string"||!o.url)throw new ie("POST /billing/checkout returned no url","unknown",s.status);return o.url}async createIntake(t,n={}){let r={recipient_bundle:t.recipientBundle,label:t.label,what:t.what,kind:t.kind??"any"};return t.whereUrl&&(r.where_url=t.whereUrl),t.ttlSeconds!==void 0&&(r.ttl_seconds=t.ttlSeconds),t.to&&(r.to=t.to),t.bind&&(r.bind=t.bind),await(await this.request("/intake",{what:"POST /intake",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:n.signal})).json()}async getIntake(t,n={}){let r=n.waitSeconds?`?wait=${n.waitSeconds}`:"";return await(await this.request(`/intake/${z(t)}${r}`,{what:`GET /intake/${t}`,signal:n.signal})).json()}async fulfilIntake(t,n,r={}){return await(await this.request(`/intake/${z(t)}/fulfil`,{what:`POST /intake/${t}/fulfil`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seal_id:n.sealId,share_code:n.shareCode,fragment:n.fragment}),signal:r.signal})).json()}async putBundle(t,n={}){await this.request("/intake/bundles",{what:"PUT /intake/bundles",method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({bundle:ne(t)}),signal:n.signal})}async getBundle(t,n={}){try{let r=await this.request(`/intake/bundles/${z(t)}`,{what:`GET /intake/bundles/${t}`,signal:n.signal});return de((await r.json()).bundle)}catch(r){if(r instanceof ie&&r.status===404)return null;throw r}}async requestAddressProof(t,n={}){return await(await this.request("/intake/proof",{what:"POST /intake/proof",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:t}),signal:n.signal})).json()}async listInbox(t,n={}){let r=new URLSearchParams({to:t.address});return n.waitSeconds&&r.set("wait",String(Math.min(n.waitSeconds,_e.limits.INTAKE_WAIT_MAX_SECONDS))),n.seen&&r.set("seen",n.seen),n.all&&r.set("all","1"),await(await this.request(`/intake?${r.toString()}`,{what:"GET /intake",headers:Mt(t),signal:n.signal})).json()}async dismissInboxItem(t,n,r={}){let a=new URLSearchParams({to:n.address,item:t});await this.request(`/intake?${a.toString()}`,{what:"DELETE /intake",method:"DELETE",headers:Mt(n),signal:r.signal})}async pushKey(t={}){return(await(await this.request("/intake/push-key",{what:"GET /intake/push-key",signal:t.signal})).json()).vapid_public}async setInboxPush(t,n,r,a={}){let s=n?"POST":"DELETE";await this.request("/intake/subscriptions",{what:`${s} /intake/subscriptions`,method:s,headers:{"Content-Type":"application/json",...Mt(r)},body:JSON.stringify({to:r.address,endpoint:t}),signal:a.signal})}async createLease(t,n,r={}){return await(await this.request("/lease",{what:"POST /lease",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner_token_hash:t,expires_at:n}),signal:r.signal})).json()}async revokeLease(t,n,r={}){return await(await this.request(`/lease/${z(t)}/revoke`,{what:`POST /lease/${t}/revoke`,method:"POST",headers:ge.ownerHeaders(n),signal:r.signal})).json()}async leaseStatus(t,n={}){let r={"Content-Type":"application/json"};n.etag&&(r["If-None-Match"]=n.etag);let a=await this.fetchImpl(this.url("/lease/status"),{method:"POST",headers:{...pn(),...r},body:JSON.stringify({ids:t}),credentials:this.credentials,signal:n.signal});if(a.status===304)return null;if(!a.ok)throw await Ct(a,`POST /lease/status failed: ${a.status}`);return{statuses:await a.json(),etag:a.headers.get("ETag")}}},_o=3;function Mt(e){return{[fe.proof.header_address]:e.address,[fe.proof.header_proof]:e.proof}}function yr(e){let t=new URLSearchParams({file_id:e.fileId});return e.shareCode&&t.set("share_code",e.shareCode),t.toString()}function br(e,t,n){"to"in e&&(t.to=e.to,t.fragment=e.fragment,e.label&&(t.label=e.label),e.sender&&Object.assign(n,Mt(e.sender)))}function wo(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason);return}let a=()=>{clearTimeout(s),r(t?.reason)},s=setTimeout(()=>{t?.removeEventListener("abort",a),n()},e);t?.addEventListener("abort",a,{once:!0})})}function mr(e,t,n){if(typeof e.encrypted_blob!="string"||e.encrypted_blob.length===0)throw new ie(`${t} returned an empty blob`,"unknown",n);return de(e.encrypted_blob)}function go(e,t){let n=e.headers,r=typeof n.getSetCookie=="function"?n.getSetCookie():[],a=r.length>0?r:(()=>{let s=e.headers.get("set-cookie");return s?[s]:[]})();for(let s of a){let o=s.split(";",1)[0]?.trim()??"";if(o.startsWith(`${t}=`))return o}return null}var yo=32,bo=32,Kt=_e.limits.MAX_BLOB_SIZE,Er=_e.limits.MAX_FILE_KEYS;function aa(e){if(e>Er)throw new Error(`Too many file keys: ${e} exceeds maximum of ${Er}`)}var mo=class extends Error{constructor(){super("Invalid encryption key"),this.name="BlobDecryptionError"}};function sa(){return crypto.getRandomValues(new Uint8Array(yo))}async function oa(e){let t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}function kn(){return crypto.getRandomValues(new Uint8Array(bo))}async function ia(e,t,n,r,a,s,o){aa(t.size);let i={owner_token:e,file_keys:Object.fromEntries(t),...r?{message:r}:{},...a?{nda_file:a}:{},...s&&Object.keys(s).length>0?{bindings:s}:{},...o?{payload:o}:{}};return ca(i,n)}async function la(e,t,n,r,a,s,o){aa(e.size);let i={file_keys:Object.fromEntries(e),...n?{message:n}:{},...r?{nda_file:r}:{},...a?{reply_to:ne(a)}:{},...s&&Object.keys(s).length>0?{bindings:s}:{},...o?{payload:o}:{}};return ca(i,t)}async function ca(e,t){let n=new TextEncoder().encode(JSON.stringify(e)),r=12+n.length+16;if(r>Kt)throw new Error(`Blob size ${r} exceeds maximum of ${Kt}`);let a=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:a,tagLength:128},s,n),i=new Uint8Array(12+o.byteLength);return i.set(a,0),i.set(new Uint8Array(o),12),i}function Eo(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.v===1&&typeof t.name=="string"&&(t.class==="outbound"||t.class==="inprocess")&&Array.isArray(t.hosts)&&t.hosts.every(n=>typeof n=="string")}function So(e){return typeof e.bindings!="object"||e.bindings===null?{}:Object.fromEntries(Object.entries(e.bindings).filter(([,t])=>Eo(t)))}function Ao(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.file_keys!="object"||t.file_keys===null)return!1;for(let[n,r]of Object.entries(t.file_keys))if(typeof n!="string"||typeof r!="string")return!1;return!(t.message!==void 0&&typeof t.message!="string"||t.reply_to!==void 0&&typeof t.reply_to!="string"||t.payload!==void 0&&typeof t.payload!="string")}async function vo(e,t){let n=await xo(e,t);if(!Ao(n))throw new Error("Invalid share blob structure");return n}async function xo(e,t){if(e.length>Kt)throw new Error(`Blob size ${e.length} exceeds maximum of ${Kt}`);if(e.length<28)throw new Error("Encrypted blob too short");let n=e.slice(0,12),r=e.slice(12),a=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),s;try{s=await crypto.subtle.decrypt({name:"AES-GCM",iv:n,tagLength:128},a,r)}catch{throw new mo}try{return JSON.parse(new TextDecoder().decode(s))}catch{throw new Error("Invalid JSON in decrypted blob")}}var Dl=_e.limits.MAX_FILE_KEYS;var Ue=64,Sr=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],ko=new Int32Array(64).map((e,t)=>Math.floor(Math.abs(Math.sin(t+1))*2**32)|0),To=new Uint8Array(new Uint32Array([1]).buffer)[0]===1;function Ar(e,t,n){let r=e[0],a=e[1],s=e[2],o=e[3];for(let i=0;i<64;i++){let c,d;i<16?(c=a&s|~a&o,d=i):i<32?(c=o&a|~o&s,d=5*i+1&15):i<48?(c=a^s^o,d=3*i+5&15):(c=s^(a|~o),d=7*i&15);let f=r+c+ko[i]+t[n+d]|0;r=o,o=s,s=a,a=a+(f<<Sr[i]|f>>>32-Sr[i])|0}e[0]=e[0]+r|0,e[1]=e[1]+a|0,e[2]=e[2]+s|0,e[3]=e[3]+o|0}var Tn=class{constructor(){this.state=new Int32Array([1732584193,-271733879,-1732584194,271733878]),this.pending=new Uint8Array(Ue),this.pendingLength=0,this.totalBytes=0,this.scratch=new Int32Array(16)}update(e){this.totalBytes+=e.length;let t=0;if(this.pendingLength>0){let r=Math.min(Ue-this.pendingLength,e.length);if(this.pending.set(e.subarray(0,r),this.pendingLength),this.pendingLength+=r,t=r,this.pendingLength<Ue)return this;this.compressBytes(this.pending,0,Ue),this.pendingLength=0}let n=e.length-(e.length-t)%Ue;return this.compressBytes(e,t,n),n<e.length&&(this.pending.set(e.subarray(n)),this.pendingLength=e.length-n),this}digest(){let e=new Uint8Array(this.pendingLength<56?Ue:2*Ue);e.set(this.pending.subarray(0,this.pendingLength)),e[this.pendingLength]=128;let t=new DataView(e.buffer);t.setUint32(e.length-8,this.totalBytes*8>>>0,!0),t.setUint32(e.length-4,Math.floor(this.totalBytes/2**29),!0),this.compressBytes(e,0,e.length);let n=new Uint8Array(16),r=new DataView(n.buffer);for(let a=0;a<4;a++)r.setInt32(a*4,this.state[a],!0);return n}compressBytes(e,t,n){if(t>=n)return;if(To&&(e.byteOffset+t)%4===0){let a=new Int32Array(e.buffer,e.byteOffset+t,(n-t)/4);for(let s=0;s<a.length;s+=16)Ar(this.state,a,s);return}let r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=t;a<n;a+=Ue){for(let s=0;s<16;s++)this.scratch[s]=r.getInt32(a+s*4,!0);Ar(this.state,this.scratch,0)}}};function Io(e){return Pe(new Tn().update(e).digest())}var dn=4*1024*1024;async function Oo(e){let t=new Tn;for(let n=0;n<e.length;n+=dn)t.update(e.subarray(n,Math.min(n+dn,e.length))),n+dn<e.length&&await pt();return Pe(t.digest())}var da=class{constructor(e){if(this.cryptoKey=null,e.key.length!==32)throw new Error("Key must be 32 bytes (AES-256)");this.segmentSize=Sn(e.header).segmentSize,this.header=e.header.subarray(0,Fe),this.key=e.key}async init(){this.cryptoKey=await Yr(this.key)}sha256Hex(){return Ye(this.header)}async encryptSegment(e,t,n){if(!this.cryptoKey)throw new Error("Encryptor.init() was not awaited");if(!(t?n.length<=this.segmentSize&&(n.length>0||e===0):n.length===this.segmentSize))throw new Error(`segment ${e}${t?" (last)":""} cannot carry ${n.length} bytes at segment size ${this.segmentSize}`);return Xs(this.cryptoKey,n,jr(this.header,e,t))}};async function Ro(e,t,n,r){let a=new Uint8Array(t);try{let s=new da({key:a,header:n});await s.init();let o=new Tn().update(s.header),i=[vr(s.header)],c=Math.max(1,Math.ceil(e.size/s.segmentSize));for(let d=0;d<c;d++){let f=Math.min((d+1)*s.segmentSize,e.size),h=new Uint8Array(await e.slice(d*s.segmentSize,f).arrayBuffer()),u=await s.encryptSegment(d,d===c-1,h);h.fill(0),o.update(u),i.push(vr(u)),r?.(f,e.size)}return{blob:new Blob(i),md5_b64:Pe(o.digest())}}finally{a.fill(0)}}function vr(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var De=class extends Error{constructor(e,t,n){super(t),this.name="DecryptError",this.kind=e,this.cause=n}};function Po(e,t){e.chunks.push(t),e.bytes+=t.length}function Ut(e,t){let n=new Uint8Array(t),r=0;for(;r<t;){let a=e.chunks[0],s=t-r;a.length<=s?(n.set(a,r),r+=a.length,e.chunks.shift()):(n.set(a.subarray(0,s),r),r+=s,e.chunks[0]=a.subarray(s))}return e.bytes-=t,n}function Lo(e,t){let n=Ut(e,t);return e.chunks.unshift(n),e.bytes+=t,n}function Do(e,t){let n=t.expectedSha256Hex.trim().toLowerCase();if(!/^[0-9a-f]{64}$/.test(n))throw new De("integrity","the expected sha256_hex is not 64 hex characters");let r={chunks:[],bytes:0},a,s=null,o=null,i=0,c=0,d=null,f=async(u,p)=>{if(u.length<Hr)throw new De("integrity",`segment ${c} is ${u.length} bytes: the stream was cut`);try{return await Zs(a,u,o==="v4"?jr(s,c,p):null)}catch(g){throw new De("integrity",`segment ${c} does not decrypt as the ${p?"last":"next"} segment of this file: moved, cut, extended or changed`,g)}finally{c+=1}},h=async()=>{if(r.bytes<Wt)return!1;let u=Vs(Lo(r,Wt));if(u===null)throw new De("outdated","the file is in a format newer than this client: update it");let p=u==="v4"?Fe:zr;if(r.bytes<p)return!1;if(u==="v3"){d=Js();for(let b of r.chunks)d.update(b)}let g=Ut(r,p),_;try{_=u==="v4"?Sn(g).segmentSize:Ys(g).segmentSize}catch(b){throw new De("integrity",b instanceof Error?b.message:String(b),b)}if(u==="v4"&&await Ye(g)!==n)throw new De("integrity","the file header is not the one registered for this file");return s=g,o=u,i=Gs(_),!0};return new TransformStream({async start(){a=await Yr(e)},async transform(u,p){if(u.length!==0&&(Po(r,u),d&&d.update(u),!(o===null&&!await h())))for(;r.bytes>i;){let g=Ut(r,i),_=await f(g,!1);g.fill(0),t.onPlaintextBytes?.(_.length),p.enqueue(_)}},async flush(u){if(o===null)throw new De("integrity",r.bytes===0?"the ciphertext stream is empty":"the ciphertext stream was cut inside its header");if(o==="v3"){if(Array.from(d.digest(),_=>_.toString(16).padStart(2,"0")).join("")!==n)throw new De("integrity","the ciphertext is not the one registered for this file");if(r.bytes===0)return}let p=await f(Ut(r,r.bytes),!0);t.onPlaintextBytes?.(p.length),u.enqueue(p)}},{highWaterMark:1},{highWaterMark:1})}var Cl=gt("SwDownload");var Ml=10*6e4;var ua={version:1,default:"application/octet-stream",extensions:{json:"application/json",txt:"text/plain",log:"text/plain",md:"text/plain",csv:"text/csv",html:"text/html",htm:"text/html",xml:"application/xml",pdf:"application/pdf",zip:"application/zip",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}},No="_",Bo=200,Co=new TextEncoder;function _n(e){return Co.encode(e).length}function xr(e,t){let n="",r=0;for(let a of e){if(r+=_n(a),r>t)break;n+=a}return n}var Mo=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]);function Uo(){if(typeof process<"u"&&process.platform)switch(process.platform){case"win32":return"windows";case"darwin":return"macos";case"linux":return"linux";case"android":return"android";default:return"unknown"}if(typeof navigator<"u"&&navigator.userAgent){let e=navigator.userAgent.toLowerCase();if(e.includes("win"))return"windows";if(e.includes("android"))return"android";if(e.includes("iphone")||e.includes("ipad")||e.includes("ipod"))return"ios";if(e.includes("mac"))return"macos";if(e.includes("linux"))return"linux"}return"unknown"}function Fo(e,t){let n=e.charCodeAt(0);if(n<32||n===127||/[\u202A-\u202E\u2066-\u2069\u200E\u200F\u061C]/.test(e))return!1;switch(t){case"windows":return!/[<>:"/\\|?*]/.test(e);case"macos":case"ios":return!/[/:]/.test(e);case"linux":case"android":return e!=="/";default:return!/[<>:"/\\|?*]/.test(e)}}function Wo(e){let t=e.split(".")[0].toUpperCase();return Mo.has(t)}function ha(e,t={}){let{platform:n=Uo(),replacement:r=No,maxLength:a=Bo,fallback:s="file"}=t;if(!e||!e.trim())return s;let o=e.normalize("NFC");o=o.trim(),o=o.replace(/^\.+|\.+$/g,""),o=[...o].map(d=>Fo(d,n)?d:r).join("");let c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(o=o.replace(new RegExp(`${c}+`,"g"),r),o=o.replace(new RegExp(`^(?:\\.|${c})+|${c}+$`,"g"),""),(n==="windows"||n==="unknown")&&Wo(o)&&(o=`${r}${o}`),_n(o)>a){let d=o.lastIndexOf(".");if(d>0&&d>o.length-10){let f=o.slice(d);o=xr(o.slice(0,d),a-_n(f))+f}else o=xr(o,a)}return!o||o===r?s:o}var Ho=new Map(Object.entries(ua.extensions));function $o(e){let t=e.lastIndexOf("."),n=t>=0&&t<e.length-1?e.slice(t+1).toLowerCase():"";return Ho.get(n)??ua.default}var Ul=B.upload.MULTIPART_THRESHOLD_BYTES,Fl=B.upload.MULTIPART_THRESHOLD_BYTES;var Wl=new TextEncoder;var Hl=gt("FolderZip");var $l=100*1024*1024,Kl=4*1024*1024;var zt="Encrypted file",Gt="application/octet-stream";function fa(e){return new TextEncoder().encode(`field:${e}`)}async function kr(e,t,n){let r=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.importKey("raw",t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),{name:"AES-GCM"},!1,["encrypt"]),s={name:"AES-GCM",iv:r,tagLength:128};if(n){let i=fa(n);s.additionalData=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}let o=await crypto.subtle.encrypt(s,a,new TextEncoder().encode(e));return{ciphertext:Pe(new Uint8Array(o)),nonce:Pe(r)}}async function Tr(e,t,n,r){let a=Ot(e),s=Ot(t);return(async i=>{let c={name:"AES-GCM",iv:s};i&&(c.additionalData=i);let d=await crypto.subtle.decrypt(c,n,a);return new TextDecoder().decode(d)})(r?fa(r):void 0)}async function Ko(e,t){let n=zt,r=Gt;if(e.name_encrypted&&e.name_nonce&&e.name_nonce.length>0)try{n=await Tr(e.name_encrypted,e.name_nonce,t,"name")}catch{n=zt}if(e.mime_encrypted&&e.mime_nonce&&e.mime_nonce.length>0)try{r=await Tr(e.mime_encrypted,e.mime_nonce,t,"mime")}catch{r=Gt}return{name:n,mime:r}}async function zo(e){return crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!1,["decrypt"])}async function Go(e,t){try{let n=await zo(t);return Ko(e,n)}catch{return{name:zt,mime:Gt}}}var jo=gt("upload"),ht=4*1024*1024;function jt(){return new DOMException("Upload aborted","AbortError")}async function Yo(e){let{stream:t,totalBytes:n,key:r,header:a,partSize:s,signal:o,yieldToRenderer:i,onSegment:c}=e,d=new da({key:r,header:a});await d.init();let f=d.segmentSize,h=Math.max(1,Math.ceil(n/f)),u=0,p=A=>new O(`The file changed while it was being sent: ${A} ${u} of ${n} bytes`,"FILE_CHANGED"),g=!0,_=0,b=0,v=[],D=0,k=A=>{if(v.length>0&&v[0].length===A)return D-=A,v.shift();let L=new Uint8Array(A),ae=0;for(;ae<A;){let F=v[0],H=A-ae;F.length<=H?(L.set(F,ae),ae+=F.length,v.shift()):(L.set(F.subarray(0,H),ae),v[0]=F.subarray(H),ae+=H)}return D-=A,L},R=[],W=0,U=async A=>{let L=new Uint8Array(A),ae=0,F=0;for(;ae<A;){let H=R[0],be=i?ht-F:Number.MAX_SAFE_INTEGER,X=Math.min(H.length,A-ae,be);L.set(H.subarray(0,X),ae),ae+=X,F+=X,X===H.length?R.shift():R[0]=H.subarray(X),i&&F>=ht&&ae<A&&(F=0,await pt())}return W-=A,L},S=async A=>{if(b+=1,e.hashParts===!1)await e.onPart(b,A);else{let L=i?await Oo(A):Io(A);await e.onPart(b,A,L)}i&&await pt()},C=async A=>{if(!i){A.fill(0);return}for(let L=0;L<A.length;L+=ht)A.fill(0,L,Math.min(L+ht,A.length)),L+ht<A.length&&await pt()},N=async()=>{for(;W>=s;)await S(await U(s))},we=async(A,L)=>{if(o?.aborted)throw jt();let ae=_;_+=1;let F=performance.now(),H=d.encryptSegment(ae,L,A);await N();let be=await H;await C(A),jo.debug(`encrypt segment=${_} bytes=${A.length} time=${Math.round(performance.now()-F)}ms`);let X;g?(X=new Uint8Array(a.length+be.length),X.set(a,0),X.set(be,a.length),g=!1):X=be,c?.(_),R.push(X),W+=X.length},ye=t.getReader();try{for(;;){if(o?.aborted)throw jt();let{done:A,value:L}=await ye.read();if(A)break;if(L&&L.length>0){if(u+=L.length,u>n)throw p("it gave more than");v.push(L),D+=L.length}for(;D>=f;)await we(k(f),_===h-1)}if(u<n)throw p("it ended at");(D>0||_===0)&&await we(k(D),!0),await N(),W>0&&await S(await U(W))}finally{ye.releaseLock()}}function Vo(e,t){let n=0;return new ReadableStream({async pull(r){if(n>=e.size){r.close();return}let a=Math.min(n+t,e.size);try{let s=await e.slice(n,a).arrayBuffer();r.enqueue(new Uint8Array(s)),n=a}catch(s){r.error(s)}}})}function qo(e,t,n){let{file:r,key:a,header:s,partSize:o,totalBytes:i,signal:c,initialCredits:d,onSegment:f,onPart:h}=n;return new Promise((u,p)=>{let g=!1,_=!1,b=0,v=Promise.resolve(),D=U=>{g||(g=!0,p(U))},k=()=>{!_||b>0||v.then(()=>{g||(g=!0,u())})};if(c){if(c.aborted){D(jt());return}c.addEventListener("abort",()=>D(jt()),{once:!0})}e.onerror=t.onerror=U=>{D(new Error(`crypto worker crashed: ${String(U?.message??U)}`))},e.onmessage=U=>{let S=U.data;if(S.type==="segment"){f?.(S.segmentNumber);return}if(S.type==="part"){b+=1,t.postMessage({type:"md5",partNumber:S.partNumber,buffer:S.buffer},[S.buffer]);return}if(S.type==="done"){_=!0,k();return}S.type==="error"&&D(new Error(S.message))},t.onmessage=U=>{let S=U.data;if(S.type!=="md5")return;b-=1;let C=new Uint8Array(S.buffer);v=v.then(async()=>{g||(await h(S.partNumber,C,S.md5),e.postMessage({type:"credit"}))}).catch(D),k()};let R=new ArrayBuffer(a.length);new Uint8Array(R).set(a);let W=s.slice().buffer;e.postMessage({type:"start",file:r,key:R,header:W,partSize:o,totalBytes:i,credits:d},[R,W])})}var Xo=null;function Zo(){return Xo}var $e=gt("upload");function Jo(e){return e.now-e.lastLookAt>2*e.every?!1:e.now-e.lastActivityAt>=e.silenceMs}var Ir="<Code>BadDigest</Code>",Qo=2;function Vt(e){let t=pn();return e?e.type==="bearer"?{...t,Authorization:`Bearer ${e.value}`}:e.type==="ownerToken"?{...t,"X-Owner-Token":e.value}:{...t,"X-API-Key":e.value}:t}async function ei(e){return ti({file:e.file,sealId:e.sealId,fileId:e.fileId,key:e.key,header:e.header,baseUrl:e.baseUrl,auth:e.auth,partSize:e.partSize,onProgress:e.onProgress,signal:e.signal,transport:e.transport,onStreamed:e.onStreamed,onConflict:e.onConflict})}async function ti(e){let{file:t,partSize:n}=e;return ni({stream:Vo(t,Sn(e.header).segmentSize),totalBytes:t.size,sealId:e.sealId,fileId:e.fileId,key:e.key,header:e.header,baseUrl:e.baseUrl,auth:e.auth,partSize:n,onProgress:e.onProgress,signal:e.signal,sourceFile:t,transport:e.transport,onStreamed:e.onStreamed,onConflict:e.onConflict})}async function ni(e){let{stream:t,totalBytes:n,sealId:r,fileId:a,key:s,header:o,baseUrl:i,auth:c,partSize:d,contentType:f="application/octet-stream",onProgress:h,signal:u,sourceFile:p,onStreamed:g,onConflict:_}=e,b=An(e.transport),v=b.clock;if(s.length!==32)throw new O("Key must be 32 bytes","ENCRYPTION_FAILED");if(d<B.upload.S3_MIN_PART_SIZE_BYTES)throw new O(`Part size must be at least ${B.upload.S3_MIN_PART_SIZE_BYTES} bytes (S3 spec)`,"INVALID_STATUS");let D=new Uint8Array(s),k=Vt(c),R=En(n),W=Math.ceil(R/d),U=null,S=[],C=0,N=0,we="encrypting",ye=[],A=null,L,ae=w=>{let m=v.now();ye.push({at:m,bytes:w});let T=Math.max(A??m,m-b.speedWindowMs);for(;ye.length>0&&ye[0].at<T;)ye.shift();let M=m-T;M>0&&(L=Math.round(ye.reduce((I,Z)=>I+Z.bytes,0)/M*1e3))},F=w=>{we=w;let m=R-C;h?.({phase:w,percent:w==="done"?100:Math.min(99,Math.floor(C/R*100)),deliveredBytes:C,preparedBytes:N,totalBytes:R,speedBps:L,etaMs:L&&L>0?Math.round(m/L*1e3):void 0,state:H.state,attempt:H.retriesSinceDelivery+1})},H=new ea(b,()=>F(we),v.now),be=new AbortController,X=u?vn([u,be.signal]):be.signal,Je=(w,m)=>$t(m,{clock:H,policy:b,signal:X,classify:Qr,what:w}),Qe=async w=>{throw D.fill(0),new O("Upload aborted","ABORTED")},se=w=>{if(U)try{Ze(`${i}/upload/multipart/abort`,{method:"POST",headers:{"Content-Type":"application/json",...k},body:JSON.stringify(w?{upload_id:U,discard_file:!0}:{upload_id:U}),keepalive:!0}).catch(()=>{})}catch{}},le=!1,xe=new Map,ke=null,Q=null,Ne=[],Be=new Set,Ee=b.poolStart,mt=b.poolMax,Et=0,We=null,St=0,At=0,et=null,Qt=[],jn=[],tt=new Set,nt=v.now(),Yn=!1,en=w=>{nt=v.now();for(let m of[...tt])m.reconnect(w)};function za(w,m){let T=w.ciphertext.length;if(T>=d&&m>0){let Z=Math.min(w.flowsAtStart??1,Be.size);if(jn.push({rate:T/m,flows:Z}),T/m*1e3<b.putFloorBytesPerSecond*2&&Ee>b.poolMin){Ee-=1,mt=Ee,et=null,Et+=1,We=v.now(),St=0,At=0;return}}if(w.round!==Et||(St+=T,At+=1,At<Ee||We===null))return;let M=v.now()-We;if(M<=0)return;let I=St/M;et===null||I>et*b.poolGrowRatio?Ee=Math.min(mt,Ee+1):I<et*b.poolShrinkRatio&&(Ee=Math.max(Math.min(b.poolStart,mt),Ee-1)),et=I,Et+=1,We=v.now(),St=0,At=0}function Ga(w,m){let T=v.now()-m;if(T<b.hedgeMinInflightMs)return!1;let M=Be.size,I=jn.filter(Y=>Y.flows>=M).map(Y=>Y.rate);if(I.length===0)return!1;I.sort((Y,$)=>Y-$);let Z=I[Math.floor(I.length/2)];return w.ciphertext.length/T*b.hedgeLagFactor<Z}async function ja(w,m,T,M,I,Z){if(!to()&&typeof XMLHttpRequest<"u"&&typeof document<"u")return await new Promise(($,ce)=>{let V=new XMLHttpRequest,oe=!1;Yn=!0,V.upload.onprogress=he=>{Z.onSocketActivity(he.loaded,he.lengthComputable?he.total:w.length),ee(),ee=Te()};let Te=()=>v.after(hn(w.length,b),()=>{oe||Z.onDeadline()}),ee=Te(),q=()=>{ee(),I.removeEventListener("abort",re)},re=()=>{oe||(oe=!0,V.abort(),q(),ce(new O("Upload aborted","ABORTED",void 0,T)))};if(V.onload=()=>{if(oe)return;oe=!0;let he={status:V.status,etag:V.getResponseHeader("ETag")?.replace(/"/g,"")??null,badDigest:V.status===400&&String(V.responseText??"").includes(Ir)};q(),$(he)},V.onerror=()=>{oe||(oe=!0,q(),ce(new O(`Failed to upload part ${T}: network error`,"NETWORK",void 0,T,!0)))},V.onabort=()=>{oe||(oe=!0,q(),ce(new O("Upload aborted","ABORTED",void 0,T)))},I.aborted){q(),ce(new O("Upload aborted","ABORTED",void 0,T));return}I.addEventListener("abort",re,{once:!0}),V.open("PUT",M),V.setRequestHeader("Content-MD5",m),V.send(w)});let Y;try{Y=await Ze(M,{method:"PUT",headers:{"Content-MD5":m},body:w,signal:Xr(I,hn(w.length,b))})}catch($){throw u?.aborted||I.aborted?ze($,"Upload aborted"):new O(`Part ${T}: transport failure (${$ instanceof Error?$.message:String($)})`,"NETWORK",void 0,T,!0)}return{status:Y.status,etag:Y.headers.get("ETag")?.replace(/"/g,"")??null,badDigest:Y.status===400&&(await Y.text().catch(()=>"")).includes(Ir)}}function Ya(w,m){if(m.badDigest)throw new O(`Part ${w} arrived corrupted (BadDigest)`,"BAD_DIGEST",m.status,w,!0);if(m.status<200||m.status>=300)throw new O(`Failed to upload part ${w}: ${m.status}`,m.status===404?"EXPIRED_UPLOAD_ID":"NETWORK",m.status,w,m.status!==404);if(!m.etag)throw new O(`No ETag returned for part ${w}`,"S3_ETAG_MISMATCH",void 0,w);return m.etag}async function Va(w,m){let T=v.now(),M=()=>{},I=0,Z=0,Y=T,$=null,ce=()=>{},V={reconnect:oe=>ce(oe,!1),hasUnsentBytes:()=>$?.unsent??!1};tt.add(V);try{let oe=await new Promise((ee,q)=>{let re=!1,he=Ce=>{re||(re=!0,Ce())},Xn=()=>{let Ce=new AbortController,rt=()=>Ce.abort();X?.aborted?Ce.abort():X?.addEventListener("abort",rt,{once:!0});let Ie={ctl:Ce,unsent:!0,ended:Promise.resolve()};$=Ie,Y=v.now(),nt=Y,Ie.ended=ja(w.ciphertext,w.contentMd5,w.partNumber,m,Ce.signal,{onSocketActivity:(Oe,at)=>{nt=v.now(),Ie.unsent=Oe<at},onDeadline:()=>{if(++Z<2)return ce("copy deadline",!1,!1);$===Ie&&he(()=>q(new O(`Part ${w.partNumber}: no answer from storage after a reconnect`,"NETWORK",void 0,w.partNumber,!0)))}}).then(Oe=>{if($===Ie)try{let at=Ya(w.partNumber,Oe);he(()=>ee(at))}catch(at){he(()=>q(at))}},Oe=>{$===Ie&&he(()=>q(ze(Oe,`Failed to upload part ${w.partNumber}`)))}).finally(()=>{Ie.unsent=!1,X?.removeEventListener("abort",rt)})};ce=(Ce,rt,Ie=!0)=>{let Oe=$;re||Oe===null||u?.aborted||($=null,I=rt?I+1:Ie?0:I,$e.debug(`${rt?"replace":"reconnect"} part=${w.partNumber} (${Ce})`),Oe.ctl.abort(),Oe.ended.then(()=>{re||(X?.aborted?he(()=>q(new O("Upload aborted","ABORTED",void 0,w.partNumber))):Xn())}))},Xn(),M=v.every(b.hedgePollMs,()=>{re||u?.aborted||$===null||I>=Qo||Ga(w,Y)&&ce(`slower than its peers after ${Math.round(v.now()-T)}ms`,!0)})}),Te=v.now();S.push({part_number:w.partNumber,etag:oe}),C+=w.ciphertext.length,ae(w.ciphertext.length),za(w,Te-T),H.delivered(),nt=Te,$e.debug(`part=${w.partNumber}/${W} put=${Math.round(Te-T)}ms size=${w.ciphertext.length}${I>0?` replaced\xD7${I}`:""}`),F("uploading")}finally{tt.delete(V),ce=()=>{},M(),$?.ctl.abort()}}let vt=(w,m,T)=>_t(w,m,T,X);async function qa(){try{let w=await vt(`${i}/upload/multipart/status?upload_id=${encodeURIComponent(U??"")}`,{method:"GET",headers:k},b.controlTimeoutMs);if(!w.ok)return null;let m=await w.json();return typeof m.status=="string"?m.status:null}catch{return null}}async function Vn(w){let m=performance.now(),T=await Je("presign batch",async()=>{let I=await vt(`${i}/upload/multipart/parts`,{method:"POST",headers:{"Content-Type":"application/json",...k},body:JSON.stringify({upload_id:U,part_numbers:w})},b.controlTimeoutMs);if(!I.ok)throw await qe(I,"Failed to get presigned URLs",I.status===404?"EXPIRED_UPLOAD_ID":"NETWORK");let{urls:Z}=await I.json();return Z}),M=new Map;for(let[I,Z]of Object.entries(T))M.set(Number(I),Z);return $e.debug(`batch presign ${w.length} urls in ${Math.round(performance.now()-m)}ms`),M}async function Xa(w){let m=[];for(let M=w;M<=W&&m.length<B.upload.PRESIGN_BATCH_SIZE;M++)xe.has(M)||m.push(M);if(m.length===0)return;let T=await Vn(m);for(let[M,I]of T)xe.set(M,I)}function qn(w){ke||(ke=Xa(w).catch(()=>{}).finally(()=>{ke=null}))}async function Za(w){await pt(),We??(We=v.now()),A??(A=We),w.round=Et,w.flowsAtStart=Be.size;let m=xe.get(w.partNumber);!m&&ke&&(await ke,m=xe.get(w.partNumber)),xe.delete(w.partNumber),qn(w.partNumber+1),await $t(async({after:T})=>{if((!m||T==="refresh_url")&&(m=(await Vn([w.partNumber])).get(w.partNumber),!m))throw new O(`No presigned URL for part ${w.partNumber}`,"NETWORK",void 0,w.partNumber,!0);await Va(w,m)},{clock:H,policy:b,signal:X,classify:Jr,what:`part ${w.partNumber}`})}function tn(){for(;!Q&&!u?.aborted&&Be.size<Ee&&Ne.length>0;){let w=Ne.shift(),m=Za(w).catch(T=>{Q??(Q=ze(T,"Part upload failed"))}).finally(()=>{Be.delete(m);let T=Qt;Qt=[];for(let M of T)M();tn()});Be.add(m)}}let Ja=()=>new Promise(w=>{Qt.push(w)}),Qa=(()=>{let w=globalThis,m=globalThis.navigator?.connection,T=m?.type,M=()=>en("network is back"),I=()=>H.connectionLost(),Z=()=>{let V=m?.type;V!==T&&(T=V,en("network changed"))};w.addEventListener?.("online",M),w.addEventListener?.("offline",I),m?.addEventListener?.("change",Z);let Y=Math.max(10,b.livenessSilenceMs/4),$=v.now(),ce=v.every(Y,()=>{let V=v.now(),oe=Jo({now:V,lastLookAt:$,every:Y,lastActivityAt:nt,silenceMs:b.livenessSilenceMs});$=V,!(!Yn||tt.size===0||!oe)&&[...tt].some(Te=>Te.hasUnsentBytes())&&(H.connectionLost(),en("every socket silent"))});return()=>{ce(),w.removeEventListener?.("online",M),w.removeEventListener?.("offline",I),m?.removeEventListener?.("change",Z)}})();try{let w=performance.now();if($e.debug(`starting multipart: totalBytes=${n} parts=${W} partSize=${d} pool=${b.poolStart}..${b.poolMax}`),u?.aborted)throw new O("Upload aborted","ABORTED");F("encrypting"),U=await Je("multipart init",async()=>{let ee=await vt(`${i}/upload/multipart/init`,{method:"POST",headers:{"Content-Type":"application/json",...k},body:JSON.stringify({seal_id:r,content_type:f,content_length:R,part_size:d,file_id:a})},b.controlTimeoutMs);if(!ee.ok)throw await qe(ee,"Failed to initialize multipart upload","NETWORK");return(await ee.json()).upload_id}),qn(1),F("encrypting");let m=!1,T=()=>{m=!0,F("encrypting")},M=async(ee,q,re)=>{for(m=!0,N+=q.length,F("encrypting"),u?.aborted&&await Qe(u?.aborted===!0),Ne.push({partNumber:ee,ciphertext:q,contentMd5:re}),tn();Ne.length>=b.partQueueLimit;)if(await Ja(),Q)throw Q;if(Q)throw Q},I=()=>Yo({stream:t,totalBytes:n,key:D,header:o,partSize:d,signal:u,yieldToRenderer:typeof document<"u",onSegment:T,onPart:M}),Z=Zo(),Y=null;if(p&&Z&&typeof document<"u"){let ee=null;try{ee=Z(),Y=[ee,Z()]}catch{ee?.terminate()}}if(Y){let[ee,q]=Y;$e.debug("crypto pipeline: worker");try{await qo(ee,q,{file:p,key:D,header:o,partSize:d,totalBytes:n,signal:u,initialCredits:b.partQueueLimit,onSegment:T,onPart:M})}catch(re){let he=ze(re,"Crypto worker failed");if(he.code==="ABORTED"||m)throw he;$e.debug(`crypto worker failed before output \u2014 inline fallback (${he.message})`),await I()}finally{ee.terminate(),q.terminate()}}else await I();for(;tn(),!(Q||(u?.aborted&&await Qe(!0),Be.size===0&&Ne.length===0));)await Promise.race(Be);if(Q)throw Q;F("verifying"),u?.aborted&&await Qe(u?.aborted===!0),le=!0,g?.();let $=!1,ce,V=await Je("complete",async()=>{let ee=$;$=!0;let q=await vt(`${i}/upload/multipart/complete`,{method:"POST",headers:{"Content-Type":"application/json",...k},body:JSON.stringify({upload_id:U,parts:S.map(re=>({part_number:re.part_number,etag:re.etag})),..._?{on_conflict:_}:{}})},b.completeTimeoutMs);if(q.ok){let re=await q.json().catch(()=>null);return typeof re?.conflict_with=="string"&&(ce=re.conflict_with),re?.status==="verified"}if(ee&&q.status===400&&await qa()==="completed")return!1;throw await qe(q,"Failed to complete multipart upload",q.status===404?"EXPIRED_UPLOAD_ID":"INVALID_STATUS")});H.delivered(),F("done");let oe=Math.round(performance.now()-w),Te=n/(1024*1024)/(oe/1e3);return $e.debug(`DONE totalTime=${oe}ms speed=${Te.toFixed(2)}MB/s parts=${S.length}`),D.fill(0),{verified:V,...ce?{conflictWith:ce}:{}}}catch(w){D.fill(0);let m=ze(w,"Unknown upload error");throw le&&m.code!=="ABORTED"&&(m.httpStatus===void 0||m.httpStatus>=500)||se(m.code==="ABORTED"),m}finally{Qa(),H.dispose(),be.abort()}}var qt={multipartThresholdBytes:B.upload.MULTIPART_THRESHOLD_BYTES,partSizeBytes:B.upload.DEFAULT_PART_SIZE_BYTES,zipSmallLimitBytes:B.upload.INMEMORY_BLOB_LIMIT_BYTES};function ri(e,t=qt){return e<=B.upload.FINE_PART_MAX_FILE_BYTES?B.upload.FINE_PART_SIZE_BYTES:t.partSizeBytes}function ai(e,t){return e>=t.multipartThresholdBytes}function si(e){if(!(e.kind==="none"||!e.value)){if(e.kind==="ownerToken")return{type:"ownerToken",value:e.value};if(e.kind==="bearer")return{type:"bearer",value:e.value}}}function In(e){return e.ownerToken?{type:"ownerToken",value:e.ownerToken}:si(e.auth)}function oi(e){return e.ownerToken?e.ownerToken:e.auth.kind==="ownerToken"?e.auth.value:void 0}var ii={encrypting:[0,30],uploading:[30,95],verifying:[95,99],done:[100,100]},Or=[2,12],li=[12,95],ci=[95,99];function Rr(e,t){let n=0;return r=>{let a=Math.min(1,Math.max(0,r.fraction)),s;e==="single-put"?s=ii[r.phase]:r.phase==="done"?s=[100,100]:r.phase==="verifying"?s=ci:r.deliveredBytes===0?s=Or:s=li;let o=s===Or?Math.min(1,Math.max(0,r.preparedFraction??0)):a,i=s[0]+(s[1]-s[0])*o,c=r.phase==="done"?100:Math.min(99,Math.round(i));n=Math.max(n,c),t({phase:r.phase,percent:n,deliveredBytes:r.deliveredBytes,preparedBytes:r.preparedBytes,totalBytes:r.totalBytes,speedBps:r.speedBps,etaMs:r.etaMs,state:r.state,attempt:r.attempt})}}var On=class{constructor(e,t){this.run=t,this.cancelled=!1,this.running=null,this.ctx=e.ctx,this.policy=e.policy,this.sealId=e.sealId,this.createdSeal=e.createdSeal,this.expiresAt=e.expiresAt,this.files=e.files}get pending(){return this.files.filter(e=>e.state==="pending")}get verification(){return this.files.every(e=>e.state==="verified")?"verified":"pending"}async resume(e={}){if(this.cancelled)throw new O("Upload session was cancelled","ABORTED");return this.running??(this.running=this.run(this,e).catch(t=>{throw so(ze(t,"Upload failed"),this)}).finally(()=>{this.running=null})),this.running}async cancel(){this.cancelled=!0;let e=oi(this.ctx);if(!e){let n=this.ctx.revokeFilePath;if(!n||this.createdSeal)return;for(let r of this.pending){let a=n.replace("{sealId}",encodeURIComponent(this.sealId)).replace("{fileId}",encodeURIComponent(r.fileId));await Ze(`${this.ctx.baseUrl}${a}`,{method:"DELETE",headers:Vt(In(this.ctx)),credentials:this.ctx.credentials??"include"}).catch(()=>{})}return}let t=new yt({baseUrl:this.ctx.baseUrl,credentials:this.ctx.credentials??"include"});try{if(this.createdSeal){await t.revoke(this.sealId,e);return}for(let n of this.pending)await t.revokeFile(this.sealId,n.fileId,e)}catch{}}};function di(e,t,n){let r=t.length;if(!e||e.length<r)throw new Error(`${n} returned ${e?.length??0} file record(s) for ${r} file(s) \u2014 cannot upload ciphertext`);let a=e.slice(e.length-r);return a.forEach((s,o)=>{if(!s?.id)throw new Error(`${n}: file record ${o} has no id \u2014 cannot upload ciphertext`);if(s.sha256_hex===void 0)throw new Error(`${n}: file record ${o} carries no sha256_hex \u2014 refusing to pair it by position`);if(s.sha256_hex!==t[o])throw new Error(`${n}: file record ${o} has sha256=${s.sha256_hex.slice(0,16)}\u2026 but we sent ${t[o].slice(0,16)}\u2026 \u2014 response order corrupted, refusing to upload`)}),a}function ui(e){return e>=200&&e<300||e===204}async function hi(e){let{ctx:t,sealId:n,fileId:r,ciphertext:a,authHeaders:s,onVerifying:o,label:i,signal:c,clock:d,transport:f}=e,h=` for ${i}`,u={"Content-Type":"application/json",...s},p=t.credentials??"include",g=(k,R)=>$t(R,{clock:d,policy:f,signal:c,classify:Qr,what:k}),_=()=>g(`initiate${h}`,async()=>{let k=await _t(`${t.baseUrl}/upload/initiate`,{method:"POST",headers:u,credentials:p,body:JSON.stringify({seal_id:n,content_type:"application/octet-stream",content_length:a.blob.size,file_id:r})},f.controlTimeoutMs,c);if(k.status===409)return null;if(!k.ok)throw await qe(k,`Upload initiate failed${h}`,"NETWORK");let R=await k.json();return R.already_verified?null:R}),b=await _();if(b===null)return!1;let v=!1;if(await $t(async({after:k})=>{if(k==="refresh_url"){let U=await _();if(U===null){v=!0;return}b=U}let{upload_url:R}=b,W=await _t(R,{method:"PUT",body:a.blob,headers:{"Content-Type":"application/octet-stream","Content-MD5":a.md5_b64}},hn(a.blob.size,f),c);if(W.status===400&&(await W.clone().text().catch(()=>"")).includes("<Code>BadDigest</Code>"))throw new O(`Upload arrived corrupted (BadDigest)${h}`,"BAD_DIGEST",400,void 0,!0);if(!ui(W.status))throw new O(`Upload PUT failed${h}: ${W.status}`,"NETWORK",W.status)},{clock:d,policy:f,signal:c,classify:Jr,what:`PUT${h}`}),v)return!1;d.delivered(),o();let D=await g(`confirm${h}`,async()=>{let k=await _t(`${t.baseUrl}/upload/confirm`,{method:"POST",headers:u,credentials:p,body:JSON.stringify({seal_id:n,file_id:r,...t.onConflict?{on_conflict:t.onConflict}:{}})},f.controlTimeoutMs,c);if(k.status===409)return!1;if(!k.ok)throw await qe(k,`Upload confirm failed${h}`,"NETWORK");let R=await k.json().catch(()=>null);return typeof R?.conflict_with=="string"&&e.onConflictWith(R.conflict_with),R?.status==="verified"});return d.delivered(),D}async function pa(e,t,n,r,a,s){try{let o=await _t(`${e.baseUrl}/upload/status/${encodeURIComponent(t)}/${n}`,{method:"GET",headers:r,credentials:e.credentials??"include"},a.controlTimeoutMs,s);if(!o.ok)return null;let i=await o.json();return typeof i.status=="string"?i.status:null}catch(o){if(o instanceof O&&o.code==="ABORTED")throw o;return null}}var fi=new Set(["failed","size_mismatch","verification_error"]),pi=new Set(["verified","pending_verification"]);async function _i(e){let{ctx:t,sealId:n,digest:r,authHeaders:a,transport:s,signal:o,label:i}=e,c=s.verifyFallbackWaitMs,d=performance.now(),f=s.verifyPollBackoffMs;for(let h=0;;h++){let u=f[Math.min(h,f.length-1)]??0;if(performance.now()-d+u>c)return"pending";u>0&&await xn(u,o);let p=await pa(t,n,r,a,s,o);if(p==="verified")return"verified";if(p!==null&&fi.has(p))throw new O(`The server rejected ${i} after upload (${p}). It has to be sent again.`,"VERIFICATION_REJECTED");if(p===null&&h===0)return"pending"}}async function wi(e,t,n={}){let{ctx:r,policy:a,sealId:s}=e,{file:o,key:i,fileId:c}=t,{onProgress:d,signal:f}=n;if(t.state!=="pending")return;if(f?.aborted)throw new O("Upload aborted","ABORTED");let h=In(r),u=Vt(h),p=An(a.transport),g=async S=>{if(t.state=S?"verified":"uploaded",!S)try{await _i({ctx:r,sealId:s,digest:t.sha256_hex,authHeaders:u,transport:p,signal:f,label:o.name})==="verified"&&(t.state="verified")}catch(C){throw C instanceof O&&C.code==="VERIFICATION_REJECTED"&&(t.state="pending",t.prepared=void 0,t.streamed=void 0),C}};if(ai(o.size,a)){if(t.streamed){let A=await pa(r,s,t.sha256_hex,u,p,f);if(A!==null&&pi.has(A)){await g(A==="verified");return}}let S=Rr("multipart",A=>d?.(A)),C=null,N=await ei({file:o,sealId:s,fileId:c,key:i,header:t.header,baseUrl:r.baseUrl,auth:h,partSize:ri(o.size,a),onProgress:A=>{C=A;let L=A.phase==="done";S({...A,phase:L?"verifying":A.phase,fraction:L?0:A.deliveredBytes/A.totalBytes,preparedFraction:A.totalBytes>0?(A.preparedBytes??0)/A.totalBytes:0,preparedBytes:A.preparedBytes})},signal:f,transport:a.transport,onStreamed:()=>{t.streamed=!0},onConflict:r.onConflict});t.streamed=void 0,t.conflictWith=N.conflictWith,await g(N.verified);let we=t.encryptedSize;S({...C??{phase:"done",percent:100,deliveredBytes:we,totalBytes:we,state:"running",attempt:1},phase:"done",fraction:1});return}let _=Rr("single-put",S=>d?.(S)),b=t.encryptedSize,v={phase:"encrypting",fraction:0,delivered:!1},D=null,k=(S,C,N=v.delivered)=>{v={phase:S,fraction:C,delivered:N},_({phase:S,fraction:C,deliveredBytes:N?b:0,totalBytes:b,state:D?.state??"running",attempt:(D?.retriesSinceDelivery??0)+1})};t.prepared||(k("encrypting",0),t.prepared=await Ro(o,i,t.header,S=>k("encrypting",o.size>0?S/o.size:1)));let R=t.prepared,W=new ea(p,()=>k(v.phase,v.fraction));D=W,k("uploading",0);let U;try{U=await hi({ctx:r,sealId:s,fileId:c,ciphertext:R,authHeaders:u,onVerifying:()=>k("verifying",0,!0),label:o.name,signal:f,clock:W,transport:p,onConflictWith:S=>{t.conflictWith=S}})}finally{W.dispose()}k("verifying",.5,!0),await g(U),t.prepared=void 0,k("done",1,!0)}function gi(e){if(!e.roomId){if(!e.ownerTokenHash)throw new Error("ownerTokenHash is required for seal creation (SHORT LINKS)");if(e.ownerTokenHash.length!==64||!/^[a-f0-9]{64}$/i.test(e.ownerTokenHash))throw new Error("ownerTokenHash must be 64 hex characters (SHA256)")}}function yi(e,t){t.ttl&&(e.ttl=t.ttl),t.roomId&&(e.room_id=t.roomId),t.otp&&(e.otp=t.otp),t.nda&&(e.nda=!0),t.ownerEmail&&(e.owner_email=t.ownerEmail),t.singleUse&&(e.single_use=!0),t.geo&&t.geo.length>0&&(e.geo=t.geo),typeof t.maxOpens=="number"&&t.maxOpens>0&&(e.max_opens=t.maxOpens),t.tier&&(e.tier=t.tier)}async function bi(e,t,n,r,a={}){let s=await kr(a.relativePath??e.name,t,"name"),o=await kr(e.type||$o(e.name),t,"mime"),i={size:n,sha256_hex:r,name_encrypted:s.ciphertext,name_nonce:s.nonce,mime_encrypted:o.ciphertext,mime_nonce:o.nonce,encryption_version:pe.current_format_version};return a.parentFolderId&&(i.parent_folder_id=a.parentFolderId),a.supersedes&&(i.supersedes=a.supersedes,i.layout="whole"),i}async function mi(e,t,n,r,a){if(n?.aborted)throw new O("Upload aborted","ABORTED");let s=Ze(e,t);return new Promise((o,i)=>{let c=!1,d=p=>{c||(c=!0,u(),i(p),s.then(async g=>g.ok?r(await g.json()):void 0).catch(()=>{}))},f=()=>d(new O("Upload aborted","ABORTED")),h=setTimeout(()=>d(new O(`The registration got no answer in ${Math.round(a/1e3)} s`,"NETWORK",void 0,void 0,!0)),a),u=()=>{clearTimeout(h),n?.removeEventListener("abort",f)};n?.addEventListener("abort",f,{once:!0}),s.then(p=>{c||(c=!0,u(),o(p))},p=>{c||(c=!0,u(),i(p))})})}function Ei(e){return An(e.transport).completeTimeoutMs}async function Si(e,t,n,r){try{return di(e,t,n)}catch(a){throw await r((e??[]).filter(s=>s.sha256_hex!==void 0&&t.includes(s.sha256_hex))).catch(()=>{}),a}}async function Ai(e,t){if(t?.aborted)throw await e.cancel(),new O("Upload aborted","ABORTED")}async function vi(e,t,n,r,a){let s={files_meta:t};e.ownerTokenHash&&(s.owner_token_hash=e.ownerTokenHash),yi(s,e);let o=await mi(`${e.baseUrl}/seal`,{method:"POST",headers:{"Content-Type":"application/json",...Vt(In(e))},credentials:e.credentials??"include",body:JSON.stringify(s)},n,r,a);if(!o.ok)throw await qe(o,"Create seal failed","UNKNOWN");return await o.json()}async function xi(e,t){let n=js();return{file:e,key:t,header:n,sha256_hex:await Ye(n)}}async function ki(e,t,n,r){await e.onRegistered?.(t,n.map((a,s)=>({fileId:r[s].id,sha256_hex:a.sha256_hex,key:a.key})))}function Ti(e,t){return e.map((n,r)=>({index:r,fileId:t[r].id,file:n.file,key:n.key,header:n.header,sha256_hex:n.sha256_hex,encryptedSize:En(n.file.size),state:"pending"}))}async function _a(e,t,n=qt,r={}){gi(e);let a=await xi(t,Qs()),s=(d,f)=>new On({ctx:e,policy:n,sealId:d.id,createdSeal:!0,expiresAt:d.expires_at,files:f},async(h,u)=>{let p=h.files[0];return await wi(h,p,{onProgress:g=>u.onProgress?.(g),signal:u.signal}),{sealId:h.sealId,fileId:p.fileId,encryptionKey:p.key,sha256_hex:p.sha256_hex,expiresAt:h.expiresAt,verification:h.verification}}),o=await vi(e,[await bi(t,a.key,En(t.size),a.sha256_hex)],r.signal,d=>s(d,[]).cancel(),Ei(n)),i=await Si(o.files,[a.sha256_hex],`Create seal ${o.id}`,()=>s(o,[]).cancel()),c=s(o,Ti([a],i));return await Ai(c,r.signal),await ki(r,o.id,[a],i),c.resume(r)}var Pr=[2e3,4e3,8e3,15e3],un=_e.limits.TIER_BYTES,Gl=Object.keys(un).filter(e=>e!=="free").sort((e,t)=>un[e]-un[t]);function wa(e){return e instanceof O&&e.httpStatus===402&&e.session?e.session:null}function ga(e,t=Date.now()){let n=t+_e.limits.PAYMENT_WAIT_MAX_SECONDS*1e3,r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)?Math.min(n,r):n}async function ya(e,t,n,r){for(let a=0;;a++){try{let o=await e.getOwnerSeal(t,n,{signal:r.signal});if(r.tier?o.tier===r.tier:o.tier&&o.tier!=="free")return o}catch(o){if(r.signal?.aborted||o instanceof ie&&o.code!=="transient"&&o.code!=="rate_limited")throw o}let s=Pr[Math.min(a,Pr.length-1)];if(Date.now()+s>r.deadline)return null;await xn(s,r.signal)}}var jl=_e.limits.ttl_options;var Rn=8,Pn=43,wn=4,Xt=/^[A-Za-z0-9_-]+$/;function Ii(e,t){if(!Xt.test(e))return!1;try{let n=e.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return atob(n).length===t}catch{return!1}}function Ln(e){return e.length===Rn&&Xt.test(e)}function Dn(e){return e.length===Pn&&Ii(e,32)}function ba(e,t){if(!Ln(e))throw new Error(`Invalid sealId: must be ${Rn} base64url characters`);if(!Dn(t))throw new Error(`Invalid linkKey: must be ${Pn} base64url characters (32 bytes)`);return`/s/${e}#${t}`}function ma(e,t,n){if(!Ln(e))throw new Error(`Invalid sealId: must be ${Rn} base64url characters`);if(t.length!==wn||!Xt.test(t))throw new Error(`Invalid shareCode: must be ${wn} base64url characters`);if(!Dn(n))throw new Error(`Invalid linkKey: must be ${Pn} base64url characters (32 bytes)`);return`/s/${e}/${t}#${n}`}var Ft=class extends Error{constructor(e,t){super(t),this.name="ShareUrlError",this.code=e}};function Oi(e){let t;try{t=new URL(e)}catch{throw new Ft("url_invalid",`not a valid URL (${e.length} characters)`)}let n;try{n=Ri(t.pathname.replace(/\/+$/,""))}catch{throw new Ft("url_invalid",`expected /s/<seal_id>[/<share_code>] path, got: ${t.pathname}`)}let r=t.hash.replace(/^#/,"").trim(),a=n.shareCode??null;if(!r)return{sealId:n.sealId,shareCode:a,fragmentVariant:"none",fragment:r};if(!Dn(r))throw new Ft("url_invalid",`the fragment is not one 43-character key (got ${r.length} characters): a mangled link, or one from a newer client \u2014 update it`);return{sealId:n.sealId,shareCode:a,fragmentVariant:"key",fragment:r}}function Ri(e){let t=e.match(/^\/s\/([A-Za-z0-9_-]{8})(?:\/([A-Za-z0-9_-]{4}))?$/);if(!t)throw new Error("Invalid seal URL format");let n=t[1],r=t[2];if(!Ln(n))throw new Error("Invalid sealId in URL");if(r&&(r.length!==wn||!Xt.test(r)))throw new Error("Invalid shareCode in URL");return{sealId:n,shareCode:r}}var Nn=fe.scopes.share_link,Ea=fe.scopes.owner_copy;var Lr=Xe.sealed_box_v2.version_byte,Dr=Xe.sealed_box_v2.packed_length,wt=64,Yt=32,Nr=32;var Sa=/^[A-Za-z0-9_-]+$/;function Aa(){return crypto.getRandomValues(new Uint8Array(wt))}async function Bn(e,t=1){let n=await dt();if(e.length===wt)return n.WasmIdentity.fromSeed64(e,t);if(e.length===Yt)return n.WasmIdentity.fromSeed32(e);throw new Error(`a seed is ${wt} bytes, or the ${Yt} of a key made before, got ${e.length}`)}async function Cn(e,t=1){let n=await Bn(e,t);try{return{bundle:n.bundle(),address:n.address(),words:n.words()}}finally{n.free()}}function va(e){let t=e.trim().replace(/=+$/,"");if(t.length!==43)throw new Error(`an address is 43 urlsafe-base64-no-pad characters, got ${t.length}`);if(!Sa.test(t))throw new Error("not valid urlsafe-base64-no-pad: contains characters outside [A-Za-z0-9_-] (standard-base64 input is rejected \u2014 copy the exact address from `seal keygen` or `sealnet-mcp pubkey`)");return t}async function xa(e,t){return(await dt()).wasm_bundle_verify_for_address(e,t)}async function Mn(e){return(await dt()).wasm_bundle_address(e)}async function Un(e,t,n,r){if(e.length!==Nr)throw new Error(`a wrapped key is ${Nr} bytes, got ${e.length}`);if(r.length===0)throw new Error("the scope id must not be empty: the wrap binds to it");return ne((await dt()).wasm_sealbox_wrap(e,t,n,r))}var Ke=class extends Error{constructor(e,t,n){super(t),this.name="WrapError",this.kind=e,this.cause=n}};async function Pi(e,t,n,r,a=1){if(r.length===0)throw new Ke("parse","the scope id must not be empty: the wrap binds to it");if(!Sa.test(e))throw new Ke("parse","the wrap is not urlsafe-base64-no-pad");let s=de(e);if(s[0]!==Lr)throw new Ke("parse",`the wrap is not a sealed box v${Lr}: a newer client made it \u2014 update this one`);if(s.length!==Dr)throw new Ke("parse",`the wrap is ${s.length} bytes, expected ${Dr}`);if(t.length!==wt&&t.length!==Yt)throw new Ke("parse",`a seed is ${wt} bytes, or the ${Yt} of a key made before, got ${t.length}`);let o=await Bn(t,a);try{return o.open(s,n,r)}catch(i){throw new Ke("aead","the wrap does not open: it is not for this seed, or its scope, id or bytes were changed",i)}finally{o.free()}}async function Li(e,t){let n=await Bn(e);try{let r=n.inboxProof(BigInt(t.ts),de(t.challenge));return`${t.ts}.${t.challenge}.${ne(r)}`}finally{n.free()}}var gn={version:2,name:"FINGERPRINT_WORDS",description:"Eight words that name the identity key of a bundle to a person (SPEC-AEON-V4 \xA75.3; eight since AUDIT K251, owner 11.11: eight words, 24 bits, were ground in 207 s on one Mac): word i (i = 0 \u2026 7) is words[byte i of SHA-256(identity public key)] \u2014 the first eight bytes of the same SHA-256 that is the address, so a client names an address by its own first bytes without hashing again \u2014 64 bits in all, written in lower case with one space between them; the first three are the three of before. The agent shows them in its chat, box.seal.net and seal.net/i/{id} show them on the page, so a person sees at a glance whether both sides hold the same key. One list for every language and client: 256 English nouns of 3 to 7 letters, no two sharing their first three letters, in alphabetical order.",digest:"sha256",count:8,separator:" ",words:["acorn","album","amber","anchor","apple","arrow","atlas","bamboo","banjo","basket","beach","bell","bench","berry","birch","bison","bloom","boat","bolt","bottle","brick","broom","butter","cabin","cactus","camel","candle","cargo","castle","cedar","cherry","clock","coast","comet","copper","coral","cotton","crab","crown","daisy","dawn","deer","delta","desert","diamond","dolphin","dove","dragon","drum","duck","dune","eagle","earth","echo","egg","elk","ember","emerald","engine","falcon","farm","feather","fence","fern","fig","finch","fish","flag","flute","fog","forest","fossil","fox","frog","garden","gate","gazelle","gecko","geyser","ginger","giraffe","glacier","globe","goat","gold","goose","grape","guitar","hammer","harbor","hawk","hazel","hedge","heron","hill","hippo","hive","honey","horse","igloo","iguana","iris","iron","island","ivory","jacket","jaguar","jasmine","jelly","jewel","juice","jungle","kayak","kelp","kettle","kite","kiwi","koala","ladder","lagoon","lamp","lantern","lava","leaf","lemon","leopard","lily","lime","lion","lizard","llama","lobster","lotus","lynx","magnet","mango","maple","marble","meadow","melon","meteor","mint","mirror","monkey","moon","mosaic","muffin","nail","nectar","needle","nest","oasis","ocean","olive","opal","orange","orbit","orchid","otter","owl","palm","panda","paper","parrot","peach","pebble","pelican","pencil","pepper","piano","pine","pizza","planet","plum","pony","poppy","prism","pumpkin","quartz","queen","quill","rabbit","radio","raft","raven","reed","rhino","ribbon","ridge","river","robin","rocket","rose","ruby","sail","salmon","sand","saturn","scroll","shark","shell","ship","silk","sled","sloth","snail","snow","spider","spruce","star","stone","sugar","summit","swan","table","teapot","thunder","tiger","tile","timber","toast","tomato","topaz","torch","tower","trout","truck","tulip","turtle","unicorn","valley","vanilla","vase","velvet","violin","volcano","wagon","walnut","wave","whale","wheat","whistle","willow","window","wizard","wolf","wombat","wren","yacht","yarn","yeti","yucca","zebra","zenith","zinc","zipper"],vector:{public_key_b64url:"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",sha256_prefix_hex:"66687aadf862bd77",words:"iron ivory lava plum yacht horse river lagoon"}},Di=gn.words,Ni=/^[A-Za-z0-9_-]{43}$/;function ka(e){if(!Ni.test(e))throw new Error(`an address is 43 base64url characters, got ${e.length}`);let t=de(e);return Array.from(t.subarray(0,gn.count),n=>Di[n]).join(gn.separator)}var Ta=fe.payloads.pair.mime,Vl=fe.payloads.device.mime,ql=fe.payloads.delivery.mime,Xl=fe.payloads.approve.mime,Zl=fe.payloads.approve_answer.mime,Jl=fe.payloads.summary.mime,Ia=fe.pair_what,Br=fe.payloads.name_max,Ql=_e.limits.APPROVE_BODY_SHOWN_BYTES;var Cr=Xe.keybundle.packed_length,Mr=2;var Bi=/^[A-Za-z0-9_-]+$/;function Oa(e){let t=Ci(e,"pairing");if(typeof t.bundle!="string"||!Bi.test(t.bundle))throw new Error("pairing bundle is not base64url");return{bundle:Mi(de(t.bundle)),name:Ui(t.name)}}function Ci(e,t){let n;try{n=JSON.parse(new TextDecoder().decode(e))}catch{throw new Error(`${t} payload is not JSON`)}if(typeof n!="object"||n===null||n.v!==Mr)throw new Error(`${t} payload is not version ${Mr}`);return n}function Mi(e){if(e.length!==Cr)throw new Error(`a bundle is ${Cr} bytes, got ${e.length}`);return e}function Ui(e){if(typeof e!="string"||e.length===0||e.length>Br)throw new Error(`name must be 1 to ${Br} characters`);return e}var Fi={version:1,name:"SECRETS",description:"How a secret travels (SPEC-AGENTS \xA74.3, \xA76.1). `mime` is the marker a sender pins on a file that is a secret (`seal send --kind secret`, the intake page, the local dialog); it rides encrypted in the file metadata, so a receiving agent saves it to disk and never reads it into a conversation (`seal_open inline` refuses it). `sources`: where well-known keys are created, service name \u2192 the host of its key page. A request's `where_url` whose host is in this list is shown as that service; any other https host is shown with the note that the address came from the agent and should be checked. Data, not code: a service is added with one line.",mime:"application/vnd.seal.secret",sources:{Anthropic:"console.anthropic.com",AWS:"console.aws.amazon.com","Brave Search":"api.search.brave.com",Cloudflare:"dash.cloudflare.com",DigitalOcean:"cloud.digitalocean.com",Discord:"discord.com",GitHub:"github.com","Google AI Studio":"aistudio.google.com","Google Cloud":"console.cloud.google.com",Groq:"console.groq.com","Hugging Face":"huggingface.co",Mistral:"console.mistral.ai",npm:"www.npmjs.com",OpenAI:"platform.openai.com",OpenRouter:"openrouter.ai",PyPI:"pypi.org",Slack:"api.slack.com",Stripe:"dashboard.stripe.com",Supabase:"supabase.com","Telegram BotFather":"t.me",Twilio:"console.twilio.com",Vercel:"vercel.com"},patterns_note:"What a key looks like, for every reader: `seal doctor --transcripts`, the scanner of the Pro web page and the `sealfs` detector (C1 \u042039). `pattern` is an expression in the subset all three run alike \u2014 JS, Python `re`, Rust `regex`: no lookaround, no backreference, no inline flag; a boundary is `\\b` inside the expression. The flags are shared: case-insensitive and multiline. A match that contains a string of the entry's `allowlist` (case-insensitive) is no finding. A match of an entry with `checksum` is a finding only when it passes that sum: `luhn` \u2014 the Luhn sum of its digits is 0 modulo 10; `iban` \u2014 its characters but spaces, upper-cased, the first four moved to the end, each letter read as a number (A = 10 \u2026 Z = 35), are 1 modulo 97. A finding is shown masked: its first four characters, `\u2026`, its last two. `vectors.hit` holds a finding of the entry, `vectors.clean` none; every reader passes them. The scanner page does not take a file larger than `max_file_bytes`; `seal doctor` reads agent transcripts of any size, a line at a time \u2014 skipping a long transcript would hide its leak. Data, not code: a service is added with one entry.",max_file_bytes:10485760,wildcard_public_second_level:["ac","co","com","edu","gov","go","ne","net","or","org","mil","int","gob","ltd","plc","me","nom"],shared_host_suffixes:["s3.amazonaws.com","cloudfront.net","azurewebsites.net","appspot.com","firebaseapp.com","web.app","github.io","githubusercontent.com","gitlab.io","herokuapp.com","pages.dev","workers.dev","vercel.app","netlify.app","onrender.com","fly.dev","blogspot.com","ngrok.io","ngrok-free.app","glitch.me","surge.sh"],shared_host_note:"Names under which each customer has a name of its own (the private part of the public suffix list): a host there is one service with the label before it, as `x.co.uk` is \u2014 AUDIT K162: by its last two labels every github.io page was one service.",wildcard_note:"A proposed `*.<name>` binds a key unless <name> is a public suffix: one label (`*.com`), or two where the second is a two-letter country top level and the first is one of wildcard_public_second_level (`*.co.uk` would be a root for every .co.uk host; `*.me.com` is a name of its own); a bare name needs two labels (SPEC agent egress \xA74.2, review of phase 1).",guard_note:"What the guard does with a key of an entry (SPEC agent egress \xA74.1, read by `seal-client-core::guard`). `hosts`: where the key is a way in, the default binding a person confirms or narrows; `*.` is one label. `place`: where the guard puts the value \u2014 `bearer` (Authorization: Bearer), `header:<name>`, `query:<param>`, `basic_user`, `basic_pass`, `userinfo`, `url` (the secret is the request address itself, a webhook). `class`: `outbound` \u2014 a key a program enters a service with, the proxy puts it in; `inprocess` \u2014 a key a program works with itself (a webhook signing secret, a database password of a driver that uses no proxy, a private key, an assignment the pattern matches with its name): the program gets the value, by the person's word on the page. `surrogate`: the form of the stand-in the agent sees \u2014 `keep_prefix` (kept as it is), `alphabet` (`base62`, `base64url`, `hex`, `digits`, `base32`, `classes` \u2014 each character keeps its class and punctuation stays), `length` (a number, else the value's), `checksum` (`github_crc32`: the last six characters are the CRC32 of the body, base62), `parts` (`password`: of a connection URI only the password changes). An entry without `surrogate` is treated by classes. `provision_commands`: commands that write a key as data into a service's own store; a surrogate in their arguments or stdin is refused unless the binding's `provision` names the host (\xA75.4, \xA76.4). Data, not code: a service is added with one entry.",provision_commands:[{command:"wrangler secret put",host:"api.cloudflare.com"},{command:"gh secret set",host:"api.github.com"},{command:"vercel env add",host:"api.vercel.com"},{command:"fly secrets set",host:"api.machines.dev"},{command:"kubectl create secret",host:null},{command:"aws secretsmanager put-secret-value",host:"*.amazonaws.com"},{command:"heroku config:set",host:"api.heroku.com"},{command:"doppler secrets set",host:"api.doppler.com"}],patterns:[{name:"openai_api_key",pattern:"\\bsk-proj-[A-Za-z0-9_-]{40,}",severity:"critical",description:"OpenAI API Key",keywords:["openai","sk-proj-"],hosts:["api.openai.com"],place:"bearer",class:"outbound",surrogate:{keep_prefix:"^sk-proj-",alphabet:"base64url"},vectors:{hit:"OPENAI_API_KEY=sk-proj-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdEf",clean:"OPENAI_API_KEY=sk-proj-AbCdEfGhIj"}},{name:"anthropic_api_key",pattern:"\\bsk-ant-[A-Za-z0-9_-]{40,}",severity:"critical",description:"Anthropic API Key",keywords:["anthropic","sk-ant-"],hosts:["api.anthropic.com"],place:"header:x-api-key",class:"outbound",surrogate:{keep_prefix:"^sk-ant-(?:api[0-9]{2}-)?",alphabet:"base64url"},vectors:{hit:"sk-ant-api03-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789AbCd",clean:"sk-ant-api03-short"}},{name:"github_token",pattern:"\\b(?:gh[pousr]|github_pat)_[A-Za-z0-9_]{30,}",severity:"critical",description:"GitHub Token",keywords:["github","token","ghp_","github_pat_"],hosts:["api.github.com","github.com","uploads.github.com","codeload.github.com"],place:"bearer",class:"outbound",surrogate:{keep_prefix:"^(?:gh[pousr]|github_pat)_",alphabet:"classes",checksum:"github_crc32"},vectors:{hit:"token: ghp_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",clean:"token: xghp_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789"}},{name:"gitlab_token",pattern:"glpat-[A-Za-z0-9\\-]{20,}",severity:"critical",description:"GitLab Personal Access Token",keywords:["gitlab","token"],hosts:["gitlab.com"],place:"header:PRIVATE-TOKEN",class:"outbound",surrogate:{keep_prefix:"^glpat-",alphabet:"classes"},vectors:{hit:"glpat-AbCdEfGhIjKlMnOpQrSt",clean:"glpat-short"}},{name:"aws_access_key_id",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",severity:"critical",description:"AWS Access Key ID",keywords:["aws","amazon","access_key","accesskey"],class:"inprocess",surrogate:{keep_prefix:"^(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)",alphabet:"classes"},vectors:{hit:"AKIAIOSFODNN7EXAMPLE",clean:"AKIAIOSFODNN7EXAMPLEX"}},{name:"aws_secret_access_key",pattern:`aws[_\\-\\.]?secret[_\\-\\.]?access[_\\-\\.]?key['\\"]?\\s*[:=]\\s*['\\"]?([A-Za-z0-9/+=]{40})['\\"]?`,severity:"critical",description:"AWS Secret Access Key",keywords:["aws","secret","access_key"],class:"inprocess",surrogate:{keep_prefix:`^.*[:=]\\s*['\\"]?`,alphabet:"classes"},vectors:{hit:'aws_secret_access_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"',clean:'aws_secret_access_key = "short"'}},{name:"stripe_live_key",pattern:"\\b[sr]k_live_[A-Za-z0-9]{20,}",severity:"critical",description:"Stripe Live Secret Key",keywords:["stripe","live","secret"],hosts:["api.stripe.com","files.stripe.com"],place:"bearer",class:"outbound",surrogate:{keep_prefix:"^[sr]k_live_",alphabet:"base62"},vectors:{hit:"sk_live_AbCdEfGhIjKlMnOpQrStUvWx",clean:"sk_live_AbCd"}},{name:"stripe_test_key",pattern:"\\b[sr]k_test_[A-Za-z0-9]{20,}",severity:"medium",description:"Stripe Test Secret Key",keywords:["stripe","test"],hosts:["api.stripe.com","files.stripe.com"],place:"bearer",class:"outbound",surrogate:{keep_prefix:"^[sr]k_test_",alphabet:"base62"},vectors:{hit:"rk_test_AbCdEfGhIjKlMnOpQrStUvWx",clean:"rk_test_AbCd"}},{name:"stripe_publishable_live",pattern:"pk_live_[A-Za-z0-9]{24,}",severity:"low",description:"Stripe Live Publishable Key",keywords:["stripe","publishable"],vectors:{hit:"pk_live_AbCdEfGhIjKlMnOpQrStUvWx",clean:"pk_live_AbCd"}},{name:"stripe_webhook_secret",pattern:"\\bwhsec_[A-Za-z0-9]{32,}",severity:"critical",description:"Stripe Webhook Signing Secret",keywords:["stripe","webhook","whsec_"],class:"inprocess",surrogate:{keep_prefix:"^whsec_",alphabet:"base62"},vectors:{hit:"STRIPE_WEBHOOK_SECRET=whsec_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",clean:"STRIPE_WEBHOOK_SECRET=whsec_short"}},{name:"slack_token",pattern:"\\bxox[abprs]-[A-Za-z0-9-]{20,}",severity:"critical",description:"Slack Token",keywords:["slack","token","xox"],hosts:["slack.com"],place:"bearer",class:"outbound",surrogate:{keep_prefix:"^xox[abprs]-",alphabet:"classes"},vectors:{hit:"xoxb-1234567890-1234567890123-AbCdEfGhIjKl",clean:"xoxb-12345"}},{name:"slack_webhook",pattern:"https://hooks\\.slack\\.com/services/T[A-Z0-9]+/B[A-Z0-9]+/[A-Za-z0-9]+",severity:"high",description:"Slack Webhook URL",keywords:["slack","webhook","hooks.slack.com"],hosts:["hooks.slack.com"],place:"url",class:"outbound",surrogate:{keep_prefix:"^https://hooks\\.slack\\.com/services/T[A-Z0-9]+/B",alphabet:"classes"},vectors:{hit:"https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",clean:"https://hooks.slack.com/services/"}},{name:"google_api_key",pattern:"\\bAIza[0-9A-Za-z\\-_]{35}",severity:"high",description:"Google API Key",keywords:["google","api","AIza"],hosts:["*.googleapis.com"],place:"query:key",class:"outbound",surrogate:{keep_prefix:"^AIza",alphabet:"base64url"},vectors:{hit:"AIzaSyAbCdEfGhIjKlMnOpQrStUvWxYz0123456",clean:"AIzaSyShort"}},{name:"google_oauth_client_secret",pattern:`client[_\\-]?secret['\\"]?\\s*[:=]\\s*['\\"]?([A-Za-z0-9\\-_]{24})['\\"]?`,severity:"high",description:"Google OAuth Client Secret",keywords:["google","oauth","client_secret"],class:"inprocess",surrogate:{keep_prefix:`^.*[:=]\\s*['\\"]?`,alphabet:"classes"},vectors:{hit:'client_secret: "AbCdEfGhIjKlMnOpQrStUvWx"',clean:'client_secret: "short"'}},{name:"private_key",pattern:"-----BEGIN (?:RSA |EC |DSA |OPENSSH |ENCRYPTED |PGP )?PRIVATE KEY(?:\\s+BLOCK)?-----",severity:"critical",description:"Private Key",keywords:["private","key","-----BEGIN"],vectors:{hit:"-----BEGIN OPENSSH PRIVATE KEY-----",clean:"-----BEGIN PUBLIC KEY-----"}},{name:"jwt_token",pattern:"eyJ[A-Za-z0-9_-]*\\.eyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*",severity:"high",description:"JSON Web Token (JWT)",keywords:["jwt","token","eyJ"],vectors:{hit:"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.c2lnbmF0dXJl",clean:"eyJhbGciOiJIUzI1NiJ9"}},{name:"basic_auth",pattern:"(?:basic\\s+)[A-Za-z0-9+/=]{20,}",severity:"high",description:"Basic Authentication Header",keywords:["basic","auth","authorization"],vectors:{hit:"Authorization: Basic dXNlcjpwYXNzd29yZDEyMzQ1Ng==",clean:"Basic auth is disabled"}},{name:"bearer_token",pattern:"bearer\\s+[A-Za-z0-9_\\-\\.]{20,}",severity:"high",description:"Bearer Token",keywords:["bearer","token","authorization"],vectors:{hit:"Authorization: Bearer AbCdEfGhIjKlMnOpQrStUvWx",clean:"Bearer token expired"}},{name:"postgres_uri",pattern:"postgres(?:ql)?://[^:]+:[^@]+@[^/]+/[^\\s]+",severity:"critical",description:"PostgreSQL Connection String",keywords:["postgres","postgresql","database"],class:"inprocess",surrogate:{parts:"password"},vectors:{hit:"postgresql://app:hunter2secret@db.internal:5432/app",clean:"postgresql://db.internal/app"}},{name:"mysql_uri",pattern:"mysql://[^:]+:[^@]+@[^/]+/[^\\s]+",severity:"critical",description:"MySQL Connection String",keywords:["mysql","database"],class:"inprocess",surrogate:{parts:"password"},vectors:{hit:"mysql://app:hunter2secret@db.internal/app",clean:"mysql://db.internal/app"}},{name:"mongodb_uri",pattern:"mongodb(?:\\+srv)?://[^:]+:[^@]+@[^\\s]+",severity:"critical",description:"MongoDB Connection String",keywords:["mongodb","mongo","database"],class:"inprocess",surrogate:{parts:"password"},vectors:{hit:"mongodb+srv://app:hunter2secret@cluster0.example.net",clean:"mongodb://localhost"}},{name:"redis_uri",pattern:"redis://[^:]*:[^@]+@[^\\s]+",severity:"high",description:"Redis Connection String",keywords:["redis","cache"],class:"inprocess",surrogate:{parts:"password"},vectors:{hit:"redis://:hunter2secret@cache.internal:6379",clean:"redis://cache.internal:6379"}},{name:"azure_storage_key",pattern:`(?:account[_\\-]?key|storage[_\\-]?key)['\\"]?\\s*[:=]\\s*['\\"]?([A-Za-z0-9+/=]{88})['\\"]?`,severity:"critical",description:"Azure Storage Account Key",keywords:["azure","storage","account_key"],vectors:{hit:"AccountKey=AbCdEfGhIjKlMnOpQrStUvWxYz0123456789+/AbCdEfGhIjKlMnOpQrStUvWxYz0123456789+/AbCdEfGhIjKl",clean:"AccountKey=short"}},{name:"gcp_service_account",pattern:'"type"\\s*:\\s*"service_account"',severity:"critical",description:"GCP Service Account JSON",keywords:["gcp","google","service_account"],vectors:{hit:'{"type": "service_account", "project_id": "demo"}',clean:'{"type": "user"}'}},{name:"sendgrid_api_key",pattern:"SG\\.[A-Za-z0-9_-]{22}\\.[A-Za-z0-9_-]{43}",severity:"high",description:"SendGrid API Key",keywords:["sendgrid","email","SG."],hosts:["api.sendgrid.com"],place:"bearer",class:"outbound",surrogate:{keep_prefix:"^SG\\.",alphabet:"classes"},vectors:{hit:"SG.AbCdEfGhIjKlMnOpQrStUv.AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdE",clean:"SG.short.key"}},{name:"twilio_api_key",pattern:"SK[a-f0-9]{32}",severity:"high",description:"Twilio API Key",keywords:["twilio","sms"],hosts:["api.twilio.com"],place:"basic_user",class:"outbound",surrogate:{keep_prefix:"^SK",alphabet:"hex"},vectors:{hit:"SK0123456789abcdef0123456789abcdef",clean:"SK0123456789abcdef"}},{name:"npm_token",pattern:"npm_[A-Za-z0-9]{36}",severity:"high",description:"NPM Access Token",keywords:["npm","token"],hosts:["registry.npmjs.org"],place:"bearer",class:"outbound",surrogate:{keep_prefix:"^npm_",alphabet:"base62"},vectors:{hit:"npm_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",clean:"npm_short"}},{name:"pypi_token",pattern:"pypi-[A-Za-z0-9_-]{100,}",severity:"high",description:"PyPI API Token",keywords:["pypi","token","python"],hosts:["upload.pypi.org"],place:"basic_pass",class:"outbound",surrogate:{keep_prefix:"^pypi-",alphabet:"base64url"},vectors:{hit:"pypi-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdEfGhIjKlMnOpQrStUvWx",clean:"pypi-short"}},{name:"generic_password",pattern:`(?:password|passwd|pwd|secret)['\\"]?\\s*[:=]\\s*['\\"]([^'\\"]{8,})['\\"]`,severity:"medium",description:"Generic Password Assignment",keywords:["password","passwd","secret"],allowlist:["password123","changeme","example","placeholder","xxxxxxxx"],class:"inprocess",surrogate:{keep_prefix:`^.*[:=]\\s*['\\"]`,alphabet:"classes"},vectors:{hit:'password = "s3cr3t-Value!"',clean:'password = "changeme-now"'}},{name:"generic_api_key",pattern:`(?:api[_\\-]?key|apikey)['\\"]?\\s*[:=]\\s*['\\"]([A-Za-z0-9_\\-]{20,})['\\"]`,severity:"medium",description:"Generic API Key Assignment",keywords:["api_key","apikey"],class:"inprocess",surrogate:{keep_prefix:`^.*[:=]\\s*['\\"]`,alphabet:"classes"},vectors:{hit:'api_key = "AbCdEfGhIjKlMnOpQrStUvWx"',clean:'api_key = "short"'}},{name:"seal_link",pattern:"https://seal\\.net/(?:pro/)?s/[A-Za-z0-9_/-]{8,}#[A-Za-z0-9_-]{43}",severity:"critical",description:"SEAL link (it opens its seal)",keywords:["seal","seal.net/s/"],vectors:{hit:"https://seal.net/s/AbCd1234/Xy7Q#AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCde",clean:"https://seal.net/s/AbCd1234/Xy7Q"}},{name:"payment_card",pattern:"\\b(?:\\d[ -]?){12,18}\\d\\b",checksum:"luhn",severity:"high",description:"Payment Card Number",keywords:["card","visa","mastercard"],vectors:{hit:"card: 4111 1111 1111 1111",clean:"card: 4111 1111 1111 1112"}},{name:"iban",pattern:"\\b[A-Z]{2}\\d{2}(?: ?[A-Z0-9]{4}){2,7}(?: ?[A-Z0-9]{1,3})?\\b",checksum:"iban",severity:"high",description:"IBAN",keywords:["iban","bank","account"],vectors:{hit:"IBAN DE89 3704 0044 0532 0130 00, please",clean:"IBAN DE89 3704 0044 0532 0130 01, please"}},{name:"passport_number",pattern:"\\bpassport(?:\\s*(?:no|number|#))?\\.?\\s*[:=#]?\\s*[A-Z]{0,2}[0-9]{6,9}\\b",severity:"high",description:"Passport Number",keywords:["passport"],vectors:{hit:"Passport No: X1234567",clean:"Passport photos: 2 copies"}}]},Wi=Fi.mime,G=class extends Error{constructor(e,t,n){super(t),this.name="OpenError",this.code=e,this.cause=n}},Hi=32;async function Fn(e,t,n={}){let r;try{r=Oi(t)}catch(_){throw _ instanceof Ft?new G(_.code,_.message,_):_}if(r.shareCode===null)throw new G("url_invalid","share code missing from the URL path (/s/<seal_id>/<share_code>#<key>)");let{sealId:a,shareCode:s}=r,o=n.seed,i=n.wrap??null,c=r.fragmentVariant==="key"?de(r.fragment):i!==null&&o?await Ur(i,o,a):null;c!==null&&await gr(a,c);let d=n.signal?{signal:n.signal}:{},f;try{f=ho(await e.getMetadata(r.sealId,{...d,shareCode:s}))}catch(_){throw _ instanceof ie&&(_.code==="not_found"||_.code==="revoked")?new G(_.code==="revoked"?"seal_revoked":"seal_not_found",`seal ${r.sealId} ${_.code==="revoked"?"has been revoked":"was not found or has expired"}`,_):new G("metadata_failed",`reading seal ${r.sealId} failed: ${yn(_)}`,_)}if(f.revokedAt!==null)throw new G("seal_revoked",`seal ${r.sealId} has been revoked`);if(f.files.length===0)throw new G("seal_not_ready",`seal ${r.sealId} has no files available yet: the server verifies an upload before offering it. Retry in a few seconds.`);let h;try{let _=await e.getShareBlob(a,s,d);if(h=_.blob,c===null){if(_.wrap===null)throw new G("url_no_fragment","the link carries no key after #: copy it whole");if(!o)throw new G("targeted_fragment_invalid","this link is addressed to someone: pass their seed to open it");c=await Ur(_.wrap,o,a),await gr(a,c)}}catch(_){throw _ instanceof G?_:_ instanceof ie&&(_.code==="not_found"||_.code==="revoked")?new G(_.code==="revoked"?"share_link_revoked":"share_link_not_found",`share link ${a}/${s} ${_.code==="revoked"?"has been revoked":"was not found"}`,_):new G("share_blob_fetch_failed",`share blob fetch failed: ${yn(_)}`,_)}let u,p;try{let _=await vo(h,c);u=_.file_keys,p=So(_)}catch(_){throw new G("share_blob_decrypt_failed","the share blob does not open with this link \u2014 mistyped URL, or the link was revoked and minted again",_)}let g=await Promise.all(f.files.map(_=>Yi(_,u,p)));return{sealId:a,expiresAt:f.expiresAt,singleUse:f.singleUse,maxOpens:f.maxOpens,otpRequired:f.otpRequired,ndaRequired:f.ndaRequired,files:g}}async function Ur(e,t,n){try{return await Pi(e,t,Nn,n)}catch(r){let a=r instanceof Ke&&r.kind==="aead";throw new G(a?"targeted_decrypt_failed":"targeted_fragment_invalid",yn(r),r)}}async function Ra(e,t,n={}){for(;;){n.signal?.throwIfAborted();let r=Date.now(),a;try{a=await e.getIntake(t,{...n,waitSeconds:_e.limits.INTAKE_WAIT_MAX_SECONDS})}catch(o){throw o instanceof ie&&o.code==="not_found"?new G("request_expired","the request expired before anybody answered",o):o}if(a.status==="expired")throw new G("request_expired","nobody answered before the request expired");if(a.status==="fulfilled"){if(a.share_path&&a.fragment)return{sharePath:a.share_path,wrap:a.fragment};throw new G("share_blob_corrupt","the request was answered without its link")}if(a.status!=="pending")throw new G("client_outdated",`the request is ${String(a.status)}, a state this client does not know`);let s=$i-(Date.now()-r);s>0&&await Ki(s,n.signal)}}var $i=2e3;function Ki(e,t){return new Promise((n,r)=>{let a=()=>{clearTimeout(s),r(t?.reason)},s=setTimeout(()=>{t?.removeEventListener("abort",a),n()},e);t?.addEventListener("abort",a,{once:!0})})}var zi=64*1024;async function Pa(e,t,n,r){let a=await Fn(e,t,r),[s,...o]=a.files;if(!s?.key||!s.sha256Hex||o.length>0||Da(s.mime)!==n||s.size>zi)throw new G("share_blob_corrupt",`the answer is not one ${n} file`);let i=await e.downloadCiphertext(a.sealId,{fileId:s.id},r.signal?{signal:r.signal}:{});if(!i.body)throw new G("share_blob_corrupt","the answer came without a body");let c=Hn(i.body,s.key,s.sha256Hex).stream.getReader(),d=[];for(let u=await c.read();!u.done;u=await c.read())d.push(u.value);let f=new Uint8Array(d.reduce((u,p)=>u+p.length,0)),h=0;for(let u of d)f.set(u,h),h+=u.length;return f}var Gi=3e4,Fr=new Map;async function ji(e,t,n){let r=await e.getBundle(t.address,n);r!==null&&Xi(r,t.bundle)||await e.putBundle(t.bundle,n)}async function Wr(e,t,n={}){let r=await Cn(t),a=`${e.baseUrl} ${r.address}`,s=Fr.get(a);if(!n.fresh&&s&&s.until>Date.now())return s.proof;await ji(e,r,n);let o=await e.requestAddressProof(r.address,n),i={address:r.address,proof:await Li(t,o)};return Fr.set(a,{proof:i,until:Date.parse(o.expires_at)-Gi}),i}async function Zt(e,t,n,r){let a=n?{signal:n}:{};try{return await r(await Wr(e,t,a))}catch(s){if(!(s instanceof ie&&s.appCode==="intake.proof_required"))throw s;return r(await Wr(e,t,{...a,fresh:!0}))}}async function Wn(e,t,n={}){let r=n;return Zt(e,t,n.signal,a=>e.listInbox(a,r))}async function La(e,t,n,r={}){return Zt(e,t,r.signal,a=>e.dismissInboxItem(n,a,r))}async function Yi(e,t,n){let r=e.sha256_hex?t[e.sha256_hex]:void 0,a={id:e.id,size:e.size,sha256Hex:e.sha256_hex};if(r===void 0)return{...a,name:zt,mime:Gt,secret:!1,key:null,binding:null};let s;try{s=de(r)}catch(f){throw new G("share_blob_corrupt",`share blob carries a non-base64url key for ${e.sha256_hex}`,f)}if(s.length!==Hi)throw new G("share_blob_corrupt",`share blob key for ${e.sha256_hex} is ${s.length} bytes`);let{name:o,mime:i}=await Go(e,s),c=Da(i)===Wi,d=c&&e.sha256_hex?n[e.sha256_hex]??null:null;return{...a,name:o,mime:i,secret:c,key:s,binding:d}}function Da(e){return(e.split(";")[0]??e).trim().toLowerCase()}function Hn(e,t,n,r=()=>{}){let a=new Uint8Array(t),s=Nt.create(),o=0,i,c=new Promise((u,p)=>{i={resolve:u,reject:p}});c.catch(()=>{});let d=new TransformStream({transform(u,p){r(u.length),p.enqueue(u)}}),f=new TransformStream({transform(u,p){s.update(u),o+=u.length,p.enqueue(u)},flush(){a.fill(0),i.resolve({sizeBytes:o,sha256:qi(s.digest())})}}),h=e.pipeThrough(d).pipeThrough(Do(a,{expectedSha256Hex:n})).pipeThrough(f);return{stream:Zi(h,i.reject,a),done:c}}function Vi(e){return e instanceof De?new G(e.kind==="outdated"?"client_outdated":"integrity_check_failed",e.message,e):e}function qi(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function Xi(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Zi(e,t,n){let r=e.getReader();return new ReadableStream({async pull(a){try{let{value:s,done:o}=await r.read();o?a.close():a.enqueue(s)}catch(s){let o=Vi(s);n.fill(0),t(o),a.error(o)}},cancel(a){return n.fill(0),t(a),r.cancel(a)}})}function yn(e){return e instanceof Error?e.message:String(e)}var tc=_e.limits.LEASE_DEFAULT_DAYS,nc=_e.limits.LEASE_MAX_DAYS,rc=_e.limits.LEASE_POLL_SECONDS,ac=_e.limits.LEASE_STATUS_BATCH_MAX;var Na={version:1,limits:{MAX_FILES_PER_SEAL:30,FREE_TIER_BYTES:1073741824,MAX_TOTAL_SIZE_BYTES:1073741824,MAX_FILE_SIZE_BYTES:10737418240,MAX_MULTIPART_FILE_SIZE_BYTES:10737418240,MAX_BLOB_SIZE:1048576,MAX_BLOB_BASE64_SIZE:1468006,MAX_MESSAGE_LENGTH:5e3,MAX_FILE_KEYS:1e4,MAX_ACTIVE_UPLOADS_PER_SEAL:10,MAX_OPENS_PER_SEAL_FREE:10,TIER_BYTES:{free:1073741824,"5gb":5368709120,"50gb":53687091200,"500gb":536870912e3},SEAL_TIERS:{"5gb":{bytes:5368709120,amount_cents:900,duration_days:90,name:"5 GB / 3 months",description:"One-time payment for 5 GB storage and 3 months TTL"},"50gb":{bytes:53687091200,amount_cents:2900,duration_days:180,name:"50 GB / 6 months",description:"One-time payment for 50 GB storage and 6 months TTL"},"500gb":{bytes:536870912e3,amount_cents:9900,duration_days:365,name:"500 GB / 12 months",description:"One-time payment for 500 GB storage and 12 months TTL"}},PRO_REGIONS:["eu-west","eu-central","us-east","us-west","apac-southeast","apac-northeast"],ttl_options:["5m","30m","1h","1d","7d"],OTP_LENGTH:{min:6,max:10},USER_PASSWORD_MIN_LENGTH:8,INTAKE_TTL_DEFAULT_SECONDS:900,INTAKE_TTL_MAX_SECONDS:86400,INTAKE_WAIT_MAX_SECONDS:25,PAYMENT_WAIT_MAX_SECONDS:82800,ADDRESS_PROOF_TTL_SECONDS:300,INBOX_MAX_ITEMS:200,LEASE_DEFAULT_DAYS:7,LEASE_MAX_DAYS:90,LEASE_STATUS_BATCH_MAX:500,LEASE_POLL_SECONDS:600,LEASE_KEEP_DAYS:30,APPROVE_WAIT_SECONDS:120,APPROVE_BODY_SHOWN_BYTES:2048,DRIVE_OPEN_TTL_SECONDS:300,DRIVE_PRESIGN_WINDOW_DEFAULT_BYTES:67108864,DRIVE_PRESIGN_WINDOW_MIN_BYTES:8388608,DRIVE_PRESIGN_UNBOUND_TTL_SECONDS:30,DRIVE_WRITE_LEASE_SECONDS:7200,DRIVE_WRITE_BACK_SECONDS:5,VERSION_RETENTION_DAYS_DEFAULT:30,VERSION_KEEP_MIN:10,GRANT_WORKLOAD_MAX_TTL_DAYS:90,SENSOR_OPENS_PER_MINUTE_DEFAULT:120,SENSOR_BYTES_PER_MINUTE_DEFAULT:2147483648,SENSOR_SECRETS_PER_MINUTE_DEFAULT:20,SENSOR_NOVELTY_WINDOW_DAYS:30,SENSOR_HOLD_TTL_SECONDS:86400,SENSOR_BASELINE_MIN_HOURS:72,SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT:107374182400}};var j=class e extends Error{code;status;details;constructor(t,n,r,a=null,s){super(t,s),this.name="SealError",this.code=n,this.status=r,this.details=a&&el(a),Error.captureStackTrace&&Error.captureStackTrace(this,e)}toJSON(){return{name:this.name,message:this.message,code:this.code,status:this.status,details:this.details}}},Qi=["ownerToken","ownerLinkKey"];function el(e){let t={...e};for(let n of Qi){if(!(n in t))continue;let r=t[n];delete t[n],Object.defineProperty(t,n,{value:r,enumerable:!1,writable:!1,configurable:!1})}return t}var tl={url_invalid:"VALIDATION_ERROR",url_no_fragment:"VALIDATION_ERROR",targeted_fragment_invalid:"INVALID_KEY",targeted_decrypt_failed:"INVALID_KEY",seal_not_found:"RESOURCE_NOT_FOUND",seal_revoked:"RESOURCE_NOT_FOUND",share_link_not_found:"RESOURCE_NOT_FOUND",share_link_revoked:"RESOURCE_NOT_FOUND",request_expired:"RESOURCE_NOT_FOUND",seal_not_ready:"SERVICE_UNAVAILABLE",metadata_failed:"SERVICE_UNAVAILABLE",share_blob_fetch_failed:"SERVICE_UNAVAILABLE",share_blob_decrypt_failed:"DECRYPTION_ERROR",share_blob_corrupt:"DECRYPTION_ERROR",integrity_check_failed:"DECRYPTION_ERROR",client_outdated:"CLIENT_OUTDATED"};function ue(e,t,n=null){if(e instanceof j)return e;if(e instanceof G){let r=e.cause instanceof ie?e.cause.status:400;return new j(e.message,tl[e.code],r,{...n,reason:e.code},{cause:e})}if(e instanceof ie){let r=e.appCode==="client.outdated"?"CLIENT_OUTDATED":e.appCode==="intake.proof_required"?"AUTH_INVALID_KEY":e.code==="not_found"||e.code==="revoked"?"RESOURCE_NOT_FOUND":e.code==="auth"?"AUTH_INSUFFICIENT_SCOPE":e.code==="rate_limited"?"RATE_LIMITED":e.code==="transient"?"SERVICE_UNAVAILABLE":"INTERNAL_ERROR";return new j(e.detail??t,r,e.status,n,{cause:e})}return new j(e instanceof Error?e.message:t,"INTERNAL_ERROR",500,n,{cause:e})}var kc=Na.limits.ttl_options,Jt=class{api;baseUrl;shareUrlBase;credentials;constructor(t){this.baseUrl=(t?.apiUrl||"").replace(/\/$/,""),this.shareUrlBase=(t?.shareUrl||"https://seal.net").replace(/\/$/,"").replace(/\/s$/,""),this.credentials=t?.credentials,this.api=new yt({baseUrl:this.baseUrl,...this.credentials!==void 0?{credentials:this.credentials}:{}})}async create(t){if(t.nda&&!t.ownerEmail)throw new j("ownerEmail is required when nda=true","VALIDATION_ERROR",400);if(t.tier&&!t.onPaymentRequired)throw new j("onPaymentRequired is required with tier","VALIDATION_ERROR",400);let n=(S,C)=>{if(C!==void 0)try{return va(C)}catch(N){throw new j(`${S}: ${N instanceof Error?N.message:String(N)}`,"VALIDATION_ERROR",400)}},r=n("to",t.to),a=n("owner",t.owner),s=t.signal?{signal:t.signal}:{},o=async S=>{let C=await this.api.getBundle(S,s);return C&&await xa(C,S)?C:null},i=null;if(r){try{i=await o(r)}catch(S){throw ue(S,"Failed to read the recipient key")}if(!i)throw new j(`to: ${r} has no published key: ask the recipient for their address again`,"RESOURCE_NOT_FOUND",404)}let c=a?await o(a).catch(()=>null):null,d=t.keyPair?de(t.keyPair.secretKey):null,f=S=>d?Zt(this.api,d,t.signal,S):S(),h=t.mimeType||t.file instanceof File&&t.file.type||"application/octet-stream",u;if(t.file instanceof File&&t.file.name===t.filename&&t.file.type===h)u=t.file;else if(t.file instanceof Blob)u=new File([t.file],t.filename,{type:h});else if(t.file instanceof Uint8Array){let S=t.file.buffer.slice(t.file.byteOffset,t.file.byteOffset+t.file.byteLength);u=new File([S],t.filename,{type:h})}else u=new File([t.file],t.filename,{type:h});let p=sa(),g=ne(p),_=await oa(p),b=kn(),v=ne(b),D={baseUrl:this.baseUrl,auth:{kind:"none"},ttl:t.ttl,ownerTokenHash:_,ownerToken:g,...this.credentials!==void 0?{credentials:this.credentials}:{},...t.otp!==void 0?{otp:t.otp}:{},...t.nda!==void 0?{nda:t.nda}:{},...t.nda&&t.ownerEmail!==void 0?{ownerEmail:t.ownerEmail}:{},...t.singleUse!==void 0?{singleUse:t.singleUse}:{},...t.geoAllowlist!==void 0?{geo:t.geoAllowlist}:{},...t.maxOpens!==void 0?{maxOpens:t.maxOpens}:{},...t.tier!==void 0?{tier:t.tier}:{}},k=null,R=S=>({sealId:S,ownerToken:g,ownerLinkKey:v}),W=t.message?.trim()?t.message:void 0,U=!1;try{let S=t.onProgress,C={...S?{onProgress:se=>S({phase:se.phase,percent:se.percent})}:{},...t.signal?{signal:t.signal}:{},onRegistered:async(se,le)=>{k=se;let xe=new Map(le.map(Q=>[Q.sha256_hex,ne(Q.key)])),ke=ne(await ia(g,xe,b,W));if(a&&c){let Q=await Un(b,c,Ea,se);U=await f(Ne=>this.api.writeOwnerBlob(se,g,ke,{...s,to:a,fragment:Q,label:"sealnet",...Ne?{sender:Ne}:{}})).then(()=>!0,()=>!1)}try{U||await this.api.writeOwnerBlob(se,g,ke,s)}catch(Q){throw ue(Q,"Failed to store encrypted blob",R(se))}}},N,we;try{N=await _a(D,u,qt,C),we=N.expiresAt}catch(se){let le=wa(se);if(!le||!t.tier||!t.onPaymentRequired)throw se;let xe=t.signal?{signal:t.signal}:{};await t.onPaymentRequired(await this.api.createCheckout(le.sealId,g,t.tier,xe));let ke=ga(le instanceof On?le.expiresAt:void 0),Q=await ya(this.api,le.sealId,g,{deadline:ke,...xe});if(!Q)throw await this.api.revoke(le.sealId,g).catch(()=>{}),new j("The seal was not paid in time and was revoked","PAYMENT_REQUIRED",402,R(le.sealId));N=await le.resume(C),we=Q.expires_at}if(!we)throw new j(`Seal ${N.sealId}: the server sent no expiry`,"INTERNAL_ERROR",500,R(N.sealId));let ye=new Map;ye.set(N.sha256_hex,ne(N.encryptionKey));let A=kn(),L=ne(A),ae=await la(ye,A,W),F=r&&i?await Un(A,i,Nn,N.sealId):null,H;try{let se=ne(ae);H=r&&F?await f(le=>this.api.createShareLink(N.sealId,g,se,A,{...s,to:r,fragment:F,label:"sealnet",...le?{sender:le}:{}})):await this.api.createShareLink(N.sealId,g,se,A,s)}catch(se){throw ue(se,"Seal created but share link mint failed",R(N.sealId))}let be=ma(N.sealId,H,L),X=`${this.shareUrlBase}${F?be.split("#")[0]:be}`,Je=`${this.shareUrlBase}${ba(N.sealId,v)}`,Qe=Pe(N.encryptionKey);return{sealId:N.sealId,shareUrl:X,ownerUrl:Je,ownerToken:g,expiresAt:we,encryptionKey:Qe,fileId:N.fileId,delivered:F!==null,ownerCopy:U}}catch(S){if(S instanceof j)throw S;if(k){let C=S instanceof Error?S.message:String(S);throw new j(`Seal ${k} was created but the create flow was interrupted: ${C}`,"INTERNAL_ERROR",500,R(k),{cause:S})}throw S}}async revoke(t,n,r={}){try{return await this.api.revoke(t,n,r.signal?{signal:r.signal}:{})}catch(a){throw ue(a,"Failed to revoke seal")}}};async function Ba(e,t,n){let r=await import("fs/promises"),a=await import("path");await r.mkdir(t,{recursive:!0});let s=Array.from(crypto.getRandomValues(new Uint8Array(6)),d=>d.toString(16).padStart(2,"0")).join(""),o=a.join(t,`.seal-partial-${s}`),i=await r.open(o,"wx",384),c=!1;try{await e.stream.pipeTo(new WritableStream({async write(p){await i.write(p)}}));let{sizeBytes:d,sha256:f}=await e.done;await i.sync(),await i.close();let h=a.extname(n),u=n.slice(0,n.length-h.length);for(let p=0;p<1e3;p++){let g=a.join(t,p===0?n:`${u} (${p})${h}`);try{await r.link(o,g)}catch(_){let b=_.code;if(b==="EEXIST")continue;if(b!=="EPERM"&&b!=="ENOTSUP"&&b!=="EOPNOTSUPP"&&b!=="ENOSYS")throw _;if(await r.access(g).then(()=>!0,()=>!1))continue;return await r.rename(o,g),c=!0,{path:g,sizeBytes:d,sha256:f}}return c=!0,await r.unlink(o).catch(()=>{}),{path:g,sizeBytes:d,sha256:f}}throw new Error(`no free name for ${n} in ${t}`)}finally{c||(await i.close().catch(()=>{}),await r.unlink(o).catch(()=>{}))}}var nl=/^[A-Za-z0-9_-]{86}$/;function bt(e){if(nl.test(e.secretKey))return de(e.secretKey);let t=e.secretKey.length===43?"This key is of the kind before: make a new one with keygen() and give its address to whoever sends to you. What was sent to the old address does not open.":"secretKey is not a SEAL key: expected the 86 base64url characters keygen() gives";throw new j(t,"INVALID_KEY",400)}async function Ca(e,t,n,r){let a=n.signal?{signal:n.signal}:{},s=await Fn(e,t,{...n.keyPair?{seed:bt(n.keyPair)}:{},...r?{wrap:r}:{},...a});if(s.ndaRequired)throw new j("This seal asks for an NDA signature: open it in a browser","AUTH_INSUFFICIENT_SCOPE",403);let o=null;if(s.otpRequired){if(!n.password)throw new j("This seal is password-protected: pass `password`","AUTH_INVALID_KEY",401);o=(await e.verifyOtp(s.sealId,{code:n.password},a)).sessionCookie}let i=s.files.filter(h=>h.key!==null&&h.sha256Hex!==null),c=i.reduce((h,u)=>h+u.size,0),d=0;return{seal:s,covered:i,read:async h=>{let u=await e.downloadCiphertext(s.sealId,{fileId:h.id,...o?{sessionCookie:o}:{}},a);if(!u.body)throw new j(`Download of ${h.name} returned no body`,"INTERNAL_ERROR",u.status);return Hn(u.body,h.key,h.sha256Hex,p=>{d+=p,n.onProgress?.(d,c)})}}}async function $n(e,t,n={},r=null){try{let{seal:a,covered:s,read:o}=await Ca(e,t,n,r);return{sealId:a.sealId,expiresAt:a.expiresAt,files:s.map(i=>({name:i.name,mime:i.mime,size:i.size,secret:i.secret,read:()=>o(i).catch(c=>Promise.reject(ue(c,"Download failed")))}))}}catch(a){throw ue(a,"Failed to open the link")}}async function Kn(e,t,n,r={},a=null){try{let{seal:s,covered:o,read:i}=await Ca(e,t,r,a),c=[];for(let d of o){let f=await Ba(await i(d),n,ha(d.name));c.push({name:d.name,mime:d.mime,secret:d.secret,...f})}return{sealId:s.sealId,expiresAt:s.expiresAt,files:c}}catch(s){throw ue(s,"Failed to open the link")}}async function Ma(e,t,n){try{let r=await e.createIntake({recipientBundle:n.recipientBundle,label:n.label??"sealnet",what:n.what,...n.whereUrl?{whereUrl:n.whereUrl}:{},...n.kind?{kind:n.kind}:{},...n.ttl!==void 0?{ttlSeconds:n.ttl}:{},...n.to!==void 0?{to:n.to}:{}},n.signal?{signal:n.signal}:{});return{intakeId:r.id,url:`${t}/i/${r.id}`,words:(await Mn(de(n.recipientBundle))).words,expiresAt:r.expires_at}}catch(r){throw ue(r,"Failed to create the request")}}async function zn(e,t,n){try{return await Ra(e,t,n?{signal:n}:{})}catch(r){throw ue(r,"Failed to wait for the request")}}async function Ua(e,t,n){let r;try{r=await e.createIntake({recipientBundle:n.keyPair.bundle,label:(n.name??"sealnet").slice(0,80),what:Ia,kind:"pair"},n.signal?{signal:n.signal}:{})}catch(s){throw ue(s,"Failed to create the pairing request")}let a=async()=>{let{sharePath:s,wrap:o}=await zn(e,r.id,n.signal);try{let i=await Pa(e,`${t}${s}`,Ta,{seed:bt(n.keyPair),wrap:o,...n.signal?{signal:n.signal}:{}}),{bundle:c,name:d}=Oa(i);return{address:(await Mn(c)).address,name:d}}catch(i){throw ue(i,"The answer of the inbox did not open")}};return{url:`${t}/i/${r.id}`,words:n.keyPair.words,expiresAt:r.expires_at,wait:a}}async function Fa(){let e=Aa(),{address:t,bundle:n,words:r}=await Cn(e);return{secretKey:ne(e),address:t,bundle:ne(n),words:r}}async function Wa(e,t){let n=bt(t.keyPair),r=Date.now()+(t.wait??0)*1e3;try{for(;;){let a=Math.ceil((r-Date.now())/1e3),s=await Wn(e,n,{...a>0?{waitSeconds:a}:{},...t.seen!==void 0?{seen:t.seen}:{},...t.signal?{signal:t.signal}:{}});if((t.seen!==void 0?s.version!==t.seen:s.items.length>0)||Date.now()>=r)return{version:s.version,items:s.items.map(i=>({id:i.id,fromWords:i.sender===null?null:ka(i.sender),label:i.label,receivedAt:i.at,expiresAt:i.expires_at}))}}}catch(a){throw ue(a,"Failed to read the inbox")}}async function Ha(e,t,n,r){let a;try{a=(await Wn(e,bt(r.keyPair),r.signal?{signal:r.signal}:{})).items}catch(o){throw ue(o,"Failed to read the inbox")}let s=a.find(o=>o.id===n.id);if(!s)throw new j(`${n.id} is not in the inbox: it was revoked, expired or removed`,"RESOURCE_NOT_FOUND",404);return{url:`${t}${s.path}`,wrap:s.fragment}}async function $a(e,t,n){try{await La(e,bt(n.keyPair),t.id,n.signal?{signal:n.signal}:{})}catch(r){throw ue(r,"Failed to remove the item")}}var[rl="",Ka=""]="sdk-web/3.0.0".split("/");typeof globalThis.process?.versions?.node!="string"&&lr(Se);var Gn=class{seals;api;site;constructor(t={}){ta(rl,Ka);let n=t.apiUrl??"https://api.seal.net";this.site=(t.shareUrl??"https://seal.net").replace(/\/$/,"").replace(/\/s$/,""),this.seals=new Jt({apiUrl:n,shareUrl:this.site,credentials:"omit"}),this.api=new yt({baseUrl:n,credentials:"omit"})}async send(t){return this.seals.create(t)}async open(t,n={}){let{to:r,...a}=n,s;if(typeof t=="string")s={url:t,wrap:null};else if(a.keyPair)s=await Ha(this.api,this.site,t,{keyPair:a.keyPair,...a.signal?{signal:a.signal}:{}});else throw new j("An inbox item opens with the seed it was sent to: pass `keyPair`","VALIDATION_ERROR",400);return r!==void 0?Kn(this.api,s.url,r,a,s.wrap):$n(this.api,s.url,a,s.wrap)}async inbox(t){return Wa(this.api,t)}async dismiss(t,n){return $a(this.api,t,n)}async request(t){return Ma(this.api,this.site,t)}async waitFor(t,n){let{sharePath:r,wrap:a}=await zn(this.api,t,n.signal),{to:s,...o}=n,i=`${this.site}${r}`;return s!==void 0?Kn(this.api,i,s,o,a):$n(this.api,i,o,a)}async pair(t){return Ua(this.api,this.site,t)}async keygen(){return Fa()}async revoke(t,n,r={}){return this.seals.revoke(t,n,r)}},al=Ka;return os(sl);})();
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
@noble/hashes/esm/utils.js:
|