UNPKG

@apeleghq/cms-classes

Version:

A collection of utility classes to encode ASN.1 data following DER rules

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