@small-tech/auto-encrypt 2.3.0 → 3.1.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.
@@ -1,8 +1,6 @@
1
- 'use strict';
2
-
3
1
  // Require @panva’s fork of ASN1 that’s already included as part of the Jose library.
4
2
  // https://github.com/panva/asn1.js/
5
- const asn1 = require('@panva/asn1.js');
3
+ import asn1 from '@panva/asn1.js';
6
4
 
7
5
  /**
8
6
  * RFC5280 X509 and Extension Definitions
@@ -13,8 +11,6 @@ const asn1 = require('@panva/asn1.js');
13
11
  * stripped. There’s no reason to include the whole library again.)
14
12
  */
15
13
 
16
- const rfc5280 = exports;
17
-
18
14
  // OIDs
19
15
  const x509OIDs = {
20
16
  '2 5 29 9': 'subjectDirectoryAttributes',
@@ -46,38 +42,35 @@ const x509OIDs = {
46
42
  // tbsCertList TBSCertList,
47
43
  // signatureAlgorithm AlgorithmIdentifier,
48
44
  // signature BIT STRING }
49
- const CertificateList = asn1.define('CertificateList', function() {
45
+ export const CertificateList = asn1.define('CertificateList', function() {
50
46
  this.seq().obj(
51
47
  this.key('tbsCertList').use(TBSCertList),
52
48
  this.key('signatureAlgorithm').use(AlgorithmIdentifier),
53
49
  this.key('signature').bitstr()
54
50
  );
55
51
  });
56
- rfc5280.CertificateList = CertificateList;
57
52
 
58
53
  // AlgorithmIdentifier ::= SEQUENCE {
59
54
  // algorithm OBJECT IDENTIFIER,
60
55
  // parameters ANY DEFINED BY algorithm OPTIONAL }
61
- const AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function() {
56
+ export const AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function() {
62
57
  this.seq().obj(
63
58
  this.key('algorithm').objid(),
64
59
  this.key('parameters').optional().any()
65
60
  );
66
61
  });
67
- rfc5280.AlgorithmIdentifier = AlgorithmIdentifier;
68
62
 
69
63
  // Certificate ::= SEQUENCE {
70
64
  // tbsCertificate TBSCertificate,
71
65
  // signatureAlgorithm AlgorithmIdentifier,
72
66
  // signature BIT STRING }
73
- const Certificate = asn1.define('Certificate', function() {
67
+ export const Certificate = asn1.define('Certificate', function() {
74
68
  this.seq().obj(
75
69
  this.key('tbsCertificate').use(TBSCertificate),
76
70
  this.key('signatureAlgorithm').use(AlgorithmIdentifier),
77
71
  this.key('signature').bitstr()
78
72
  );
79
73
  });
80
- rfc5280.Certificate = Certificate;
81
74
 
82
75
  // TBSCertificate ::= SEQUENCE {
83
76
  // version [0] Version DEFAULT v1,
@@ -90,7 +83,7 @@ rfc5280.Certificate = Certificate;
90
83
  // issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
91
84
  // subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
92
85
  // extensions [3] Extensions OPTIONAL
93
- const TBSCertificate = asn1.define('TBSCertificate', function() {
86
+ export const TBSCertificate = asn1.define('TBSCertificate', function() {
94
87
  this.seq().obj(
95
88
  this.key('version').def('v1').explicit(0).use(Version),
96
89
  this.key('serialNumber').int(),
@@ -104,50 +97,45 @@ const TBSCertificate = asn1.define('TBSCertificate', function() {
104
97
  this.key('extensions').optional().explicit(3).seqof(Extension)
105
98
  );
106
99
  });
107
- rfc5280.TBSCertificate = TBSCertificate;
108
100
 
109
101
  // Version ::= INTEGER { v1(0), v2(1), v3(2) }
110
- const Version = asn1.define('Version', function() {
102
+ export const Version = asn1.define('Version', function() {
111
103
  this.int({
112
104
  0: 'v1',
113
105
  1: 'v2',
114
106
  2: 'v3'
115
107
  });
116
108
  });
117
- rfc5280.Version = Version;
118
109
 
119
110
  // Validity ::= SEQUENCE {
120
111
  // notBefore Time,
121
112
  // notAfter Time }
122
- const Validity = asn1.define('Validity', function() {
113
+ export const Validity = asn1.define('Validity', function() {
123
114
  this.seq().obj(
124
115
  this.key('notBefore').use(Time),
125
116
  this.key('notAfter').use(Time)
126
117
  );
127
118
  });
128
- rfc5280.Validity = Validity;
129
119
 
130
120
  // Time ::= CHOICE {
131
121
  // utcTime UTCTime,
132
122
  // generalTime GeneralizedTime }
133
- const Time = asn1.define('Time', function() {
123
+ export const Time = asn1.define('Time', function() {
134
124
  this.choice({
135
125
  utcTime: this.utctime(),
136
126
  genTime: this.gentime()
137
127
  });
138
128
  });
139
- rfc5280.Time = Time;
140
129
 
141
130
  // SubjectPublicKeyInfo ::= SEQUENCE {
142
131
  // algorithm AlgorithmIdentifier,
143
132
  // subjectPublicKey BIT STRING }
144
- const SubjectPublicKeyInfo = asn1.define('SubjectPublicKeyInfo', function() {
133
+ export const SubjectPublicKeyInfo = asn1.define('SubjectPublicKeyInfo', function() {
145
134
  this.seq().obj(
146
135
  this.key('algorithm').use(AlgorithmIdentifier),
147
136
  this.key('subjectPublicKey').bitstr()
148
137
  );
149
138
  });
150
- rfc5280.SubjectPublicKeyInfo = SubjectPublicKeyInfo;
151
139
 
152
140
  // TBSCertList ::= SEQUENCE {
153
141
  // version Version OPTIONAL,
@@ -161,7 +149,7 @@ rfc5280.SubjectPublicKeyInfo = SubjectPublicKeyInfo;
161
149
  // crlEntryExtensions Extensions OPTIONAL
162
150
  // } OPTIONAL,
163
151
  // crlExtensions [0] Extensions OPTIONAL }
164
- const TBSCertList = asn1.define('TBSCertList', function() {
152
+ export const TBSCertList = asn1.define('TBSCertList', function() {
165
153
  this.seq().obj(
166
154
  this.key('version').optional().int(),
167
155
  this.key('signature').use(AlgorithmIdentifier),
@@ -172,7 +160,6 @@ const TBSCertList = asn1.define('TBSCertList', function() {
172
160
  this.key('crlExtensions').explicit(0).optional().seqof(Extension)
173
161
  );
174
162
  });
175
- rfc5280.TBSCertList = TBSCertList;
176
163
 
177
164
  const RevokedCertificate = asn1.define('RevokedCertificate', function() {
178
165
  this.seq().obj(
@@ -186,7 +173,7 @@ const RevokedCertificate = asn1.define('RevokedCertificate', function() {
186
173
  // extnID OBJECT IDENTIFIER,
187
174
  // critical BOOLEAN DEFAULT FALSE,
188
175
  // extnValue OCTET STRING }
189
- const Extension = asn1.define('Extension', function() {
176
+ export const Extension = asn1.define('Extension', function() {
190
177
  this.seq().obj(
191
178
  this.key('extnID').objid(x509OIDs),
192
179
  this.key('critical').bool().def(false),
@@ -197,16 +184,14 @@ const Extension = asn1.define('Extension', function() {
197
184
  })
198
185
  );
199
186
  });
200
- rfc5280.Extension = Extension;
201
187
 
202
188
  // Name ::= CHOICE { -- only one possibility for now --
203
189
  // rdnSequence RDNSequence }
204
- const Name = asn1.define('Name', function() {
190
+ export const Name = asn1.define('Name', function() {
205
191
  this.choice({
206
192
  rdnSequence: this.use(RDNSequence)
207
193
  });
208
194
  });
209
- rfc5280.Name = Name;
210
195
 
211
196
  // GeneralName ::= CHOICE {
212
197
  // otherName [0] AnotherName,
@@ -218,7 +203,7 @@ rfc5280.Name = Name;
218
203
  // uniformResourceIdentifier [6] IA5String,
219
204
  // iPAddress [7] OCTET STRING,
220
205
  // registeredID [8] OBJECT IDENTIFIER }
221
- const GeneralName = asn1.define('GeneralName', function() {
206
+ export const GeneralName = asn1.define('GeneralName', function() {
222
207
  this.choice({
223
208
  otherName: this.implicit(0).use(AnotherName),
224
209
  rfc822Name: this.implicit(1).ia5str(),
@@ -230,83 +215,73 @@ const GeneralName = asn1.define('GeneralName', function() {
230
215
  registeredID: this.implicit(8).objid()
231
216
  });
232
217
  });
233
- rfc5280.GeneralName = GeneralName;
234
218
 
235
219
  // GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
236
- const GeneralNames = asn1.define('GeneralNames', function() {
220
+ export const GeneralNames = asn1.define('GeneralNames', function() {
237
221
  this.seqof(GeneralName);
238
222
  });
239
- rfc5280.GeneralNames = GeneralNames;
240
223
 
241
224
  // AnotherName ::= SEQUENCE {
242
225
  // type-id OBJECT IDENTIFIER,
243
226
  // value [0] EXPLICIT ANY DEFINED BY type-id }
244
- const AnotherName = asn1.define('AnotherName', function() {
227
+ export const AnotherName = asn1.define('AnotherName', function() {
245
228
  this.seq().obj(
246
229
  this.key('type-id').objid(),
247
230
  this.key('value').explicit(0).any()
248
231
  );
249
232
  });
250
- rfc5280.AnotherName = AnotherName;
251
233
 
252
234
  // EDIPartyName ::= SEQUENCE {
253
235
  // nameAssigner [0] DirectoryString OPTIONAL,
254
236
  // partyName [1] DirectoryString }
255
- const EDIPartyName = asn1.define('EDIPartyName', function() {
237
+ export const EDIPartyName = asn1.define('EDIPartyName', function() {
256
238
  this.seq().obj(
257
239
  this.key('nameAssigner').implicit(0).optional().use(DirectoryString),
258
240
  this.key('partyName').implicit(1).use(DirectoryString)
259
241
  );
260
242
  });
261
- rfc5280.EDIPartyName = EDIPartyName;
262
243
 
263
244
  // RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
264
- const RDNSequence = asn1.define('RDNSequence', function() {
245
+ export const RDNSequence = asn1.define('RDNSequence', function() {
265
246
  this.seqof(RelativeDistinguishedName);
266
247
  });
267
- rfc5280.RDNSequence = RDNSequence;
268
248
 
269
249
  // RelativeDistinguishedName ::=
270
250
  // SET SIZE (1..MAX) OF AttributeTypeAndValue
271
- const RelativeDistinguishedName = asn1.define('RelativeDistinguishedName',
251
+ export const RelativeDistinguishedName = asn1.define('RelativeDistinguishedName',
272
252
  function() {
273
253
  this.setof(AttributeTypeAndValue);
274
254
  });
275
- rfc5280.RelativeDistinguishedName = RelativeDistinguishedName;
276
255
 
277
256
  // AttributeTypeAndValue ::= SEQUENCE {
278
257
  // type AttributeType,
279
258
  // value AttributeValue }
280
- const AttributeTypeAndValue = asn1.define('AttributeTypeAndValue', function() {
259
+ export const AttributeTypeAndValue = asn1.define('AttributeTypeAndValue', function() {
281
260
  this.seq().obj(
282
261
  this.key('type').use(AttributeType),
283
262
  this.key('value').use(AttributeValue)
284
263
  );
285
264
  });
286
- rfc5280.AttributeTypeAndValue = AttributeTypeAndValue;
287
265
 
288
266
  // Attribute ::= SEQUENCE {
289
267
  // type AttributeType,
290
268
  // values SET OF AttributeValue }
291
- const Attribute = asn1.define('Attribute', function() {
269
+ export const Attribute = asn1.define('Attribute', function() {
292
270
  this.seq().obj(
293
271
  this.key('type').use(AttributeType),
294
272
  this.key('values').setof(AttributeValue)
295
273
  );
296
274
  });
297
- rfc5280.Attribute = Attribute;
298
275
 
299
276
  // AttributeType ::= OBJECT IDENTIFIER
300
- const AttributeType = asn1.define('AttributeType', function() {
277
+ export const AttributeType = asn1.define('AttributeType', function() {
301
278
  this.objid();
302
279
  });
303
- rfc5280.AttributeType = AttributeType;
304
280
 
305
281
  // AttributeValue ::= ANY -- DEFINED BY AttributeType
306
- const AttributeValue = asn1.define('AttributeValue', function() {
282
+ export const AttributeValue = asn1.define('AttributeValue', function() {
307
283
  this.any();
308
284
  });
309
- rfc5280.AttributeValue = AttributeValue;
310
285
 
311
286
  // DirectoryString ::= CHOICE {
312
287
  // teletexString TeletexString (SIZE (1..MAX)),
@@ -314,7 +289,7 @@ rfc5280.AttributeValue = AttributeValue;
314
289
  // universalString UniversalString (SIZE (1..MAX)),
315
290
  // utf8String UTF8String (SIZE (1..MAX)),
316
291
  // bmpString BMPString (SIZE (1..MAX)) }
317
- const DirectoryString = asn1.define('DirectoryString', function() {
292
+ export const DirectoryString = asn1.define('DirectoryString', function() {
318
293
  this.choice({
319
294
  teletexString: this.t61str(),
320
295
  printableString: this.printstr(),
@@ -323,13 +298,12 @@ const DirectoryString = asn1.define('DirectoryString', function() {
323
298
  bmpString: this.bmpstr()
324
299
  });
325
300
  });
326
- rfc5280.DirectoryString = DirectoryString;
327
301
 
328
302
  // AuthorityKeyIdentifier ::= SEQUENCE {
329
303
  // keyIdentifier [0] KeyIdentifier OPTIONAL,
330
304
  // authorityCertIssuer [1] GeneralNames OPTIONAL,
331
305
  // authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL }
332
- const AuthorityKeyIdentifier = asn1.define('AuthorityKeyIdentifier', function() {
306
+ export const AuthorityKeyIdentifier = asn1.define('AuthorityKeyIdentifier', function() {
333
307
  this.seq().obj(
334
308
  this.key('keyIdentifier').implicit(0).optional().use(KeyIdentifier),
335
309
  this.key('authorityCertIssuer').implicit(1).optional().use(GeneralNames),
@@ -337,27 +311,24 @@ const AuthorityKeyIdentifier = asn1.define('AuthorityKeyIdentifier', function()
337
311
  .use(CertificateSerialNumber)
338
312
  );
339
313
  });
340
- rfc5280.AuthorityKeyIdentifier = AuthorityKeyIdentifier;
341
314
 
342
315
  // KeyIdentifier ::= OCTET STRING
343
- const KeyIdentifier = asn1.define('KeyIdentifier', function() {
316
+ export const KeyIdentifier = asn1.define('KeyIdentifier', function() {
344
317
  this.octstr();
345
318
  });
346
- rfc5280.KeyIdentifier = KeyIdentifier;
347
319
 
348
320
  // CertificateSerialNumber ::= INTEGER
349
- const CertificateSerialNumber = asn1.define('CertificateSerialNumber',
321
+ export const CertificateSerialNumber = asn1.define('CertificateSerialNumber',
350
322
  function() {
351
323
  this.int();
352
324
  });
353
- rfc5280.CertificateSerialNumber = CertificateSerialNumber;
354
325
 
355
326
  // ORAddress ::= SEQUENCE {
356
327
  // built-in-standard-attributes BuiltInStandardAttributes,
357
328
  // built-in-domain-defined-attributes BuiltInDomainDefinedAttributes
358
329
  // OPTIONAL,
359
330
  // extension-attributes ExtensionAttributes OPTIONAL }
360
- const ORAddress = asn1.define('ORAddress', function() {
331
+ export const ORAddress = asn1.define('ORAddress', function() {
361
332
  this.seq().obj(
362
333
  this.key('builtInStandardAttributes').use(BuiltInStandardAttributes),
363
334
  this.key('builtInDomainDefinedAttributes').optional()
@@ -365,7 +336,6 @@ const ORAddress = asn1.define('ORAddress', function() {
365
336
  this.key('extensionAttributes').optional().use(ExtensionAttributes)
366
337
  );
367
338
  });
368
- rfc5280.ORAddress = ORAddress;
369
339
 
370
340
  // BuiltInStandardAttributes ::= SEQUENCE {
371
341
  // country-name CountryName OPTIONAL,
@@ -377,7 +347,7 @@ rfc5280.ORAddress = ORAddress;
377
347
  // numeric-user-identifier [4] IMPLICIT NumericUserIdentifier OPTIONAL,
378
348
  // personal-name [5] IMPLICIT PersonalName OPTIONAL,
379
349
  // organizational-unit-names [6] IMPLICIT OrganizationalUnitNames OPTIONAL }
380
- const BuiltInStandardAttributes = asn1.define('BuiltInStandardAttributes',
350
+ export const BuiltInStandardAttributes = asn1.define('BuiltInStandardAttributes',
381
351
  function() {
382
352
  this.seq().obj(
383
353
  this.key('countryName').optional().use(CountryName),
@@ -395,79 +365,69 @@ const BuiltInStandardAttributes = asn1.define('BuiltInStandardAttributes',
395
365
  .use(OrganizationalUnitNames)
396
366
  );
397
367
  });
398
- rfc5280.BuiltInStandardAttributes = BuiltInStandardAttributes;
399
368
 
400
369
  // CountryName ::= CHOICE {
401
370
  // x121-dcc-code NumericString,
402
371
  // iso-3166-alpha2-code PrintableString }
403
- const CountryName = asn1.define('CountryName', function() {
372
+ export const CountryName = asn1.define('CountryName', function() {
404
373
  this.choice({
405
374
  x121DccCode: this.numstr(),
406
375
  iso3166Alpha2Code: this.printstr()
407
376
  });
408
377
  });
409
- rfc5280.CountryName = CountryName;
410
-
411
378
 
412
379
  // AdministrationDomainName ::= CHOICE {
413
380
  // numeric NumericString,
414
381
  // printable PrintableString }
415
- const AdministrationDomainName = asn1.define('AdministrationDomainName',
382
+ export const AdministrationDomainName = asn1.define('AdministrationDomainName',
416
383
  function() {
417
384
  this.choice({
418
385
  numeric: this.numstr(),
419
386
  printable: this.printstr()
420
387
  });
421
388
  });
422
- rfc5280.AdministrationDomainName = AdministrationDomainName;
423
389
 
424
390
  // NetworkAddress ::= X121Address
425
- const NetworkAddress = asn1.define('NetworkAddress', function() {
391
+ export const NetworkAddress = asn1.define('NetworkAddress', function() {
426
392
  this.use(X121Address);
427
393
  });
428
- rfc5280.NetworkAddress = NetworkAddress;
429
394
 
430
395
  // X121Address ::= NumericString
431
- const X121Address = asn1.define('X121Address', function() {
396
+ export const X121Address = asn1.define('X121Address', function() {
432
397
  this.numstr();
433
398
  });
434
- rfc5280.X121Address = X121Address;
435
399
 
436
400
  // TerminalIdentifier ::= PrintableString
437
- const TerminalIdentifier = asn1.define('TerminalIdentifier', function() {
401
+ export const TerminalIdentifier = asn1.define('TerminalIdentifier', function() {
438
402
  this.printstr();
439
403
  });
440
- rfc5280.TerminalIdentifier = TerminalIdentifier;
441
404
 
442
405
  // PrivateDomainName ::= CHOICE {
443
406
  // numeric NumericString,
444
407
  // printable PrintableString }
445
- const PrivateDomainName = asn1.define('PrivateDomainName', function() {
408
+ export const PrivateDomainName = asn1.define('PrivateDomainName', function() {
446
409
  this.choice({
447
410
  numeric: this.numstr(),
448
411
  printable: this.printstr()
449
412
  });
450
413
  });
451
- rfc5280.PrivateDomainName = PrivateDomainName;
452
414
 
453
415
  // OrganizationName ::= PrintableString
454
- const OrganizationName = asn1.define('OrganizationName', function() {
416
+ export const OrganizationName = asn1.define('OrganizationName', function() {
455
417
  this.printstr();
456
418
  });
457
- rfc5280.OrganizationName = OrganizationName;
458
419
 
459
420
  // NumericUserIdentifier ::= NumericString
460
- const NumericUserIdentifier = asn1.define('NumericUserIdentifier', function() {
421
+ export const NumericUserIdentifier = asn1.define('NumericUserIdentifier', function() {
461
422
  this.numstr();
462
423
  });
463
- rfc5280.NumericUserIdentifier = NumericUserIdentifier;
464
424
 
465
425
  // PersonalName ::= SET {
466
426
  // surname [0] IMPLICIT PrintableString,
467
427
  // given-name [1] IMPLICIT PrintableString OPTIONAL,
468
428
  // initials [2] IMPLICIT PrintableString OPTIONAL,
469
429
  // generation-qualifier [3] IMPLICIT PrintableString OPTIONAL }
470
- const PersonalName = asn1.define('PersonalName', function() {
430
+ export const PersonalName = asn1.define('PersonalName', function() {
471
431
  this.set().obj(
472
432
  this.key('surname').implicit(0).printstr(),
473
433
  this.key('givenName').implicit(1).printstr(),
@@ -475,69 +435,60 @@ const PersonalName = asn1.define('PersonalName', function() {
475
435
  this.key('generationQualifier').implicit(3).printstr()
476
436
  );
477
437
  });
478
- rfc5280.PersonalName = PersonalName;
479
438
 
480
439
  // OrganizationalUnitNames ::= SEQUENCE SIZE (1..ub-organizational-units)
481
440
  // OF OrganizationalUnitName
482
- const OrganizationalUnitNames = asn1.define('OrganizationalUnitNames',
441
+ export const OrganizationalUnitNames = asn1.define('OrganizationalUnitNames',
483
442
  function() {
484
443
  this.seqof(OrganizationalUnitName);
485
444
  });
486
- rfc5280.OrganizationalUnitNames = OrganizationalUnitNames;
487
445
 
488
446
  // OrganizationalUnitName ::= PrintableString (SIZE
489
447
  // (1..ub-organizational-unit-name-length))
490
- const OrganizationalUnitName = asn1.define('OrganizationalUnitName', function() {
448
+ export const OrganizationalUnitName = asn1.define('OrganizationalUnitName', function() {
491
449
  this.printstr();
492
450
  });
493
- rfc5280.OrganizationalUnitName = OrganizationalUnitName;
494
451
 
495
452
  // uiltInDomainDefinedAttributes ::= SEQUENCE SIZE
496
453
  // (1..ub-domain-defined-attributes)
497
454
  // OF BuiltInDomainDefinedAttribute
498
- const BuiltInDomainDefinedAttributes = asn1.define(
455
+ export const BuiltInDomainDefinedAttributes = asn1.define(
499
456
  'BuiltInDomainDefinedAttributes', function() {
500
457
  this.seqof(BuiltInDomainDefinedAttribute);
501
458
  });
502
- rfc5280.BuiltInDomainDefinedAttributes = BuiltInDomainDefinedAttributes;
503
459
 
504
460
  // BuiltInDomainDefinedAttribute ::= SEQUENCE {
505
461
  // type PrintableString (SIZE (1..ub-domain-defined-attribute-type-length)),
506
462
  // value PrintableString (SIZE (1..ub-domain-defined-attribute-value-length))
507
463
  //}
508
- const BuiltInDomainDefinedAttribute = asn1.define('BuiltInDomainDefinedAttribute',
464
+ export const BuiltInDomainDefinedAttribute = asn1.define('BuiltInDomainDefinedAttribute',
509
465
  function() {
510
466
  this.seq().obj(
511
467
  this.key('type').printstr(),
512
468
  this.key('value').printstr()
513
469
  );
514
470
  });
515
- rfc5280.BuiltInDomainDefinedAttribute = BuiltInDomainDefinedAttribute;
516
-
517
471
 
518
472
  // ExtensionAttributes ::= SET SIZE (1..ub-extension-attributes) OF
519
473
  // ExtensionAttribute
520
- const ExtensionAttributes = asn1.define('ExtensionAttributes', function() {
474
+ export const ExtensionAttributes = asn1.define('ExtensionAttributes', function() {
521
475
  this.seqof(ExtensionAttribute);
522
476
  });
523
- rfc5280.ExtensionAttributes = ExtensionAttributes;
524
477
 
525
478
  // ExtensionAttribute ::= SEQUENCE {
526
479
  // extension-attribute-type [0] IMPLICIT INTEGER,
527
480
  // extension-attribute-value [1] ANY DEFINED BY extension-attribute-type }
528
- const ExtensionAttribute = asn1.define('ExtensionAttribute', function() {
481
+ export const ExtensionAttribute = asn1.define('ExtensionAttribute', function() {
529
482
  this.seq().obj(
530
483
  this.key('extensionAttributeType').implicit(0).int(),
531
484
  this.key('extensionAttributeValue').any().explicit(1).int()
532
485
  );
533
486
  });
534
- rfc5280.ExtensionAttribute = ExtensionAttribute;
535
487
 
536
488
  // SubjectKeyIdentifier ::= KeyIdentifier
537
- const SubjectKeyIdentifier = asn1.define('SubjectKeyIdentifier', function() {
489
+ export const SubjectKeyIdentifier = asn1.define('SubjectKeyIdentifier', function() {
538
490
  this.use(KeyIdentifier);
539
491
  });
540
- rfc5280.SubjectKeyIdentifier = SubjectKeyIdentifier;
541
492
 
542
493
  // KeyUsage ::= BIT STRING {
543
494
  // digitalSignature (0),
@@ -550,179 +501,157 @@ rfc5280.SubjectKeyIdentifier = SubjectKeyIdentifier;
550
501
  // cRLSign (6),
551
502
  // encipherOnly (7),
552
503
  // decipherOnly (8) }
553
- const KeyUsage = asn1.define('KeyUsage', function() {
504
+ export const KeyUsage = asn1.define('KeyUsage', function() {
554
505
  this.bitstr();
555
506
  });
556
- rfc5280.KeyUsage = KeyUsage;
557
507
 
558
508
  // CertificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation
559
- const CertificatePolicies = asn1.define('CertificatePolicies', function() {
509
+ export const CertificatePolicies = asn1.define('CertificatePolicies', function() {
560
510
  this.seqof(PolicyInformation);
561
511
  });
562
- rfc5280.CertificatePolicies = CertificatePolicies;
563
512
 
564
513
  // PolicyInformation ::= SEQUENCE {
565
514
  // policyIdentifier CertPolicyId,
566
515
  // policyQualifiers SEQUENCE SIZE (1..MAX) OF PolicyQualifierInfo
567
516
  // OPTIONAL }
568
- const PolicyInformation = asn1.define('PolicyInformation', function() {
517
+ export const PolicyInformation = asn1.define('PolicyInformation', function() {
569
518
  this.seq().obj(
570
519
  this.key('policyIdentifier').use(CertPolicyId),
571
520
  this.key('policyQualifiers').optional().use(PolicyQualifiers)
572
521
  );
573
522
  });
574
- rfc5280.PolicyInformation = PolicyInformation;
575
523
 
576
524
  // CertPolicyId ::= OBJECT IDENTIFIER
577
- const CertPolicyId = asn1.define('CertPolicyId', function() {
525
+ export const CertPolicyId = asn1.define('CertPolicyId', function() {
578
526
  this.objid();
579
527
  });
580
- rfc5280.CertPolicyId = CertPolicyId;
581
528
 
582
- const PolicyQualifiers = asn1.define('PolicyQualifiers', function() {
529
+ export const PolicyQualifiers = asn1.define('PolicyQualifiers', function() {
583
530
  this.seqof(PolicyQualifierInfo);
584
531
  });
585
- rfc5280.PolicyQualifiers = PolicyQualifiers;
586
532
 
587
533
  // PolicyQualifierInfo ::= SEQUENCE {
588
534
  // policyQualifierId PolicyQualifierId,
589
535
  // qualifier ANY DEFINED BY policyQualifierId }
590
- const PolicyQualifierInfo = asn1.define('PolicyQualifierInfo', function() {
536
+ export const PolicyQualifierInfo = asn1.define('PolicyQualifierInfo', function() {
591
537
  this.seq().obj(
592
538
  this.key('policyQualifierId').use(PolicyQualifierId),
593
539
  this.key('qualifier').any()
594
540
  );
595
541
  });
596
- rfc5280.PolicyQualifierInfo = PolicyQualifierInfo;
597
542
 
598
543
  // PolicyQualifierId ::= OBJECT IDENTIFIER
599
- const PolicyQualifierId = asn1.define('PolicyQualifierId', function() {
544
+ export const PolicyQualifierId = asn1.define('PolicyQualifierId', function() {
600
545
  this.objid();
601
546
  });
602
- rfc5280.PolicyQualifierId = PolicyQualifierId;
603
547
 
604
548
  // PolicyMappings ::= SEQUENCE SIZE (1..MAX) OF SEQUENCE {
605
549
  // issuerDomainPolicy CertPolicyId,
606
550
  // subjectDomainPolicy CertPolicyId }
607
- const PolicyMappings = asn1.define('PolicyMappings', function() {
551
+ export const PolicyMappings = asn1.define('PolicyMappings', function() {
608
552
  this.seqof(PolicyMapping);
609
553
  });
610
- rfc5280.PolicyMappings = PolicyMappings;
611
554
 
612
- const PolicyMapping = asn1.define('PolicyMapping', function() {
555
+ export const PolicyMapping = asn1.define('PolicyMapping', function() {
613
556
  this.seq().obj(
614
557
  this.key('issuerDomainPolicy').use(CertPolicyId),
615
558
  this.key('subjectDomainPolicy').use(CertPolicyId)
616
559
  );
617
560
  });
618
- rfc5280.PolicyMapping = PolicyMapping;
619
561
 
620
562
  // SubjectAltName ::= GeneralNames
621
- const SubjectAlternativeName = asn1.define('SubjectAlternativeName', function() {
563
+ export const SubjectAlternativeName = asn1.define('SubjectAlternativeName', function() {
622
564
  this.use(GeneralNames);
623
565
  });
624
- rfc5280.SubjectAlternativeName = SubjectAlternativeName;
625
566
 
626
567
  // IssuerAltName ::= GeneralNames
627
- const IssuerAlternativeName = asn1.define('IssuerAlternativeName', function() {
568
+ export const IssuerAlternativeName = asn1.define('IssuerAlternativeName', function() {
628
569
  this.use(GeneralNames);
629
570
  });
630
- rfc5280.IssuerAlternativeName = IssuerAlternativeName;
631
571
 
632
572
  // SubjectDirectoryAttributes ::= SEQUENCE SIZE (1..MAX) OF Attribute
633
- const SubjectDirectoryAttributes = asn1.define('SubjectDirectoryAttributes',
573
+ export const SubjectDirectoryAttributes = asn1.define('SubjectDirectoryAttributes',
634
574
  function() {
635
575
  this.seqof(Attribute);
636
576
  });
637
- rfc5280.SubjectDirectoryAttributes = SubjectDirectoryAttributes;
638
577
 
639
578
  // BasicConstraints ::= SEQUENCE {
640
579
  // cA BOOLEAN DEFAULT FALSE,
641
580
  // pathLenConstraint INTEGER (0..MAX) OPTIONAL }
642
- const BasicConstraints = asn1.define('BasicConstraints', function() {
581
+ export const BasicConstraints = asn1.define('BasicConstraints', function() {
643
582
  this.seq().obj(
644
583
  this.key('cA').bool().def(false),
645
584
  this.key('pathLenConstraint').optional().int()
646
585
  );
647
586
  });
648
- rfc5280.BasicConstraints = BasicConstraints;
649
587
 
650
588
  // NameConstraints ::= SEQUENCE {
651
589
  // permittedSubtrees [0] GeneralSubtrees OPTIONAL,
652
590
  // excludedSubtrees [1] GeneralSubtrees OPTIONAL }
653
- const NameConstraints = asn1.define('NameConstraints', function() {
591
+ export const NameConstraints = asn1.define('NameConstraints', function() {
654
592
  this.seq().obj(
655
593
  this.key('permittedSubtrees').implicit(0).optional().use(GeneralSubtrees),
656
594
  this.key('excludedSubtrees').implicit(1).optional().use(GeneralSubtrees)
657
595
  );
658
596
  });
659
- rfc5280.NameConstraints = NameConstraints;
660
597
 
661
598
  // GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
662
- const GeneralSubtrees = asn1.define('GeneralSubtrees', function() {
599
+ export const GeneralSubtrees = asn1.define('GeneralSubtrees', function() {
663
600
  this.seqof(GeneralSubtree);
664
601
  });
665
- rfc5280.GeneralSubtrees = GeneralSubtrees;
666
602
 
667
603
  // GeneralSubtree ::= SEQUENCE {
668
604
  // base GeneralName,
669
605
  // minimum [0] BaseDistance DEFAULT 0,
670
606
  // maximum [1] BaseDistance OPTIONAL }
671
- const GeneralSubtree = asn1.define('GeneralSubtree', function() {
607
+ export const GeneralSubtree = asn1.define('GeneralSubtree', function() {
672
608
  this.seq().obj(
673
609
  this.key('base').use(GeneralName),
674
610
  this.key('minimum').implicit(0).def(0).use(BaseDistance),
675
611
  this.key('maximum').implicit(0).optional().use(BaseDistance)
676
612
  );
677
613
  });
678
- rfc5280.GeneralSubtree = GeneralSubtree;
679
614
 
680
615
  // BaseDistance ::= INTEGER
681
- const BaseDistance = asn1.define('BaseDistance', function() {
616
+ export const BaseDistance = asn1.define('BaseDistance', function() {
682
617
  this.int();
683
618
  });
684
- rfc5280.BaseDistance = BaseDistance;
685
619
 
686
620
  // PolicyConstraints ::= SEQUENCE {
687
621
  // requireExplicitPolicy [0] SkipCerts OPTIONAL,
688
622
  // inhibitPolicyMapping [1] SkipCerts OPTIONAL }
689
- const PolicyConstraints = asn1.define('PolicyConstraints', function() {
623
+ export const PolicyConstraints = asn1.define('PolicyConstraints', function() {
690
624
  this.seq().obj(
691
625
  this.key('requireExplicitPolicy').implicit(0).optional().use(SkipCerts),
692
626
  this.key('inhibitPolicyMapping').implicit(1).optional().use(SkipCerts)
693
627
  );
694
628
  });
695
- rfc5280.PolicyConstraints = PolicyConstraints;
696
629
 
697
630
  // SkipCerts ::= INTEGER
698
- const SkipCerts = asn1.define('SkipCerts', function() {
631
+ export const SkipCerts = asn1.define('SkipCerts', function() {
699
632
  this.int();
700
633
  });
701
- rfc5280.SkipCerts = SkipCerts;
702
634
 
703
635
  // ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
704
- const ExtendedKeyUsage = asn1.define('ExtendedKeyUsage', function() {
636
+ export const ExtendedKeyUsage = asn1.define('ExtendedKeyUsage', function() {
705
637
  this.seqof(KeyPurposeId);
706
638
  });
707
- rfc5280.ExtendedKeyUsage = ExtendedKeyUsage;
708
639
 
709
640
  // KeyPurposeId ::= OBJECT IDENTIFIER
710
- const KeyPurposeId = asn1.define('KeyPurposeId', function() {
641
+ export const KeyPurposeId = asn1.define('KeyPurposeId', function() {
711
642
  this.objid();
712
643
  });
713
- rfc5280.KeyPurposeId = KeyPurposeId;
714
644
 
715
645
  // RLDistributionPoints ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint
716
- const CRLDistributionPoints = asn1.define('CRLDistributionPoints', function() {
646
+ export const CRLDistributionPoints = asn1.define('CRLDistributionPoints', function() {
717
647
  this.seqof(DistributionPoint);
718
648
  });
719
- rfc5280.CRLDistributionPoints = CRLDistributionPoints;
720
649
 
721
650
  // DistributionPoint ::= SEQUENCE {
722
651
  // distributionPoint [0] DistributionPointName OPTIONAL,
723
652
  // reasons [1] ReasonFlags OPTIONAL,
724
653
  // cRLIssuer [2] GeneralNames OPTIONAL }
725
- const DistributionPoint = asn1.define('DistributionPoint', function() {
654
+ export const DistributionPoint = asn1.define('DistributionPoint', function() {
726
655
  this.seq().obj(
727
656
  this.key('distributionPoint').optional().explicit(0)
728
657
  .use(DistributionPointName),
@@ -730,18 +659,16 @@ const DistributionPoint = asn1.define('DistributionPoint', function() {
730
659
  this.key('cRLIssuer').optional().implicit(2).use(GeneralNames)
731
660
  );
732
661
  });
733
- rfc5280.DistributionPoint = DistributionPoint;
734
662
 
735
663
  // DistributionPointName ::= CHOICE {
736
664
  // fullName [0] GeneralNames,
737
665
  // nameRelativeToCRLIssuer [1] RelativeDistinguishedName }
738
- const DistributionPointName = asn1.define('DistributionPointName', function() {
666
+ export const DistributionPointName = asn1.define('DistributionPointName', function() {
739
667
  this.choice({
740
668
  fullName: this.implicit(0).use(GeneralNames),
741
669
  nameRelativeToCRLIssuer: this.implicit(1).use(RelativeDistinguishedName)
742
670
  });
743
671
  });
744
- rfc5280.DistributionPointName = DistributionPointName;
745
672
 
746
673
  // ReasonFlags ::= BIT STRING {
747
674
  // unused (0),
@@ -753,64 +680,54 @@ rfc5280.DistributionPointName = DistributionPointName;
753
680
  // certificateHold (6),
754
681
  // privilegeWithdrawn (7),
755
682
  // aACompromise (8) }
756
- const ReasonFlags = asn1.define('ReasonFlags', function() {
683
+ export const ReasonFlags = asn1.define('ReasonFlags', function() {
757
684
  this.bitstr();
758
685
  });
759
- rfc5280.ReasonFlags = ReasonFlags;
760
686
 
761
687
  // InhibitAnyPolicy ::= SkipCerts
762
- const InhibitAnyPolicy = asn1.define('InhibitAnyPolicy', function() {
688
+ export const InhibitAnyPolicy = asn1.define('InhibitAnyPolicy', function() {
763
689
  this.use(SkipCerts);
764
690
  });
765
- rfc5280.InhibitAnyPolicy = InhibitAnyPolicy;
766
691
 
767
692
  // FreshestCRL ::= CRLDistributionPoints
768
- const FreshestCRL = asn1.define('FreshestCRL', function() {
693
+ export const FreshestCRL = asn1.define('FreshestCRL', function() {
769
694
  this.use(CRLDistributionPoints);
770
695
  });
771
- rfc5280.FreshestCRL = FreshestCRL;
772
696
 
773
697
  // AuthorityInfoAccessSyntax ::=
774
698
  // SEQUENCE SIZE (1..MAX) OF AccessDescription
775
- const AuthorityInfoAccessSyntax = asn1.define('AuthorityInfoAccessSyntax',
776
- function() {
777
- this.seqof(AccessDescription);
778
- });
779
- rfc5280.AuthorityInfoAccessSyntax = AuthorityInfoAccessSyntax;
699
+ export const AuthorityInfoAccessSyntax = asn1.define('AuthorityInfoAccessSyntax', function() {
700
+ this.seqof(AccessDescription);
701
+ });
780
702
 
781
703
  // AccessDescription ::= SEQUENCE {
782
704
  // accessMethod OBJECT IDENTIFIER,
783
705
  // accessLocation GeneralName }
784
- const AccessDescription = asn1.define('AccessDescription', function() {
706
+ export const AccessDescription = asn1.define('AccessDescription', function() {
785
707
  this.seq().obj(
786
708
  this.key('accessMethod').objid(),
787
709
  this.key('accessLocation').use(GeneralName)
788
710
  );
789
711
  });
790
- rfc5280.AccessDescription = AccessDescription;
791
712
 
792
713
  // SubjectInfoAccessSyntax ::=
793
714
  // SEQUENCE SIZE (1..MAX) OF AccessDescription
794
- const SubjectInformationAccess = asn1.define('SubjectInformationAccess',
795
- function() {
796
- this.seqof(AccessDescription);
797
- });
798
- rfc5280.SubjectInformationAccess = SubjectInformationAccess;
715
+ export const SubjectInformationAccess = asn1.define('SubjectInformationAccess', function() {
716
+ this.seqof(AccessDescription);
717
+ });
799
718
 
800
719
  /**
801
720
  * CRL Extensions
802
721
  */
803
722
 
804
723
  // CRLNumber ::= INTEGER
805
- const CRLNumber = asn1.define('CRLNumber', function() {
724
+ export const CRLNumber = asn1.define('CRLNumber', function() {
806
725
  this.int();
807
726
  });
808
- rfc5280.CRLNumber = CRLNumber;
809
727
 
810
- const DeltaCRLIndicator = asn1.define('DeltaCRLIndicator', function() {
728
+ export const DeltaCRLIndicator = asn1.define('DeltaCRLIndicator', function() {
811
729
  this.use(CRLNumber);
812
730
  });
813
- rfc5280.DeltaCRLIndicator = DeltaCRLIndicator;
814
731
 
815
732
  // IssuingDistributionPoint ::= SEQUENCE {
816
733
  // distributionPoint [0] DistributionPointName OPTIONAL,
@@ -819,7 +736,7 @@ rfc5280.DeltaCRLIndicator = DeltaCRLIndicator;
819
736
  // onlySomeReasons [3] ReasonFlags OPTIONAL,
820
737
  // indirectCRL [4] BOOLEAN DEFAULT FALSE,
821
738
  // onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE }
822
- const IssuingDistributionPoint = asn1.define('IssuingDistributionPoint',
739
+ export const IssuingDistributionPoint = asn1.define('IssuingDistributionPoint',
823
740
  function() {
824
741
  this.seq().obj(
825
742
  this.key('distributionPoint').explicit(0).optional()
@@ -831,7 +748,6 @@ const IssuingDistributionPoint = asn1.define('IssuingDistributionPoint',
831
748
  this.key('onlyContainsAttributeCerts').implicit(5).def(false).bool()
832
749
  );
833
750
  });
834
- rfc5280.IssuingDistributionPoint = IssuingDistributionPoint;
835
751
 
836
752
  // CRLReason ::= ENUMERATED {
837
753
  // unspecified (0),
@@ -845,7 +761,7 @@ rfc5280.IssuingDistributionPoint = IssuingDistributionPoint;
845
761
  // removeFromCRL (8),
846
762
  // privilegeWithdrawn (9),
847
763
  // aACompromise (10) }
848
- const ReasonCode = asn1.define('ReasonCode', function() {
764
+ export const ReasonCode = asn1.define('ReasonCode', function() {
849
765
  this.enum({
850
766
  0: 'unspecified',
851
767
  1: 'keyCompromise',
@@ -859,19 +775,16 @@ const ReasonCode = asn1.define('ReasonCode', function() {
859
775
  10: 'aACompromise'
860
776
  });
861
777
  });
862
- rfc5280.ReasonCode = ReasonCode;
863
778
 
864
779
  // InvalidityDate ::= GeneralizedTime
865
- const InvalidityDate = asn1.define('InvalidityDate', function() {
780
+ export const InvalidityDate = asn1.define('InvalidityDate', function() {
866
781
  this.gentime();
867
782
  });
868
- rfc5280.InvalidityDate = InvalidityDate;
869
783
 
870
784
  // CertificateIssuer ::= GeneralNames
871
- const CertificateIssuer = asn1.define('CertificateIssuer', function() {
785
+ export const CertificateIssuer = asn1.define('CertificateIssuer', function() {
872
786
  this.use(GeneralNames);
873
787
  });
874
- rfc5280.CertificateIssuer = CertificateIssuer;
875
788
 
876
789
  // OID label to extension model mapping
877
790
  const x509Extensions = {