Selaa lähdekoodia

totp dist files

isundil 1 kuukausi sitten
vanhempi
commit
654b42f0bf
4 muutettua tiedostoa jossa 8 lisäystä ja 3 poistoa
  1. 2 0
      dist/totpChecker.d.ts
  2. 1 1
      dist/totpChecker.d.ts.map
  3. 5 2
      dist/totpChecker.js
  4. 0 0
      dist/totpChecker.js.map

+ 2 - 0
dist/totpChecker.d.ts

@@ -5,6 +5,7 @@ export interface ToTpGeneratorOptions {
     algorithm?: TotpAlgorithm;
     label?: string;
     secretLength?: number;
+    secret?: string;
     issuer: string;
 }
 export interface ToTpSecretAndUrl {
@@ -16,6 +17,7 @@ export declare class TotpChecker {
     private static DoGenerateCode;
     private static getCurrentPeriod;
     static GenerateCode(totpSecret: string, period?: number, digits?: number, algorithm?: TotpAlgorithm): string;
+    static GenerateSecret(secretLength?: number): string;
     static GenerateUrl(optionsOrIssuer: ToTpGeneratorOptions | string): ToTpSecretAndUrl;
 }
 //# sourceMappingURL=totpChecker.d.ts.map

+ 1 - 1
dist/totpChecker.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"totpChecker.d.ts","sourceRoot":"","sources":["../src/totpChecker.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAClB;AAID,qBAAa,WAAW;WACA,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,M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CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM;WAIrG,cAAc,CAAC,YAAY,CAAC,EAAC,MAAM;WAInC,WAAW,CAAC,eAAe,EAAE,oBAAoB,GAAG,MAAM,GAAG,gBAAgB;CAa9F"}

+ 5 - 2
dist/totpChecker.js

@@ -47,14 +47,17 @@ export class TotpChecker {
     static GenerateCode(totpSecret, period, digits, algorithm) {
         return TotpChecker.DoGenerateCode(totpSecret, this.getCurrentPeriod(period), digits || 6, algorithm || "SHA-1").shift();
     }
+    static GenerateSecret(secretLength) {
+        secretLength = secretLength || 13;
+        return Array.from(crypto.randomBytes(secretLength)).map(x => RFC_4648[x % RFC_4648.length]).join("");
+    }
     static GenerateUrl(optionsOrIssuer) {
         let options = typeof optionsOrIssuer === "string" ? { issuer: optionsOrIssuer } : optionsOrIssuer;
         options.digits = options.digits || 6;
         options.period = options.period || 30;
         options.algorithm = options.algorithm || "SHA-1";
         options.label = encodeURIComponent(options.label || options.issuer);
-        options.secretLength = options.secretLength || 13;
-        const secretStr = Array.from(crypto.randomBytes(options.secretLength)).map(x => RFC_4648[x % RFC_4648.length]).join("");
+        const secretStr = options.secret || TotpChecker.GenerateSecret(options.secretLength || 13);
         return {
             url: `otpauth://totp/${options.issuer}?issuer=${options.issuer}&secret=${secretStr}&digits=${options.digits}&period=${options.period}&algorithm=${options.algorithm}`,
             secret: secretStr

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/totpChecker.js.map


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä