Skip to content

Commit 71357a5

Browse files
committed
remove jssha
1 parent ee74e8d commit 71357a5

File tree

4 files changed

+18
-54
lines changed

4 files changed

+18
-54
lines changed

package-lock.json

Lines changed: 11 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"@types/argon2-browser": "^1.6.0",
2424
"@types/chrome": "^0.0.86",
2525
"@types/crypto-js": "^3.1.43",
26-
"@types/jssha": "2.0.0",
2726
"@types/uuid": "^3.4.5",
2827
"base64-loader": "^1.0.0",
2928
"fork-ts-checker-webpack-plugin": "^1.3.5",
@@ -42,7 +41,6 @@
4241
"dependencies": {
4342
"argon2-browser": "^1.12.0",
4443
"crypto-js": "^3.1.9-1",
45-
"jssha": "^2.3.1",
4644
"qrcode-generator": "^1.4.3",
4745
"qrcode-reader": "^1.0.4",
4846
"uuid": "^3.3.3",

src/models/key-utilities.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as jsSHA from "jssha";
21
import { OTPType } from "./otp";
2+
import * as CryptoJS from "crypto-js";
33

44
// Originally based on the JavaScript implementation as provided by Russell
55
// Sayers on his Tin Isles blog:
@@ -145,16 +145,14 @@ export class KeyUtilities {
145145
}
146146
}
147147

148-
// external library for SHA functionality
149-
const hmacObj = new jsSHA("SHA-1", "HEX");
150-
hmacObj.setHMACKey(key, "HEX");
151-
hmacObj.update(time);
152-
const hmac = hmacObj.getHMAC("HEX");
148+
const hmacObj = CryptoJS.HmacSHA1(
149+
CryptoJS.enc.Hex.parse(time),
150+
CryptoJS.enc.Hex.parse(key)
151+
);
152+
const hmac = CryptoJS.enc.Hex.stringify(hmacObj);
153153

154154
let offset = 0;
155-
if (hmac !== "KEY MUST BE IN BYTE INCREMENTS") {
156-
offset = this.hex2dec(hmac.substring(hmac.length - 1));
157-
}
155+
offset = this.hex2dec(hmac.substring(hmac.length - 1));
158156

159157
let otp =
160158
(this.hex2dec(hmac.substr(offset * 2, 8)) & this.hex2dec("7fffffff")) +

src/models/otp.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ export class OTPEntry implements IOTPEntry {
141141
}
142142

143143
genUUID() {
144-
// await this.delete();
145144
this.hash = uuid();
146-
// await this.create();
147145
}
148146

149147
generate() {

0 commit comments

Comments
 (0)