File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33exports . randomBytes = exports . rng = exports . pseudoRandomBytes = exports . prng = require ( 'randombytes' )
4+
5+ exports . getRandomValues = function ( abv ) {
6+ var l = abv . length
7+ while ( l -- ) {
8+ var bytes = exports . randomBytes ( 7 )
9+ var randomFloat = ( bytes [ 0 ] % 32 ) / 32
10+
11+ for ( var i = 0 ; i < bytes . length ; i ++ ) {
12+ var byte = bytes [ i ]
13+ randomFloat = ( randomFloat + byte ) / 256
14+ }
15+
16+ abv [ l ] = Math . floor ( randomFloat * 256 )
17+ }
18+ return abv
19+ }
20+
21+ exports . randomUUID = function ( ) {
22+ return '10000000-1000-4000-8000-100000000000' . replace ( / [ 0 1 8 ] / g, function ( c ) {
23+ return ( c ^ ( exports . getRandomValues ( new Uint8Array ( 1 ) ) [ 0 ] & ( 15 >> ( c / 4 ) ) ) ) . toString ( 16 )
24+ } )
25+ }
26+
427exports . createHash = exports . Hash = require ( 'create-hash' )
528exports . createHmac = exports . Hmac = require ( 'create-hmac' )
629
@@ -65,6 +88,10 @@ exports.privateDecrypt = publicEncrypt.privateDecrypt
6588// }
6689// })
6790
91+ var { Crypto } = require ( '@peculiar/webcrypto' ) ;
92+ var crypto = new Crypto ( ) ;
93+ exports . subtle = crypto . subtle ;
94+
6895var rf = require ( 'randomfill' )
6996
7097exports . randomFill = rf . randomFill
@@ -94,4 +121,4 @@ exports.constants = {
94121 'POINT_CONVERSION_COMPRESSED' : 2 ,
95122 'POINT_CONVERSION_UNCOMPRESSED' : 4 ,
96123 'POINT_CONVERSION_HYBRID' : 6
97- }
124+ }
Original file line number Diff line number Diff line change 2828 "pbkdf2" : " ^3.0.3" ,
2929 "public-encrypt" : " ^4.0.0" ,
3030 "randombytes" : " ^2.0.0" ,
31- "randomfill" : " ^1.0.3"
31+ "randomfill" : " ^1.0.3" ,
32+ "@peculiar/webcrypto" : " 1.4.3"
3233 },
3334 "devDependencies" : {
3435 "hash-test-vectors" : " ~1.3.2" ,
You can’t perform that action at this time.
0 commit comments