File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ 'use strict' ;
5
+
6
+ const crypto = require ( 'isomorphic-webcrypto' ) ;
7
+ require ( 'fast-text-encoding' ) ;
8
+
9
+ module . exports = {
10
+ /**
11
+ * Hashes a string of data using SHA-256.
12
+ *
13
+ * @param {string } string - the string to hash.
14
+ *
15
+ * @return {Uint8Array } the hash digest.
16
+ */
17
+ async sha256digest ( { string} ) {
18
+ const bytes = new TextEncoder ( ) . encode ( string ) ;
19
+ return new Uint8Array (
20
+ await crypto . subtle . digest ( 'SHA-256' , bytes )
21
+ ) ;
22
+ }
23
+ } ;
Original file line number Diff line number Diff line change 30
30
],
31
31
"dependencies" : {
32
32
"@digitalbazaar/security-context" : " ^1.0.0" ,
33
- "jsonld" : " digitalbazaar/jsonld.js#v5.2.1-rc1" ,
33
+ "fast-text-encoding" : " ^1.0.3" ,
34
+ "isomorphic-webcrypto" : " ^2.3.8" ,
35
+ "jsonld" : " digitalbazaar/jsonld.js#v5.2.1-rc2" ,
34
36
"serialize-error" : " ^8.0.1"
35
37
},
36
38
"devDependencies" : {
79
81
},
80
82
"browser" : {
81
83
"crypto" : false ,
82
- "./lib/sha256digest.js" : " ./lib/sha256digest-browser.js"
84
+ "./lib/sha256digest.js" : " ./lib/sha256digest-browser.js" ,
85
+ "fast-text-encoding" : false ,
86
+ "isomorphic-webcrypto" : false
87
+ },
88
+ "react-native" : {
89
+ "crypto" : false ,
90
+ "./lib/sha256digest.js" : " ./lib/sha256digest-reactnative.js" ,
91
+ "./lib/sha256digest-browser.js" : false
83
92
}
84
93
}
You can’t perform that action at this time.
0 commit comments