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