vite 2.8.0-beta.1 → 2.8.0-beta.5
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.
- package/CHANGELOG.md +79 -1
- package/LICENSE.md +65 -57
- package/bin/vite.js +3 -1
- package/client.d.ts +4 -0
- package/dist/client/client.mjs +10 -5
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/dep-0ebab0df.js +0 -1
- package/dist/node/chunks/dep-2056ae8a.js +0 -1
- package/dist/node/chunks/{dep-fccf00e1.js → dep-6c133e83.js} +147 -482
- package/dist/node/chunks/{dep-e4a9e288.js → dep-ae5bfd1c.js} +1 -2
- package/dist/node/chunks/{dep-e4dc9ea2.js → dep-aff09a4c.js} +3423 -2774
- package/dist/node/chunks/{dep-51191982.js → dep-ba706304.js} +16 -5
- package/dist/node/cli.js +4 -6
- package/dist/node/index.d.ts +20 -18
- package/dist/node/index.js +1 -3
- package/package.json +22 -22
- package/src/client/client.ts +12 -6
- package/types/chokidar.d.ts +27 -18
- package/types/importMeta.d.ts +17 -2
- package/dist/node/build.d.ts +0 -200
- package/dist/node/certificate.d.ts +0 -2
- package/dist/node/chunks/dep-0ebab0df.js.map +0 -1
- package/dist/node/chunks/dep-2056ae8a.js.map +0 -1
- package/dist/node/chunks/dep-51191982.js.map +0 -1
- package/dist/node/chunks/dep-e4a9e288.js.map +0 -1
- package/dist/node/chunks/dep-e4dc9ea2.js.map +0 -1
- package/dist/node/chunks/dep-fccf00e1.js.map +0 -1
- package/dist/node/cli.d.ts +0 -1
- package/dist/node/cli.js.map +0 -1
- package/dist/node/config.d.ts +0 -227
- package/dist/node/constants.d.ts +0 -33
- package/dist/node/http.d.ts +0 -88
- package/dist/node/importGlob.d.ts +0 -14
- package/dist/node/index.js.map +0 -1
- package/dist/node/logger.d.ts +0 -35
- package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
- package/dist/node/optimizer/index.d.ts +0 -66
- package/dist/node/optimizer/registerMissing.d.ts +0 -2
- package/dist/node/optimizer/scan.d.ts +0 -9
- package/dist/node/packages.d.ts +0 -25
- package/dist/node/plugin.d.ts +0 -115
- package/dist/node/plugins/asset.d.ts +0 -40
- package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
- package/dist/node/plugins/clientInjections.d.ts +0 -7
- package/dist/node/plugins/css.d.ts +0 -71
- package/dist/node/plugins/dataUri.d.ts +0 -5
- package/dist/node/plugins/define.d.ts +0 -3
- package/dist/node/plugins/esbuild.d.ts +0 -15
- package/dist/node/plugins/html.d.ts +0 -105
- package/dist/node/plugins/importAnalysis.d.ts +0 -46
- package/dist/node/plugins/importAnalysisBuild.d.ts +0 -15
- package/dist/node/plugins/index.d.ts +0 -3
- package/dist/node/plugins/json.d.ts +0 -22
- package/dist/node/plugins/loadFallback.d.ts +0 -5
- package/dist/node/plugins/manifest.d.ts +0 -14
- package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
- package/dist/node/plugins/preAlias.d.ts +0 -5
- package/dist/node/plugins/reporter.d.ts +0 -3
- package/dist/node/plugins/resolve.d.ts +0 -38
- package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
- package/dist/node/plugins/terser.d.ts +0 -3
- package/dist/node/plugins/wasm.d.ts +0 -3
- package/dist/node/plugins/worker.d.ts +0 -5
- package/dist/node/plugins/workerImportMetaUrl.d.ts +0 -3
- package/dist/node/preview.d.ts +0 -31
- package/dist/node/server/hmr.d.ts +0 -37
- package/dist/node/server/index.d.ts +0 -222
- package/dist/node/server/middlewares/base.d.ts +0 -3
- package/dist/node/server/middlewares/error.d.ts +0 -8
- package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
- package/dist/node/server/middlewares/proxy.d.ts +0 -20
- package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
- package/dist/node/server/middlewares/static.d.ts +0 -6
- package/dist/node/server/middlewares/time.d.ts +0 -2
- package/dist/node/server/middlewares/transform.d.ts +0 -3
- package/dist/node/server/moduleGraph.d.ts +0 -53
- package/dist/node/server/openBrowser.d.ts +0 -15
- package/dist/node/server/pluginContainer.d.ts +0 -37
- package/dist/node/server/searchRoot.d.ts +0 -8
- package/dist/node/server/send.d.ts +0 -10
- package/dist/node/server/sourcemap.d.ts +0 -8
- package/dist/node/server/transformRequest.d.ts +0 -14
- package/dist/node/server/ws.d.ts +0 -14
- package/dist/node/ssr/ssrExternal.d.ts +0 -7
- package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
- package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
- package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
- package/dist/node/ssr/ssrTransform.d.ts +0 -8
- package/dist/node/utils.d.ts +0 -115
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var build = require('./dep-
|
|
3
|
+
var build = require('./dep-aff09a4c.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.
|
|
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:
|
|
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(
|
|
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 =
|
|
16289
|
-
error.actualIssuer =
|
|
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
|
-
//
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
|
|
16299
|
-
|
|
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
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
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
|
-
//
|
|
16553
|
-
cert.md =
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
|
|
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
|
|
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
|
|
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
|
-
//
|
|
16896
|
-
csr.md =
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
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
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
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
|
-
|
|
17107
|
-
|
|
17108
|
-
|
|
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
|
-
//
|
|
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-fccf00e1.js.map
|