vite 2.8.0-beta.1 → 2.8.0-beta.2

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

Files changed (81) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/node/chunks/dep-0ebab0df.js +0 -1
  3. package/dist/node/chunks/dep-2056ae8a.js +0 -1
  4. package/dist/node/chunks/{dep-fccf00e1.js → dep-8072b56e.js} +146 -480
  5. package/dist/node/chunks/{dep-e4dc9ea2.js → dep-8a5fd784.js} +99 -65
  6. package/dist/node/chunks/{dep-51191982.js → dep-91aeb93b.js} +1 -2
  7. package/dist/node/chunks/{dep-e4a9e288.js → dep-a68f5a28.js} +1 -2
  8. package/dist/node/cli.js +4 -5
  9. package/dist/node/index.js +1 -2
  10. package/package.json +2 -2
  11. package/types/importMeta.d.ts +8 -2
  12. package/dist/node/build.d.ts +0 -200
  13. package/dist/node/certificate.d.ts +0 -2
  14. package/dist/node/chunks/dep-0ebab0df.js.map +0 -1
  15. package/dist/node/chunks/dep-2056ae8a.js.map +0 -1
  16. package/dist/node/chunks/dep-51191982.js.map +0 -1
  17. package/dist/node/chunks/dep-e4a9e288.js.map +0 -1
  18. package/dist/node/chunks/dep-e4dc9ea2.js.map +0 -1
  19. package/dist/node/chunks/dep-fccf00e1.js.map +0 -1
  20. package/dist/node/cli.d.ts +0 -1
  21. package/dist/node/cli.js.map +0 -1
  22. package/dist/node/config.d.ts +0 -227
  23. package/dist/node/constants.d.ts +0 -33
  24. package/dist/node/http.d.ts +0 -88
  25. package/dist/node/importGlob.d.ts +0 -14
  26. package/dist/node/index.js.map +0 -1
  27. package/dist/node/logger.d.ts +0 -35
  28. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  29. package/dist/node/optimizer/index.d.ts +0 -66
  30. package/dist/node/optimizer/registerMissing.d.ts +0 -2
  31. package/dist/node/optimizer/scan.d.ts +0 -9
  32. package/dist/node/packages.d.ts +0 -25
  33. package/dist/node/plugin.d.ts +0 -115
  34. package/dist/node/plugins/asset.d.ts +0 -40
  35. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  36. package/dist/node/plugins/clientInjections.d.ts +0 -7
  37. package/dist/node/plugins/css.d.ts +0 -71
  38. package/dist/node/plugins/dataUri.d.ts +0 -5
  39. package/dist/node/plugins/define.d.ts +0 -3
  40. package/dist/node/plugins/esbuild.d.ts +0 -15
  41. package/dist/node/plugins/html.d.ts +0 -105
  42. package/dist/node/plugins/importAnalysis.d.ts +0 -46
  43. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -15
  44. package/dist/node/plugins/index.d.ts +0 -3
  45. package/dist/node/plugins/json.d.ts +0 -22
  46. package/dist/node/plugins/loadFallback.d.ts +0 -5
  47. package/dist/node/plugins/manifest.d.ts +0 -14
  48. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  49. package/dist/node/plugins/preAlias.d.ts +0 -5
  50. package/dist/node/plugins/reporter.d.ts +0 -3
  51. package/dist/node/plugins/resolve.d.ts +0 -38
  52. package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
  53. package/dist/node/plugins/terser.d.ts +0 -3
  54. package/dist/node/plugins/wasm.d.ts +0 -3
  55. package/dist/node/plugins/worker.d.ts +0 -5
  56. package/dist/node/plugins/workerImportMetaUrl.d.ts +0 -3
  57. package/dist/node/preview.d.ts +0 -31
  58. package/dist/node/server/hmr.d.ts +0 -37
  59. package/dist/node/server/index.d.ts +0 -222
  60. package/dist/node/server/middlewares/base.d.ts +0 -3
  61. package/dist/node/server/middlewares/error.d.ts +0 -8
  62. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  63. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  64. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  65. package/dist/node/server/middlewares/static.d.ts +0 -6
  66. package/dist/node/server/middlewares/time.d.ts +0 -2
  67. package/dist/node/server/middlewares/transform.d.ts +0 -3
  68. package/dist/node/server/moduleGraph.d.ts +0 -53
  69. package/dist/node/server/openBrowser.d.ts +0 -15
  70. package/dist/node/server/pluginContainer.d.ts +0 -37
  71. package/dist/node/server/searchRoot.d.ts +0 -8
  72. package/dist/node/server/send.d.ts +0 -10
  73. package/dist/node/server/sourcemap.d.ts +0 -8
  74. package/dist/node/server/transformRequest.d.ts +0 -14
  75. package/dist/node/server/ws.d.ts +0 -14
  76. package/dist/node/ssr/ssrExternal.d.ts +0 -7
  77. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  78. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
  79. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  80. package/dist/node/ssr/ssrTransform.d.ts +0 -8
  81. package/dist/node/utils.d.ts +0 -115
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var build = require('./dep-e4dc9ea2.js');
3
+ var build = require('./dep-8a5fd784.js');
4
4
  var require$$1 = require('crypto');
5
5
  require('fs');
6
6
  require('path');
@@ -2495,261 +2495,6 @@ util$1.clearItems = function(api, id, location) {
2495
2495
  _callStorageFunction(_clearItems, arguments, location);
2496
2496
  };
2497
2497
 
2498
- /**
2499
- * Parses the scheme, host, and port from an http(s) url.
2500
- *
2501
- * @param str the url string.
2502
- *
2503
- * @return the parsed url object or null if the url is invalid.
2504
- */
2505
- util$1.parseUrl = function(str) {
2506
- // FIXME: this regex looks a bit broken
2507
- var regex = /^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;
2508
- regex.lastIndex = 0;
2509
- var m = regex.exec(str);
2510
- var url = (m === null) ? null : {
2511
- full: str,
2512
- scheme: m[1],
2513
- host: m[2],
2514
- port: m[3],
2515
- path: m[4]
2516
- };
2517
- if(url) {
2518
- url.fullHost = url.host;
2519
- if(url.port) {
2520
- if(url.port !== 80 && url.scheme === 'http') {
2521
- url.fullHost += ':' + url.port;
2522
- } else if(url.port !== 443 && url.scheme === 'https') {
2523
- url.fullHost += ':' + url.port;
2524
- }
2525
- } else if(url.scheme === 'http') {
2526
- url.port = 80;
2527
- } else if(url.scheme === 'https') {
2528
- url.port = 443;
2529
- }
2530
- url.full = url.scheme + '://' + url.fullHost;
2531
- }
2532
- return url;
2533
- };
2534
-
2535
- /* Storage for query variables */
2536
- var _queryVariables = null;
2537
-
2538
- /**
2539
- * Returns the window location query variables. Query is parsed on the first
2540
- * call and the same object is returned on subsequent calls. The mapping
2541
- * is from keys to an array of values. Parameters without values will have
2542
- * an object key set but no value added to the value array. Values are
2543
- * unescaped.
2544
- *
2545
- * ...?k1=v1&k2=v2:
2546
- * {
2547
- * "k1": ["v1"],
2548
- * "k2": ["v2"]
2549
- * }
2550
- *
2551
- * ...?k1=v1&k1=v2:
2552
- * {
2553
- * "k1": ["v1", "v2"]
2554
- * }
2555
- *
2556
- * ...?k1=v1&k2:
2557
- * {
2558
- * "k1": ["v1"],
2559
- * "k2": []
2560
- * }
2561
- *
2562
- * ...?k1=v1&k1:
2563
- * {
2564
- * "k1": ["v1"]
2565
- * }
2566
- *
2567
- * ...?k1&k1:
2568
- * {
2569
- * "k1": []
2570
- * }
2571
- *
2572
- * @param query the query string to parse (optional, default to cached
2573
- * results from parsing window location search query).
2574
- *
2575
- * @return object mapping keys to variables.
2576
- */
2577
- util$1.getQueryVariables = function(query) {
2578
- var parse = function(q) {
2579
- var rval = {};
2580
- var kvpairs = q.split('&');
2581
- for(var i = 0; i < kvpairs.length; i++) {
2582
- var pos = kvpairs[i].indexOf('=');
2583
- var key;
2584
- var val;
2585
- if(pos > 0) {
2586
- key = kvpairs[i].substring(0, pos);
2587
- val = kvpairs[i].substring(pos + 1);
2588
- } else {
2589
- key = kvpairs[i];
2590
- val = null;
2591
- }
2592
- if(!(key in rval)) {
2593
- rval[key] = [];
2594
- }
2595
- // disallow overriding object prototype keys
2596
- if(!(key in Object.prototype) && val !== null) {
2597
- rval[key].push(unescape(val));
2598
- }
2599
- }
2600
- return rval;
2601
- };
2602
-
2603
- var rval;
2604
- if(typeof(query) === 'undefined') {
2605
- // set cached variables if needed
2606
- if(_queryVariables === null) {
2607
- if(typeof(window) !== 'undefined' && window.location && window.location.search) {
2608
- // parse window search query
2609
- _queryVariables = parse(window.location.search.substring(1));
2610
- } else {
2611
- // no query variables available
2612
- _queryVariables = {};
2613
- }
2614
- }
2615
- rval = _queryVariables;
2616
- } else {
2617
- // parse given query
2618
- rval = parse(query);
2619
- }
2620
- return rval;
2621
- };
2622
-
2623
- /**
2624
- * Parses a fragment into a path and query. This method will take a URI
2625
- * fragment and break it up as if it were the main URI. For example:
2626
- * /bar/baz?a=1&b=2
2627
- * results in:
2628
- * {
2629
- * path: ["bar", "baz"],
2630
- * query: {"k1": ["v1"], "k2": ["v2"]}
2631
- * }
2632
- *
2633
- * @return object with a path array and query object.
2634
- */
2635
- util$1.parseFragment = function(fragment) {
2636
- // default to whole fragment
2637
- var fp = fragment;
2638
- var fq = '';
2639
- // split into path and query if possible at the first '?'
2640
- var pos = fragment.indexOf('?');
2641
- if(pos > 0) {
2642
- fp = fragment.substring(0, pos);
2643
- fq = fragment.substring(pos + 1);
2644
- }
2645
- // split path based on '/' and ignore first element if empty
2646
- var path = fp.split('/');
2647
- if(path.length > 0 && path[0] === '') {
2648
- path.shift();
2649
- }
2650
- // convert query into object
2651
- var query = (fq === '') ? {} : util$1.getQueryVariables(fq);
2652
-
2653
- return {
2654
- pathString: fp,
2655
- queryString: fq,
2656
- path: path,
2657
- query: query
2658
- };
2659
- };
2660
-
2661
- /**
2662
- * Makes a request out of a URI-like request string. This is intended to
2663
- * be used where a fragment id (after a URI '#') is parsed as a URI with
2664
- * path and query parts. The string should have a path beginning and
2665
- * delimited by '/' and optional query parameters following a '?'. The
2666
- * query should be a standard URL set of key value pairs delimited by
2667
- * '&'. For backwards compatibility the initial '/' on the path is not
2668
- * required. The request object has the following API, (fully described
2669
- * in the method code):
2670
- * {
2671
- * path: <the path string part>.
2672
- * query: <the query string part>,
2673
- * getPath(i): get part or all of the split path array,
2674
- * getQuery(k, i): get part or all of a query key array,
2675
- * getQueryLast(k, _default): get last element of a query key array.
2676
- * }
2677
- *
2678
- * @return object with request parameters.
2679
- */
2680
- util$1.makeRequest = function(reqString) {
2681
- var frag = util$1.parseFragment(reqString);
2682
- var req = {
2683
- // full path string
2684
- path: frag.pathString,
2685
- // full query string
2686
- query: frag.queryString,
2687
- /**
2688
- * Get path or element in path.
2689
- *
2690
- * @param i optional path index.
2691
- *
2692
- * @return path or part of path if i provided.
2693
- */
2694
- getPath: function(i) {
2695
- return (typeof(i) === 'undefined') ? frag.path : frag.path[i];
2696
- },
2697
- /**
2698
- * Get query, values for a key, or value for a key index.
2699
- *
2700
- * @param k optional query key.
2701
- * @param i optional query key index.
2702
- *
2703
- * @return query, values for a key, or value for a key index.
2704
- */
2705
- getQuery: function(k, i) {
2706
- var rval;
2707
- if(typeof(k) === 'undefined') {
2708
- rval = frag.query;
2709
- } else {
2710
- rval = frag.query[k];
2711
- if(rval && typeof(i) !== 'undefined') {
2712
- rval = rval[i];
2713
- }
2714
- }
2715
- return rval;
2716
- },
2717
- getQueryLast: function(k, _default) {
2718
- var rval;
2719
- var vals = req.getQuery(k);
2720
- if(vals) {
2721
- rval = vals[vals.length - 1];
2722
- } else {
2723
- rval = _default;
2724
- }
2725
- return rval;
2726
- }
2727
- };
2728
- return req;
2729
- };
2730
-
2731
- /**
2732
- * Makes a URI out of a path, an object with query parameters, and a
2733
- * fragment. Uses jQuery.param() internally for query string creation.
2734
- * If the path is an array, it will be joined with '/'.
2735
- *
2736
- * @param path string path or array of strings.
2737
- * @param query object with query parameters. (optional)
2738
- * @param fragment fragment string. (optional)
2739
- *
2740
- * @return string object with request parameters.
2741
- */
2742
- util$1.makeLink = function(path, query, fragment) {
2743
- // join path parts if needed
2744
- path = jQuery.isArray(path) ? path.join('/') : path;
2745
-
2746
- var qstr = jQuery.param(query || {});
2747
- fragment = fragment || '';
2748
- return path +
2749
- ((qstr.length > 0) ? ('?' + qstr) : '') +
2750
- ((fragment.length > 0) ? ('#' + fragment) : '');
2751
- };
2752
-
2753
2498
  /**
2754
2499
  * Check if an object is empty.
2755
2500
  *
@@ -3187,6 +2932,8 @@ _IN('1.2.840.10040.4.3', 'dsa-with-sha1');
3187
2932
  _IN('1.3.14.3.2.7', 'desCBC');
3188
2933
 
3189
2934
  _IN('1.3.14.3.2.26', 'sha1');
2935
+ // Deprecated equivalent of sha1WithRSAEncryption
2936
+ _IN('1.3.14.3.2.29', 'sha1WithRSASignature');
3190
2937
  _IN('2.16.840.1.101.3.4.2.1', 'sha256');
3191
2938
  _IN('2.16.840.1.101.3.4.2.2', 'sha384');
3192
2939
  _IN('2.16.840.1.101.3.4.2.3', 'sha512');
@@ -3249,16 +2996,19 @@ _IN('2.16.840.1.101.3.4.1.42', 'aes256-CBC');
3249
2996
 
3250
2997
  // certificate issuer/subject OIDs
3251
2998
  _IN('2.5.4.3', 'commonName');
3252
- _IN('2.5.4.5', 'serialName');
2999
+ _IN('2.5.4.4', 'surname');
3000
+ _IN('2.5.4.5', 'serialNumber');
3253
3001
  _IN('2.5.4.6', 'countryName');
3254
3002
  _IN('2.5.4.7', 'localityName');
3255
3003
  _IN('2.5.4.8', 'stateOrProvinceName');
3256
3004
  _IN('2.5.4.9', 'streetAddress');
3257
3005
  _IN('2.5.4.10', 'organizationName');
3258
3006
  _IN('2.5.4.11', 'organizationalUnitName');
3007
+ _IN('2.5.4.12', 'title');
3259
3008
  _IN('2.5.4.13', 'description');
3260
3009
  _IN('2.5.4.15', 'businessCategory');
3261
3010
  _IN('2.5.4.17', 'postalCode');
3011
+ _IN('2.5.4.42', 'givenName');
3262
3012
  _IN('1.3.6.1.4.1.311.60.2.1.2', 'jurisdictionOfIncorporationStateOrProvinceName');
3263
3013
  _IN('1.3.6.1.4.1.311.60.2.1.3', 'jurisdictionOfIncorporationCountryName');
3264
3014
 
@@ -8030,8 +7780,15 @@ pem.decode = function(str) {
8030
7780
  break;
8031
7781
  }
8032
7782
 
7783
+ // accept "NEW CERTIFICATE REQUEST" as "CERTIFICATE REQUEST"
7784
+ // https://datatracker.ietf.org/doc/html/rfc7468#section-7
7785
+ var type = match[1];
7786
+ if(type === 'NEW CERTIFICATE REQUEST') {
7787
+ type = 'CERTIFICATE REQUEST';
7788
+ }
7789
+
8033
7790
  var msg = {
8034
- type: match[1],
7791
+ type: type,
8035
7792
  procType: null,
8036
7793
  contentDomain: null,
8037
7794
  dekInfo: null,
@@ -8802,7 +8559,7 @@ prng.create = function(plugin) {
8802
8559
  // throw in more pseudo random
8803
8560
  next = seed >>> (i << 3);
8804
8561
  next ^= Math.floor(Math.random() * 0x0100);
8805
- b.putByte(String.fromCharCode(next & 0xFF));
8562
+ b.putByte(next & 0xFF);
8806
8563
  }
8807
8564
  }
8808
8565
  }
@@ -14886,7 +14643,8 @@ p7v.recipientInfoValidator = {
14886
14643
  name: 'RecipientInfo.keyEncryptionAlgorithm.parameter',
14887
14644
  tagClass: asn1$3.Class.UNIVERSAL,
14888
14645
  constructed: false,
14889
- captureAsn1: 'encParameter'
14646
+ captureAsn1: 'encParameter',
14647
+ optional: true
14890
14648
  }]
14891
14649
  }, {
14892
14650
  name: 'RecipientInfo.encryptedKey',
@@ -15905,6 +15663,101 @@ var _readSignatureParameters = function(oid, obj, fillDefaults) {
15905
15663
  return params;
15906
15664
  };
15907
15665
 
15666
+ /**
15667
+ * Create signature digest for OID.
15668
+ *
15669
+ * @param options
15670
+ * signatureOid: the OID specifying the signature algorithm.
15671
+ * type: a human readable type for error messages
15672
+ * @return a created md instance. throws if unknown oid.
15673
+ */
15674
+ var _createSignatureDigest = function(options) {
15675
+ switch(oids[options.signatureOid]) {
15676
+ case 'sha1WithRSAEncryption':
15677
+ // deprecated alias
15678
+ case 'sha1WithRSASignature':
15679
+ return forge$2.md.sha1.create();
15680
+ case 'md5WithRSAEncryption':
15681
+ return forge$2.md.md5.create();
15682
+ case 'sha256WithRSAEncryption':
15683
+ return forge$2.md.sha256.create();
15684
+ case 'sha384WithRSAEncryption':
15685
+ return forge$2.md.sha384.create();
15686
+ case 'sha512WithRSAEncryption':
15687
+ return forge$2.md.sha512.create();
15688
+ case 'RSASSA-PSS':
15689
+ return forge$2.md.sha256.create();
15690
+ default:
15691
+ var error = new Error(
15692
+ 'Could not compute ' + options.type + ' digest. ' +
15693
+ 'Unknown signature OID.');
15694
+ error.signatureOid = options.signatureOid;
15695
+ throw error;
15696
+ }
15697
+ };
15698
+
15699
+ /**
15700
+ * Verify signature on certificate or CSR.
15701
+ *
15702
+ * @param options:
15703
+ * certificate the certificate or CSR to verify.
15704
+ * md the signature digest.
15705
+ * signature the signature
15706
+ * @return a created md instance. throws if unknown oid.
15707
+ */
15708
+ var _verifySignature = function(options) {
15709
+ var cert = options.certificate;
15710
+ var scheme;
15711
+
15712
+ switch(cert.signatureOid) {
15713
+ case oids.sha1WithRSAEncryption:
15714
+ // deprecated alias
15715
+ case oids.sha1WithRSASignature:
15716
+ /* use PKCS#1 v1.5 padding scheme */
15717
+ break;
15718
+ case oids['RSASSA-PSS']:
15719
+ var hash, mgf;
15720
+
15721
+ /* initialize mgf */
15722
+ hash = oids[cert.signatureParameters.mgf.hash.algorithmOid];
15723
+ if(hash === undefined || forge$2.md[hash] === undefined) {
15724
+ var error = new Error('Unsupported MGF hash function.');
15725
+ error.oid = cert.signatureParameters.mgf.hash.algorithmOid;
15726
+ error.name = hash;
15727
+ throw error;
15728
+ }
15729
+
15730
+ mgf = oids[cert.signatureParameters.mgf.algorithmOid];
15731
+ if(mgf === undefined || forge$2.mgf[mgf] === undefined) {
15732
+ var error = new Error('Unsupported MGF function.');
15733
+ error.oid = cert.signatureParameters.mgf.algorithmOid;
15734
+ error.name = mgf;
15735
+ throw error;
15736
+ }
15737
+
15738
+ mgf = forge$2.mgf[mgf].create(forge$2.md[hash].create());
15739
+
15740
+ /* initialize hash function */
15741
+ hash = oids[cert.signatureParameters.hash.algorithmOid];
15742
+ if(hash === undefined || forge$2.md[hash] === undefined) {
15743
+ var error = new Error('Unsupported RSASSA-PSS hash function.');
15744
+ error.oid = cert.signatureParameters.hash.algorithmOid;
15745
+ error.name = hash;
15746
+ throw error;
15747
+ }
15748
+
15749
+ scheme = forge$2.pss.create(
15750
+ forge$2.md[hash].create(), mgf, cert.signatureParameters.saltLength
15751
+ );
15752
+ break;
15753
+ }
15754
+
15755
+ // verify signature on cert using public key
15756
+ return cert.publicKey.verify(
15757
+ options.md.digest().getBytes(), options.signature, scheme
15758
+ );
15759
+ };
15760
+
15908
15761
  /**
15909
15762
  * Converts an X.509 certificate from PEM format.
15910
15763
  *
@@ -16285,43 +16138,18 @@ pki$2.createCertificate = function() {
16285
16138
  'The parent certificate did not issue the given child ' +
16286
16139
  'certificate; the child certificate\'s issuer does not match the ' +
16287
16140
  'parent\'s subject.');
16288
- error.expectedIssuer = issuer.attributes;
16289
- error.actualIssuer = subject.attributes;
16141
+ error.expectedIssuer = subject.attributes;
16142
+ error.actualIssuer = issuer.attributes;
16290
16143
  throw error;
16291
16144
  }
16292
16145
 
16293
16146
  var md = child.md;
16294
16147
  if(md === null) {
16295
- // check signature OID for supported signature types
16296
- if(child.signatureOid in oids) {
16297
- var oid = oids[child.signatureOid];
16298
- switch(oid) {
16299
- case 'sha1WithRSAEncryption':
16300
- md = forge$2.md.sha1.create();
16301
- break;
16302
- case 'md5WithRSAEncryption':
16303
- md = forge$2.md.md5.create();
16304
- break;
16305
- case 'sha256WithRSAEncryption':
16306
- md = forge$2.md.sha256.create();
16307
- break;
16308
- case 'sha384WithRSAEncryption':
16309
- md = forge$2.md.sha384.create();
16310
- break;
16311
- case 'sha512WithRSAEncryption':
16312
- md = forge$2.md.sha512.create();
16313
- break;
16314
- case 'RSASSA-PSS':
16315
- md = forge$2.md.sha256.create();
16316
- break;
16317
- }
16318
- }
16319
- if(md === null) {
16320
- var error = new Error('Could not compute certificate digest. ' +
16321
- 'Unknown signature OID.');
16322
- error.signatureOid = child.signatureOid;
16323
- throw error;
16324
- }
16148
+ // create digest for OID signature types
16149
+ md = _createSignatureDigest({
16150
+ signatureOid: child.signatureOid,
16151
+ type: 'certificate'
16152
+ });
16325
16153
 
16326
16154
  // produce DER formatted TBSCertificate and digest it
16327
16155
  var tbsCertificate = child.tbsCertificate || pki$2.getTBSCertificate(child);
@@ -16330,52 +16158,9 @@ pki$2.createCertificate = function() {
16330
16158
  }
16331
16159
 
16332
16160
  if(md !== null) {
16333
- var scheme;
16334
-
16335
- switch(child.signatureOid) {
16336
- case oids.sha1WithRSAEncryption:
16337
- scheme = undefined; /* use PKCS#1 v1.5 padding scheme */
16338
- break;
16339
- case oids['RSASSA-PSS']:
16340
- var hash, mgf;
16341
-
16342
- /* initialize mgf */
16343
- hash = oids[child.signatureParameters.mgf.hash.algorithmOid];
16344
- if(hash === undefined || forge$2.md[hash] === undefined) {
16345
- var error = new Error('Unsupported MGF hash function.');
16346
- error.oid = child.signatureParameters.mgf.hash.algorithmOid;
16347
- error.name = hash;
16348
- throw error;
16349
- }
16350
-
16351
- mgf = oids[child.signatureParameters.mgf.algorithmOid];
16352
- if(mgf === undefined || forge$2.mgf[mgf] === undefined) {
16353
- var error = new Error('Unsupported MGF function.');
16354
- error.oid = child.signatureParameters.mgf.algorithmOid;
16355
- error.name = mgf;
16356
- throw error;
16357
- }
16358
-
16359
- mgf = forge$2.mgf[mgf].create(forge$2.md[hash].create());
16360
-
16361
- /* initialize hash function */
16362
- hash = oids[child.signatureParameters.hash.algorithmOid];
16363
- if(hash === undefined || forge$2.md[hash] === undefined) {
16364
- throw {
16365
- message: 'Unsupported RSASSA-PSS hash function.',
16366
- oid: child.signatureParameters.hash.algorithmOid,
16367
- name: hash
16368
- };
16369
- }
16370
-
16371
- scheme = forge$2.pss.create(forge$2.md[hash].create(), mgf,
16372
- child.signatureParameters.saltLength);
16373
- break;
16374
- }
16375
-
16376
- // verify signature on cert using public key
16377
- rval = cert.publicKey.verify(
16378
- md.digest().getBytes(), child.signature, scheme);
16161
+ rval = _verifySignature({
16162
+ certificate: cert, md: md, signature: child.signature
16163
+ });
16379
16164
  }
16380
16165
 
16381
16166
  return rval;
@@ -16549,37 +16334,11 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16549
16334
  cert.tbsCertificate = capture.tbsCertificate;
16550
16335
 
16551
16336
  if(computeHash) {
16552
- // check signature OID for supported signature types
16553
- cert.md = null;
16554
- if(cert.signatureOid in oids) {
16555
- var oid = oids[cert.signatureOid];
16556
- switch(oid) {
16557
- case 'sha1WithRSAEncryption':
16558
- cert.md = forge$2.md.sha1.create();
16559
- break;
16560
- case 'md5WithRSAEncryption':
16561
- cert.md = forge$2.md.md5.create();
16562
- break;
16563
- case 'sha256WithRSAEncryption':
16564
- cert.md = forge$2.md.sha256.create();
16565
- break;
16566
- case 'sha384WithRSAEncryption':
16567
- cert.md = forge$2.md.sha384.create();
16568
- break;
16569
- case 'sha512WithRSAEncryption':
16570
- cert.md = forge$2.md.sha512.create();
16571
- break;
16572
- case 'RSASSA-PSS':
16573
- cert.md = forge$2.md.sha256.create();
16574
- break;
16575
- }
16576
- }
16577
- if(cert.md === null) {
16578
- var error = new Error('Could not compute certificate digest. ' +
16579
- 'Unknown signature OID.');
16580
- error.signatureOid = cert.signatureOid;
16581
- throw error;
16582
- }
16337
+ // create digest for OID signature type
16338
+ cert.md = _createSignatureDigest({
16339
+ signatureOid: cert.signatureOid,
16340
+ type: 'certificate'
16341
+ });
16583
16342
 
16584
16343
  // produce DER formatted TBSCertificate and digest it
16585
16344
  var bytes = asn1$2.toDer(cert.tbsCertificate);
@@ -16588,6 +16347,8 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16588
16347
 
16589
16348
  // handle issuer, build issuer message digest
16590
16349
  var imd = forge$2.md.sha1.create();
16350
+ var ibytes = asn1$2.toDer(capture.certIssuer);
16351
+ imd.update(ibytes.getBytes());
16591
16352
  cert.issuer.getField = function(sn) {
16592
16353
  return _getAttribute(cert.issuer, sn);
16593
16354
  };
@@ -16595,7 +16356,7 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16595
16356
  _fillMissingFields([attr]);
16596
16357
  cert.issuer.attributes.push(attr);
16597
16358
  };
16598
- cert.issuer.attributes = pki$2.RDNAttributesAsArray(capture.certIssuer, imd);
16359
+ cert.issuer.attributes = pki$2.RDNAttributesAsArray(capture.certIssuer);
16599
16360
  if(capture.certIssuerUniqueId) {
16600
16361
  cert.issuer.uniqueId = capture.certIssuerUniqueId;
16601
16362
  }
@@ -16603,6 +16364,8 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16603
16364
 
16604
16365
  // handle subject, build subject message digest
16605
16366
  var smd = forge$2.md.sha1.create();
16367
+ var sbytes = asn1$2.toDer(capture.certSubject);
16368
+ smd.update(sbytes.getBytes());
16606
16369
  cert.subject.getField = function(sn) {
16607
16370
  return _getAttribute(cert.subject, sn);
16608
16371
  };
@@ -16610,7 +16373,7 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16610
16373
  _fillMissingFields([attr]);
16611
16374
  cert.subject.attributes.push(attr);
16612
16375
  };
16613
- cert.subject.attributes = pki$2.RDNAttributesAsArray(capture.certSubject, smd);
16376
+ cert.subject.attributes = pki$2.RDNAttributesAsArray(capture.certSubject);
16614
16377
  if(capture.certSubjectUniqueId) {
16615
16378
  cert.subject.uniqueId = capture.certSubjectUniqueId;
16616
16379
  }
@@ -16892,37 +16655,11 @@ pki$2.certificationRequestFromAsn1 = function(obj, computeHash) {
16892
16655
  csr.certificationRequestInfo = capture.certificationRequestInfo;
16893
16656
 
16894
16657
  if(computeHash) {
16895
- // check signature OID for supported signature types
16896
- csr.md = null;
16897
- if(csr.signatureOid in oids) {
16898
- var oid = oids[csr.signatureOid];
16899
- switch(oid) {
16900
- case 'sha1WithRSAEncryption':
16901
- csr.md = forge$2.md.sha1.create();
16902
- break;
16903
- case 'md5WithRSAEncryption':
16904
- csr.md = forge$2.md.md5.create();
16905
- break;
16906
- case 'sha256WithRSAEncryption':
16907
- csr.md = forge$2.md.sha256.create();
16908
- break;
16909
- case 'sha384WithRSAEncryption':
16910
- csr.md = forge$2.md.sha384.create();
16911
- break;
16912
- case 'sha512WithRSAEncryption':
16913
- csr.md = forge$2.md.sha512.create();
16914
- break;
16915
- case 'RSASSA-PSS':
16916
- csr.md = forge$2.md.sha256.create();
16917
- break;
16918
- }
16919
- }
16920
- if(csr.md === null) {
16921
- var error = new Error('Could not compute certification request digest. ' +
16922
- 'Unknown signature OID.');
16923
- error.signatureOid = csr.signatureOid;
16924
- throw error;
16925
- }
16658
+ // create digest for OID signature type
16659
+ csr.md = _createSignatureDigest({
16660
+ signatureOid: csr.signatureOid,
16661
+ type: 'certification request'
16662
+ });
16926
16663
 
16927
16664
  // produce DER formatted CertificationRequestInfo and digest it
16928
16665
  var bytes = asn1$2.toDer(csr.certificationRequestInfo);
@@ -17062,38 +16799,10 @@ pki$2.createCertificationRequest = function() {
17062
16799
 
17063
16800
  var md = csr.md;
17064
16801
  if(md === null) {
17065
- // check signature OID for supported signature types
17066
- if(csr.signatureOid in oids) {
17067
- // TODO: create DRY `OID to md` function
17068
- var oid = oids[csr.signatureOid];
17069
- switch(oid) {
17070
- case 'sha1WithRSAEncryption':
17071
- md = forge$2.md.sha1.create();
17072
- break;
17073
- case 'md5WithRSAEncryption':
17074
- md = forge$2.md.md5.create();
17075
- break;
17076
- case 'sha256WithRSAEncryption':
17077
- md = forge$2.md.sha256.create();
17078
- break;
17079
- case 'sha384WithRSAEncryption':
17080
- md = forge$2.md.sha384.create();
17081
- break;
17082
- case 'sha512WithRSAEncryption':
17083
- md = forge$2.md.sha512.create();
17084
- break;
17085
- case 'RSASSA-PSS':
17086
- md = forge$2.md.sha256.create();
17087
- break;
17088
- }
17089
- }
17090
- if(md === null) {
17091
- var error = new Error(
17092
- 'Could not compute certification request digest. ' +
17093
- 'Unknown signature OID.');
17094
- error.signatureOid = csr.signatureOid;
17095
- throw error;
17096
- }
16802
+ md = _createSignatureDigest({
16803
+ signatureOid: csr.signatureOid,
16804
+ type: 'certification request'
16805
+ });
17097
16806
 
17098
16807
  // produce DER formatted CertificationRequestInfo and digest it
17099
16808
  var cri = csr.certificationRequestInfo ||
@@ -17103,51 +16812,9 @@ pki$2.createCertificationRequest = function() {
17103
16812
  }
17104
16813
 
17105
16814
  if(md !== null) {
17106
- var scheme;
17107
-
17108
- switch(csr.signatureOid) {
17109
- case oids.sha1WithRSAEncryption:
17110
- /* use PKCS#1 v1.5 padding scheme */
17111
- break;
17112
- case oids['RSASSA-PSS']:
17113
- var hash, mgf;
17114
-
17115
- /* initialize mgf */
17116
- hash = oids[csr.signatureParameters.mgf.hash.algorithmOid];
17117
- if(hash === undefined || forge$2.md[hash] === undefined) {
17118
- var error = new Error('Unsupported MGF hash function.');
17119
- error.oid = csr.signatureParameters.mgf.hash.algorithmOid;
17120
- error.name = hash;
17121
- throw error;
17122
- }
17123
-
17124
- mgf = oids[csr.signatureParameters.mgf.algorithmOid];
17125
- if(mgf === undefined || forge$2.mgf[mgf] === undefined) {
17126
- var error = new Error('Unsupported MGF function.');
17127
- error.oid = csr.signatureParameters.mgf.algorithmOid;
17128
- error.name = mgf;
17129
- throw error;
17130
- }
17131
-
17132
- mgf = forge$2.mgf[mgf].create(forge$2.md[hash].create());
17133
-
17134
- /* initialize hash function */
17135
- hash = oids[csr.signatureParameters.hash.algorithmOid];
17136
- if(hash === undefined || forge$2.md[hash] === undefined) {
17137
- var error = new Error('Unsupported RSASSA-PSS hash function.');
17138
- error.oid = csr.signatureParameters.hash.algorithmOid;
17139
- error.name = hash;
17140
- throw error;
17141
- }
17142
-
17143
- scheme = forge$2.pss.create(forge$2.md[hash].create(), mgf,
17144
- csr.signatureParameters.saltLength);
17145
- break;
17146
- }
17147
-
17148
- // verify signature on csr using its public key
17149
- rval = csr.publicKey.verify(
17150
- md.digest().getBytes(), csr.signature, scheme);
16815
+ rval = _verifySignature({
16816
+ certificate: csr, md: md, signature: csr.signature
16817
+ });
17151
16818
  }
17152
16819
 
17153
16820
  return rval;
@@ -19811,4 +19478,3 @@ function createCertificate() {
19811
19478
  }
19812
19479
 
19813
19480
  exports.createCertificate = createCertificate;
19814
- //# sourceMappingURL=dep-fccf00e1.js.map