oneie 5.10.3 → 5.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +1 -1
- package/dist/src/age-bkszskq3.js +1 -0
- package/dist/src/client-hppvrwms.js +1 -0
- package/dist/src/evm-tx-fkrv10z8.js +1 -0
- package/dist/src/hl-run-jrehxvy0.js +1 -0
- package/dist/src/index-c721kdkc.js +2170 -0
- package/dist/src/{index-y4xe5pm7.js → index-mcxks4zv.js} +3 -3
- package/dist/src/index-mztja10b.js +12 -0
- package/dist/src/index.js +600 -600
- package/dist/src/message-key-fjjcvfeh.js +1 -0
- package/dist/src/message-lock-tk2daazy.js +5 -0
- package/dist/src/sweep-order-eys4wynj.js +1 -0
- package/dist/src/{sweep-runner-mk3ek1mk.js → sweep-runner-h1ynn3g5.js} +1 -1
- package/dist/src/wallet-h7y2ycjk.js +1 -0
- package/package.json +1 -1
- package/dist/src/age-74tmaw4t.js +0 -1
- package/dist/src/client-3daam667.js +0 -1
- package/dist/src/evm-tx-33z1n2zx.js +0 -1
- package/dist/src/hl-run-bx11y304.js +0 -1
- package/dist/src/index-exa86q8e.js +0 -2170
- package/dist/src/index-stdwesmk.js +0 -12
- package/dist/src/message-key-sy2jmj5v.js +0 -1
- package/dist/src/message-lock-9p4jbjtc.js +0 -5
- package/dist/src/sweep-order-yf30eb7c.js +0 -1
- package/dist/src/wallet-e3473qat.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}function
|
|
1
|
+
var Rr=900000,Kn=120000;function Tn(n){return["ONE sweep order",`workspace: ${n.workspace}`,`agent: ${n.actor}`,`chain: ${n.chain}`,`destination: ${n.destination}`,`amount: ${n.amount.toString()}`,`nonce: ${n.nonce}`,`expires: ${n.expiresAt}`].join(`
|
|
2
|
+
`)}function Hn(n){return["ONE agent handover",`agent: ${n.agent}`,`from: ${n.from}`,`to: ${n.to}`,`chain: ${n.chain}`,`nonce: ${n.nonce}`,`expires: ${n.expiresAt}`].join(`
|
|
3
3
|
`)}
|
|
4
|
-
export{
|
|
4
|
+
export{Rr,Kn,Tn,Hn};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{x,d,We,p,j,ye,Z,On,Ge,T}from"./index-c721kdkc.js";/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function zt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function yt(t){if(typeof t!=="boolean")throw TypeError(`boolean expected, not ${t}`)}function ct(t){if(typeof t!=="number")throw TypeError("number expected, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw RangeError("positive integer expected, got "+t)}function P(t,e,o=""){let n=zt(t),r=t?.length,i=e!==void 0;if(!n||i&&r!==e){let s=o&&`"${o}" `,a=i?` of length ${e}`:"",f=n?`length=${r}`:`type=${typeof t}`,h=s+"expected Uint8Array"+a+", got "+f;if(!n)throw TypeError(h);throw RangeError(h)}return t}function gt(t,e=!0){if(t.destroyed)throw Error("Hash instance has been destroyed");if(e&&t.finished)throw Error("Hash#digest() has already been called")}function mt(t,e,o=!1){P(t,void 0,"output");let n=e.outputLen;if(t.length<n)throw RangeError("digestInto() expects output buffer of length at least "+n);if(o&&!at(t))throw Error("invalid output, must be aligned")}function V(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function D(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function jt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}var et=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),$t=(t)=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var Wt=(t)=>{for(let e=0;e<t.length;e++)t[e]=$t(t[e]);return t},q=et?(t)=>t:Wt;function Lt(t,e){if(e==null||typeof e!=="object")throw Error("options must be defined");return Object.assign(t,e)}function Ut(t,e){if(t.length!==e.length)return!1;let o=0;for(let n=0;n<t.length;n++)o|=t[n]^e[n];return o===0}function Et(t,e,o){let n=e,r=o||(()=>[]),i=(a,f)=>n(f,...r(a)).update(a).digest(),s=n(new Uint8Array(t),...r(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...f)=>n(a,...f),i}var _t=(t,e)=>{function o(n,...r){if(P(n,void 0,"key"),t.nonceLength!==void 0){let l=r[0];P(l,t.varSizeNonce?void 0:t.nonceLength,"nonce")}let i=t.tagLength;if(i&&r[1]!==void 0)P(r[1],void 0,"AAD");let s=e(n,...r),a=(l,y)=>{if(y!==void 0){if(l!==2)throw Error("cipher output not supported");P(y,void 0,"output")}},f=!1;return{encrypt(l,y){if(f)throw Error("cannot encrypt() twice with same key + nonce");return f=!0,P(l),a(s.encrypt.length,y),s.encrypt(l,y)},decrypt(l,y){if(P(l),i&&l.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,y),s.decrypt(l,y)}}}return Object.assign(o,t),o};function lt(t,e,o=!0){if(e===void 0)return new Uint8Array(t);if(P(e,void 0,"output"),e.length!==t)throw Error('"output" expected Uint8Array of length '+t+", got: "+e.length);if(o&&!at(e))throw Error("invalid output, must be aligned");return e}function Bt(t,e,o){ct(t),ct(e),yt(o);let n=new Uint8Array(16),r=jt(n);return r.setBigUint64(0,BigInt(e),o),r.setBigUint64(8,BigInt(t),o),n}function at(t){return t.byteOffset%4===0}function ht(t){return Uint8Array.from(P(t))}var It=(t)=>Uint8Array.from(t.split(""),(e)=>e.charCodeAt(0)),Xt=(()=>q(V(It("expand 16-byte k"))))(),Ft=(()=>q(V(It("expand 32-byte k"))))();function L(t,e){return t<<e|t>>>32-e}var ut=64,Gt=16,xt=(()=>4294967295)(),Tt=Uint32Array.of();function Dt(t,e,o,n,r,i,s,a){let f=r.length,h=new Uint8Array(ut),l=V(h),y=et&&at(r)&&at(i),b=y?V(r):Tt,g=y?V(i):Tt;if(!et){for(let w=0;w<f;s++){if(t(e,o,n,l,s,a),q(l),s>=xt)throw Error("arx: counter overflow");let m=Math.min(ut,f-w);for(let E=0,U;E<m;E++)U=w+E,i[U]=r[U]^h[E];w+=m}return}for(let w=0;w<f;s++){if(t(e,o,n,l,s,a),s>=xt)throw Error("arx: counter overflow");let m=Math.min(ut,f-w);if(y&&m===ut){let E=w/4;if(w%4!==0)throw Error("arx: invalid block position");for(let U=0,z;U<Gt;U++)z=E+U,g[z]=b[z]^l[U];w+=ut;continue}for(let E=0,U;E<m;E++)U=w+E,i[U]=r[U]^h[E];w+=m}}function kt(t,e){let{allowShortKeys:o,extendNonceFn:n,counterLength:r,counterRight:i,rounds:s}=Lt({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!=="function")throw Error("core must be a function");return ct(r),ct(s),yt(i),yt(o),(a,f,h,l,y=0)=>{P(a,void 0,"key"),P(f,void 0,"nonce"),P(h,void 0,"data");let b=h.length;if(l=lt(b,l,!1),ct(y),y<0||y>=xt)throw Error("arx: counter overflow");let g=[],w=a.length,m,E;if(w===32)g.push(m=ht(a)),E=Ft;else if(w===16&&o)m=new Uint8Array(32),m.set(a),m.set(a,16),E=Xt,g.push(m);else throw P(a,32,"arx key"),Error("invalid key size");if(!et||!at(f))g.push(f=ht(f));let U=V(m);if(n){if(f.length!==24)throw Error("arx: extended nonce must be 24 bytes");let G=f.subarray(0,16);if(et)n(E,U,V(G),U);else{let J=q(Uint32Array.from(E));n(J,U,V(G),U),D(J),q(U)}f=f.subarray(16)}else if(!et)q(U);let z=16-r;if(z!==f.length)throw Error(`arx: nonce must be ${z} or 16 bytes`);if(z!==12){let G=new Uint8Array(12);G.set(f,i?0:12-f.length),f=G,g.push(f)}let tt=q(V(f));try{return Dt(t,E,U,tt,h,l,y,s),l}finally{D(...g)}}}function W(t,e){return t[e++]&255|(t[e++]&255)<<8}class At{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(t){t=ht(P(t,32,"key"));let e=W(t,0),o=W(t,2),n=W(t,4),r=W(t,6),i=W(t,8),s=W(t,10),a=W(t,12),f=W(t,14);this.r[0]=e&8191,this.r[1]=(e>>>13|o<<3)&8191,this.r[2]=(o>>>10|n<<6)&7939,this.r[3]=(n>>>7|r<<9)&8191,this.r[4]=(r>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let h=0;h<8;h++)this.pad[h]=W(t,16+2*h)}process(t,e,o=!1){let n=o?0:2048,{h:r,r:i}=this,s=i[0],a=i[1],f=i[2],h=i[3],l=i[4],y=i[5],b=i[6],g=i[7],w=i[8],m=i[9],E=W(t,e+0),U=W(t,e+2),z=W(t,e+4),tt=W(t,e+6),G=W(t,e+8),J=W(t,e+10),X=W(t,e+12),F=W(t,e+14),_=r[0]+(E&8191),B=r[1]+((E>>>13|U<<3)&8191),I=r[2]+((U>>>10|z<<6)&8191),k=r[3]+((z>>>7|tt<<9)&8191),A=r[4]+((tt>>>4|G<<12)&8191),R=r[5]+(G>>>1&8191),C=r[6]+((G>>>14|J<<2)&8191),O=r[7]+((J>>>11|X<<5)&8191),S=r[8]+((X>>>8|F<<8)&8191),N=r[9]+(F>>>5|n),u=0,v=u+_*s+B*(5*m)+I*(5*w)+k*(5*g)+A*(5*b);u=v>>>13,v&=8191,v+=R*(5*y)+C*(5*l)+O*(5*h)+S*(5*f)+N*(5*a),u+=v>>>13,v&=8191;let K=u+_*a+B*s+I*(5*m)+k*(5*w)+A*(5*g);u=K>>>13,K&=8191,K+=R*(5*b)+C*(5*y)+O*(5*l)+S*(5*h)+N*(5*f),u+=K>>>13,K&=8191;let H=u+_*f+B*a+I*s+k*(5*m)+A*(5*w);u=H>>>13,H&=8191,H+=R*(5*g)+C*(5*b)+O*(5*y)+S*(5*l)+N*(5*h),u+=H>>>13,H&=8191;let M=u+_*h+B*f+I*a+k*s+A*(5*m);u=M>>>13,M&=8191,M+=R*(5*w)+C*(5*g)+O*(5*b)+S*(5*y)+N*(5*l),u+=M>>>13,M&=8191;let Y=u+_*l+B*h+I*f+k*a+A*s;u=Y>>>13,Y&=8191,Y+=R*(5*m)+C*(5*w)+O*(5*g)+S*(5*b)+N*(5*y),u+=Y>>>13,Y&=8191;let nt=u+_*y+B*l+I*h+k*f+A*a;u=nt>>>13,nt&=8191,nt+=R*s+C*(5*m)+O*(5*w)+S*(5*g)+N*(5*b),u+=nt>>>13,nt&=8191;let rt=u+_*b+B*y+I*l+k*h+A*f;u=rt>>>13,rt&=8191,rt+=R*a+C*s+O*(5*m)+S*(5*w)+N*(5*g),u+=rt>>>13,rt&=8191;let st=u+_*g+B*b+I*y+k*l+A*h;u=st>>>13,st&=8191,st+=R*f+C*a+O*s+S*(5*m)+N*(5*w),u+=st>>>13,st&=8191;let it=u+_*w+B*g+I*b+k*y+A*l;u=it>>>13,it&=8191,it+=R*h+C*f+O*a+S*s+N*(5*m),u+=it>>>13,it&=8191;let ft=u+_*m+B*w+I*g+k*b+A*y;u=ft>>>13,ft&=8191,ft+=R*l+C*h+O*f+S*a+N*s,u+=ft>>>13,ft&=8191,u=(u<<2)+u|0,u=u+v|0,v=u&8191,u=u>>>13,K+=u,r[0]=v,r[1]=K,r[2]=H,r[3]=M,r[4]=Y,r[5]=nt,r[6]=rt,r[7]=st,r[8]=it,r[9]=ft}finalize(){let{h:t,pad:e}=this,o=new Uint16Array(10),n=t[1]>>>13;t[1]&=8191;for(let s=2;s<10;s++)t[s]+=n,n=t[s]>>>13,t[s]&=8191;t[0]+=n*5,n=t[0]>>>13,t[0]&=8191,t[1]+=n,n=t[1]>>>13,t[1]&=8191,t[2]+=n,o[0]=t[0]+5,n=o[0]>>>13,o[0]&=8191;for(let s=1;s<10;s++)o[s]=t[s]+n,n=o[s]>>>13,o[s]&=8191;o[9]-=8192;let r=(n^1)-1;for(let s=0;s<10;s++)o[s]&=r;r=~r;for(let s=0;s<10;s++)t[s]=t[s]&r|o[s];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let i=t[0]+e[0];t[0]=i&65535;for(let s=1;s<8;s++)i=(t[s]+e[s]|0)+(i>>>16)|0,t[s]=i&65535;D(o)}update(t){gt(this),P(t),t=ht(t);let{buffer:e,blockLen:o}=this,n=t.length;for(let r=0;r<n;){let i=Math.min(o-this.pos,n-r);if(i===o){for(;o<=n-r;r+=o)this.process(t,r);continue}if(e.set(t.subarray(r,r+i),this.pos),this.pos+=i,r+=i,this.pos===o)this.process(e,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,D(this.h,this.r,this.buffer,this.pad)}digestInto(t){gt(this),mt(t,this),this.finished=!0;let{buffer:e,h:o}=this,{pos:n}=this;if(n){e[n++]=1;for(;n<16;n++)e[n]=0;this.process(e,0,!0)}this.finalize();let r=0;for(let i=0;i<8;i++)t[r++]=o[i]>>>0,t[r++]=o[i]>>>8}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let o=t.slice(0,e);return this.destroy(),o}}var Rt=Et(32,(t)=>new At(t));function Vt(t,e,o,n,r,i=20){let s=t[0],a=t[1],f=t[2],h=t[3],l=e[0],y=e[1],b=e[2],g=e[3],w=e[4],m=e[5],E=e[6],U=e[7],z=r,tt=o[0],G=o[1],J=o[2],X=s,F=a,_=f,B=h,I=l,k=y,A=b,R=g,C=w,O=m,S=E,N=U,u=z,v=tt,K=G,H=J;for(let Y=0;Y<i;Y+=2)X=X+I|0,u=L(u^X,16),C=C+u|0,I=L(I^C,12),X=X+I|0,u=L(u^X,8),C=C+u|0,I=L(I^C,7),F=F+k|0,v=L(v^F,16),O=O+v|0,k=L(k^O,12),F=F+k|0,v=L(v^F,8),O=O+v|0,k=L(k^O,7),_=_+A|0,K=L(K^_,16),S=S+K|0,A=L(A^S,12),_=_+A|0,K=L(K^_,8),S=S+K|0,A=L(A^S,7),B=B+R|0,H=L(H^B,16),N=N+H|0,R=L(R^N,12),B=B+R|0,H=L(H^B,8),N=N+H|0,R=L(R^N,7),X=X+k|0,H=L(H^X,16),S=S+H|0,k=L(k^S,12),X=X+k|0,H=L(H^X,8),S=S+H|0,k=L(k^S,7),F=F+A|0,u=L(u^F,16),N=N+u|0,A=L(A^N,12),F=F+A|0,u=L(u^F,8),N=N+u|0,A=L(A^N,7),_=_+R|0,v=L(v^_,16),C=C+v|0,R=L(R^C,12),_=_+R|0,v=L(v^_,8),C=C+v|0,R=L(R^C,7),B=B+I|0,K=L(K^B,16),O=O+K|0,I=L(I^O,12),B=B+I|0,K=L(K^B,8),O=O+K|0,I=L(I^O,7);let M=0;n[M++]=s+X|0,n[M++]=a+F|0,n[M++]=f+_|0,n[M++]=h+B|0,n[M++]=l+I|0,n[M++]=y+k|0,n[M++]=b+A|0,n[M++]=g+R|0,n[M++]=w+C|0,n[M++]=m+O|0,n[M++]=E+S|0,n[M++]=U+N|0,n[M++]=z+u|0,n[M++]=tt+v|0,n[M++]=G+K|0,n[M++]=J+H|0}var Yt=kt(Vt,{counterRight:!1,counterLength:4,allowShortKeys:!1});var qt=new Uint8Array(16),Ct=(t,e)=>{t.update(e);let o=e.length%16;if(o)t.update(qt.subarray(o))},Zt=new Uint8Array(32);function Ot(t,e,o,n,r){if(r!==void 0)P(r,void 0,"AAD");let i=t(e,o,Zt),s=Bt(n.length,r?r.length:0,!0),a=Rt.create(i);if(r)Ct(a,r);Ct(a,n),a.update(s);let f=a.digest();return D(i,s),f}var Qt=(t)=>(e,o,n)=>({encrypt(i,s){let a=i.length;s=lt(a+16,s,!1),s.set(i);let f=s.subarray(0,-16);t(e,o,f,f,1);let h=Ot(t,e,o,f,n);return s.set(h,a),D(h),s},decrypt(i,s){s=lt(i.length-16,s,!1);let a=i.subarray(0,-16),f=i.subarray(-16),h=Ot(t,e,o,a,n);if(!Ut(f,h))throw D(h),Error("invalid tag");return s.set(i.subarray(0,-16)),t(e,o,s,s,1),D(h),s}}),pt=_t({blockSize:64,nonceLength:12,tagLength:16},Qt(Yt));var dt=Uint8Array.of(0),Jt=Uint8Array.of();function te(t,e,o,n=32,r){We(t),x(n,"length"),d(e,void 0,"prk");let i=t.outputLen;if(e.length<i)throw Error('"prk" must be at least HashLen octets');if(n>255*i)throw Error("Length must be <= 255*HashLen");let s=Math.ceil(n/i);if(o===void 0)o=Jt;else d(o,void 0,"info");if(!s){if(r)p(e);return new Uint8Array}let a=r&&s===1?e:new Uint8Array(s*i),{iHash:f,oHash:h}=Z.create(t,e),l=r?e:new Uint8Array(i),y=s>1?r?.iHash||t.create():void 0;for(let g=0;g<s-1;g++){dt[0]=g+1;let w=f._cloneInto(y);if(g)w.update(l);w.update(o).update(dt).digestInto(l),h._cloneInto(y).update(l).digestInto(l),a.set(l,i*g)}if(dt[0]=s,s>1)f.update(l);if(f.update(o).update(dt).digestInto(l),h.update(l).digestInto(l),a.set(l,i*(s-1)),f.destroy(),h.destroy(),y?.destroy(),l!==a)p(l);if(p(dt),n===a.length)return a;let b=a.slice(0,n);return p(a),b}var qe=(t,e,o,n,r)=>{if(We(t),o===void 0)o=new Uint8Array(t.outputLen);let i=Z.create(t,o).update(e);return te(t,i.digest(),n,r,i)};var Mn="age-encryption.org/v1",ot="-----BEGIN AGE ENCRYPTED FILE-----",En="-----END AGE ENCRYPTED FILE-----",St="age-encryption.org/v1/X25519",Nt="age",Mt="age-secret-key-",wt=65536,hr=128,bt=16,ee=new TextEncoder,vt=new TextDecoder,Q=(t)=>ee.encode(t);class c extends Error{code;constructor(t,e){super(e);this.code=t,this.name="AgeError"}}function $n(t){if(t.length!==32)throw new c("bad_key","an X25519 public key is 32 bytes");return T.encode(Nt,T.toWords(t),!1)}function gr(t){let e=t.trim(),o;try{o=T.decode(e,!1)}catch{throw new c("bad_key","not an age recipient (age1…)")}if(o.prefix!==Nt)throw new c("bad_key",`not an age recipient: prefix ${o.prefix}`);let n=T.fromWords(o.words);if(n.length!==32)throw new c("bad_key","an age recipient carries 32 bytes");return n}function Fn(t){if(t.length!==32)throw new c("bad_key","an X25519 secret is 32 bytes");return T.encode(Mt,T.toWords(t),!1).toUpperCase()}function Sr(t){let e=t.trim().toLowerCase(),o;try{o=T.decode(e,!1)}catch{throw new c("bad_key","not an age identity (AGE-SECRET-KEY-1…)")}if(o.prefix!==Mt)throw new c("bad_key",`not an age identity: prefix ${o.prefix}`);let n=T.fromWords(o.words);if(n.length!==32)throw new c("bad_key","an age identity carries 32 bytes");return n}function Ar(t){return $n(ye.getPublicKey(t))}function ne(t,e){let o=ye.utils.randomSecretKey(),n=null,r=null;try{let i=ye.getPublicKey(o);try{n=ye.getSharedSecret(o,e)}catch{throw new c("bad_key","low-order recipient point")}if(n.every((f)=>f===0))throw new c("bad_key","low-order recipient point");let s=new Uint8Array(64);s.set(i,0),s.set(e,32),r=qe(j,n,s,Q(St),32);let a=pt(r,new Uint8Array(12)).encrypt(t);return{share:i,body:a}}finally{o.fill(0),n?.fill(0),r?.fill(0)}}function Kt(t,e){let o=qe(j,t,new Uint8Array(0),Q("header"),32),n=Z(j,o,e);return o.fill(0),n}function Ht(t,e){let o=new Uint8Array(12),n=t;for(let r=10;r>=0&&n>0;r--)o[r]=n%256,n=Math.floor(n/256);return o[11]=e?1:0,o}function Pt(t){let e=new Uint8Array(t.reduce((n,r)=>n+r.length,0)),o=0;for(let n of t)e.set(n,o),o+=n.length;return e}function br(t,e){if(e.length===0)throw new c("bad_key","seal it for at least one recipient");let o=e.map(gr),n=crypto.getRandomValues(new Uint8Array(16));try{let r=[Mn];for(let b of o){let{share:g,body:w}=ne(n,b);r.push(`-> X25519 ${Ge.encode(g)}`,Ge.encode(w))}r.push("---");let i=Q(r.join(`
|
|
2
|
+
`)),s=Kt(n,i),a=Q(`${r.join(`
|
|
3
|
+
`)} ${Ge.encode(s)}
|
|
4
|
+
`),f=crypto.getRandomValues(new Uint8Array(16)),h=qe(j,n,f,Q("payload"),32),l=[a,f],y=Math.max(1,Math.ceil(t.length/wt));for(let b=0;b<y;b++){let g=t.subarray(b*wt,Math.min(t.length,(b+1)*wt));l.push(pt(h,Ht(b,b===y-1)).encrypt(g))}return h.fill(0),Pt(l)}finally{n.fill(0)}}var oe=1048576,re=/^[\x21-\x7e]+$/;function yr(t){let e=Math.min(t.length,oe),o=0,n=()=>{let f=o;while(f<e&&t[f]!==10){if(t[f]<32||t[f]>126)throw new c("malformed","header byte outside printable ASCII");f++}if(f>=e)throw new c("malformed","header runs off the end of the file");let h=vt.decode(t.subarray(o,f));return o=f+1,h};if(n()!==Mn)throw new c("malformed","not an age file: missing version line");let r=[],i=null,s=0;while(i===null){s=o;let f=n();if(f.startsWith("---")){i=f;break}if(!f.startsWith("-> "))throw new c("malformed","unexpected header line");let h=f.slice(3).split(" ");if(!h.every((w)=>re.test(w)))throw new c("malformed","stanza arguments must be non-empty visible ASCII");let[l,...y]=h,b=[];for(;;){let w=n();if(b.push(w),w.length<64)break;if(w.length>64)throw new c("malformed","stanza body line over 64 columns")}let g;try{g=Ge.decode(b.join(""))}catch{throw new c("malformed","stanza body is not base64")}if(r.push({type:l,args:y,body:g}),r.length>hr)throw new c("unsupported",`sealed for more than ${hr} readers`)}if(!i.startsWith("--- "))throw new c("malformed","header footer must be `--- ` and a MAC");let a;try{a=Ge.decode(i.slice(4))}catch{throw new c("malformed","header MAC is not base64")}if(a.length!==32)throw new c("malformed","header MAC is not 32 bytes");if(r.some((f)=>f.type==="scrypt")&&r.length!==1)throw new c("malformed","scrypt must be the only recipient");return{stanzas:r,mac:a,upToDashes:t.subarray(0,s+3),payload:t.subarray(o)}}function se(t,e){if(t.length!==e.length)return!1;let o=0;for(let n=0;n<t.length;n++)o|=t[n]^e[n];return o===0}function wr(t,e){if(e.length===0)throw new c("no_identity","no identity to open it with");let{stanzas:o,mac:n,upToDashes:r,payload:i}=yr(t),s=o.filter((h)=>h.type==="X25519");if(s.length===0){let h=[...new Set(o.map((l)=>l.type))].join(", ")||"none";throw new c("unsupported",`no X25519 recipient in this file (stanzas: ${h})`)}let a=null,f=e.map((h)=>ye.getPublicKey(h));for(let h of s){if(h.args.length!==1||h.body.length!==32)throw new c("malformed","bad X25519 stanza");let l;try{l=Ge.decode(h.args[0])}catch{throw new c("malformed","X25519 share is not base64")}if(l.length!==32)throw new c("malformed","X25519 share is not 32 bytes");for(let y=0;y<e.length;y++){let b;try{b=ye.getSharedSecret(e[y],l)}catch{throw new c("malformed","X25519 share is a low-order point")}if(b.every((m)=>m===0))throw new c("malformed","X25519 share is a low-order point");let g=new Uint8Array(64);g.set(l,0),g.set(f[y],32);let w=qe(j,b,g,Q(St),32);b.fill(0);try{a=pt(w,new Uint8Array(12)).decrypt(h.body)}catch{a=null}finally{w.fill(0)}if(a)break}if(a)break}if(!a)throw new c("no_identity","none of your keys opens this");try{if(!se(Kt(a,r),n))throw new c("tampered","header MAC does not match");if(i.length<16)throw new c("malformed","payload shorter than its nonce");let h=i.subarray(0,16),l=qe(j,a,h,Q("payload"),32);try{let y=i.subarray(16),b=wt+bt,g=[],w=0,m=0;for(;;){let E=y.length-m;if(E<bt)throw new c("malformed","payload chunk shorter than its tag");let U=E<=b,z=U?E:b;if(U&&z===bt&&w>0)throw new c("malformed","empty final chunk");try{g.push(pt(l,Ht(w,U)).decrypt(y.subarray(m,m+z)))}catch{throw new c("tampered",`payload chunk ${w} does not authenticate`)}if(m+=z,w++,U)break}return Pt(g)}finally{l.fill(0)}}finally{a.fill(0)}}function kr(t){let e=On.encode(t),o=[];for(let n=0;n<e.length;n+=64)o.push(e.slice(n,n+64));return[ot,...o,En].join(`
|
|
5
|
+
`)+`
|
|
6
|
+
`}function vr(t){let o=t.replace(/^[ \t\r\n]+|[ \t\r\n]+$/g,"").replace(/\r\n/g,`
|
|
7
|
+
`);if(o.includes("\r"))throw new c("malformed","armor: a bare carriage return");let n=o.split(`
|
|
8
|
+
`);if(n.length<3||n[0]!==ot||n[n.length-1]!==En)throw new c("malformed","no armored age block found");let r=n.slice(1,-1);for(let i=0;i<r.length;i++){let s=i===r.length-1;if(r[i].length>64||!s&&r[i].length!==64||r[i].length===0)throw new c("malformed","armor: lines must be 64 columns, the last 1-64");if(!/^[A-Za-z0-9+/=]+$/.test(r[i]))throw new c("malformed","armored body is not base64")}try{return On.decode(r.join(""))}catch{throw new c("malformed","armored body is not base64")}}function xr(t){let e=t.replace(/\r\n?/g,`
|
|
9
|
+
`),o=e.indexOf(ot),n=e.indexOf(En,o<0?0:o);if(o<0||n<0)throw new c("malformed","no armored age block found");let r=e.slice(o+ot.length,n).split(`
|
|
10
|
+
`).map((i)=>i.trim()).filter((i)=>i.length>0);if(r.length===0)throw new c("malformed","armored block is empty");return[ot,...r,En].join(`
|
|
11
|
+
`)}function Er(t){let e=t.trimStart();return e.startsWith(ot)||e.startsWith(Mn)}function $r(t,e){return kr(br(Q(t),e))}function _r(t,e){let o=t.includes(ot)?vr(xr(t)):Q(t);return wr(o,e)}function Tr(t,e){return vt.decode(_r(t,e))}
|
|
12
|
+
export{qe,Mn,ot,En,hr,c,$n,gr,Fn,Sr,Ar,br,yr,wr,kr,vr,xr,Er,$r,_r,Tr};
|