vite 2.8.0-beta.0 → 2.8.0-beta.4

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 (87) hide show
  1. package/CHANGELOG.md +79 -1
  2. package/LICENSE.md +34 -54
  3. package/bin/vite.js +3 -1
  4. package/client.d.ts +4 -0
  5. package/dist/client/client.mjs +10 -5
  6. package/dist/client/client.mjs.map +1 -1
  7. package/dist/node/chunks/dep-0ebab0df.js +0 -1
  8. package/dist/node/chunks/dep-2056ae8a.js +0 -1
  9. package/dist/node/chunks/{dep-7cd25957.js → dep-2451c479.js} +1 -2
  10. package/dist/node/chunks/{dep-372aad6a.js → dep-4ef300ce.js} +1 -2
  11. package/dist/node/chunks/{dep-920a704a.js → dep-778bed46.js} +147 -482
  12. package/dist/node/chunks/{dep-5ad1713b.js → dep-7b4d034a.js} +3065 -2361
  13. package/dist/node/cli.js +4 -6
  14. package/dist/node/index.d.ts +10 -1
  15. package/dist/node/index.js +1 -3
  16. package/package.json +6 -6
  17. package/src/client/client.ts +12 -6
  18. package/types/importMeta.d.ts +17 -2
  19. package/dist/node/build.d.ts +0 -200
  20. package/dist/node/certificate.d.ts +0 -2
  21. package/dist/node/chunks/dep-0ebab0df.js.map +0 -1
  22. package/dist/node/chunks/dep-2056ae8a.js.map +0 -1
  23. package/dist/node/chunks/dep-372aad6a.js.map +0 -1
  24. package/dist/node/chunks/dep-5ad1713b.js.map +0 -1
  25. package/dist/node/chunks/dep-7cd25957.js.map +0 -1
  26. package/dist/node/chunks/dep-920a704a.js.map +0 -1
  27. package/dist/node/cli.d.ts +0 -1
  28. package/dist/node/cli.js.map +0 -1
  29. package/dist/node/config.d.ts +0 -221
  30. package/dist/node/constants.d.ts +0 -33
  31. package/dist/node/http.d.ts +0 -88
  32. package/dist/node/importGlob.d.ts +0 -14
  33. package/dist/node/index.js.map +0 -1
  34. package/dist/node/logger.d.ts +0 -35
  35. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  36. package/dist/node/optimizer/index.d.ts +0 -66
  37. package/dist/node/optimizer/registerMissing.d.ts +0 -2
  38. package/dist/node/optimizer/scan.d.ts +0 -9
  39. package/dist/node/packages.d.ts +0 -25
  40. package/dist/node/plugin.d.ts +0 -115
  41. package/dist/node/plugins/asset.d.ts +0 -40
  42. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  43. package/dist/node/plugins/clientInjections.d.ts +0 -7
  44. package/dist/node/plugins/css.d.ts +0 -70
  45. package/dist/node/plugins/dataUri.d.ts +0 -5
  46. package/dist/node/plugins/define.d.ts +0 -3
  47. package/dist/node/plugins/esbuild.d.ts +0 -15
  48. package/dist/node/plugins/html.d.ts +0 -103
  49. package/dist/node/plugins/importAnalysis.d.ts +0 -46
  50. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -15
  51. package/dist/node/plugins/index.d.ts +0 -3
  52. package/dist/node/plugins/json.d.ts +0 -22
  53. package/dist/node/plugins/loadFallback.d.ts +0 -5
  54. package/dist/node/plugins/manifest.d.ts +0 -14
  55. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  56. package/dist/node/plugins/preAlias.d.ts +0 -5
  57. package/dist/node/plugins/reporter.d.ts +0 -3
  58. package/dist/node/plugins/resolve.d.ts +0 -38
  59. package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
  60. package/dist/node/plugins/terser.d.ts +0 -3
  61. package/dist/node/plugins/wasm.d.ts +0 -3
  62. package/dist/node/plugins/worker.d.ts +0 -3
  63. package/dist/node/preview.d.ts +0 -31
  64. package/dist/node/server/hmr.d.ts +0 -37
  65. package/dist/node/server/index.d.ts +0 -222
  66. package/dist/node/server/middlewares/base.d.ts +0 -3
  67. package/dist/node/server/middlewares/error.d.ts +0 -8
  68. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  69. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  70. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  71. package/dist/node/server/middlewares/static.d.ts +0 -6
  72. package/dist/node/server/middlewares/time.d.ts +0 -2
  73. package/dist/node/server/middlewares/transform.d.ts +0 -3
  74. package/dist/node/server/moduleGraph.d.ts +0 -53
  75. package/dist/node/server/openBrowser.d.ts +0 -15
  76. package/dist/node/server/pluginContainer.d.ts +0 -37
  77. package/dist/node/server/searchRoot.d.ts +0 -8
  78. package/dist/node/server/send.d.ts +0 -10
  79. package/dist/node/server/sourcemap.d.ts +0 -8
  80. package/dist/node/server/transformRequest.d.ts +0 -14
  81. package/dist/node/server/ws.d.ts +0 -14
  82. package/dist/node/ssr/ssrExternal.d.ts +0 -7
  83. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  84. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
  85. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  86. package/dist/node/ssr/ssrTransform.d.ts +0 -8
  87. package/dist/node/utils.d.ts +0 -115
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var build = require('./dep-5ad1713b.js');
3
+ var build = require('./dep-7b4d034a.js');
4
4
  var require$$1 = require('crypto');
5
5
  require('fs');
6
6
  require('path');
@@ -22,7 +22,6 @@ require('assert');
22
22
  require('buffer');
23
23
  require('querystring');
24
24
  require('esbuild');
25
- require('json5');
26
25
  require('child_process');
27
26
  require('worker_threads');
28
27
  require('readline');
@@ -2495,261 +2494,6 @@ util$1.clearItems = function(api, id, location) {
2495
2494
  _callStorageFunction(_clearItems, arguments, location);
2496
2495
  };
2497
2496
 
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
2497
  /**
2754
2498
  * Check if an object is empty.
2755
2499
  *
@@ -3187,6 +2931,8 @@ _IN('1.2.840.10040.4.3', 'dsa-with-sha1');
3187
2931
  _IN('1.3.14.3.2.7', 'desCBC');
3188
2932
 
3189
2933
  _IN('1.3.14.3.2.26', 'sha1');
2934
+ // Deprecated equivalent of sha1WithRSAEncryption
2935
+ _IN('1.3.14.3.2.29', 'sha1WithRSASignature');
3190
2936
  _IN('2.16.840.1.101.3.4.2.1', 'sha256');
3191
2937
  _IN('2.16.840.1.101.3.4.2.2', 'sha384');
3192
2938
  _IN('2.16.840.1.101.3.4.2.3', 'sha512');
@@ -3249,16 +2995,19 @@ _IN('2.16.840.1.101.3.4.1.42', 'aes256-CBC');
3249
2995
 
3250
2996
  // certificate issuer/subject OIDs
3251
2997
  _IN('2.5.4.3', 'commonName');
3252
- _IN('2.5.4.5', 'serialName');
2998
+ _IN('2.5.4.4', 'surname');
2999
+ _IN('2.5.4.5', 'serialNumber');
3253
3000
  _IN('2.5.4.6', 'countryName');
3254
3001
  _IN('2.5.4.7', 'localityName');
3255
3002
  _IN('2.5.4.8', 'stateOrProvinceName');
3256
3003
  _IN('2.5.4.9', 'streetAddress');
3257
3004
  _IN('2.5.4.10', 'organizationName');
3258
3005
  _IN('2.5.4.11', 'organizationalUnitName');
3006
+ _IN('2.5.4.12', 'title');
3259
3007
  _IN('2.5.4.13', 'description');
3260
3008
  _IN('2.5.4.15', 'businessCategory');
3261
3009
  _IN('2.5.4.17', 'postalCode');
3010
+ _IN('2.5.4.42', 'givenName');
3262
3011
  _IN('1.3.6.1.4.1.311.60.2.1.2', 'jurisdictionOfIncorporationStateOrProvinceName');
3263
3012
  _IN('1.3.6.1.4.1.311.60.2.1.3', 'jurisdictionOfIncorporationCountryName');
3264
3013
 
@@ -8030,8 +7779,15 @@ pem.decode = function(str) {
8030
7779
  break;
8031
7780
  }
8032
7781
 
7782
+ // accept "NEW CERTIFICATE REQUEST" as "CERTIFICATE REQUEST"
7783
+ // https://datatracker.ietf.org/doc/html/rfc7468#section-7
7784
+ var type = match[1];
7785
+ if(type === 'NEW CERTIFICATE REQUEST') {
7786
+ type = 'CERTIFICATE REQUEST';
7787
+ }
7788
+
8033
7789
  var msg = {
8034
- type: match[1],
7790
+ type: type,
8035
7791
  procType: null,
8036
7792
  contentDomain: null,
8037
7793
  dekInfo: null,
@@ -8802,7 +8558,7 @@ prng.create = function(plugin) {
8802
8558
  // throw in more pseudo random
8803
8559
  next = seed >>> (i << 3);
8804
8560
  next ^= Math.floor(Math.random() * 0x0100);
8805
- b.putByte(String.fromCharCode(next & 0xFF));
8561
+ b.putByte(next & 0xFF);
8806
8562
  }
8807
8563
  }
8808
8564
  }
@@ -14886,7 +14642,8 @@ p7v.recipientInfoValidator = {
14886
14642
  name: 'RecipientInfo.keyEncryptionAlgorithm.parameter',
14887
14643
  tagClass: asn1$3.Class.UNIVERSAL,
14888
14644
  constructed: false,
14889
- captureAsn1: 'encParameter'
14645
+ captureAsn1: 'encParameter',
14646
+ optional: true
14890
14647
  }]
14891
14648
  }, {
14892
14649
  name: 'RecipientInfo.encryptedKey',
@@ -15905,6 +15662,101 @@ var _readSignatureParameters = function(oid, obj, fillDefaults) {
15905
15662
  return params;
15906
15663
  };
15907
15664
 
15665
+ /**
15666
+ * Create signature digest for OID.
15667
+ *
15668
+ * @param options
15669
+ * signatureOid: the OID specifying the signature algorithm.
15670
+ * type: a human readable type for error messages
15671
+ * @return a created md instance. throws if unknown oid.
15672
+ */
15673
+ var _createSignatureDigest = function(options) {
15674
+ switch(oids[options.signatureOid]) {
15675
+ case 'sha1WithRSAEncryption':
15676
+ // deprecated alias
15677
+ case 'sha1WithRSASignature':
15678
+ return forge$2.md.sha1.create();
15679
+ case 'md5WithRSAEncryption':
15680
+ return forge$2.md.md5.create();
15681
+ case 'sha256WithRSAEncryption':
15682
+ return forge$2.md.sha256.create();
15683
+ case 'sha384WithRSAEncryption':
15684
+ return forge$2.md.sha384.create();
15685
+ case 'sha512WithRSAEncryption':
15686
+ return forge$2.md.sha512.create();
15687
+ case 'RSASSA-PSS':
15688
+ return forge$2.md.sha256.create();
15689
+ default:
15690
+ var error = new Error(
15691
+ 'Could not compute ' + options.type + ' digest. ' +
15692
+ 'Unknown signature OID.');
15693
+ error.signatureOid = options.signatureOid;
15694
+ throw error;
15695
+ }
15696
+ };
15697
+
15698
+ /**
15699
+ * Verify signature on certificate or CSR.
15700
+ *
15701
+ * @param options:
15702
+ * certificate the certificate or CSR to verify.
15703
+ * md the signature digest.
15704
+ * signature the signature
15705
+ * @return a created md instance. throws if unknown oid.
15706
+ */
15707
+ var _verifySignature = function(options) {
15708
+ var cert = options.certificate;
15709
+ var scheme;
15710
+
15711
+ switch(cert.signatureOid) {
15712
+ case oids.sha1WithRSAEncryption:
15713
+ // deprecated alias
15714
+ case oids.sha1WithRSASignature:
15715
+ /* use PKCS#1 v1.5 padding scheme */
15716
+ break;
15717
+ case oids['RSASSA-PSS']:
15718
+ var hash, mgf;
15719
+
15720
+ /* initialize mgf */
15721
+ hash = oids[cert.signatureParameters.mgf.hash.algorithmOid];
15722
+ if(hash === undefined || forge$2.md[hash] === undefined) {
15723
+ var error = new Error('Unsupported MGF hash function.');
15724
+ error.oid = cert.signatureParameters.mgf.hash.algorithmOid;
15725
+ error.name = hash;
15726
+ throw error;
15727
+ }
15728
+
15729
+ mgf = oids[cert.signatureParameters.mgf.algorithmOid];
15730
+ if(mgf === undefined || forge$2.mgf[mgf] === undefined) {
15731
+ var error = new Error('Unsupported MGF function.');
15732
+ error.oid = cert.signatureParameters.mgf.algorithmOid;
15733
+ error.name = mgf;
15734
+ throw error;
15735
+ }
15736
+
15737
+ mgf = forge$2.mgf[mgf].create(forge$2.md[hash].create());
15738
+
15739
+ /* initialize hash function */
15740
+ hash = oids[cert.signatureParameters.hash.algorithmOid];
15741
+ if(hash === undefined || forge$2.md[hash] === undefined) {
15742
+ var error = new Error('Unsupported RSASSA-PSS hash function.');
15743
+ error.oid = cert.signatureParameters.hash.algorithmOid;
15744
+ error.name = hash;
15745
+ throw error;
15746
+ }
15747
+
15748
+ scheme = forge$2.pss.create(
15749
+ forge$2.md[hash].create(), mgf, cert.signatureParameters.saltLength
15750
+ );
15751
+ break;
15752
+ }
15753
+
15754
+ // verify signature on cert using public key
15755
+ return cert.publicKey.verify(
15756
+ options.md.digest().getBytes(), options.signature, scheme
15757
+ );
15758
+ };
15759
+
15908
15760
  /**
15909
15761
  * Converts an X.509 certificate from PEM format.
15910
15762
  *
@@ -16285,43 +16137,18 @@ pki$2.createCertificate = function() {
16285
16137
  'The parent certificate did not issue the given child ' +
16286
16138
  'certificate; the child certificate\'s issuer does not match the ' +
16287
16139
  'parent\'s subject.');
16288
- error.expectedIssuer = issuer.attributes;
16289
- error.actualIssuer = subject.attributes;
16140
+ error.expectedIssuer = subject.attributes;
16141
+ error.actualIssuer = issuer.attributes;
16290
16142
  throw error;
16291
16143
  }
16292
16144
 
16293
16145
  var md = child.md;
16294
16146
  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
- }
16147
+ // create digest for OID signature types
16148
+ md = _createSignatureDigest({
16149
+ signatureOid: child.signatureOid,
16150
+ type: 'certificate'
16151
+ });
16325
16152
 
16326
16153
  // produce DER formatted TBSCertificate and digest it
16327
16154
  var tbsCertificate = child.tbsCertificate || pki$2.getTBSCertificate(child);
@@ -16330,52 +16157,9 @@ pki$2.createCertificate = function() {
16330
16157
  }
16331
16158
 
16332
16159
  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);
16160
+ rval = _verifySignature({
16161
+ certificate: cert, md: md, signature: child.signature
16162
+ });
16379
16163
  }
16380
16164
 
16381
16165
  return rval;
@@ -16549,37 +16333,11 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16549
16333
  cert.tbsCertificate = capture.tbsCertificate;
16550
16334
 
16551
16335
  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
- }
16336
+ // create digest for OID signature type
16337
+ cert.md = _createSignatureDigest({
16338
+ signatureOid: cert.signatureOid,
16339
+ type: 'certificate'
16340
+ });
16583
16341
 
16584
16342
  // produce DER formatted TBSCertificate and digest it
16585
16343
  var bytes = asn1$2.toDer(cert.tbsCertificate);
@@ -16588,6 +16346,8 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16588
16346
 
16589
16347
  // handle issuer, build issuer message digest
16590
16348
  var imd = forge$2.md.sha1.create();
16349
+ var ibytes = asn1$2.toDer(capture.certIssuer);
16350
+ imd.update(ibytes.getBytes());
16591
16351
  cert.issuer.getField = function(sn) {
16592
16352
  return _getAttribute(cert.issuer, sn);
16593
16353
  };
@@ -16595,7 +16355,7 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16595
16355
  _fillMissingFields([attr]);
16596
16356
  cert.issuer.attributes.push(attr);
16597
16357
  };
16598
- cert.issuer.attributes = pki$2.RDNAttributesAsArray(capture.certIssuer, imd);
16358
+ cert.issuer.attributes = pki$2.RDNAttributesAsArray(capture.certIssuer);
16599
16359
  if(capture.certIssuerUniqueId) {
16600
16360
  cert.issuer.uniqueId = capture.certIssuerUniqueId;
16601
16361
  }
@@ -16603,6 +16363,8 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16603
16363
 
16604
16364
  // handle subject, build subject message digest
16605
16365
  var smd = forge$2.md.sha1.create();
16366
+ var sbytes = asn1$2.toDer(capture.certSubject);
16367
+ smd.update(sbytes.getBytes());
16606
16368
  cert.subject.getField = function(sn) {
16607
16369
  return _getAttribute(cert.subject, sn);
16608
16370
  };
@@ -16610,7 +16372,7 @@ pki$2.certificateFromAsn1 = function(obj, computeHash) {
16610
16372
  _fillMissingFields([attr]);
16611
16373
  cert.subject.attributes.push(attr);
16612
16374
  };
16613
- cert.subject.attributes = pki$2.RDNAttributesAsArray(capture.certSubject, smd);
16375
+ cert.subject.attributes = pki$2.RDNAttributesAsArray(capture.certSubject);
16614
16376
  if(capture.certSubjectUniqueId) {
16615
16377
  cert.subject.uniqueId = capture.certSubjectUniqueId;
16616
16378
  }
@@ -16892,37 +16654,11 @@ pki$2.certificationRequestFromAsn1 = function(obj, computeHash) {
16892
16654
  csr.certificationRequestInfo = capture.certificationRequestInfo;
16893
16655
 
16894
16656
  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
- }
16657
+ // create digest for OID signature type
16658
+ csr.md = _createSignatureDigest({
16659
+ signatureOid: csr.signatureOid,
16660
+ type: 'certification request'
16661
+ });
16926
16662
 
16927
16663
  // produce DER formatted CertificationRequestInfo and digest it
16928
16664
  var bytes = asn1$2.toDer(csr.certificationRequestInfo);
@@ -17062,38 +16798,10 @@ pki$2.createCertificationRequest = function() {
17062
16798
 
17063
16799
  var md = csr.md;
17064
16800
  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
- }
16801
+ md = _createSignatureDigest({
16802
+ signatureOid: csr.signatureOid,
16803
+ type: 'certification request'
16804
+ });
17097
16805
 
17098
16806
  // produce DER formatted CertificationRequestInfo and digest it
17099
16807
  var cri = csr.certificationRequestInfo ||
@@ -17103,51 +16811,9 @@ pki$2.createCertificationRequest = function() {
17103
16811
  }
17104
16812
 
17105
16813
  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);
16814
+ rval = _verifySignature({
16815
+ certificate: csr, md: md, signature: csr.signature
16816
+ });
17151
16817
  }
17152
16818
 
17153
16819
  return rval;
@@ -19695,7 +19361,7 @@ pki.privateKeyInfoToPem = function(pki, maxline) {
19695
19361
  return forge.pem.encode(msg, {maxline: maxline});
19696
19362
  };
19697
19363
 
19698
- // simplified fork of
19364
+ // Simplified fork of selfsigned with inlined options and partial
19699
19365
  // a hexString is considered negative if it's most significant bit is 1
19700
19366
  // because serial numbers use ones' complement notation
19701
19367
  // this RFC in section 4.1.2.2 requires serial numbers to be positive
@@ -19811,4 +19477,3 @@ function createCertificate() {
19811
19477
  }
19812
19478
 
19813
19479
  exports.createCertificate = createCertificate;
19814
- //# sourceMappingURL=dep-920a704a.js.map