@apeleghq/cms-classes
Version:
A collection of utility classes to encode ASN.1 data following DER rules
2 lines (1 loc) • 10.9 kB
JavaScript
import{Asn1Sequence as he}from"@apeleghq/asn1-der";var P=class extends he{constructor(t,e){super(e?[t,e]:[t])}},s=P;import{Asn1Sequence as Oe}from"@apeleghq/asn1-der";var N=class extends Oe{constructor(t,e){super([t,e])}},De=N;import{Asn1Set as Te}from"@apeleghq/asn1-der";var K=class extends Te{},ge=K;import{Asn1Set as xe}from"@apeleghq/asn1-der";var G=class extends xe{constructor(t){super(t)}},f=G;import{Asn1ContextSpecific as B,Asn1Sequence as ye}from"@apeleghq/asn1-der";import{Asn1Integer as we}from"@apeleghq/asn1-der";var H,L,v,b,W,V,j=class extends we{static get v0(){return H||(H=new this(0)),H}static get v1(){return L||(L=new this(1)),L}static get v2(){return v||(v=new this(2)),v}static get v3(){return b||(b=new this(3)),b}static get v4(){return W||(W=new this(4)),W}static get v5(){return V||(V=new this(5)),V}get version(){return this.version_}constructor(t){super(t),this.version_=t}},i=j;var U=class extends ye{constructor(t,e,o,n,_,d){let A={},M=i.v0;super([M,n?new B(0,n,!1):A,t,e,_?new B(1,_,!1):A,o,d?new B(2,d,!1):A].filter(Ee=>Ee!==A))}},Re=U;import{Asn1Sequence as Me}from"@apeleghq/asn1-der";var q=class extends Me{constructor(t,e,o){super([t,e,o])}},kt=q;import{Asn1Set as Pe}from"@apeleghq/asn1-der";var F=class extends Pe{constructor(t){super(t)}},Ne=F;import{Asn1ContextSpecific as u,Asn1Integer as z,Asn1Object as a,Asn1OctetString as C,Asn1Sequence as p}from"@apeleghq/asn1-der";var Xt="1.2.840.10045.4.3.2",Qt="1.2.840.10045.4.3.3",Jt="1.2.840.10045.4.3.4";var h="1.2.840.113549.1.1.7",m="1.2.840.113549.1.1.8";var T="1.2.840.113549.1.1.10",Zt="1.2.840.113549.1.1.11",zt="1.2.840.113549.1.1.12",$t="1.2.840.113549.1.1.13";var O="1.2.840.113549.1.5.12",te="1.2.840.113549.1.7.1",ee="1.2.840.113549.1.7.2",re="1.2.840.113549.1.7.3";var oe="1.2.840.113549.1.7.6";var Y="1.2.840.113549.1.9.16.3.9";var ne="1.2.840.113549.2.7";var ie="1.2.840.113549.2.9",se="1.2.840.113549.2.10",Se="1.2.840.113549.2.11";var ae="2.16.840.1.101.3.4.1.2";var _e="2.16.840.1.101.3.4.1.6";var Ae="2.16.840.1.101.3.4.1.22";var Ie="2.16.840.1.101.3.4.1.26";var pe="2.16.840.1.101.3.4.1.42";var fe="2.16.840.1.101.3.4.1.46";var ce="2.16.840.1.101.3.4.2.1",me="2.16.840.1.101.3.4.2.2",le="2.16.840.1.101.3.4.2.3";import{Asn1Object as k}from"@apeleghq/asn1-der";var X,Q,J,Z=class extends s{static get sha256(){return X||(X=new this(new k(ce))),X}static get sha384(){return Q||(Q=new this(new k(me))),Q}static get sha512(){return J||(J=new this(new k(le))),J}},S=Z;var $,tt,et,rt,ot=class extends s{static get aes128cbc(){return t=>{if(t.byteLength!==16)throw new RangeError("Invalid IV length");return new this(new a(ae),new C(t))}}static get aes192cbc(){return t=>{if(t.byteLength!==16)throw new RangeError("Invalid IV length");return new this(new a(Ae),new C(t))}}static get aes256cbc(){return t=>{if(t.byteLength!==16)throw new RangeError("Invalid IV length");return new this(new a(pe),new C(t))}}static get aes128gcm16(){return t=>new this(new a(_e),new p([new C(t),new z(16)]))}static get aes192gcm16(){return t=>new this(new a(Ie),new p([new C(t),new z(16)]))}static get aes256gcm16(){return t=>new this(new a(fe),new p([new C(t),new z(16)]))}static get rsaOaepWithRfc8017DefaultParams(){return $||($=new this(new a(h),new p([]))),$}static get rsaOaepWithSha256Mgf1Sha256Empty(){return tt||(tt=new this(new a(h),new p([new u(0,S.sha256,!0),new u(1,new p([new a(m),S.sha256]),!0)]))),tt}static get rsaOaepWithSha384Mgf1Sha384Empty(){return et||(et=new this(new a(h),new p([new u(0,S.sha384,!0),new u(1,new p([new a(m),S.sha384]),!0)]))),et}static get rsaOaepWithSha512Mgf1Sha512Empty(){return rt||(rt=new this(new a(h),new p([new u(0,S.sha512,!0),new u(1,new p([new a(m),S.sha512]),!0)]))),rt}},g=ot;import{Asn1Object as Ke}from"@apeleghq/asn1-der";var nt,it,st,St,at=class r extends Ke{static get idData(){return nt||(nt=new r(te)),nt}static get idEncryptedData(){return it||(it=new r(oe)),it}static get idEnvelopedData(){return st||(st=new r(re)),st}static get idSignedData(){return St||(St=new r(ee)),St}},_t=at;import{Asn1Set as Ge}from"@apeleghq/asn1-der";var At=class extends Ge{constructor(t){super(t)}},It=At;import{Asn1ContextSpecific as He,Asn1Sequence as Le}from"@apeleghq/asn1-der";var pt=class extends Le{constructor(t,e){super(e?[t,new He(0,e,!0)]:[t]),this.eContentType_=t}get eContentType(){return this.eContentType_}},ve=pt;import{Asn1OctetString as be}from"@apeleghq/asn1-der";var ft=class extends be{},We=ft;import{Asn1ContextSpecific as Ve,Asn1Sequence as je}from"@apeleghq/asn1-der";var ct=class extends je{constructor(t,e,o){super(o?[t,e,new Ve(0,o,!1)]:[t,e]),this.contentType_=t}get contentType(){return this.contentType_}},Be=ct;import{Asn1ContextSpecific as Ue,Asn1Sequence as qe}from"@apeleghq/asn1-der";var mt=class extends qe{constructor(t,e){let o=e?i.v2:i.v0;super(e?[o,t,new Ue(1,e,!1)]:[o,t])}},Fe=mt;import{Asn1OctetString as Ye}from"@apeleghq/asn1-der";var lt=class extends Ye{},ke=lt;import{Asn1ContextSpecific as de,Asn1Sequence as Je}from"@apeleghq/asn1-der";import{Asn1ContextSpecific as Xe,Asn1Sequence as Qe}from"@apeleghq/asn1-der";var dt=class extends Qe{constructor(t,e,o){let n=i.v0;super(o?[n,new Xe(0,o,!1),t,e]:[n,t,e]),this.version_=n}get version(){return this.version_}},D=dt;var ut=class extends Je{constructor(t,e,o,n){let _={},d=t.kinds.has(D)?i.v3:o||n||Array.from(t.versions).some(A=>A.version!==0)?i.v2:i.v0;super([d,o?new de(0,o,!1):_,t,e,n?new de(1,n,!1):_].filter(A=>A!==_))}},Ze=ut;import{Asn1Sequence as ze}from"@apeleghq/asn1-der";var Ct=class extends ze{constructor(t,e){super([t,e])}},Et=Ct;import{Asn1Integer as x,Asn1Null as w,Asn1Object as l,Asn1OctetString as y,Asn1Sequence as R}from"@apeleghq/asn1-der";var ht=class extends s{static get pbkdf2sha1(){return(t,e)=>new this(new l(O),new R([new y(t),new x(e),new s(new l(ne),new w)]))}static get pbkdf2sha256(){return(t,e)=>new this(new l(O),new R([new y(t),new x(e),new s(new l(ie),new w)]))}static get pbkdf2sha384(){return(t,e)=>new this(new l(O),new R([new y(t),new x(e),new s(new l(se),new w)]))}static get pbkdf2sha512(){return(t,e)=>new this(new l(O),new R([new y(t),new x(e),new s(new l(Se),new w)]))}},$e=ht;import{Asn1Object as ue}from"@apeleghq/asn1-der";var Ot=class extends s{static get pwriAes256cbc(){return t=>new this(new ue(Y),g.aes256cbc(t))}static get pwriAes256gcm(){return t=>new this(new ue(Y),g.aes256gcm16(t))}},tr=Ot;import{Asn1OctetString as er}from"@apeleghq/asn1-der";var Dt=class extends er{},rr=Dt;import{Asn1ContextSpecific as or,Asn1Sequence as nr}from"@apeleghq/asn1-der";var Tt=class extends nr{constructor(t){super(t?[new or(0,t,!1)]:[])}},ir=Tt;import{Asn1ContextSpecific as sr}from"@apeleghq/asn1-der";var gt=class extends sr{constructor(t){super(3,t,!1),this.version_=t.version}get kind(){return D}get version(){return this.version_}},Sr=gt;import{Asn1Set as ar}from"@apeleghq/asn1-der";var xt=class extends ar{constructor(t){super(t);let e=new Set,o=new Set;t.forEach(n=>{e.add(n.kind),o.add(n.version)}),this.kinds_=e,this.versions_=o}get kinds(){return this.kinds_}get versions(){return this.versions_}},_r=xt;import{Asn1ContextSpecific as c,Asn1Integer as wt,Asn1Null as yt,Asn1Object as I,Asn1Sequence as E}from"@apeleghq/asn1-der";var Rt,Mt,Pt,Nt,Kt,Gt,Ht,Lt,vt,bt=class extends s{static get ecdsaWithSha256(){return Rt||(Rt=new this(new I(Xt))),Rt}static get ecdsaWithSha384(){return Mt||(Mt=new this(new I(Qt))),Mt}static get ecdsaWithSha512(){return Pt||(Pt=new this(new I(Jt))),Pt}static get rsaPssWithSha256Mgf1Sha256Salt32(){return Nt||(Nt=new this(new I(T),new E([new c(0,S.sha256,!0),new c(1,new E([new I(m),S.sha256]),!0),new c(2,new wt(32),!0)]))),Nt}static get rsaPssWithSha384Mgf1Sha384Salt48(){return Kt||(Kt=new this(new I(T),new E([new c(0,S.sha384,!0),new c(1,new E([new I(m),S.sha384]),!0),new c(2,new wt(48),!0)]))),Kt}static get rsaPssWithSha512Mgf1Sha512Salt64(){return Gt||(Gt=new this(new I(T),new E([new c(0,S.sha512,!0),new c(1,new E([new I(m),S.sha512]),!0),new c(2,new wt(64),!0)]))),Gt}static get sha256WithRsaEncryption(){return Ht||(Ht=new this(new I(Zt),new yt)),Ht}static get sha384WithRsaEncryption(){return Lt||(Lt=new this(new I(zt),new yt)),Lt}static get sha512WithRsaEncryption(){return vt||(vt=new this(new I($t),new yt)),vt}},Ar=bt;import{Asn1OctetString as Ir}from"@apeleghq/asn1-der";var Wt=class extends Ir{},pr=Wt;import{Asn1Set as fr}from"@apeleghq/asn1-der";var Vt=class extends fr{constructor(t){super(t)}},cr=Vt;import{Asn1Sequence as mr}from"@apeleghq/asn1-der";var jt=class extends mr{constructor(t,e){let o=Array.from(e.versions).some(n=>n.version===3)||t.eContentType!==_t.idData?i.v3:i.v1;super([o,e.digestAlgorithms,t,e])}},lr=jt;import{ASN1_CLASS_CONTEXT_SPECIFIC_ as ur,Asn1Base as Cr}from"@apeleghq/asn1-der";import{Asn1OctetString as dr}from"@apeleghq/asn1-der";var Bt=class extends dr{},Ut=Bt;var qt=class extends Cr{constructor(t){if(t instanceof Et)super(t.class_,t.primitive_,t.tag_),this.signerInfoVersion_=i.v1;else if(t instanceof Ut)super(ur,t.primitive_,0),this.signerInfoVersion_=i.v3;else throw new Error("Invalid signer type");this.data_=t}get signerInfoVersion(){return this.signerInfoVersion_}rawContents_(){return this.data_.rawContents_()}},Er=qt;import{Asn1ContextSpecific as Ce,Asn1Sequence as hr}from"@apeleghq/asn1-der";var Ft=class extends hr{constructor(t,e,o,n,_,d){let A={};super([t.signerInfoVersion,t,e,_?new Ce(0,_,!1):A,o,n,d?new Ce(1,d,!1):A].filter(M=>M!==A)),this.digestAlgorithmId_=e,this.version_=t.signerInfoVersion}get digestAlgorithm(){return this.digestAlgorithmId_}get version(){return this.version_}},Or=Ft;import{Asn1Set as Dr}from"@apeleghq/asn1-der";var Yt=class extends Dr{constructor(t){super(t);let e=[],o=new Set;t.forEach(n=>{let _=n.digestAlgorithm;e.includes(_)||e.push(_),o.add(n.version)}),this.digestAlgorithms_=new It(e),this.versions_=o}get digestAlgorithms(){return this.digestAlgorithms_}get versions(){return this.versions_}},Tr=Yt;export{s as AlgorithmIdentifier,De as Attribute,ge as AttributeValue,f as Attributes,f as AuthAttributes,Re as AuthEnvelopedData,i as CMSVersion,kt as CertificateChoices,Ne as CertificateSet,g as ContentEncryptionAlgorithmIdentifier,_t as ContentType,S as DigestAlgorithmIdentifier,It as DigestAlgorithmIdentifiers,ve as EncapsulatedContentInfo,We as EncryptedContent,Be as EncryptedContentInfo,Fe as EncryptedData,ke as EncryptedKey,Ze as EnvelopedData,Et as IssuerAndSerialNumber,$e as KeyDerivationAlgorithmIdentifier,tr as KeyEncryptionAlgorithmIdentifier,rr as MessageAuthenticationCode,ir as OriginatorInfo,D as PasswordRecipientInfo,Sr as RecipientInfo,_r as RecipientInfos,Ar as SignatureAlgorithmIdentifier,pr as SignatureValue,cr as SignedAttributes,lr as SignedData,Er as SignerIdentifier,Or as SignerInfo,Tr as SignerInfos,Ut as SubjectKeyIdentifier,f as UnauthAttributes,f as UnprotectedAttributes,f as UnsignedAttributes};