mybase 1.1.43 → 1.1.44

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mybase",
3
- "version": "1.1.43",
3
+ "version": "1.1.44",
4
4
  "description": "",
5
5
  "main": "mybase.js",
6
6
  "scripts": {
@@ -6,7 +6,7 @@ export declare class OTPGenerator {
6
6
  generateOTP(): string;
7
7
  validateOTP(otp: string): boolean;
8
8
  age(otp: string): Timespan;
9
- private generateOTPWithNonce;
9
+ generateOTPWithNonce(nonce: number): string;
10
10
  private isValid;
11
11
  private extractNonce;
12
12
  }
@@ -49,7 +49,6 @@ class OTPGenerator {
49
49
  const nonce = this.extractNonce(otp);
50
50
  return new Timespan_1.Timespan(Date.now() - nonce);
51
51
  }
52
- // Helper to generate OTP based on a specific nonce
53
52
  generateOTPWithNonce(nonce) {
54
53
  const hash = crypto.createHmac('sha256', this.passkey).update(nonce.toString()).digest('hex');
55
54
  const otp = [...hash.slice(0, this.length)].map(char => String.fromCharCode((parseInt(char, 16) % 26) + 97)).join('');
@@ -24,8 +24,7 @@ export class OTPGenerator {
24
24
  return new Timespan(Date.now() - nonce)
25
25
  }
26
26
 
27
- // Helper to generate OTP based on a specific nonce
28
- private generateOTPWithNonce(nonce: number): string {
27
+ public generateOTPWithNonce(nonce: number): string { // lets keep it public for testing
29
28
  const hash = crypto.createHmac('sha256', this.passkey).update(nonce.toString()).digest('hex');
30
29
  const otp = [...hash.slice(0, this.length)].map(char => String.fromCharCode((parseInt(char, 16) % 26) + 97)).join('');
31
30
  return `${otp}${nonce.toString(16).padStart(13, '0')}`;